phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file _cronjob.class.php

Documentation is available at _cronjob.class.php

  1. <?php
  2. /**
  3.  * This file implements the Cronjob class, which manages a single cron job as registered in the DB.
  4.  *
  5.  * This file is part of Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *
  11.  *  {@internal License choice
  12.  *  - If you have received this file as part of a package, please find the license.txt file in
  13.  *    the same folder or the closest folder above for complete license terms.
  14.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15.  *    then you must choose one of the following licenses before using the file:
  16.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18.  *  }}}
  19.  *
  20.  *  {@internal Open Source relicensing agreement:
  21.  *  }}}
  22.  *
  23.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  24.  * @author fplanque: Francois PLANQUE.
  25.  *
  26.  * @package pond
  27.  */
  28. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  29.  
  30. load_class('_core/model/dataobjects/_dataobject.class.php');
  31.  
  32. /**
  33.  * Cronjob
  34.  *
  35.  * Manages a single cron job as registered in the DB.
  36.  *
  37.  * @package pond
  38.  */
  39. class Cronjob extends DataObject
  40. {
  41.     var $start_datetime;
  42.     var $repeat_after = NULL;
  43.     var $name;
  44.     var $controller;
  45.  
  46.     /**
  47.      * @var array 
  48.      */
  49.     var $params;
  50.  
  51.     /**
  52.      * Constructor
  53.      *
  54.      * @param table Database row
  55.      */
  56.     function Cronjob$db_row NULL )
  57.     {
  58.         // Call parent constructor:
  59.         parent::DataObject'T_cron__task''ctsk_''ctsk_ID''''''''' );
  60.  
  61.         if$db_row != NULL )
  62.         {    // Loading an object from DB:
  63.             $this->ID              = $db_row->ctsk_ID;
  64.             $this->start_datetime  = $db_row->ctsk_start_datetime;
  65.             $this->repeat_after    = $db_row->ctsk_repeat_after;
  66.             $this->name            = $db_row->ctsk_name;
  67.             $this->controller      = $db_row->ctsk_controller;
  68.             $this->params          = $db_row->ctsk_params;
  69.         }
  70.         else
  71.         {    // New object:
  72.  
  73.         }
  74.     }
  75.  
  76.     /**
  77.      * Set param value
  78.      *
  79.      * By default, all values will be considered strings
  80.      *
  81.      * @param string parameter name
  82.      * @param mixed parameter value
  83.      * @param boolean true to set to NULL if empty value
  84.      * @return boolean true, if a value has been set; false if it has not changed
  85.      */
  86.     function set$parname$parvalue$make_null false )
  87.     {
  88.         switch$parname )
  89.         {
  90.             case 'params':
  91.                 return $this->set_param'params''string'serialize($parvalue)false );
  92.  
  93.             case 'name':
  94.                 return $this->set_param$parname'string'substr$parvalue050 )false );
  95.         }
  96.  
  97.         return $this->set_param$parname'string'$parvalue$make_null );
  98.     }
  99.  
  100.  
  101.     /**
  102.      * Get a member param by its name
  103.      *
  104.      * @param mixed Name of parameter
  105.      * @return mixed Value of parameter
  106.      */
  107.     function get$parname )
  108.     {
  109.         switch$parname )
  110.         {
  111.             case 'params':
  112.                 return unserialize$this->params );
  113.         }
  114.  
  115.         return parent::get$parname );
  116.     }
  117. }
  118.  
  119. ?>