| 41 | | |
| | 41 | |
| | 42 | var $availableTabledefIDs = array(); |
| | 43 | var $availableTabledefNames = array(); |
| | 44 | |
| | 45 | //function populateds the tabledef ids |
| | 46 | //and the tabledef names corresponding to those ids |
| | 47 | function populateTabledefArrays(){ |
| | 48 | |
| | 49 | $this->availableTabledefIDs = array(); |
| | 50 | $this->availableTabledefNames = array(); |
| | 51 | |
| | 52 | $querystatement = " |
| | 53 | SELECT |
| | 54 | `id`, |
| | 55 | `displayname` |
| | 56 | FROM |
| | 57 | `tabledefs` |
| | 58 | WHERE |
| | 59 | `type` != 'view' |
| | 60 | ORDER BY |
| | 61 | `displayname`; |
| | 62 | "; |
| | 63 | |
| | 64 | $queryresult = $this->db->query($querystatement); |
| | 65 | |
| | 66 | if($this->db->numRows($queryresult)){ |
| | 67 | while($therecord = $this->db->fetchArray($queryresult)){ |
| | 68 | |
| | 69 | $this->availableTabledefIDs[] = $therecord["id"]; |
| | 70 | $this->availableTabledefNames[] = $therecord["displayname"]; |
| | 71 | |
| | 72 | }//end while |
| | 73 | }else{ |
| | 74 | //if no valid id/names, I put in a value that will |
| | 75 | //give the arrays a count but not actually match any integers |
| | 76 | $this->availableTabledefIDs[] = "none"; |
| | 77 | $this->availableTabledefNames[] = "none"; |
| | 78 | }//end if |
| | 79 | |
| | 80 | }//end method --populateArrays-- |
| | 81 | |
| | 82 | |
| | 83 | function verifyVariables($variables){ |
| | 84 | |
| | 85 | //cannot be table default ("") |
| | 86 | if(isset($variables["tofield"])){ |
| | 87 | if($variables["tofield"] === "" || $variables["tofield"] === NULL) |
| | 88 | $this->verifyErrors[] = "The `tofield` field cannot be blank."; |
| | 89 | }else |
| | 90 | $this->verifyErrors[] = "The `tofield` field must be set."; |
| | 91 | |
| | 92 | //cannot be table default ("") |
| | 93 | if(isset($variables["fromfield"])){ |
| | 94 | if($variables["fromfield"] === "" || $variables["fromfield"] === NULL) |
| | 95 | $this->verifyErrors[] = "The `from` field cannot be blank."; |
| | 96 | }else |
| | 97 | $this->verifyErrors[] = "The `fromfield` field must be set."; |
| | 98 | |
| | 99 | //cannot be table default (0) |
| | 100 | if(isset($variables["fromtableid"])){ |
| | 101 | |
| | 102 | //must be a positive number |
| | 103 | if(((int) $variables["fromtableid"]) > 0 ){ |
| | 104 | |
| | 105 | if(!count($this->availableTabledefIDs)) |
| | 106 | $this->populateTableDefArrays(); |
| | 107 | |
| | 108 | if(!in_array(((int)$variables["fromtableid"]), $this->availableTabledefIDs)) |
| | 109 | $this->verifyErrors[] = "The `fromtableid` field does not give an existing/acceptable parent id number."; |
| | 110 | }else |
| | 111 | $this->verifyErrors[] = "The `fromtableid` field must be a positive number."; |
| | 112 | |
| | 113 | }else |
| | 114 | $this->verifyErrors[] = "The `fromtableid` field must be set."; |
| | 115 | |
| | 116 | //cannot be table default (0) |
| | 117 | if(isset($variables["totableid"])){ |
| | 118 | |
| | 119 | //must be a positive number |
| | 120 | if(((int) $variables["totableid"]) > 0 ){ |
| | 121 | |
| | 122 | if(!count($this->availableTabledefIDs)) |
| | 123 | $this->populateTableDefArrays(); |
| | 124 | |
| | 125 | if(!in_array(((int)$variables["totableid"]), $this->availableTabledefIDs)) |
| | 126 | $this->verifyErrors[] = "The `totableid` field does not give an existing/acceptable to table id number."; |
| | 127 | }else |
| | 128 | $this->verifyErrors[] = "The `totableid` field must be a positive number."; |
| | 129 | }else |
| | 130 | $this->verifyErrors[] = "The `totableid` field must be set."; |
| | 131 | |
| | 132 | //check boolean |
| | 133 | if(isset($variables["inherit"])) |
| | 134 | if($variables["inherit"] && $variables["inherit"] != 1) |
| | 135 | $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1)."; |
| | 136 | |
| | 137 | return parent::verifyVariables($variables); |
| | 138 | |
| | 139 | }//end method --verifyVariables-- |
| | 140 | |
| | 141 | |