| 50 | | |
| | 53 | |
| | 54 | //populates tabledef id array |
| | 55 | function populateTabledefArray(){ |
| | 56 | |
| | 57 | $this->availableTabledefIDs = array(); |
| | 58 | |
| | 59 | $querystatement = " |
| | 60 | SELECT |
| | 61 | `id` |
| | 62 | FROM |
| | 63 | `tabledefs`; |
| | 64 | "; |
| | 65 | |
| | 66 | $queryresult = $this->db->query($querystatement); |
| | 67 | |
| | 68 | //This is for the "global" option |
| | 69 | $this->availableTabledefIDs[] = 0; |
| | 70 | |
| | 71 | while($therecord = $this->db->fetchArray($queryresult)) |
| | 72 | $this->availableTabledefIDs[] = $therecord["id"]; |
| | 73 | |
| | 74 | |
| | 75 | |
| | 76 | }//end method --populateRoleArray-- |
| | 77 | |
| | 78 | //populates role id array |
| | 79 | function populateRoleArray(){ |
| | 80 | |
| | 81 | $this->availableRoleIDs = array(); |
| | 82 | |
| | 83 | $querystatement = " |
| | 84 | SELECT |
| | 85 | `id` |
| | 86 | FROM |
| | 87 | `roles`; |
| | 88 | "; |
| | 89 | |
| | 90 | $queryresult = $this->db->query($querystatement); |
| | 91 | |
| | 92 | //These two are added for no restriction on the role (0) and for |
| | 93 | //administrative restrictioin (-100) |
| | 94 | $this->availableRoleIDs[] = 0; |
| | 95 | $this->availableRoleIDs[] = -100; |
| | 96 | |
| | 97 | while($therecord = $this->db->fetchArray($queryresult)) |
| | 98 | $this->availableRoleIDs[] = $therecord["id"]; |
| | 99 | |
| | 100 | }//end method --populateRoleArray-- |
| | 101 | |
| | 102 | |
| | 103 | function verifyVariables($variables){ |
| | 104 | |
| | 105 | //cannot be table default ("") |
| | 106 | if(isset($variables["reportfile"])){ |
| | 107 | if($variables["reportfile"] === "" || $variables["reportfile"] === NULL) |
| | 108 | $this->verifyErrors[] = "The `reportfile` field must not be blank."; |
| | 109 | }else |
| | 110 | $this->verifyErrors[] = "The `reportfile` field must be set."; |
| | 111 | |
| | 112 | //Table default (NULL) OK |
| | 113 | if(isset($variables["type"])) |
| | 114 | if($variables["type"])//don't care if it's "" |
| | 115 | switch($variables["type"]){ |
| | 116 | case "report": |
| | 117 | case "PDF Report": |
| | 118 | case "export": |
| | 119 | break; |
| | 120 | |
| | 121 | default: |
| | 122 | $this->verifyErrors[] = "The `type` field is not an accepted value. It must be 'report', 'PDF Report', or 'export."; |
| | 123 | break; |
| | 124 | |
| | 125 | }//end switch |
| | 126 | |
| | 127 | //Table Default (0) ok becuase it means report is globally available to any table |
| | 128 | if(isset($variables["tabledefid"])){ |
| | 129 | |
| | 130 | //must be a non-negative number or NULL/"" |
| | 131 | if( (!$variables["tabledefid"]) || ((int)$variables["tabledefid"]) > 0 ){ |
| | 132 | |
| | 133 | if(!count($this->availableTabledefIDs)) |
| | 134 | $this->populateTabledefArray(); |
| | 135 | |
| | 136 | if( !in_array((int)$variables["tabledefid"], $this->availableTabledefIDs) ) |
| | 137 | $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable to table definition id number."; |
| | 138 | |
| | 139 | }else |
| | 140 | $this->verifyErrors[] = "The `tabledefid` field must be either a non-negative number or equivalent to 0."; |
| | 141 | |
| | 142 | }//end if |
| | 143 | |
| | 144 | //Table Default (0) ok becuase it means report is globally available to any user |
| | 145 | if(isset($variables["roleid"])){ |
| | 146 | |
| | 147 | //must be a number or NULL/"" |
| | 148 | if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ |
| | 149 | |
| | 150 | if(!count($this->availableRoleIDs)) |
| | 151 | $this->populateRoleArray(); |
| | 152 | |
| | 153 | if( !in_array((int)$variables["roleid"], $this->availableRoleIDs) ) |
| | 154 | $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number."; |
| | 155 | |
| | 156 | }else |
| | 157 | $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; |
| | 158 | |
| | 159 | }//end if |
| | 160 | |
| | 161 | return parent::verifyVariables($variables); |
| | 162 | |
| | 163 | }//end method |
| | 164 | |
| | 165 | |