| 53 | | |
| 54 | | function formatVariables($variables){ |
| 55 | | |
| 56 | | if($_FILES['upload']["name"]){ |
| 57 | | |
| 58 | | $variables["name"] = $_FILES['upload']["name"]; |
| 59 | | $variables["type"] = $_FILES['upload']['type']; |
| 60 | | $variables["file"] = $this->getPicture("upload"); |
| 61 | | |
| 62 | | } else { |
| 63 | | unset($this->fields["type"]); |
| 64 | | unset($this->fields["file"]); |
| | 55 | |
| | 56 | //populates the list of possible role ids |
| | 57 | //into $this->availableRoleIDs (an array) |
| | 58 | function populateRoleArray(){ |
| | 59 | |
| | 60 | $this->availableRoleIDs = array(); |
| | 61 | |
| | 62 | $querystatement = " |
| | 63 | SELECT |
| | 64 | `id` |
| | 65 | FROM |
| | 66 | `roles`; |
| | 67 | "; |
| | 68 | |
| | 69 | $queryresult = $this->db->query($querystatement); |
| | 70 | |
| | 71 | //next two should also be allowed, but aren't stored in the database |
| | 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 | //if it is set, we'll have to check, if not, it defaults to 0 which is an acceptable |
| | 84 | //value. |
| | 85 | if(isset($variables["roleid"])){ |
| | 86 | |
| | 87 | //either its numeric or == 0 |
| | 88 | if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ |
| | 89 | |
| | 90 | //check to see if the RoleIDs are populated |
| | 91 | if(!count($this->availableRoleIDs)) |
| | 92 | $this->populateRoleArray();//populate if not |
| | 93 | |
| | 94 | //check to see if the int typecast of the roleid (to allow for values |
| | 95 | //equivalent to 0) is an acceptable role id. |
| | 96 | if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) |
| | 97 | $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; |
| | 98 | }else |
| | 99 | $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; |
| 66 | | |
| 67 | | return $variables; |
| 68 | | |
| | 101 | |
| | 102 | return parent::verifyVariables($variables); |
| | 103 | |
| | 104 | }//end method |
| | 105 | |
| | 106 | |
| | 107 | function prepareVariables($variables){ |
| | 108 | |
| | 109 | if(isset($_FILES['upload'])) |
| | 110 | if($_FILES['upload']["name"]){ |
| | 111 | |
| | 112 | $variables["name"] = $_FILES['upload']["name"]; |
| | 113 | $variables["type"] = $_FILES['upload']['type']; |
| | 114 | $variables["file"] = $this->getPicture("upload"); |
| | 115 | |
| | 116 | } else { |
| | 117 | unset($this->fields["type"]); |
| | 118 | unset($this->fields["file"]); |
| | 119 | }//end if |
| | 120 | |
| | 121 | return $variables; |
| | 122 | |