phpBMS

Changeset 645 for trunk/phpbms/modules

Show
Ignore:
Timestamp:
10/06/09 13:20:39 (3 years ago)
Author:
nate
Message:
  • Added pushrecords table. This will store server/script information and how the push works.
  • Added push class which will get the information from records of tables with tabledefids and push them to server/script specified in a pushrecord.
  • Added ability to apply pushes to search options (tableoptions).
  • Added ability to automatically run pushes via the scheduler.
Location:
trunk/phpbms/modules
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/api/include/apiclass.php

    r641 r645  
    7373 
    7474    /** 
     75      *  $options 
     76      *  @var object Object containing the current request's options 
     77      */ 
     78    var $options; 
     79 
     80    /** 
    7581     * function api 
    7682     * 
     
    127133     * encodes data (usually {@link $request}) depending on the {@link $format} 
    128134     * 
    129      * Currently, this function can only decode JSON data, but support for SOAP, 
     135     * Currently, this function can only encode JSON data, but support for SOAP, 
    130136     * generic XML, or some other format may be added 
    131137     * 
     
    204210    }//end function isValidTimeFormat 
    205211 
     212 
     213    /** 
     214     * function processOptions 
     215     * @param array $options 
     216     */ 
     217 
     218    function processOptions($options) { 
     219 
     220        $this->options->useUuid = true; 
     221            if(isset($options["useUuid"])) 
     222                $this->options->useUuid = (bool)$options["useUuid"]; 
     223 
     224        /** 
     225          *   date format options 
     226          */ 
     227 
     228        $this->options->dateFormat = "SQL"; 
     229        if(defined("DATE_FORMAT")) 
     230            $this->options->dateFormat = DATE_FORMAT; 
     231 
     232        if(isset($options["dateFormat"])) 
     233            if($this->isValidDateFormat($options["dateFormat"])) 
     234                $this->options->dateFormat = $options["dateFormat"]; 
     235 
     236        /** 
     237          *  Time format options 
     238          */ 
     239 
     240        $this->options->timeFormat = "24 Hour"; 
     241        if(defined("TIME_FORMAT")) 
     242            $this->options->timeFormat = TIME_FORMAT; 
     243 
     244        if(isset($options["timeFormat"])) 
     245            if($this->isValidTimeFormat($options["timeFormat"])) 
     246                $this->options->timeFormat = $options["timeFormat"]; 
     247 
     248        /** 
     249          *  Id field options 
     250          * 
     251          *  This option dictates whether or not to keep the destination's 
     252          *  id field if "replacing" (via the mysql replace) when there is 
     253          *  no id field set. 
     254          */ 
     255        $this->options->keepDestId = true; 
     256        if(isset($options["keepDestId"])) 
     257            $this->options->keepDestId = (bool)$options["keepDestId"]; 
     258 
     259    }//end method --processOptions-- 
    206260 
    207261    /** 
     
    221275        $tabledefid = null; 
    222276 
    223         /** 
    224           *  @var bool $useUuid Whether or not to update/get/delete a record using the 
    225           *  uuid instead of the id. Default is true. 
    226           */ 
    227         $useUuid = true; 
    228  
    229277        if(!is_array($this->data)) 
    230278            $this->sendError("Passed data malformed.  Was expecting an array.", $this->data, true); 
     
    238286                $this->sendError("Malformed request number ".$i, $request); 
    239287 
    240             $useUuid = true; 
    241             if(isset($request["options"]["useUuid"])) 
    242                 $useUuid = (bool)$request["options"]["useUuid"]; 
    243  
    244288            /** 
    245               *   date format options 
     289              *  Process the options and populate the options object. 
    246290              */ 
    247  
    248             $dateFormat = "SQL"; 
    249             if(defined("DATE_FORMAT")) 
    250                 $dateFormat = DATE_FORMAT; 
    251  
    252             if(isset($request["options"]["dateFormat"])) 
    253                 if($this->isValidDateFormat($request["options"]["dateFormat"])) 
    254                     $dateFormat = $request["options"]["dateFormat"]; 
    255  
    256             /** 
    257               *  Time format options 
    258               */ 
    259  
    260             $timeFormat = "24 Hour"; 
    261             if(defined("TIME_FORMAT")) 
    262                 $timeFormat = TIME_FORMAT; 
    263  
    264             if(isset($request["options"]["dateFormat"])) 
    265                 if($this->isValidTimeFormat($request["options"]["dateFormat"])) 
    266                     $timeFormat = $request["options"]["timeFormat"]; 
     291            if(!isset($request["options"])) 
     292                $request["options"] = NULL; 
     293 
     294            $this->processOptions($request["options"]); 
    267295 
    268296            if((int) $request["tabledefid"] !== $tabledefid){ 
     
    354382 
    355383                    $processor = new $className($this->db); 
    356                     $processor->dateFormat =  $dateFormat; 
    357                     $processor->timeFormat =  $timeFormat; 
     384                    $processor->dateFormat =  $this->options->dateFormat; 
     385                    $processor->timeFormat =  $this->options->timeFormat; 
    358386 
    359387                    if(!method_exists($processor, $request["command"])) { 
     
    380408                if(class_exists($maintable)){ 
    381409                    $processor = new $maintable($this->db, $tabledefid); 
    382                     $processor->dateFormat =  $dateFormat; 
    383                     $processor->timeFormat =  $timeFormat; 
     410                    $processor->dateFormat =  $this->options->dateFormat; 
     411                    $processor->timeFormat =  $this->options->timeFormat; 
    384412                }else{ 
    385413                    $processor = new phpbmsTable($this->db, $tabledefid); 
    386                     $processor->dateFormat =  $dateFormat; 
    387                     $processor->timeFormat =  $timeFormat; 
     414                    $processor->dateFormat =  $this->options->dateFormat; 
     415                    $processor->timeFormat =  $this->options->timeFormat; 
    388416                } 
    389417 
     
    439467                            if(class_exists($maintable)){ 
    440468                                $processor = new $maintable($this->db, $tabledefid); 
    441                                 $processor->dateFormat =  $dateFormat; 
    442                                 $processor->timeFormat =  $timeFormat; 
     469                                $processor->dateFormat =  $this->options->dateFormat; 
     470                                $processor->timeFormat =  $this->options->timeFormat; 
    443471                            }else{ 
    444472                                $processor = new phpbmsTable($this->db, $tabledefid); 
    445                                 $processor->dateFormat =  $dateFormat; 
    446                                 $processor->timeFormat =  $timeFormat; 
     473                                $processor->dateFormat =  $this->options->dateFormat; 
     474                                $processor->timeFormat =  $this->options->timeFormat; 
    447475                            }//end if 
    448476 
    449477                        } else{ 
    450478                            $processor = new phpbmsTable($this->db, $tabledefid); 
    451                             $processor->dateFormat =  $dateFormat; 
    452                             $processor->timeFormat =  $timeFormat; 
     479                            $processor->dateFormat =  $this->options->dateFormat; 
     480                            $processor->timeFormat =  $this->options->timeFormat; 
    453481                        }//end if 
    454482 
     
    461489                            $overrideID = false; 
    462490                            if(is_array($request["data"])) 
    463                                 if(isset($request["data"]["id"])) 
     491                                if(isset($request["data"]["id"])){ 
     492 
    464493                                    if(((int)$request["data"]["id"]) !== 0) 
    465494                                        $overrideID = true; 
     495                                    if($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) 
     496                                        $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]); 
     497 
     498                                }elseif($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) 
     499                                    $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]); 
    466500 
    467501                            $createUuid = true; 
     
    471505                                        $overrideID = true; 
    472506                                        $createUuid = false; 
    473                                     } 
     507                                    }//end if 
    474508 
    475509                            if(!isset($processor->fields["uuid"])) 
    476510                                $createUuid = false; 
    477511 
    478                             $newid = $processor->insertRecord($request["data"], null, $overrideID, true, $createUuid); 
     512                            $newid = $processor->insertRecord($request["data"], NULL, $overrideID, true, $createUuid); 
    479513 
    480514                            if($newid){ 
     
    503537                            if(class_exists($maintable)){ 
    504538                                $processor = new $maintable($this->db, $tabledefid); 
    505                                 $processor->dateFormat =  $dateFormat; 
    506                                 $processor->timeFormat =  $timeFormat; 
     539                                $processor->dateFormat =  $this->options->dateFormat; 
     540                                $processor->timeFormat =  $this->options->timeFormat; 
    507541                            }else{ 
    508542                                $processor = new phpbmsTable($this->db, $tabledefid); 
    509                                 $processor->dateFormat =  $dateFormat; 
    510                                 $processor->timeFormat =  $timeFormat; 
     543                                $processor->dateFormat =  $this->options->dateFormat; 
     544                                $processor->timeFormat =  $this->options->timeFormat; 
    511545                            }//end if 
    512546 
    513547                        } else { 
    514548                            $processor = new phpbmsTable($this->db, $tabledefid); 
    515                             $processor->dateFormat =  $dateFormat; 
    516                             $processor->timeFormat =  $timeFormat; 
     549                            $processor->dateFormat =  $this->options->dateFormat; 
     550                            $processor->timeFormat =  $this->options->timeFormat; 
    517551                        }//end if 
    518552 
    519553                        $errorArray = $processor->verifyVariables($request["data"]); 
    520554 
    521                         if($useUuid){ 
     555                        if($this->options->useUuid){ 
    522556                            if(!isset($request["data"]["uuid"])) 
    523557                                $errorArray[] = "The `uuid` field must be set."; 
     
    532566                        else { 
    533567 
    534                             $processor->updateRecord($request["data"], NULL, (bool)$useUuid); 
     568                            $processor->updateRecord($request["data"], NULL, (bool)$this->options->useUuid); 
    535569 
    536570                            $this->_addToResponse("updated", "record updated in tabledef ".$tabledefid); 
     
    551585                            if(class_exists($maintable)){ 
    552586                                $processor = new $maintable($this->db, $tabledefid); 
    553                                 $processor->dateFormat =  $dateFormat; 
    554                                 $processor->timeFormat =  $timeFormat; 
     587                                $processor->dateFormat =  $this->options->dateFormat; 
     588                                $processor->timeFormat =  $this->options->timeFormat; 
    555589                            }else{ 
    556590                                $processor = new phpbmsTable($this->db, $tabledefid); 
    557                                 $processor->dateFormat =  $dateFormat; 
    558                                 $processor->timeFormat =  $timeFormat; 
     591                                $processor->dateFormat =  $this->options->dateFormat; 
     592                                $processor->timeFormat =  $this->options->timeFormat; 
    559593                            }//end if 
    560594 
    561595                        } else { 
    562596                            $processor = new phpbmsTable($this->db, $tabledefid); 
    563                             $processor->dateFormat =  $dateFormat; 
    564                             $processor->timeFormat =  $timeFormat; 
     597                            $processor->dateFormat =  $this->options->dateFormat; 
     598                            $processor->timeFormat =  $this->options->timeFormat; 
    565599                        }//end if 
    566600 
    567                         if(!$useUuid){ 
    568                             $therecord = $processor->getRecord((int) $request["data"]["id"], $useUuid); 
     601                        if(!$this->options->useUuid){ 
     602                            $therecord = $processor->getRecord((int) $request["data"]["id"], $this->options->useUuid); 
    569603                            $thereturn = $therecord["id"]; 
    570604                            $thevalue = (int)$request["data"]["id"]; 
    571605                        }else{ 
    572                             $therecord = $processor->getRecord(mysql_real_escape_string($request["data"]["uuid"]), $useUuid); 
     606                            $therecord = $processor->getRecord(mysql_real_escape_string($request["data"]["uuid"]), $this->options->useUuid); 
    573607                            $thereturn = $therecord["uuid"]; 
    574608                            $thevalue = $request["data"]["uuid"]; 
     
    620654 
    621655 
    622                             $result = $processor->delete_record($useUuid); 
     656                            $result = $processor->delete_record($this->options->useUuid); 
    623657 
    624658                            $this->_addToResponse($request["command"], $result); 
     
    733767 
    734768                                    $processor = new $className($this->db, $tabledefid, $request["data"]); 
    735                                     $processor->dateFormat =  $dateFormat; 
    736                                     $processor->timeFormat =  $timeFormat; 
     769                                    $processor->dateFormat =  $this->options->dateFormat; 
     770                                    $processor->timeFormat =  $this->options->timeFormat; 
    737771 
    738772                                    $methodName = $request["command"]; 
  • trunk/phpbms/modules/api/install/createtables.sql

    r530 r645  
     1CREATE TABLE `pushrecords` ( 
     2  `id` int(11) NOT NULL auto_increment, 
     3  `uuid` varchar(64) NOT NULL, 
     4  `originuuid` varchar(64) NOT NULL default '', 
     5  `destuuid` varchar(64) NOT NULL default '', 
     6  `apicommand` varchar(128) NOT NULL default 'insert', 
     7  `whereclause` varchar(256) NOT NULL default '', 
     8  `destscript` varchar(256) NOT NULL default '', 
     9  `name` varchar(128) NOT NULL default '', 
     10  `apiusername` varchar(128) NOT NULL default '', 
     11  `apipassword` varchar(128) NOT NULL default '', 
     12  `port` int(11) default NULL, 
     13  `server` varchar(255) NOT NULL default '', 
     14  `ssl` tinyint(4) NOT NULL default '0', 
     15  `httpformat` varchar(64) NOT NULL default 'POST', 
     16  `dataformat` varchar(64) NOT NULL default 'json', 
     17  `keepdestid` tinyint(1) NOT NULL default '0', 
     18  `useuuid` tinyint(1) NOT NULL default '0', 
     19  `dateformat` varchar(64) NOT NULL default 'SQL', 
     20  `timeformat` varchar(64) NOT NULL default '24 Hour', 
     21  `extraoptions` text, 
     22  `createdby` int(11) NOT NULL default '0', 
     23  `creationdate` datetime NOT NULL default '0000-00-00 00:00:00', 
     24  `modifiedby` int(11) default '0', 
     25  `modifieddate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, 
     26  PRIMARY KEY  (`id`), 
     27  UNIQUE KEY `uuid` (`uuid`) 
     28) ENGINE=InnoDB; 
  • trunk/phpbms/modules/api/install/install.php

    r525 r645  
    1818$theModule->tables = array( 
    1919                        "modules", 
     20            "tablecolumns", 
     21            "tabledefs", 
     22            "tablefindoptions", 
     23            "tableoptions", 
     24            "tablesearchablefields" 
    2025                        ); 
    2126 
  • trunk/phpbms/modules/base/cron.php

    r526 r645  
    1616        $now = gmdate('Y-m-d H:i', strtotime('now')); 
    1717 
    18         $querystatment = " 
     18        $querystatement = " 
    1919                SELECT 
    2020                        id, 
    2121                        name, 
    2222                        crontab, 
     23                        IF(`pushrecordid` != '', 'pushrecord', 'job') AS `type`, 
    2324                        job, 
     25                        `pushrecordid`, 
    2426                        startdatetime, 
    2527                        enddatetime 
     
    3133                        AND (enddatetime > NOW() OR enddatetime IS NULL)"; 
    3234 
    33         $queryresult=$db->query($querystatment); 
     35        $queryresult=$db->query($querystatement); 
    3436 
    3537        while($schedule_record=$db->fetchArray($queryresult)){ 
     
    5153                if(is_array($validTimes) && in_array($now, $validTimes)){ 
    5254 
    53                         $success = @ include($schedule_record["job"]); 
     55                        switch($schedule_record["type"]){ 
     56                                 
     57                                case "job": 
     58                                        $success = @ include($schedule_record["job"]); 
     59                                        break; 
     60                         
     61                                case "pushrecord":       
     62                                        include_once("modules/api/include/push.php"); 
     63                                        $push = new push($db, $schedule_record["pushrecordid"]); 
     64                                        $success = $push->process(); 
     65                                        break; 
     66                                 
     67                        }//end switch 
    5468 
    5569                        if($success){ 
  • trunk/phpbms/modules/base/include/scheduler.php

    r621 r645  
    5656                        $therecord["enddate"]=""; 
    5757                        $therecord["endtime"]=""; 
     58                         
     59                        $therecord["scripttype"] = "job"; 
    5860 
    5961                        return $therecord; 
     
    6567                        $therecord = parent::getRecord($id, $useUuid); 
    6668 
     69                        if($therecord["job"]) 
     70                                $therecord["scripttype"] = "job"; 
     71                        else 
     72                                $therecord["scripttype"] = "pushrecord"; 
     73                         
     74                         
     75                         
    6776                        $datearray=explode(" ",$therecord["startdatetime"]); 
    6877                        $therecord["startdate"]=$datearray[0]; 
     
    8897 
    8998                function verifyVariables($variables){ 
    90  
    91                         //must have the file that has the job that will 
    92                         //be run. 
     99                         
     100                        $validJob = true; 
    93101                        if(isset($variables["job"])){ 
    94                                 if(!$variables["job"] === "" || $variables["job"] === NULL) 
    95                                         $this->verifyErrors[] = "The `job` field must not be blank."; 
     102                                if($variables["job"] === "" || $variables["job"] === NULL) 
     103                                        $validJob = false; 
    96104                        }else 
    97                                 $this->verifyErrors[] = "The `job` field must be set."; 
     105                                $validJob = false; 
     106                                 
     107                        $validPush = true; 
     108                        if(isset($variables["pushrecordid"])){ 
     109                                if($variables["pushrecordid"] === "" || $variables["pushrecordid"] === NULL) 
     110                                        $validPush = false; 
     111                        }else 
     112                                $validPush = false; 
     113                         
     114                        if(!$validPush && !$validJob) 
     115                                $this->verifyErrors[] = "The `job` or the `pushrecordid` must be set and not blank."; 
    98116 
    99117                        //checks to see if crontab is in the (somewhat) right format 
     
    103121                                        $this->verifyErrors[] = "The `crontab` field is not of the proper form.  There must be four pairs of '::' in the field's value."; 
    104122                        }//end if 
    105  
     123                         
    106124                        return parent::verifyVariables($variables); 
    107125 
     
    133151                                $variables["enddatetime"] = NULL; 
    134152 
    135  
     153                        switch($variables["scripttype"]){ 
     154                                 
     155                                case "job": 
     156                                        $variables["pushrecordid"] = ""; 
     157                                        break; 
     158                                         
     159                                case "pushrecord": 
     160                                        $variables["job"] = ""; 
     161                                        break; 
     162                                 
     163                        }//end switch 
     164                         
    136165                        return $variables; 
    137                 } 
     166                 
     167                }//end function 
    138168 
    139169        }//end class 
  • trunk/phpbms/modules/base/include/tabledefs.php

    r641 r645  
    4646                        $therecord = parent::getDefaults(); 
    4747 
    48                         $therecord["moduleid"]=1; 
     48                        $therecord["moduleid"]="mod:29873ee8-c12a-e3f6-9010-4cd24174ffd7"; 
    4949                        $therecord["deletebutton"]="delete"; 
    5050                        $therecord["type"]="table"; 
    51                         $therecord["searchroleid"]=0; 
    52                         $therecord["importroleid"]=-100; 
    53                         $therecord["advsearchroleid"]=-100; 
    54                         $therecord["viewsqlroleid"]=-100; 
     51                        $therecord["searchroleid"] = ""; 
     52                        $therecord["importroleid"] = "Admin"; 
     53                        $therecord["advsearchroleid"] = "Admin"; 
     54                        $therecord["viewsqlroleid"] = "Admin"; 
    5555 
    5656                        return $therecord; 
     
    269269                        //and last findfields 
    270270                        $querystatement = "INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) 
    271                         VALUES ('".$variables["uuid"]."','".$variables["maintable"].".uuid','uuid',1,'field');"; 
     271                        VALUES ('".$variables["uuid"]."','".$variables["maintable"].".id','id',1,'field');"; 
    272272                        $this->db->query($querystatement); 
    273273 
  • trunk/phpbms/modules/base/include/tabledefs_options_include.php

    r551 r645  
    4444        var $tabledefuuid; 
    4545        var $tablename; 
     46        var $hasRelatedPushRecord = false; 
    4647 
    4748        function tableOptions($db, $tabledefid){ 
     
    6465 
    6566            $this->tabledefuuid = $therecord["uuid"]; 
     67 
     68            /** 
     69              *  Check for push records 
     70              */ 
     71            //if(isset($phpbms)){ 
     72            //    if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)){ 
     73            //        $querystatement = " 
     74            //            SELECT 
     75            //                `id` 
     76            //            FROM 
     77            //                `pushrecords` 
     78            //            WHERE 
     79            //                `originuuid` = '".$this->tabledefuuid."' 
     80            //        "; 
     81            // 
     82            //        $queryresult = $this->db->query($querystatement); 
     83            //        if($this->db-numRows($queryresult)) 
     84            //            $this->hasRelatedPushRecord = true; 
     85            // 
     86            //    } 
     87            //} 
     88 
    6689            $this->tablename = formatVariable($therecord["displayname"]); 
    6790 
     
    7194        function getDefaults(){ 
    7295 
    73             return array( 
     96            $thereturn = array( 
    7497                "id" => NULL, 
    7598                "name" => "", 
     
    78101                "othercommand" => 0, 
    79102                "roleid" => 0, 
    80                 "displayorder" => 0 
     103                "displayorder" => 0, 
     104                "pushrecordid" => "", 
     105                "type" => 0, 
    81106            ); 
     107             
     108            return $thereturn; 
    82109 
    83110        }//end function getDefaults 
     
    90117                    tableoptions.id, 
    91118                    tableoptions.name, 
     119                    tableoptions.name AS `displayname`, 
     120                    IF(`tableoptions`.`othercommand`='0','1',IF(`tableoptions`.`name` LIKE '%:%','3','2')) AS `commandtype`, 
    92121                    tableoptions.option, 
    93122                    tableoptions.othercommand, 
     123                    tableoptions.othercommand AS `type`, 
    94124                    tableoptions.displayorder, 
    95125                    tableoptions.roleid, 
     
    109139            $querystatement .= " 
    110140                ORDER BY 
    111                     tableoptions.othercommand, 
     141                    `commandtype`, 
    112142                    tableoptions.displayorder, 
    113143                    tableoptions.name"; 
    114144 
    115             return $this->db->query($querystatement); 
     145            $queryresult = $this->db->query($querystatement); 
     146                 
     147            $thereturn = array(); 
     148            while($therecord = $this->db->fetchArray($queryresult)){ 
     149                 
     150                $therecord["pushrecordid"] = ""; 
     151                 
     152                /** 
     153                  *  Here, we check to see if the 'name' field is a pushrecord 
     154                  *  uuid. If so, we need to set the pushrecordid. 
     155                  */ 
     156                if($therecord["commandtype"] == 3){ 
     157                         
     158                    $therecord["pushrecordid"] = $therecord["name"]; 
     159                     
     160                    /** 
     161                      *  Need name of the push record  
     162                      */                         
     163                    $pushquery = " 
     164                        SELECT 
     165                            `name` 
     166                        FROM 
     167                            `pushrecords` 
     168                        WHERE 
     169                            `uuid` = '".$therecord["name"]."' 
     170                    "; 
     171 
     172                    $pushresult = $this->db->query($pushquery); 
     173                     
     174                    if($this->db->numRows($pushresult)){ 
     175                        $pushrecord = $this->db->fetchArray($pushresult); 
     176                        $therecord["displayname"] = $pushrecord["name"]; 
     177                    }//end if 
     178                         
     179                    $therecord["type"] = 2; 
     180                     
     181                }//end if 
     182 
     183                $thereturn[] = $therecord; 
     184 
     185            }//end while 
     186 
     187            return $thereturn; 
     188            //return $this->db->query($querystatement); 
    116189 
    117190        }//end method 
    118191 
    119192 
    120         function showRecords($queryresult){ 
     193        /** 
     194          *  function showRecords 
     195          *  @param array $recordArray 
     196          */ 
     197 
     198        function showRecords($recordArray){ 
    121199 
    122200            global $phpbms; 
     
    143221                <tbody> 
    144222                    <?php 
    145                         if($this->db->numRows($queryresult)){ 
     223                        if(count($recordArray)){ 
    146224 
    147225                            $row = 1; 
    148226 
    149                             $other = 3; 
    150  
    151                             while($therecord = $this->db->fetchArray($queryresult)){ 
     227                            $other = 4; 
     228 
     229                            foreach($recordArray as $therecord){ 
    152230 
    153231                                $row = ($row == 1) ? 2 : 1; 
    154232 
    155                                     if($therecord["othercommand"] !== $other){ 
    156  
    157                                         ?><tr class="queryGroup"><td colspan="7"><?php echo ($therecord["othercommand"] == 1)? "Additional Commands" : "Integrated Features";?></td></tr><?php 
    158  
    159                                         $other = $therecord["othercommand"]; 
     233                                    if($therecord["commandtype"] !== $other){ 
     234                                         
     235                                        switch($therecord["commandtype"]){ 
     236                                             
     237                                            case 1: 
     238                                                $title = "Integrated Features"; 
     239                                                break; 
     240                                             
     241                                            case 2: 
     242                                                $title = "Additional Commands"; 
     243                                                break; 
     244                                             
     245                                            case 3: 
     246                                                $title = "Api Commands"; 
     247                                                break; 
     248                                             
     249                                        }//end if 
     250 
     251                                        ?><tr class="queryGroup"><td colspan="7"><?php echo $title;?></td></tr><?php 
     252 
     253                                        $other = $therecord["commandtype"]; 
    160254 
    161255                                    }//end if ?> 
     
    200294 
    201295                                            if($therecord["othercommand"]) 
    202                                                 echo formatVariable($therecord["name"]); 
     296                                                echo formatVariable($therecord["displayname"]); 
    203297                                            else 
    204298                                                echo "&nbsp;"; 
     
    249343                $variables["needselect"] = 0; 
    250344 
    251             if($variables["type"]){ 
    252  
    253                 $name = $variables["acName"]; 
    254                 $option = $variables["acOption"]; 
    255  
    256             } else { 
    257  
    258                 $name = $variables["ifName"]; 
    259                 $option = $variables["ifOption"]; 
    260  
    261             } //end if 
     345            switch($variables["type"]){ 
     346 
     347                case 0: 
     348                    $name = $variables["ifName"]; 
     349                    $option = $variables["ifOption"]; 
     350                    break; 
     351 
     352                case 1: 
     353                    $name = $variables["acName"]; 
     354                    $option = $variables["acOption"]; 
     355                    break; 
     356 
     357                case 2: 
     358                    $name = $variables["productid"]; 
     359                    $option = $variables["acOption"]; 
     360                    break; 
     361 
     362            }//end switch 
    262363 
    263364            $insertstatement = " 
     
    296397                $variables["needselect"] = 0; 
    297398 
     399            if($variables["type"]) 
     400                $variables["othercommand"] = 1; 
     401            else 
     402                $variables["othercommand"] = 0; 
     403 
    298404            $updatestatement = " 
    299405                UPDATE 
     
    302408                    roleid = '".$variables["roleid"]."', 
    303409                    displayorder = ".((int) $variables["displayorder"]).", 
    304                     othercommand = ".((int) $variables["type"]).", 
     410                    othercommand = ".((int) $variables["othercommand"]).", 
    305411                    needselect = ".((int) $variables["needselect"]).","; 
    306412 
    307             if(!$variables["type"]) 
    308                 $updatestatement .= " 
    309                     name = '".$variables["ifName"]."', 
    310                     `option` = '".$variables["ifOption"]."' 
    311                 "; 
    312             else 
    313                 $updatestatement .= " 
    314                     name = '".$variables["acName"]."', 
    315                     `option` = '".$variables["acOption"]."' 
    316                 "; 
     413            switch($variables["type"]){ 
     414 
     415                case 0: 
     416                    $updatestatement .= " 
     417                        name = '".$variables["ifName"]."', 
     418                        `option` = '".$variables["ifOption"]."' 
     419                    "; 
     420                    break; 
     421 
     422                case 1: 
     423                    $updatestatement .= " 
     424                        name = '".$variables["acName"]."', 
     425                        `option` = '".$variables["acOption"]."' 
     426                    "; 
     427                    break; 
     428 
     429                case 2: 
     430                    $updatestatement .= " 
     431                        `name` = '".$variables["pushrecordid"]."', 
     432                        `option` = '".$variables["acOption"]."' 
     433                    "; 
     434                    break; 
     435 
     436            }//end switch 
    317437 
    318438            $updatestatement .= " 
     
    348468 
    349469                case "edit": 
    350                     $queryresult = $this->get($variables["id"]); 
    351                     $therecord = $this->db->fetchArray($queryresult); 
     470                    $therecord = $this->get($variables["id"]); 
     471                    $therecord = $therecord[0]; 
    352472                    break; 
    353473 
  • trunk/phpbms/modules/base/javascript/tableoptions.js

    r318 r645  
    11tableOptions = { 
    2          
     2 
    33        switchType: function(e){ 
    4                  
     4 
    55                var type =      getObjectFromID("type"); 
    66                var ifDiv =     getObjectFromID("ifDiv"); 
    77                var acDiv =     getObjectFromID("acDiv"); 
    8                  
    9                 if(type.value == 1){ 
    10                          
    11                         ifDiv.style.display = "none"; 
    12                         acDiv.style.display = "block"; 
    13                          
    14                 } else { 
    15                          
    16                         ifDiv.style.display = "block"; 
    17                         acDiv.style.display = "none"; 
    18                          
    19                 }//end if                        
    20                  
     8                var acNote = getObjectFromID("acNote"); 
     9                var apiNote = getObjectFromID("apiNote"); 
     10 
     11                switch(type.value){ 
     12 
     13                        case "0": 
     14                                ifDiv.style.display = "block"; 
     15                                acDiv.style.display = "none"; 
     16                                apiNote.style.display = "none"; 
     17                                acNote.style.display = "none"; 
     18                                break; 
     19 
     20                        case "1": 
     21                                ifDiv.style.display = "none"; 
     22                                acDiv.style.display = "block"; 
     23                                apiNote.style.display = "none"; 
     24                                acNote.style.display = "block"; 
     25                                break; 
     26 
     27                        case "2": 
     28                                ifDiv.style.display = "none"; 
     29                                acDiv.style.display = "block"; 
     30                                apiNote.style.display = "block"; 
     31                                acNote.style.display = "none"; 
     32                                break; 
     33                } 
     34 
    2135        },//end method 
    22          
    23          
     36 
     37 
    2438        edit: function(e){ 
    25                  
     39 
    2640                tableOptions._tableButtonClick(e, "edit") 
    27                  
     41 
    2842        }, //end method 
    29          
    30          
     43 
     44 
    3145        del: function(e){ 
    32          
     46 
    3347                tableOptions._tableButtonClick(e, "delete") 
    3448 
    3549        },//end method 
    36          
    37          
     50 
     51 
    3852        _tableButtonClick: function(e, thecommand){ 
    39                  
     53 
    4054                var id =                getObjectFromID("id"); 
    4155                var command =   getObjectFromID("command"); 
    42                  
     56 
    4357                var button = e.src(); 
    4458 
    4559                var theid = button.id.substr(3); 
    46                  
     60 
    4761                id.value = theid; 
    4862                command.value = thecommand; 
    4963 
    50                 tableOptions.submitForm(e);  
     64                tableOptions.submitForm(e); 
    5165 
    5266        }, //end method 
    53          
    54          
     67 
     68 
    5569        submitForm: function(e){ 
    56                                  
     70 
    5771                var command = getObjectFromID("command"); 
    5872                var theform = getObjectFromID("record") 
    59                  
     73 
    6074                if(command.value == "add" || command.value == "update"){ 
    6175 
     
    6781 
    6882                }//end if 
    69                  
     83 
    7084                theform.submit(); 
    71                  
     85 
    7286        }, //end method 
    73          
    74          
     87 
     88 
    7589        cancel: function(e){ 
    7690 
    7791                var command =   getObjectFromID("command"); 
    78                  
     92 
    7993                command.value = "cancel"; 
    8094 
    81                 tableOptions.submitForm(e);  
     95                tableOptions.submitForm(e); 
    8296 
    8397        }//end method 
    84          
     98 
    8599}//end class 
    86100 
     
    88102/* ------------------------------------------------------- */ 
    89103connect(window,"onload",function() { 
    90          
     104 
    91105        var type = getObjectFromID("type") 
    92         connect(type, "onchange", tableOptions.switchType);      
    93          
     106        connect(type, "onchange", tableOptions.switchType); 
     107 
    94108        var theForm = getObjectFromID("record"); 
    95109        connect(type, "onsubmit", function(e){e.stop();}); 
    96          
     110 
    97111        var delButtons = getElementsByClassName("buttonDelete"); 
    98112        for(var i=0; i < delButtons.length; i++) 
    99                 connect(delButtons[i], "onclick", tableOptions.del);     
    100                  
     113                connect(delButtons[i], "onclick", tableOptions.del); 
     114 
    101115        var editButtons = getElementsByClassName("buttonEdit"); 
    102116        for(var i=0; i < editButtons.length; i++) 
    103                 connect(editButtons[i], "onclick", tableOptions.edit);   
    104          
     117                connect(editButtons[i], "onclick", tableOptions.edit); 
     118 
    105119        var cancelButton = getObjectFromID("cancel"); 
    106120        if(cancelButton) 
    107121                connect(cancelButton, "onclick", tableOptions.cancel); 
    108                  
     122 
    109123        var saveButton = getObjectFromID("save"); 
    110         connect(saveButton, "onclick", tableOptions.submitForm);                 
    111          
     124        connect(saveButton, "onclick", tableOptions.submitForm); 
     125 
    112126        tableOptions.switchType(); 
    113          
     127 
    114128});//end connect 
  • trunk/phpbms/modules/base/scheduler_addedit.php

    r592 r645  
    5454 
    5555        $phpbms->cssIncludes[] = "pages/scheduler.css"; 
     56        $phpbms->jsIncludes[] = "modules/base/javascript/scheduler.js"; 
    5657 
    5758                //Form Elements 
    5859                //============================================================== 
    5960                $theform = new phpbmsForm(); 
     61                $theform->id = $theform->name; 
    6062 
    6163                $theinput = new inputCheckbox("inactive",$therecord["inactive"]); 
     
    6668                $theform->addField($theinput); 
    6769 
    68                 $theinput = new inputField("job",$therecord["job"],"script",true,NULL,32,128,false); 
     70                if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)){ 
     71                         
     72                        $list = array( 
     73                                "file" => "job", 
     74                                "push record"=>"pushrecord" 
     75                        ); 
     76                        $theinput = new inputBasicList("scripttype", $therecord["scripttype"], $list, "script type"); 
     77                        $theform->addField($theinput); 
     78                         
     79                        $theinput = new inputSmartSearch($db, "pushrecordid", "Pick Push Record For Cron", $therecord["pushrecordid"]); 
     80                        $theform->addField($theinput); 
     81                 
     82                }//end if 
     83                 
     84                $theinput = new inputField("job",$therecord["job"],"script",false,NULL,32,128,false); 
    6985                $theform->addField($theinput); 
    70  
     86                 
    7187                $theinput = new inputDatePicker("startdate",$therecord["startdate"], "start date" ,true, 11, 15, false); 
    7288                $theform->addField($theinput); 
    7389 
    7490                $theinput = new inputTimePicker("starttime",$therecord["starttime"], "start time" ,true,11, 15, false); 
    75                 //$theinput->setAttribute("onchange","checkEndDate();"); 
    7691                $theform->addField($theinput); 
    7792 
     
    115130                        <p><?php $theform->showField("name");?></p> 
    116131 
    117                         <p> 
    118                                 <label for="job">script</label> <span class="notes">(path relative to <?php echo $currentpath?>)</span><br /> 
    119                                 <?php $theform->showField("job");?> 
     132                        <?php if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)){ ?> 
     133                                <p><?php $theform->showField("scripttype"); ?></p> 
     134                                <p id="pushrecordidp"> 
     135                                                <?php $theform->showField("pushrecordid"); ?> 
     136                                </p> 
     137                        <?php }//end if ?>       
     138                        <p id="jobp"> 
     139                                        <label for="job">script</label> <span class="notes">(path relative to <?php echo $currentpath?>)</span><br /> 
     140                                        <?php $theform->showField("job");?> 
    120141                        </p> 
    121142                        <p> 
  • trunk/phpbms/modules/base/smartsearches_addedit.php

    r643 r645  
    4040        include("include/fields.php"); 
    4141        include("include/tables.php"); 
     42 
    4243 
    4344        $thetable = new phpbmstable($db,"tbld:29925e0a-c825-0067-8882-db4b57866a96"); 
  • trunk/phpbms/modules/base/tabledefs_options.php

    r551 r645  
    7070                        "Additional Commands" => 1, 
    7171                ); 
    72                 $theinput = new inputBasicList("type", $therecord["othercommand"], $temparray); 
    73                 $theform->addField($theinput); 
    74  
    75                 $temparray =array( 
     72 
     73 
     74        if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)){ 
     75            $temparray["Api Commands"] = 2; 
     76 
     77            $theinput = new inputDataTableList($db, "pushrecordid", $therecord["pushrecordid"], "pushrecords", "pushrecords.uuid", 
     78                                               "pushrecords.name", "pushrecords.originuuid = '".$options->tabledefuuid."'", 
     79                                               "pushrecords.name ASC", true, "Push Record Commands"); 
     80            $theform->addField($theinput); 
     81        } 
     82 
     83                $theinput = new inputBasicList("type", $therecord["type"], $temparray); 
     84                $theform->addField($theinput); 
     85 
     86                $temparray = array( 
    7687                        "new" => "new", 
    7788                        "edit" => "edit", 
     
    157168                        <div id="acDiv"> 
    158169 
    159                                 <p class="notes"> 
    160                                         Additional command allows you to add items to the 
    161                                         other commands drop down on the search screen. 
    162                                         The PHP method name should refrence a function 
    163                                         in the tables extended searchFunctions class 
    164                                         in the [tablename].php located in the modules 
    165                                         include folder. 
    166                                 </p> 
     170                                <div id="acNote"> 
     171                    <p class="notes"> 
     172                        Additional command allows you to add items to the 
     173                        other commands drop down on the search screen. 
     174                        The PHP method name should refrence a function 
     175                        in the tables extended searchFunctions class 
     176                        in the [tablename].php located in the modules 
     177                        include folder. 
     178                    </p> 
     179                    <p><?php $theform->showField("acName") ?></p> 
     180                </div> 
     181                <?php if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)){ ?> 
     182                    <div id="apiNote"> 
     183                        <p class="notes"> 
     184                            API stuff. 
     185                        </p> 
     186                        <p><?php $theform->showfield("pushrecordid"); ?></p> 
     187                    </div> 
     188                <?php }//end if ?> 
    167189 
    168190                                <p><?php $theform->showField("acOption") ?></p> 
    169  
    170                                 <p><?php $theform->showField("acName") ?></p> 
    171191 
    172192                                <p><?php $theform->showField("needselect") ?></p> 
  • trunk/phpbms/modules/bms/include/clients.php

    r638 r645  
    228228                                if( $variables["otherphone"] !== NULL && $variables["otherphone"] !== "" && !validatePhone($variables["otherphone"])) 
    229229                                        $this->verifyErrors[] = "The `otherphone` field must have a valid phone number (as set in configuration) or must be left blank."; 
    230  
     230                        */ 
    231231                        //check bool on has credit 
    232232                        if(isset($variables["hascredit"])) 
    233233                                if($variables["hascredit"] && $variables["hascredit"] != 1) 
    234                                         $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1).";*/ 
     234                                        $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1)."; 
    235235 
    236236 
  • trunk/phpbms/modules/bms/javascript/invoice.js

    r643 r645  
    13261326function calculateTotal(){ 
    13271327 
    1328         var thetotalBD=getObjectFromID("totalBD"); 
    1329         var subtotal=getObjectFromID("totaltni"); 
    1330         var thediscount=getObjectFromID("discountamount"); 
    1331         var shipping=getObjectFromID("shipping"); 
    1332         var taxpercentage=getObjectFromID("taxpercentage"); 
    1333         var tax=getObjectFromID("tax"); 
    1334         var totalti=getObjectFromID("totalti"); 
    1335         var totaltaxable=getObjectFromID("totaltaxable"); 
    1336         var discountFromID=getObjectFromID("discount"); 
     1328        var thetotalBD = getObjectFromID("totalBD"); 
     1329        var subtotal = getObjectFromID("totaltni"); 
     1330        var thediscount = getObjectFromID("discountamount"); 
     1331        var shipping = getObjectFromID("shipping"); 
     1332        var taxpercentage = getObjectFromID("taxpercentage"); 
     1333        var tax = getObjectFromID("tax"); 
     1334        var totalti = getObjectFromID("totalti"); 
     1335        var totaltaxable = getObjectFromID("totaltaxable"); 
     1336        var discountFromID = getObjectFromID("discount"); 
    13371337 
    13381338        //calculate and reformat discount 
     
    13431343                // compute discount from discount id 
    13441344                if(discountFromID.value.indexOf("%")!=-1){ 
    1345                         numDiscount=parseFloat(thetotalBD.value)*parseFloat(discountFromID.value.substring(0,discountFromID.value.length-1))/100 
     1345                        numDiscount=parseFloat(thetotalBD.value)*parseFloat(discountFromID.value.substring(0,discountFromID.value.length-1))/100; 
    13461346                } else { 
    13471347                        numDiscount=parseFloat(discountFromID.value); 
     
    13491349        } 
    13501350 
    1351         thediscount.value= numberToCurrency(numDiscount); 
     1351        thediscount.value = numberToCurrency(numDiscount); 
    13521352 
    13531353        //calculate totaltaxable 
     
    13621362 
    13631363        //next calculate and reformat shipping 
    1364         var numshipping=currencyToNumber(shipping.value); 
    1365         shippingValue=numberToCurrency(numshipping); 
    1366         shipping.value=shippingValue; 
     1364        var numshipping = currencyToNumber(shipping.value); 
     1365        shippingValue = numberToCurrency(numshipping); 
     1366        shipping.value = shippingValue; 
    13671367 
    13681368        //next calculate and reformat tax 
     
    13861386 
    13871387        //last calculate and format the grand total 
    1388         var thetotal=numsubtotal+numshipping+numtax; 
     1388        var thetotal = roundForCurrency(numsubtotal + numshipping + numtax); 
    13891389        thetotal=numberToCurrency(thetotal); 
    13901390        totalti.value=thetotal; 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.