Changeset 485 for trunk/phpbms/modules/base/include/scheduler.php
- Timestamp:
- 04/07/09 11:44:18 (3 years ago)
- Files:
-
- 1 modified
-
trunk/phpbms/modules/base/include/scheduler.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/modules/base/include/scheduler.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class schedulers extends phpbmsTable{ 41 41 42 var $availableRoleIDs = array(); 43 42 44 function getDefaults(){ 43 45 $therecord = parent::getDefaults(); 44 46 45 47 $therecord["crontab"]="*::*::*::*::*"; 46 48 47 49 $therecord["min"]="*"; 48 50 $therecord["hrs"]="*"; … … 50 52 $therecord["mo"]="*"; 51 53 $therecord["day"]="*"; 52 53 $therecord["startdate"] =dateToString(mktime(),"SQL");54 $therecord["starttime"] ="";55 54 55 $therecord["startdate"] = dateToString(mktime(),"SQL"); 56 $therecord["starttime"] = sqlTimeFromString(timeToString(time())); 57 56 58 $therecord["enddate"]=""; 57 59 $therecord["endtime"]=""; 58 60 59 61 return $therecord; 60 62 61 63 }//end method 62 63 64 65 64 66 function getRecord($id = 0){ 65 67 $therecord = parent::getRecord($id); 66 68 67 69 $datearray=explode(" ",$therecord["startdatetime"]); 68 70 $therecord["startdate"]=$datearray[0]; 69 71 if(isset($datearray[1])) $therecord["starttime"]=$datearray[1]; else $therecord["starttime"]=""; 70 72 71 73 $datearray=explode(" ",$therecord["enddatetime"]); 72 74 $therecord["enddate"]=$datearray[0]; 73 75 if(isset($datearray[1])) $therecord["endtime"]=$datearray[1]; else $therecord["endtime"]=""; 74 76 75 77 $cronarray=explode("::",$therecord["crontab"]); 76 78 if(isset($cronarray[0])) $therecord["min"]=$cronarray[0]; else $therecord["min"]="*"; … … 79 81 if(isset($cronarray[3])) $therecord["mo"]=$cronarray[3]; else $therecord["mo"]="*"; 80 82 if(isset($cronarray[4])) $therecord["day"]=$cronarray[4]; else $therecord["day"]="*"; 81 83 82 84 $therecord["lastrun"]=formatFromSQLDatetime($therecord["lastrun"]); 83 85 84 86 return $therecord; 85 87 86 88 }//end method 87 88 89 90 91 function verifyVariables($variables){ 92 93 //must have the file that has the job that will 94 //be run. 95 if(isset($variables["job"])){ 96 if(!$variables["job"] === "" || $variables["job"] === NULL) 97 $this->verifyErrors[] = "The `job` field must not be blank."; 98 }else 99 $this->verifyErrors[] = "The `job` field must be set."; 100 101 //checks to see if crontab is in the (somewhat) right format 102 if(isset($variables["crontab"])){ 103 $explode = explode("::", $variables["crontab"]); 104 if(count($explode) != 5) 105 $this->verifyErrors[] = "The `crontab` field is not of the proper form. There must be four pairs of '::' in the field's value."; 106 }//end if 107 108 return parent::verifyVariables($variables); 109 110 }//end method 111 112 89 113 function prepareVariables($variables){ 90 114 91 115 $temparray[0]=$variables["min"]; 92 116 $temparray[1]=$variables["hrs"]; … … 95 119 $temparray[4]=$variables["day"]; 96 120 $variables["crontab"]=implode("::",$temparray); 97 121 98 122 if($variables["startdate"]){ 99 123 $variables["startdatetime"] = $variables["startdate"]; 100 124 if($variables["starttime"]) 101 125 $variables["startdatetime"] .= " ".$variables["starttime"]; 102 } 103 else 126 }else 104 127 $variables["startdatetime"] = NULL; 105 128 129 106 130 if($variables["enddate"]){ 107 131 $variables["enddatetime"] = $variables["enddate"]; 108 132 if($variables["endtime"]) 109 133 $variables["enddatetime"].=" ".$variables["endtime"]; 110 } 111 else 112 $variables["enddatetime"] = NULL; 113 114 134 }else 135 $variables["enddatetime"] = NULL; 136 137 115 138 return $variables; 116 139 } 117 118 119 function updateRecord($variables, $modifiedby = NULL){ 120 121 $variables = $this->prepareVariables($variables); 122 123 return parent::updateRecord($variables, $modifiedby); 124 } 125 126 127 function insertRecord($variables, $createdby = NULL){ 128 129 $variables = $this->prepareVariables($variables); 130 131 return parent::insertRecord($variables, $createdby); 132 } 133 140 134 141 }//end class 135 142 }//end if