| 55 | | |
| | 57 | |
| | 58 | //populates $this->availableRoleIDs |
| | 59 | function populateRoleArray(){ |
| | 60 | |
| | 61 | $this->availableRoleIDs = array(); |
| | 62 | |
| | 63 | $querystatement = " |
| | 64 | SELECT |
| | 65 | `id` |
| | 66 | FROM |
| | 67 | `roles`; |
| | 68 | "; |
| | 69 | |
| | 70 | $queryresult = $this->db->query($querystatement); |
| | 71 | |
| | 72 | $this->availableRoleIDs[] = 0;//for everyone |
| | 73 | $this->availableRoleIDs[] = -100;//for administrators |
| | 74 | |
| | 75 | while($therecord = $this->db->fetchArray($queryresult)) |
| | 76 | $this->availableRoleIDs[] = $therecord["id"]; |
| | 77 | |
| | 78 | }//end method --populateRoleArray-- |
| | 79 | |
| | 80 | |
| | 81 | function verifyVariables($variables){ |
| | 82 | |
| | 83 | |
| | 84 | //the following ifs are constructed in such a way as to allow |
| | 85 | //the integer 0 as an acceptable value |
| | 86 | |
| | 87 | if(isset($variables["maintable"])){ |
| | 88 | if($variables["maintable"] === "" || $variables["maintable"] === NULL) |
| | 89 | $this->verifyErrors[] = "The `maintable` field must not be blank."; |
| | 90 | }else |
| | 91 | $this->verifyErrors[] = "The `maintable` field must be set."; |
| | 92 | |
| | 93 | if(isset($variables["addfile"])){ |
| | 94 | if($variables["addfile"] === "" || $variables["addfile"] === NULL) |
| | 95 | $this->verifyErrors[] = "The `addfile` field must not be blank."; |
| | 96 | }else |
| | 97 | $this->verifyErrors[] = "The `addfile` field must be set."; |
| | 98 | |
| | 99 | if(isset($variables["editfile"])){ |
| | 100 | if($variables["editfile"] === "" || $variables["editfile"] === NULL) |
| | 101 | $this->verifyErrors[] = "The `editfile` field must not be blank."; |
| | 102 | }else |
| | 103 | $this->verifyErrors[] = "The `editfile` field must be set."; |
| | 104 | |
| | 105 | if(isset($variables["querytable"])){ |
| | 106 | if($variables["querytable"] === "" || $variables["querytable"] === NULL) |
| | 107 | $this->verifyErrors[] = "The `querytable` field must not be blank."; |
| | 108 | }else |
| | 109 | $this->verifyErrors[] = "The `querytable` field must be set."; |
| | 110 | |
| | 111 | if(isset($variables["defaultwhereclause"])){ |
| | 112 | if($variables["defaultwhereclause"] === "" || $variables["defaultwhereclause"] === NULL) |
| | 113 | $this->verifyErrors[] = "The `defaultwhereclause` field must not be blank."; |
| | 114 | }else |
| | 115 | $this->verifyErrors[] = "The `defaultwhereclause` field must be set."; |
| | 116 | |
| | 117 | if(isset($variables["defaultsortorder"])){ |
| | 118 | if($variables["defaultsortorder"] === "" || $variables["defaultsortorder"] === NULL) |
| | 119 | $this->verifyErrors[] = "The `defaultsortorder` field must not be blank."; |
| | 120 | }else |
| | 121 | $this->verifyErrors[] = "The `defaultsortorder` field must be set."; |
| | 122 | |
| | 123 | if(isset($variables["deletebutton"])){ |
| | 124 | if($variables["deletebutton"] === "" || $variables["deletebutton"] === NULL) |
| | 125 | $this->verifyErrors[] = "The `delete` field must not be blank."; |
| | 126 | }else |
| | 127 | $this->verifyErrors[] = "The `delete` field must be set."; |
| | 128 | |
| | 129 | //table default sufficient |
| | 130 | if(isset($variables["type"])) |
| | 131 | switch($variables["type"]){ |
| | 132 | |
| | 133 | case "table": |
| | 134 | case "view": |
| | 135 | case "system": |
| | 136 | break; |
| | 137 | |
| | 138 | default: |
| | 139 | $this->verifyErrors[] = "The value of `type` field is invalid. Its value must be |
| | 140 | 'table', 'view', or 'system'."; |
| | 141 | break; |
| | 142 | |
| | 143 | }//end switch |
| | 144 | |
| | 145 | if(isset($variables["addroleid"])){ |
| | 146 | |
| | 147 | if(is_numeric($variables["addroleid"]) || !$variables["addroleid"]){ |
| | 148 | |
| | 149 | if(!count($this->availableRoleIDs)) |
| | 150 | $this->populateRoleArray(); |
| | 151 | |
| | 152 | if(!in_array(((int)$variables["addroleid"]), $this->availableRoleIDs)) |
| | 153 | $this->verifyErrors[] = "The `addroleid` field does not give an existing/acceptable role id number."; |
| | 154 | |
| | 155 | }else |
| | 156 | $this->verifyErrors[] = "The `addroleid` field must be numeric or equivalent to 0."; |
| | 157 | |
| | 158 | }//end if |
| | 159 | |
| | 160 | if(isset($variables["editroleid"])){ |
| | 161 | |
| | 162 | if(is_numeric($variables["editroleid"]) || !$variables["editroleid"]){ |
| | 163 | |
| | 164 | if(!count($this->availableRoleIDs)) |
| | 165 | $this->populateRoleArray(); |
| | 166 | |
| | 167 | if(!in_array(((int)$variables["editroleid"]), $this->availableRoleIDs)) |
| | 168 | $this->verifyErrors[] = "The `editroleid` field does not give an existing/acceptable role id number."; |
| | 169 | |
| | 170 | }else |
| | 171 | $this->verifyErrors[] = "The `editroleid` field must be numeric or equivalent to 0."; |
| | 172 | |
| | 173 | }//end if |
| | 174 | |
| | 175 | if(isset($variables["importroleid"])){ |
| | 176 | |
| | 177 | if(is_numeric($variables["importroleid"]) || !$variables["importroleid"]){ |
| | 178 | |
| | 179 | if(!count($this->availableRoleIDs)) |
| | 180 | $this->populateRoleArray(); |
| | 181 | |
| | 182 | if(!in_array(((int)$variables["importroleid"]), $this->availableRoleIDs)) |
| | 183 | $this->verifyErrors[] = "The `importroleid` field does not give an existing/acceptable role id number."; |
| | 184 | |
| | 185 | }else |
| | 186 | $this->verifyErrors[] = "The `importroleid` field must be numeric or equivalent to 0."; |
| | 187 | |
| | 188 | }//end if |
| | 189 | |
| | 190 | if(isset($variables["searchroleid"])){ |
| | 191 | |
| | 192 | if(is_numeric($variables["searchroleid"]) || !$variables["searchroleid"]){ |
| | 193 | |
| | 194 | if(!count($this->availableRoleIDs)) |
| | 195 | $this->populateRoleArray(); |
| | 196 | |
| | 197 | if(!in_array(((int)$variables["searchroleid"]), $this->availableRoleIDs)) |
| | 198 | $this->verifyErrors[] = "The `searchroleid` field does not give an existing/acceptable role id number."; |
| | 199 | |
| | 200 | }else |
| | 201 | $this->verifyErrors[] = "The `searchroleid` field must be numeric or equivalent to 0."; |
| | 202 | |
| | 203 | }//end if |
| | 204 | |
| | 205 | if(isset($variables["advsearchroleid"])){ |
| | 206 | |
| | 207 | if(is_numeric($variables["advsearchroleid"]) || !$variables["advsearchroleid"]){ |
| | 208 | |
| | 209 | if(!count($this->availableRoleIDs)) |
| | 210 | $this->populateRoleArray(); |
| | 211 | |
| | 212 | if(!in_array(((int)$variables["advsearchroleid"]), $this->availableRoleIDs)) |
| | 213 | $this->verifyErrors[] = "The `advsearchroleid` field does not give an existing/acceptable role id number."; |
| | 214 | |
| | 215 | }else |
| | 216 | $this->verifyErrors[] = "The `advsearchroleid` field must be numeric or equivalent to 0."; |
| | 217 | |
| | 218 | }//end if |
| | 219 | |
| | 220 | if(isset($variables["viewsqlroleid"])){ |
| | 221 | |
| | 222 | if(is_numeric($variables["viewsqlroleid"]) || !$variables["viewsqlroleid"]){ |
| | 223 | |
| | 224 | if(!count($this->availableRoleIDs)) |
| | 225 | $this->populateRoleArray(); |
| | 226 | |
| | 227 | if(!in_array(((int)$variables["viewsqlroleid"]), $this->availableRoleIDs)) |
| | 228 | $this->verifyErrors[] = "The `viewsqlroleid` field does not give an existing/acceptable role id number."; |
| | 229 | |
| | 230 | }else |
| | 231 | $this->verifyErrors[] = "The `viewsqlroleid` field must benumeric or quivalent to 0."; |
| | 232 | |
| | 233 | }//end if |
| | 234 | |
| | 235 | return parent::verifyVariables($variables); |
| | 236 | |
| | 237 | }//end method --verifyVariables-- |
| | 238 | |