phpBMS

Show
Ignore:
Timestamp:
04/07/09 11:44:18 (3 years ago)
Author:
nate
Message:
  • Merged Nathan branch back into trunk.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/base/include/scheduler.php

    r285 r485  
    3939if(class_exists("phpbmsTable")){ 
    4040        class schedulers extends phpbmsTable{ 
    41          
     41 
     42                var $availableRoleIDs = array(); 
     43 
    4244                function getDefaults(){ 
    4345                        $therecord = parent::getDefaults(); 
    44                          
     46 
    4547                        $therecord["crontab"]="*::*::*::*::*"; 
    46          
     48 
    4749                        $therecord["min"]="*"; 
    4850                        $therecord["hrs"]="*"; 
     
    5052                        $therecord["mo"]="*"; 
    5153                        $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 
    5658                        $therecord["enddate"]=""; 
    5759                        $therecord["endtime"]=""; 
    58                          
     60 
    5961                        return $therecord; 
    60                          
     62 
    6163                }//end method 
    62          
    63                  
     64 
     65 
    6466                function getRecord($id = 0){ 
    6567                        $therecord = parent::getRecord($id); 
    66                          
     68 
    6769                        $datearray=explode(" ",$therecord["startdatetime"]); 
    6870                        $therecord["startdate"]=$datearray[0]; 
    6971                        if(isset($datearray[1])) $therecord["starttime"]=$datearray[1]; else $therecord["starttime"]=""; 
    70                          
     72 
    7173                        $datearray=explode(" ",$therecord["enddatetime"]); 
    7274                        $therecord["enddate"]=$datearray[0]; 
    7375                        if(isset($datearray[1])) $therecord["endtime"]=$datearray[1]; else $therecord["endtime"]=""; 
    74                  
     76 
    7577                        $cronarray=explode("::",$therecord["crontab"]); 
    7678                        if(isset($cronarray[0])) $therecord["min"]=$cronarray[0]; else $therecord["min"]="*"; 
     
    7981                        if(isset($cronarray[3])) $therecord["mo"]=$cronarray[3]; else $therecord["mo"]="*"; 
    8082                        if(isset($cronarray[4])) $therecord["day"]=$cronarray[4]; else $therecord["day"]="*"; 
    81                          
     83 
    8284                        $therecord["lastrun"]=formatFromSQLDatetime($therecord["lastrun"]); 
    83                          
     85 
    8486                        return $therecord; 
    85          
     87 
    8688                }//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 
    89113                function prepareVariables($variables){ 
    90          
     114 
    91115                        $temparray[0]=$variables["min"]; 
    92116                        $temparray[1]=$variables["hrs"]; 
     
    95119                        $temparray[4]=$variables["day"]; 
    96120                        $variables["crontab"]=implode("::",$temparray); 
    97          
     121 
    98122                        if($variables["startdate"]){ 
    99123                                $variables["startdatetime"] = $variables["startdate"]; 
    100124                                if($variables["starttime"]) 
    101125                                        $variables["startdatetime"] .= " ".$variables["starttime"]; 
    102                         } 
    103                         else 
     126                        }else 
    104127                                $variables["startdatetime"] = NULL; 
    105                  
     128 
     129 
    106130                        if($variables["enddate"]){ 
    107131                                $variables["enddatetime"] = $variables["enddate"]; 
    108132                                if($variables["endtime"]) 
    109133                                        $variables["enddatetime"].=" ".$variables["endtime"]; 
    110                         } 
    111                         else 
    112                                 $variables["enddatetime"] = NULL;  
    113          
    114                  
     134                        }else 
     135                                $variables["enddatetime"] = NULL; 
     136 
     137 
    115138                        return $variables; 
    116139                } 
    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 
    134141        }//end class 
    135142}//end if 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.