Esempio n. 1
0
 function verifyVariables($variables)
 {
     if (isset($variables["setreadytopost"])) {
         if ($variables["setreadytopost"] && $variables["setreadytopost"] != 1) {
             $this->verifyErrors[] = "The `setreadytopost` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["invoicedefault"])) {
         if ($variables["invoicedefault"] && $variables["invoicedefault"] != 1) {
             $this->verifyErrors[] = "The `invoicedefault` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["defaultassignedtoid"])) {
         if ($this->_availableUserUUIDs === NULL) {
             $this->_availableUserUUIDs = $this->_loadUUIDList("users");
             $this->_availableUserUUIDs[] = "";
             //for everyone/no one
         }
         //end if
         if (!in_array((string) $variables["defaultassignedtoid"], $this->_availableUserUUIDs)) {
             $this->verifyErrors[] = "The `defaultassignedtoid` field does not give an existing/acceptable user uuid.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 2
0
 function verifyVariables($variables)
 {
     //table's default is fine
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "percent":
             case "amount":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `type` field is invalid.\n\t\t\t\t\t\t\tIt must be either 'percent' or 'amount'.";
                 break;
         }
         //end switch
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 3
0
 function verifyVariables($variables)
 {
     //check booleans
     if (isset($variables["webenabled"])) {
         if ($variables["webenabled"] && $variables["webenabled"] != 1) {
             $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["parentid"])) {
         $tempParentId = $variables["parentid"];
         $tempUUID = "";
         if (isset($variables["uuid"])) {
             $tempUUID = $variables["uuid"];
         }
         if (!$this->checkForValidParentid($tempUUID, $tempParentId)) {
             $this->verifyErrors[] = "The `parentid` field does not give a valid parent id.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 4
0
 function verifyVariables($variables)
 {
     if (isset($variables["title"])) {
         if ($variables["title"] === "" || $variables["title"] === NULL) {
             $this->verifyErrors[] = "The `title` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `title` field must be set.";
     }
     if (isset($variables["file"])) {
         if ($variables["file"] === "" || $variables["file"] === NULL) {
             $this->verifyErrors[] = "The `file` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `file` field must be set.";
     }
     //table default of '' is sufficient
     if (isset($variables["roleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             // no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             // admin restriction
         }
         //end if
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     //table default insufficient
     if (isset($variables["moduleid"])) {
         if ($this->_availableModuleUUIDs === NULL) {
             $this->_availableModuleUUIDs = $this->_loadUUIDList("modules");
         }
         if (!in_array((string) $variables["moduleid"], $this->_availableModuleUUIDs)) {
             $this->verifyErrors[] = "The `moduleid` field does not give an existing/acceptable module id number.";
         }
     } else {
         $this->verifyErrors[] = "The `moduleid` field must be set.";
     }
     if (isset($variables["default"])) {
         if ($variables["default"] && $variables["default"] != 1) {
             $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "big":
             case "little":
                 break;
             default:
                 $this->verifyErrors[] = "The `type` field's value must be one of the following: 'big' or 'little'";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `type` field must be set.";
     }
     if (isset($variables["uuid"])) {
         if ($variables["uuid"] !== "" && $variables !== NULL) {
             if ($this->_availableUUIDs === NULL) {
                 $this->_populateUuidArray();
             }
             if (!isset($variables["id"])) {
                 $tempid = 0;
             } else {
                 $tempid = $variables["id"];
             }
             $tempuuid = $variables["uuid"];
             // using this because it looks ugly to but the brackets within brackets
             if (array_key_exists((string) $variables["uuid"], $this->_availableUUIDs)) {
                 if ($this->_availableUUIDs[$tempuuid]["id"] !== $tempid) {
                     $this->verifyErrors = "The `uuid` field must give an unique uuid.";
                 }
             }
             //end if
         } else {
             $this->verifyErrors[] = "The `uuid` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `uuid` field must be set.";
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 5
0
 function verifyVariables($variables)
 {
     //cannot be table default ("")
     if (isset($variables["tofield"])) {
         if ($variables["tofield"] === "" || $variables["tofield"] === NULL) {
             $this->verifyErrors[] = "The `tofield` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `tofield` field must be set.";
     }
     //cannot be table default ("")
     if (isset($variables["fromfield"])) {
         if ($variables["fromfield"] === "" || $variables["fromfield"] === NULL) {
             $this->verifyErrors[] = "The `from` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `fromfield` field must be set.";
     }
     //cannot be table default
     if (isset($variables["fromtableid"])) {
         if ($this->_availableTabledefUUIDs === NULL || $this->_availableTabledefNames === NULL) {
             $this->populateTableDefArrays();
         }
         if (!in_array($variables["fromtableid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `fromtableid` field does not give an existing/acceptable parent id number.";
         }
     } else {
         $this->verifyErrors[] = "The `fromtableid` field must be set.";
     }
     //cannot be table default
     if (isset($variables["totableid"])) {
         if ($this->_availableTabledefUUIDs === NULL || $this->_availableTabledefNames === NULL) {
             $this->populateTableDefArrays();
         }
         if (!in_array($variables["totableid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `totableid` field does not give an existing/acceptable to table id number.";
         }
     } else {
         $this->verifyErrors[] = "The `totableid` field must be set.";
     }
     //check boolean
     if (isset($variables["inherit"])) {
         if ($variables["inherit"] && $variables["inherit"] != 1) {
             $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 6
0
 function verifyVariables($variables)
 {
     //if it is set, we'll have to check, if not, it defaults to '' which is an acceptable
     //value.
     if (isset($variables["roleid"])) {
         //check to see if the RoleIDs are populated
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             $this->_availableRoleUUIDs[] = "Admin";
         }
         //end if
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 7
0
 function verifyVariables($variables)
 {
     //table default ok
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "NT":
             case "TS":
             case "EV":
                 break;
             case "SM":
                 //for system message, not private
                 if (isset($variables["private"])) {
                     if ($variables["private"]) {
                         $this->verifyErrors[] = "For records with `type` of 'SM' (System Message), the `private\n\t\t\t\t\t\t\t\t\t\t\t\tfield must be equivalent to 0.";
                     }
                 }
                 break;
             default:
                 $this->verifyErrors[] = "The `type` field given is not an acceptable value. Acceptable values are 'NT', 'TS', 'EV', or 'SM'";
                 break;
         }
         //end switch
     }
     //end if
     //Doesn't need to be set... only used if repeating
     if (isset($variables["repeat"])) {
         if ($variables["repeat"]) {
             if (isset($variables["startdate"])) {
                 if ($variables["startdate"]) {
                 } else {
                     $this->verifyErrors[] = "If a `note` record is set to repeat it must also have a `startdate`.";
                 }
             } else {
                 $this->verifyErrors[] = "If a `note` record is set to repeat it must also have a `startdate`.";
             }
         }
     }
     if (isset($variables["repeattype"])) {
         if ($variables["repeattype"]) {
             //it can be "" or NULL
             switch ($variables["repeattype"]) {
                 case "Daily":
                 case "Weekly":
                 case "Monthly":
                 case "Yearly":
                     break;
                 default:
                     $this->verifyErrors[] = "The `repeatetype` field given is not an acceptable value.\n\t\t\t\t\t\t\t\t\t\t\tAcceptable values are 'Daily', 'Weekly', 'Monthly', or 'Yearly'";
                     break;
             }
         }
     }
     //end switch
     //check booleans
     if (isset($variables["completed"])) {
         if ($variables["completed"] && $variables["completed"] != 1) {
             $this->verifyErrors[] = "The `completed` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["private"])) {
         if ($variables["private"] && $variables["private"] != 1) {
             $this->verifyErrors[] = "The `private` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["repeating"])) {
         if ($variables["repeating"] && $variables["repeating"] != 1) {
             $this->verifyErrors[] = "The `repeating` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 8
0
 function verifyVariables($variables)
 {
     //must have a partnumber...table default is not enough
     if (isset($variables["partnumber"])) {
         //must have some sort of partnumber
         if ($variables["partnumber"] !== "" || $variables["partnumber"] !== NULL) {
             if ($this->availableProducts === NULL) {
                 $this->populateProductArray();
             }
             //can't have this partnumber already chosen
             if (!isset($variables["id"])) {
                 $tempid = 0;
             } else {
                 $tempid = $variables["id"];
             }
             $temppartnumber = $variables["partnumber"];
             // using this because it looks ugly to put the brackets within brackets
             if (array_key_exists($variables["partnumber"], $this->availableProducts)) {
                 if ($this->availableProducts[$temppartnumber]["id"] !== $tempid) {
                     $this->verifyErrors[] = "The `partnumber` field must give an unique part number.";
                 }
             } else {
                 $this->availableProducts[$temppartnumber]["id"] = "aoihweoighaow giuahrweughauerhgaiudsf iaheiugaiuweg iagweiuha wiueg";
                 // impossible id put in
             }
             //end if
         } else {
             $this->verifyErrors[] = "The `partnumber` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `partnumber` field must be set.";
     }
     if (isset($variables["status"])) {
         switch ($variables["status"]) {
             case "In Stock":
             case "Out of Stock":
             case "Backordered":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `status` field is invalid.\n\t\t\t\t\t\t\tIt must be 'In Stock', 'Out of Stock', or 'Backordered'.";
                 break;
         }
         //end switch
     }
     //end if
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "Inventory":
             case "Non-Inventory":
             case "Service":
             case "Kit":
             case "Assembly":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `type` field is invalid.\n\t\t\t\t\t\t\tIt must be 'Inventory', 'Non-Inventory', 'Service', 'Kit', or 'Assembly'.";
                 break;
         }
         //end switch
     }
     //end if
     //check boolean
     if (isset($variables["webenabled"])) {
         if ($variables["webenabled"] && $variables["webenabled"] != 1) {
             $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["isoversized"])) {
         if ($variables["isoversized"] && $variables["isoversized"] != 1) {
             $this->verifyErrors[] = "The `isoversized` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["isprepackaged"])) {
         if ($variables["isprepackaged"] && $variables["isprepackaged"] != 1) {
             $this->verifyErrors[] = "The `isprepackaged` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["taxable"])) {
         if ($variables["taxable"] && $variables["taxable"] != 1) {
             $this->verifyErrors[] = "The `taxable` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 9
0
 function verifyVariables($variables)
 {
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "prospect":
                 if (isset($variables["becameclient"])) {
                     if ($variables["becameclient"] !== "" || $variables["becameclient"] !== NULL) {
                         $this->verifyErrors[] = "Records with `type` of 'prospect'\n\t\t\t\t\t\t\t\t\tmust have the `becameclient` field kept blank.";
                     }
                 }
                 //end if
                 if (isset($variables["hascredit"])) {
                     if ($variables["hascredit"]) {
                         $this->verifyErrors[] = "Records with `type` of 'prospect'\n\t\t\t\t\t\t\t\t\tmust have the `hascredit` field kept blank or 0.";
                     }
                 }
                 //end if
                 if (isset($variables["creditlimit"])) {
                     if ($variables["creditlimit"]) {
                         $this->verifyErrors[] = "Records with `type` of 'prospect'\n\t\t\t\t\t\t\t\t\tmust have the `creditlimit` field kept blank or 0.";
                     }
                 }
                 //end if
                 break;
             case "client":
                 if (isset($variables["becameclient"])) {
                     //Possibly run through string to date functions
                     if (!$variables["becameclient"]) {
                         $this->verifyErrors[] = "Records with `type` of 'client'\n\t\t\t\t\t\t\t\t\tmust have not have the `becameclient` field blank.";
                     }
                 } else {
                     $this->verifyErrors[] = "Records with `type` of 'client'\n\t\t\t\t\t\t\t\tmust set the `becameclient` field.";
                 }
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `type` field is invalid.\n\t\t\t\t\t\t\tIt must either be 'prospect' or 'client'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `type` field must be set.";
     }
     ////check for currency on credit limit (((real value) >= 0 ... non-negative)
     //if(isset($variables["creditlimit"]))
     //	if(!is_numeric($variables["creditlimit"]) && $variables["creditlimit"])
     //		$this->verifyErrors[] = "The `creditlimit` field must be a real number or equivalent to zero.";
     //----------------[ phone & email ]------------------------------------------------------
     /*//check valid email
     			if(isset($variables["email"]))
     				if( $variables["email"] !== NULL && $variables["email"] !== "" && !validateEmail($variables["email"]))
     					$this->verifyErrors[] = "The `email` field must have a valid email or must be left blank.";
     
     			//check valid homephone
     			if(isset($variables["homephone"]))
     				if( $variables["homephone"] !== NULL && $variables["homephone"] !== "" && !validatePhone($variables["homephone"]))
     					$this->verifyErrors[] = "The `homephone` field must have a valid phone number (as set in configuration) or must be left blank.";
     
     			//check valid workphone
     			if(isset($variables["workphone"]))
     				if( $variables["workphone"] !== NULL && $variables["workphone"] !== "" && !validatePhone($variables["workphone"]))
     					$this->verifyErrors[] = "The `workphone` field must have a valid phone number (as set in configuration) or must be left blank.";
     
     			//check valid mobilephone
     			if(isset($variables["mobilephone"]))
     				if( $variables["mobilephone"] !== NULL && $variables["mobilephone"] !== "" && !validatePhone($variables["mobilephone"]))
     					$this->verifyErrors[] = "The `mobilephone` field must have a valid phone number (as set in configuration) or must be left blank.";
     
     			//check valid fax
     			if(isset($variables["fax"]))
     				if( $variables["fax"] !== NULL && $variables["fax"] !== "" && !validatePhone($variables["fax"]))
     					$this->verifyErrors[] = "The `fax` field must have a valid phone number (as set in configuration) or must be left blank.";
     
     			//check valid otherphone
     			if(isset($variables["otherphone"]))
     				if( $variables["otherphone"] !== NULL && $variables["otherphone"] !== "" && !validatePhone($variables["otherphone"]))
     					$this->verifyErrors[] = "The `otherphone` field must have a valid phone number (as set in configuration) or must be left blank.";
     			*/
     //check bool on has credit
     if (isset($variables["hascredit"])) {
         if ($variables["hascredit"] && $variables["hascredit"] != 1) {
             $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     //----------------[ Order Defaults]------------------------------------------------------
     //Payement Method
     if (isset($variables["paymentmethodid"])) {
         if ($this->_availablePaymentMethodUUIDs === NULL) {
             $this->_availablePaymentMethodUUIDs = $this->_loadUUIDList("paymentmethods");
             $this->_availablePaymentMethodUUIDs[] = "";
             //for none
         }
         if (!in_array((string) $variables["paymentmethodid"], $this->_availablePaymentMethodUUIDs)) {
             $this->verifyErrors[] = "The `paymentmethodid` field does not give an existing/acceptable payment method uuid.";
         }
     }
     //end if
     if (isset($variables["shippingmethodid"])) {
         if ($this->_availableShippingMethodUUIDs === NULL) {
             $this->_availableShippingMethodUUIDs = $this->_loadUUIDList("shippingmethods");
             $this->_availableShippingMethodUUIDs[] = "";
             // for none
         }
         //end if
         if (!in_array((string) $variables["shippingmethodid"], $this->_availableShippingMethodUUIDs)) {
             $this->verifyErrors[] = "The `shippingmethodid` field does not give an existing/acceptable shipping method uuid.";
         }
     }
     //end if
     if (isset($variables["discountid"])) {
         if ($this->_availableDiscountUUIDs === NULL) {
             $this->_availableDiscountUUIDs = $this->_loadUUIDList("discounts");
             $this->_availableDiscountUUIDs[] = "";
             //for none
         }
         //end if
         if (!in_array((string) $variables["discountid"], $this->_availableDiscountUUIDs)) {
             $this->verifyErrors[] = "The `discount` field does not give an existing/acceptable discount uuid.";
         }
     }
     //end if
     if (isset($variables["taxareaid"])) {
         if ($this->_availableTaxUUIDs === NULL) {
             $this->_availableTaxUUIDs = $this->_loadUUIDList("tax");
             $this->_availableTaxUUIDs[] = "";
             //for none
         }
         //end if
         if (!in_array((string) $variables["taxareaid"], $this->_availableTaxUUIDs)) {
             $this->verifyErrors[] = "The `taxareaid` field does not give an existing/acceptable tax uuid.";
         }
     }
     //end if
     //---------------------[ end order defaults ]----------------------------------------
     //check sales manager id
     if (isset($variables["salesmanagerid"])) {
         if ($this->_availableUserUUIDs === NULL) {
             $this->_availableUserUUIDs = $this->_loadUUIDList("users");
             $this->_availableUserUUIDs[] = "";
         }
         //end if
         if (!in_array((string) $variables["salesmanagerid"], $this->_availableUserUUIDs)) {
             $this->verifyErrors[] = "The `salesmanagerid` field does not give an existing/acceptable user uuid.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 10
0
 function verifyVariables($variables)
 {
     //default not sufficient
     if (isset($variables["clientid"])) {
         if ($this->_availableClientUUIDs === NULL) {
             $this->_availableClientUUIDs = $this->_loadUUIDList("clients");
         }
         if (!in_array((string) $variables["clientid"], $this->_availableClientUUIDs)) {
             $this->verifyErrors[] = "The `clientid` field does not give an existing/acceptable client uuid.";
         }
     } else {
         $this->verifyErrors[] = "The `clientid` field must be set.";
     }
     //because enum, default not sufficient
     if (isset($variables["status"])) {
         switch ($variables["status"]) {
             case "open":
                 if (isset($variables["readytopost"])) {
                     if ($variables["readytopost"]) {
                         $this->verifyErrors[] = "If the `status` is 'open', the `readytopost` field must be not be '1'";
                     }
                 }
                 break;
             case "collected":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `status` field is invalid.  It must\n\t\t\t\t\t\t\tbe either 'open' or 'collected'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `status` field must be set.";
     }
     // Default is not sufficient
     if (isset($variables["paymentmethodid"])) {
         if ($this->_availablePaymentMethodUUIDs === NULL) {
             $this->_availablePaymentMethodUUIDs = $this->_loadUUIDList("paymentmethods");
             $this->_availablePaymentMethodUUIDs[] = -1;
         }
         //end if
         if (!in_array((string) $variables["paymentmethodid"], $this->_availablePaymentMethodUUIDs)) {
             $this->verifyErrors[] = "The `paymentmethod` field does not give an existing/acceptable payment method uuid.";
         }
     } else {
         $this->verifyErrors[] = "The `paymentmethodid` field must be set.";
     }
     //check booleans
     if (isset($variables["readytopost"])) {
         if ($variables["readytopost"] && $variables["readytopost"] != 1) {
             $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["posted"])) {
         if ($variables["posted"] && $variables["posted"] != 1) {
             $this->verifyErrors[] = "The `posted` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 11
0
 function verifyVariables($variables)
 {
     //---------[ check login names ]------------------------------
     if (isset($variables["login"])) {
         if ($variables["login"] !== "" || $variables["login"] !== NULL) {
             if ($this->usedLoginNames === NULL) {
                 $this->populateLoginNameArray();
             }
             if (!isset($variables["id"])) {
                 $tempid = 0;
             } else {
                 $tempid = $variables["id"];
             }
             if ($tempid < 0) {
                 $tempid = 0;
             }
             //check to see new login name is taken
             $templogin = $variables["login"];
             // using this because it looks ugly to but the brackets within brackets
             if (array_key_exists($variables["login"], $this->usedLoginNames)) {
                 if ($this->usedLoginNames[$templogin]["id"] !== $tempid) {
                     $this->verifyErrors[] = "The `login` field must give an unique login name.";
                 }
             } else {
                 $this->availableProducts[$templogin]["id"] = -1;
                 // impossible id put in (besides the type will throw off the if anyways)
             }
             //end if
         } else {
             $this->verifyErrors[] = "The `login` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `login` field must be set.";
     }
     //---------[ check email ]---------------------------------
     //if(isset($variables["email"]))
     //	if( $variables["email"] !== NULL && $variables["email"] !== "" && !validateEmail($variables["email"]))
     //		$this->verifyErrors[] = "The `email` field must have a valid email or must be left blank.";
     //---------[ check booleans ]---------------------------------
     if (isset($variables["revoked"])) {
         if ($variables["revoked"] && $variables["revoked"] != 1) {
             $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["portalaccess"])) {
         if ($variables["portalaccess"] && $variables["portalaccess"] != 1) {
             $this->verifyErrors[] = "The `portalaccess` field must be a boolean (equivalent to 0 or exactly 1).";
         }
         if ($variables["portalaccess"]) {
             if (isset($variables["admin"])) {
                 if (!$variables["admin"]) {
                     $this->verifyErrors[] = "The `admin` field must be '1' if `portalaccess` is '1'.";
                 }
             }
         }
         //end if
     }
     //end if
     if (isset($variables["admin"])) {
         if ($variables["admin"] && $variables["admin"] != 1) {
             $this->verifyErrors[] = "The `admin` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 12
0
 function verifyVariables($variables)
 {
     //the following ifs are constructed in such a way as to allow
     //the integer 0 as an acceptable value
     if (isset($variables["maintable"])) {
         if ($variables["maintable"] === "" || $variables["maintable"] === NULL) {
             $this->verifyErrors[] = "The `maintable` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `maintable` field must be set.";
     }
     if (isset($variables["addfile"])) {
         if ($variables["addfile"] === "" || $variables["addfile"] === NULL) {
             $this->verifyErrors[] = "The `addfile` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `addfile` field must be set.";
     }
     if (isset($variables["editfile"])) {
         if ($variables["editfile"] === "" || $variables["editfile"] === NULL) {
             $this->verifyErrors[] = "The `editfile` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `editfile` field must be set.";
     }
     if (isset($variables["querytable"])) {
         if ($variables["querytable"] === "" || $variables["querytable"] === NULL) {
             $this->verifyErrors[] = "The `querytable` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `querytable` field must be set.";
     }
     if (isset($variables["defaultwhereclause"])) {
         if ($variables["defaultwhereclause"] === "" || $variables["defaultwhereclause"] === NULL) {
             $this->verifyErrors[] = "The `defaultwhereclause` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `defaultwhereclause` field must be set.";
     }
     if (isset($variables["defaultsortorder"])) {
         if ($variables["defaultsortorder"] === "" || $variables["defaultsortorder"] === NULL) {
             $this->verifyErrors[] = "The `defaultsortorder` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `defaultsortorder` field must be set.";
     }
     if (isset($variables["deletebutton"])) {
         if ($variables["deletebutton"] === "" || $variables["deletebutton"] === NULL) {
             $this->verifyErrors[] = "The `delete` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `delete` field must be set.";
     }
     //table default sufficient
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "table":
             case "view":
             case "system":
                 break;
             default:
                 $this->verifyErrors[] = "The value of `type` field is invalid. Its value must be\n\t\t\t\t\t\t\t'table', 'view', or 'system'.";
                 break;
         }
     }
     //end switch
     if (isset($variables["addroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["addroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `addroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     if (isset($variables["editroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["editroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `editroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     if (isset($variables["importroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["importroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `importroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     if (isset($variables["searchroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["searchroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `searchroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     if (isset($variables["advsearchroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["advsearchroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `advsearchroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     if (isset($variables["viewsqlroleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         if (!in_array((string) $variables["viewsqlroleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `viewsqlroleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     //check moduleid
     if (isset($variables["moduleid"])) {
         if ($this->_availableModuleUUIDs === NULL) {
             $this->_availableModuleUUIDs = $this->_loadUUIDList("modules");
         }
         if (!in_array((string) $variables["moduleid"], $this->_availableModuleUUIDs)) {
             $this->verifyErrors[] = "The `moduleid` field does not give an existing/acceptable role id number.";
         }
     } else {
         $this->verifyErrors[] = "The `moduleid` field must be set.";
     }
     //table default insufficent
     // Check boolean
     if (isset($variables["canpost"])) {
         if ($variables["canpost"] && $variables["canpost"] != 1) {
             $this->verifyErrors[] = "The `canpost` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["apiaccessible"])) {
         if ($variables["apiaccessible"] && $variables["apiaccessible"] != 1) {
             $this->verifyErrors[] = "The `apiaccessible` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["hascustomfields"])) {
         if ($variables["hascustomfields"] && $variables["hascustomfields"] != 1) {
             $this->verifyErrors[] = "The `hascustomfields` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 13
0
 /**
  *  function verifyVariables
  *  @param array $variables
  */
 function verifyVariables($variables)
 {
     /**
      *  originuuid 
      */
     if (isset($variables["originuuid"])) {
         if ($this->_availableTabledefUuids === NULL) {
             $this->_availableTabledefUuids = $this->_loadUUIDList("tabledefs");
         }
         if (!in_array((string) $variables["originuuid"], $this->_availableTabledefUuids)) {
             $this->verifyErrors[] = "The `originuuid` field does not give an existing/acceptable tabledefinition uuid.";
         }
     } else {
         $this->verifyErrors[] = "The `originuuid` field must be set.";
     }
     /**
      *  whereclause 
      */
     if (isset($variables["whereclause"])) {
         switch ($variables["whereclause"]) {
             case "all":
             case "select":
                 break;
             default:
                 if ($this->_availableUserSearchesUuids === NULL) {
                     $this->_availableUserSearchesUuids = $this->_loadUUIDList("usersearches");
                 }
                 if (!in_array((string) $variables["whereclause"], $this->_availableUserSearchesUuids)) {
                     $this->verifyErrors[] = "The `usersearches` field does not give an existing/acceptable user search uuid or be of value 'all' or 'select'.";
                 }
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `whereclause` field must be set.";
     }
     /**
      *  apicommand
      */
     if (isset($variables["apicommand"])) {
         if ($variables["apicommand"] === "" || $variables["apicommand"] === NULL) {
             $this->verifyErrors[] = "The `apicommand` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `apicommand` field must be set.";
     }
     /**
      *  dateformat 
      */
     if (isset($variables["dateformat"])) {
         switch ($variables["dateformat"]) {
             case "SQL":
             case "English, UK":
             case "English, US":
             case "Dutch, NL":
                 break;
             default:
                 $this->verifyErrors[] = "The `dateformat` field's value must be one of the following:\n                        'SQL', 'English, UK', 'English, US', or 'Dutch, NL'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `dateformat` field must be set.";
     }
     /**
      *  timeformat 
      */
     if (isset($variables["timeformat"])) {
         switch ($variables["timeformat"]) {
             case "24 Hour":
             case "12 Hour":
                 break;
             default:
                 $this->verifyErrors[] = "The `timeformat` field's value\n                        must be one of the following: '24 Hour' or '12 Hour'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `timeformat` field must be set.";
     }
     /**
      *  http format 
      */
     if (isset($variables["httpformat"])) {
         switch ($variables["httpformat"]) {
             case "POST":
             case "GET":
                 break;
             default:
                 $this->verifyErrors[] = "The `httpformat` field's value must either be 'POST' or 'GET'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `httpformat` field must be set.";
     }
     /**
      *  data format 
      */
     if (isset($variables["dataformat"])) {
         switch ($variables["dataformat"]) {
             case "json":
                 break;
             default:
                 $this->verifyErrors[] = "The `dataformat` field's value must be 'json'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `dataformat` field must be set.";
     }
     /**
      *  Booleans 
      */
     if (isset($variables["useuuid"])) {
         if ($variables["useuuid"] && $variables["useuuid"] != 1) {
             $this->verifyErrors[] = "The `useuuid` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["keepdestid"])) {
         if ($variables["keepdestid"] && $variables["keepdestid"] != 1) {
             $this->verifyErrors[] = "The `keepdestid` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     if (isset($variables["ssl"])) {
         if ($variables["ssl"] && $variables["ssl"] != 1) {
             $this->verifyErrors[] = "The `ssl` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     return parent::verifyVariables($variables);
 }
Esempio n. 14
0
 function verifyVariables($variables)
 {
     //cannot be table default ("")
     if (isset($variables["reportfile"])) {
         if ($variables["reportfile"] === "" || $variables["reportfile"] === NULL) {
             $this->verifyErrors[] = "The `reportfile` field must not be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `reportfile` field must be set.";
     }
     //Table default (NULL) OK
     if (isset($variables["type"])) {
         if ($variables["type"] !== "") {
             //don't care if it's ""
             switch ($variables["type"]) {
                 case "report":
                 case "PDF Report":
                 case "export":
                     break;
                 default:
                     $this->verifyErrors[] = "The `type` field is not an accepted value.  It must be 'report', 'PDF Report', or 'export.";
                     break;
             }
         }
     }
     //end switch
     //Table Default ('') ok becuase it means report is globally available to any table
     if (isset($variables["tabledefid"])) {
         if ($this->_availableTabledefUUIDs === NULL) {
             $this->_availableTabledefUUIDs = $this->_loadUUIDList("tabledefs");
             //add the global option
             $this->_availableTabledefUUIDs[] = "";
         }
         //end if
         if (!in_array((string) $variables["tabledefid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition uuid.";
         }
     }
     //end if
     //Table Default ('') ok becuase it means report is globally available to any user
     if (isset($variables["roleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             // for no role restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for the Admin restriction
         }
         //end if
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 15
0
 /**
  * function process
  * Process request array posted to api
  *
  * The method process() loops through the request array, and attempts to
  * find a corresponding function to run for the request. It first looks for
  * a corresponding api class to load. If it does not find it, it next to
  * see if there is an overriden table class file, and finally if none of
  * these are present, it uses the standard table class.
  *
  */
 function process()
 {
     $i = 1;
     $tabledefid = null;
     if (!is_array($this->data)) {
         $this->sendError("Passed data malformed.  Was expecting an array.", $this->data, true);
     }
     foreach ($this->data as $request) {
         if (!is_array($request)) {
             $this->sendError("Malformed request number " . $i, $request);
         }
         if (!isset($request["tabledefid"]) || !isset($request["command"]) || !isset($request["data"])) {
             $this->sendError("Malformed request number " . $i, $request);
         }
         /**
          *  Process the options and populate the options object.
          */
         if (!isset($request["options"])) {
             $request["options"] = NULL;
         }
         $this->processOptions($request["options"]);
         if ((int) $request["tabledefid"] !== $tabledefid) {
             $tabledefid = mysql_real_escape_string($request["tabledefid"]);
             //First let's get the table information from the tabledef
             $querystatement = "\n                    SELECT\n                        `maintable`,\n                        `deletebutton`,\n                        `querytable`,\n                        `modules`.`name`,\n                        `apiaccessible`\n                    FROM\n                        `tabledefs` INNER JOIN `modules` ON tabledefs.moduleid = modules.uuid\n                    WHERE\n                        tabledefs.uuid = '" . $tabledefid . "'\n                ";
             $queryresult = $this->db->query($querystatement);
             if ($this->db->numRows($queryresult) == 0) {
                 if (!in_array($request["command"], array("procedure", "getsetting"))) {
                     $this->sendError("Invalid tabledefid (" . $tabledefid . ") from request number " . $i);
                     continue;
                 } else {
                     $deletebutton = "delete";
                     $maintable = "settings";
                     $modulename = "base";
                     $hasAPIOveride = false;
                     $hasTableClassOveride = false;
                 }
                 //endif
             } else {
                 $therecord = $this->db->fetchArray($queryresult);
                 if (!$therecord["apiaccessible"]) {
                     $this->sendError("Invalid tabledefid (" . $tabledefid . ") from request number " . $i . ": This table definition is inaccessible via api.");
                     continue;
                 }
                 //endif
                 $deletebutton = $therecord["deletebutton"];
                 $maintable = $therecord["maintable"];
                 $modulename = $therecord["name"];
                 //check for ovridding classes only once.
                 $hasAPIOveride = file_exists("../extendedapi/" . $maintable . ".php");
                 $hasTableClassOveride = file_exists("../" . $modulename . "/include/" . $maintable . ".php");
             }
             //endif
         }
         //endif
         /* Order in which to check for processors is as follows:
         
                        If the extendedAPI module is present, look for a file matching the main
                        table name of the table def.
                        Example: modules/extendedapi/clients.php
         
                        If a table class file exists in the module's include folder
                        use that.
                        Example: modules/bms/include/clients.php
         
                        Use the standard class module.
         
                     */
         $methodName = "";
         if ($hasAPIOveride) {
             // Found an API module table php
             @(include_once "modules/extendedapi/" . $maintable . ".php");
             $className = $className . "Api";
             if (class_exists($className)) {
                 $processor = new $className($this->db);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
                 if (!method_exists($processor, $request["command"])) {
                     $methodName = $request["command"];
                     $this->response[] = $processor->{$methodName}($request["data"], $this->options->useUuid);
                 }
                 //endif
             }
             //end if
         }
         //endif
         /* If the command starts with api_, and there is a request overload, let's assume they
               are trying to call a homeade function in the ovveriden phpBMS table that they created.
            */
         if (!$methodName && substr($request["command"], 0, 4) == "api_" && $hasTableClassOveride) {
             include_once "include/tables.php";
             @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
             if (class_exists($maintable)) {
                 $processor = new $maintable($this->db, $tabledefid);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
             } else {
                 $processor = new phpbmsTable($this->db, $tabledefid);
                 $processor->dateFormat = $this->options->dateFormat;
                 $processor->timeFormat = $this->options->timeFormat;
             }
             if (method_exists($processor, $request["command"])) {
                 $methodName = $request["command"];
                 $this->response[] = $processor->{$methodName}($request["data"], $this->options->useUuid);
             }
             //endif
         }
         //endif
         if (!$methodName) {
             /* Either using the modules overriden table class or search
                                functions class or the standard one There are several
                                standard commands that can be passed:
             
                                * insert - calls the tabledefs insertRecord command, the
                                             same command that is called on standard
                                             phpBMS forms. a variable array should be
                                             passed in the request data.
             
                                * update - calls the tabledefs iupdateRecord command, the
                                             same command that is called on standard
                                             phpBMS forms. a variable array should be
                                             passed in the request data
             
                                * delete (or the corresponding delete button command)
                                         - calls the deleteRecord searchFunctions command
                                         data should be an array of ids
             
                                * procedure - This calls a stored MySQL stored procedure
                                              request data should pass an object with the
                                              (name) and optionally an array of any
                                              (parameters)
             
                                 In addition, you can pass a command that corresponds to
                                 any additional commands as defined in the table definition
                                 the request data passed should contain an array of ids
                             */
             switch ($request["command"]) {
                 case "ping":
                     //======================================================
                     $this->_addToResponse("message", "Everything is phpBMSy!");
                     break;
                 case "getDefaults":
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $therecord = $processor->getDefaults();
                     $this->_addToResponse("retrieved", "defaults retrieved in tabledef " . $tabledefid, $therecord);
                     break;
                 case "insert":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorArray = $processor->verifyVariables((array) $request["data"]);
                     if (count($errorArray)) {
                         $this->sendError("Insert failed from request number " . $i, $errorArray);
                     } else {
                         $overrideID = false;
                         if (is_array($request["data"])) {
                             if (isset($request["data"]["id"])) {
                                 if ((int) $request["data"]["id"] !== 0) {
                                     $overrideID = true;
                                 }
                                 if ($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) {
                                     $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]);
                                 }
                             } elseif ($this->options->keepDestId && isset($request["data"]["uuid"]) && $this->options->useUuid) {
                                 $request["data"]["id"] = getId($this->db, $processor->uuid, $request["data"]["uuid"]);
                             }
                         }
                         $createUuid = true;
                         if (is_array($request["data"])) {
                             if (isset($request["data"]["uuid"])) {
                                 if ((string) $request["data"]["uuid"] !== "") {
                                     $overrideID = true;
                                     $createUuid = false;
                                 }
                             }
                         }
                         //end if
                         if (!isset($processor->fields["uuid"])) {
                             $createUuid = false;
                         }
                         $newid = $processor->insertRecord($request["data"], NULL, $overrideID, true, $createUuid);
                         if ($newid) {
                             if ($createUuid) {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $newid["uuid"]);
                             } elseif (isset($processor->fields["uuid"])) {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $request["data"]["uuid"]);
                             } else {
                                 $this->_addToResponse("added", "record added to tabledef " . $tabledefid, $newid);
                             }
                             //end if
                         } else {
                             $this->sendError("Insert failed from request number " . $i);
                         }
                     }
                     //endif
                     break;
                 case "update":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorArray = $processor->verifyVariables($request["data"]);
                     if ($this->options->useUuid) {
                         if (!isset($request["data"]["uuid"])) {
                             $errorArray[] = "The `uuid` field must be set.";
                         }
                     } else {
                         if (!isset($request["data"]["id"])) {
                             $errorArray[] = "The `id` field must be set.";
                         }
                     }
                     //end if
                     if (count($errorArray)) {
                         $this->sendError("Update failed from request number " . $i, $errorArray);
                     } else {
                         $processor->updateRecord($request["data"], NULL, (bool) $this->options->useUuid);
                         $this->_addToResponse("updated", "record updated in tabledef " . $tabledefid);
                     }
                     //endif
                     break;
                 case "get":
                     //======================================================
                     include_once "include/tables.php";
                     if ($hasTableClassOveride) {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         if (class_exists($maintable)) {
                             $processor = new $maintable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         } else {
                             $processor = new phpbmsTable($this->db, $tabledefid);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                         }
                         //end if
                     } else {
                         $processor = new phpbmsTable($this->db, $tabledefid);
                         $processor->dateFormat = $this->options->dateFormat;
                         $processor->timeFormat = $this->options->timeFormat;
                     }
                     //end if
                     $errorMessage = "";
                     if ($this->options->useUuid) {
                         if (!isset($request["data"]["uuid"])) {
                             $errorMessage = "The `uuid` field must be set.";
                         }
                     } else {
                         if (!isset($request["data"]["id"])) {
                             $errorMessage = "The `id` field must be set.";
                         }
                     }
                     //end if
                     if ($errorMessage) {
                         $this->sendError("Get failed from request number " . $i, $errorMessage);
                     } elseif (!$this->options->useUuid) {
                         $therecord = $processor->getRecord((int) $request["data"]["id"], $this->options->useUuid);
                         $thereturn = $therecord["id"];
                         $thevalue = (int) $request["data"]["id"];
                     } else {
                         $therecord = $processor->getRecord(mysql_real_escape_string($request["data"]["uuid"]), $this->options->useUuid);
                         $thereturn = $therecord["uuid"];
                         $thevalue = $request["data"]["uuid"];
                     }
                     if ($thereturn == $thevalue) {
                         $this->_addToResponse("retrieved", "record (" . htmlQuotes($thevalue) . ") retrieved in tabledef " . $tabledefid, $therecord);
                     } else {
                         $this->_addToResponse("retrieved", "no record found (" . htmlQuotes($thevalue) . ") in tabledef " . $tabledefid);
                     }
                     break;
                 case "delete":
                 case $deletebutton:
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Passed data is not array in request number " . $i, $request["data"]);
                     } else {
                         include_once "include/search_class.php";
                         if ($hasTableClassOveride) {
                             @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                             $className = $maintable . "SearchFunctions";
                             if (class_exists($className)) {
                                 $processor = new $className($this->db, $tabledefid, $request["data"]);
                             } else {
                                 $processor = new searchFunctions($this->db, $tabledefid, $request["data"]);
                             }
                         } else {
                             $processor = new searchFunctions($this->db, $tabledefid, $request["data"]);
                         }
                         $result = $processor->delete_record($this->options->useUuid);
                         $this->_addToResponse($request["command"], $result);
                     }
                     //endif
                     break;
                 case "procedure":
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Wrong passed procedure format, expected object in request number " . $i, $request["data"]);
                     } else {
                         if (!isset($request["data"]["name"])) {
                             $this->sendError("Wrong passed procedure format, name missing in request number " . $i, $request["data"]);
                         } else {
                             //check to see if stored procedure exists
                             $querystatement = "\n                                    SHOW PROCEDURE STATUS LIKE '" . mysql_real_escape_string($request["data"]["name"]) . "'\n                                ";
                             $queryresult = $this->db->query($querystatement);
                             if ($this->db->numRows($queryresult) === 0) {
                                 $this->sendError("Procedure '" . $request["data"]["name"] . "' does not exist in request number " . $i, $request["data"]);
                             } else {
                                 $parameterList = "";
                                 if (isset($request["data"]["parameters"])) {
                                     foreach ($request["data"]["parameters"] as $parameter) {
                                         $parameterList .= ", '" . mysql_real_escape_string($parameter) . "'";
                                     }
                                 }
                                 if ($parameterList) {
                                     $parameterList = substr(1, $parameterList);
                                 }
                                 $procedurestatement = "\n                                        CALL " . $request["data"]["name"] . "(" . $parameterList . ")";
                                 $queryresult = $this->db->query($procedurestatement);
                                 $result = array();
                                 while ($therecord = $this->db->fetchArray($queryresult)) {
                                     $result[] = $therecord;
                                 }
                                 $this->_addToResponse("result", "Procedure '" . $request["data"]["name"] . "' returned (" . $this->db->numRows($queryresult) . ") in request number " . $i, $result);
                             }
                             //endif
                         }
                         //endif
                     }
                     //endif
                     break;
                 case "getsetting":
                     //======================================================
                     if (!is_array($request["data"])) {
                         $this->sendError("Wrong passed data format, expected array in request number " . $i, $request["data"]);
                     } else {
                         $whereclause = "";
                         foreach ($request["data"] as $settingName) {
                             $whereclause = "OR `name` = '" . mysql_real_escape_string($settingName) . "' ";
                         }
                         if ($whereclause) {
                             $whereclause = "WHERE " . substr($whereclause, 2);
                         }
                         $querystatement = "\n                                SELECT\n                                    `name`,\n                                    `value`\n                                FROM\n                                    `settings`\n                                " . $whereclause;
                         $queryresult = $this->db->query($querystatement);
                         $settings = array();
                         while ($therecord = $this->db->fetchArray($queryresult)) {
                             $settings[$therecord["name"]] = $therecord["value"];
                         }
                         $this->_addToResponse("result", "GetSettings returned (" . count($settings) . ") in request number " . $i, $settings);
                     }
                     //endif
                     break;
                 default:
                     //======================================================
                     // a catch all for other requests.  This should correspond
                     // to an ovrriden search class function only. Calling
                     // some commands can cause response errors so be careful
                     if (!is_array($request["data"]) && !$hasTableClassOveride) {
                         $this->sendError("Passaed data is not array or function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                     } else {
                         @(include_once "modules/" . $modulename . "/include/" . $maintable . ".php");
                         $className = $maintable . "SearchFunctions";
                         if (!class_exists($className)) {
                             $this->sendError("Function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                         } else {
                             $processor = new $className($this->db, $tabledefid, $request["data"]);
                             $processor->dateFormat = $this->options->dateFormat;
                             $processor->timeFormat = $this->options->timeFormat;
                             $methodName = $request["command"];
                             if (!method_exists($processor, $methodName)) {
                                 $this->sendError("Function (" . $request["command"] . ") does not exist in request number " . $i, $request["data"]);
                             } else {
                                 $result = $processor->{$methodName}();
                                 $this->_addToResponse($request["command"], $result);
                             }
                             //endif method_exists
                         }
                         //endif $className
                     }
                     //endif
                     break;
             }
             //endswitch $request["command"]
         }
         //endif $modulename
         $i++;
     }
     //endforeach
     $this->displayResult();
 }
Esempio n. 16
0
 function verifyVariables($variables)
 {
     //must have a client
     if (isset($variables["clientid"])) {
         if ($this->_availableClientUUIDs === NULL) {
             $this->_availableClientUUIDs = $this->_loadUUIDList("clients");
         }
         if (!in_array((string) $variables["clientid"], $this->_availableClientUUIDs)) {
             $this->verifyErrors[] = "The `clientid` field does not give an existing/acceptable client id number.";
         }
     } else {
         $this->verifyErrors[] = "The `clientid` field must be set.";
     }
     //table default (NULL) is not enough
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "Quote":
             case "Order":
             case "Invoice":
             case "VOID":
                 break;
             default:
                 $this->verifyErrors[] = "The value of the `type` field is invalid.  It must be 'Quote',\n\t\t\t\t\t\t\t'Order', 'Invoice', or 'VOID'.";
                 break;
         }
         //end switch
     } else {
         $this->verifyErrors[] = "The `type` field must be set.";
     }
     //check assigned to id
     if (isset($variables["assignedtoid"])) {
         if ($this->_availableUserUUIDs === NULL) {
             $this->_availableUserUUIDs = $this->_loadUUIDList("users");
             $this->_availableUserUUIDs[] = "";
             //for none
         }
         //end if
         if (!in_array((string) $variables["assignedtoid"], $this->_availableUserUUIDs)) {
             $this->verifyErrors[] = "The `assignedtoid` field does not give an existing/acceptable user id number.";
         }
     }
     //end if
     //check status id
     if (isset($variables["statusid"])) {
         if ($this->_availableStatusUUIDs === NULL) {
             $this->_availableStatusUUIDs = $this->_loadUUIDList("invoicestatuses");
         }
         if (!in_array((string) $variables["statusid"], $this->_availableStatusUUIDs)) {
             $this->verifyErrors[] = "The `statusid` field does not give an existing/acceptable status id number.";
         }
     } else {
         $this->verifyErrors[] = "The `statusid` field must be set.";
     }
     //end if
     //check booleans
     //readytopost
     if (isset($variables["readytopost"])) {
         if ($variables["readytopost"] && $variables["readytopost"] != 1) {
             $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     //weborder
     if (isset($variables["weborder"])) {
         if ($variables["weborder"] && $variables["weborder"] != 1) {
             $this->verifyErrors[] = "The `weborder` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     //shiptosameasbilling
     if (isset($variables["shiptosameasbilling"])) {
         if ($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != 1) {
             $this->verifyErrors[] = "The `shiptosameasbilling` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     //iscreditmemo
     if (isset($variables["iscreditmemo"])) {
         if ($variables["iscreditmemo"] && $variables["iscreditmemo"] != 1) {
             $this->verifyErrors[] = "The `iscreditmemo` field must be a boolean (equivalent to 0 or exactly 1).";
         }
     }
     //check addresss ids
     //check secondary line item ids
     return parent::verifyVariables($variables);
 }
Esempio n. 17
0
 function verifyVariables($variables)
 {
     if (isset($variables["uuid"])) {
         if ($variables["uuid"] === "" && $variables["uuid"] === NULL) {
             $this->verifyErrors[] = "The `uuid` field cannot be blank.";
         }
     } else {
         $this->verifyErrors[] = "The `uuid` field must be set.";
     }
     //table default ('') for `roleid` is ok (i.e. doesn't have to be set)
     if (isset($variables["roleid"])) {
         //check for populated role id array
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             //for no restrictions
             $this->_availableRoleUUIDs[] = "Admin";
             //for admin restriction
         }
         //end if
         //check to see if the int typecast role id is in one of the available ones
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     //check parent ids under certain circumstances
     //not set is acceptable
     if (isset($variables["parentid"])) {
         $uuid = "";
         // can still check for an invalid parentid even though the current uuid is bad
         //use the current id if it exists (A menu record cannot be its own parent)
         if (isset($variables["uuid"])) {
             if ($variables["uuid"] !== "" && $variables["uuid"] !== NULL) {
                 $uuid = $variables["uuid"];
             }
         }
         //Select run every time because `id` can be different
         if (!$this->checkParentMenuUUIDs($uuid, (string) $variables["parentid"])) {
             $this->verifyErrors[] = "The `parentid` field does not give an existing/acceptable parentid uuid.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 18
0
 function verifyVariables($variables)
 {
     //table default (SCH) is sufficient
     if (isset($variables["type"])) {
         switch ($variables["type"]) {
             case "SRT":
             case "SCH":
                 break;
             default:
                 $this->verifyErrors[] = "The value of `type` field is invalid. Its value must be\n\t\t\t\t\t\t\t'SRT' or 'SCH'.";
                 break;
         }
         //end switch
     }
     //end if
     //table default (0) is sufficient
     if (isset($variables["userid"])) {
         if ($this->_availableUserUUIDs === NULL) {
             $this->_availableUserUUIDs = $this->_loadUUIDList("users");
             $this->_availableUserUUIDs[] = '';
         }
         //endif
         if (!in_array((string) $variables["userid"], $this->_availableUserUUIDs)) {
             $this->verifyErrors[] = "The `userid` field does not give an existing/acceptable user id number.";
         }
     }
     //end if
     //The table default is not enough, so it must be set
     if (isset($variables["tabledefid"])) {
         if ($this->_availableTabledefUUIDs === NULL) {
             $this->_availableTabledefUUIDs = $this->_loadUUIDList("tabledefs");
         }
         if (!in_array($variables["tabledefid"], $this->_availableTabledefUUIDs)) {
             $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition id number.";
         }
     } else {
         $this->verifyErrors[] = "The `tabledefid` field must be set.";
     }
     //table default (0) is sufficient
     if (isset($variables["roleid"])) {
         if ($this->_availableRoleUUIDs === NULL) {
             $this->_availableRoleUUIDs = $this->_loadUUIDList("roles");
             $this->_availableRoleUUIDs[] = "";
             $this->_availableRoleUUIDs[] = "Admin";
         }
         //endif
         if (!in_array((string) $variables["roleid"], $this->_availableRoleUUIDs)) {
             $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }
Esempio n. 19
0
 function verifyVariables($variables)
 {
     $validJob = true;
     if (isset($variables["job"])) {
         if ($variables["job"] === "" || $variables["job"] === NULL) {
             $validJob = false;
         }
     } else {
         $validJob = false;
     }
     $validPush = true;
     if (isset($variables["pushrecordid"])) {
         if ($variables["pushrecordid"] === "" || $variables["pushrecordid"] === NULL) {
             $validPush = false;
         }
     } else {
         $validPush = false;
     }
     if (!$validPush && !$validJob) {
         $this->verifyErrors[] = "The `job` or the `pushrecordid` must be set and not blank.";
     }
     //checks to see if crontab is in the (somewhat) right format
     if (isset($variables["crontab"])) {
         $explode = explode("::", $variables["crontab"]);
         if (count($explode) != 5) {
             $this->verifyErrors[] = "The `crontab` field is not of the proper form.  There must be four pairs of '::' in the field's value.";
         }
     }
     //end if
     return parent::verifyVariables($variables);
 }