| 67 | | $uuid = getUuid($this->db, "tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3", $tabledefid); |
| 68 | | |
| 69 | | $insertstatement = " |
| 70 | | INSERT INTO |
| 71 | | usersearches |
| 72 | | ( |
| 73 | | userid, |
| 74 | | tabledefid, |
| 75 | | name, |
| 76 | | `type`, |
| 77 | | sqlclause |
| 78 | | ) VALUES ( |
| 79 | | '".mysql_real_escape_string($userid)."', |
| 80 | | '".mysql_real_escape_string($uuid)."', |
| 81 | | '".mysql_real_escape_string($name)."', |
| 82 | | 'SCH', |
| 83 | | '".addslashes($_SESSION["tableparams"][$tabledefid]["querywhereclause"])."' |
| 84 | | )"; |
| 85 | | |
| 86 | | $this->db->query($insertstatement); |
| 87 | | |
| 88 | | echo "search saved"; |
| | 67 | $uuid = getUuid($this->db, "tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3", $tabledefid); |
| | 68 | |
| | 69 | $insertstatement = " |
| | 70 | INSERT INTO |
| | 71 | usersearches |
| | 72 | ( |
| | 73 | userid, |
| | 74 | tabledefid, |
| | 75 | name, |
| | 76 | `type`, |
| | 77 | sqlclause |
| | 78 | ) VALUES ( |
| | 79 | '".mysql_real_escape_string($userid)."', |
| | 80 | '".mysql_real_escape_string($uuid)."', |
| | 81 | '".mysql_real_escape_string($name)."', |
| | 82 | 'SCH', |
| | 83 | '".addslashes($_SESSION["tableparams"][$tabledefid]["querywhereclause"])."' |
| | 84 | )"; |
| | 85 | |
| | 86 | $this->db->query($insertstatement); |
| | 87 | |
| | 88 | echo "search saved"; |
| 123 | | $numrows = $this->db->numRows($queryresult); |
| 124 | | |
| 125 | | ?> |
| 126 | | <select id="LSList" name="LSList" <?php if ($numrows<1) echo "disabled" ?> size="10" style="width:170px;height:160px;" onchange="LSsearchSelect(this,'<?php echo APP_PATH ?>')"> |
| 127 | | <?php if($numrows<1) {?> |
| 128 | | |
| 129 | | <option value="NA">No Saved Searches</option> |
| 130 | | |
| 131 | | <?php |
| 132 | | } else { |
| 133 | | |
| 134 | | $numglobal=0; |
| 135 | | |
| 136 | | while($therecord=$this->db->fetchArray($queryresult)) |
| 137 | | if($therecord["userid"]<1) $numglobal++; |
| 138 | | |
| 139 | | $this->db->seek($queryresult,0); |
| 140 | | |
| 141 | | if($numglobal>0){ ?> |
| 142 | | <option value="NA" style="font-style:italic;font-weight:bold"> -- global searches ---------</option> |
| 143 | | <?php |
| 144 | | }//end if |
| 145 | | |
| 146 | | $userqueryline = true; |
| 147 | | |
| 148 | | while($therecord=$this->db->fetchArray($queryresult)){ |
| 149 | | |
| 150 | | if ($therecord["userid"] != '' and $userqueryline) { |
| 151 | | |
| 152 | | $userqueryline = false; |
| 153 | | |
| 154 | | ?><option value="NA" style="font-style:italic;font-weight:bold"> -- user searches ---------</option><?php |
| 155 | | |
| 156 | | }//endif |
| 157 | | |
| 158 | | ?><option value="<?php echo $therecord["id"]?>"><?php echo $therecord["name"]?></option><?php |
| 159 | | |
| 160 | | }// end while |
| 161 | | |
| 162 | | }//end if |
| 163 | | ?> |
| 164 | | </select> |
| 165 | | <?php |
| | 123 | $numrows = $this->db->numRows($queryresult); |
| | 124 | |
| | 125 | ?> |
| | 126 | <select id="LSList" name="LSList" <?php if ($numrows<1) echo "disabled" ?> size="10" style="width:170px;height:160px;" onchange="LSsearchSelect(this,'<?php echo APP_PATH ?>')"> |
| | 127 | <?php if($numrows<1) {?> |
| | 128 | |
| | 129 | <option value="NA">No Saved Searches</option> |
| | 130 | |
| | 131 | <?php |
| | 132 | } else { |
| | 133 | |
| | 134 | $numglobal=0; |
| | 135 | |
| | 136 | while($therecord=$this->db->fetchArray($queryresult)) |
| | 137 | if($therecord["userid"]<1) $numglobal++; |
| | 138 | |
| | 139 | $this->db->seek($queryresult,0); |
| | 140 | |
| | 141 | if($numglobal>0){ ?> |
| | 142 | <option value="NA" style="font-style:italic;font-weight:bold"> -- global searches ---------</option> |
| | 143 | <?php |
| | 144 | }//end if |
| | 145 | |
| | 146 | $userqueryline = true; |
| | 147 | |
| | 148 | while($therecord=$this->db->fetchArray($queryresult)){ |
| | 149 | |
| | 150 | if ($therecord["userid"] != '' and $userqueryline) { |
| | 151 | |
| | 152 | $userqueryline = false; |
| | 153 | |
| | 154 | ?><option value="NA" style="font-style:italic;font-weight:bold"> -- user searches ---------</option><?php |
| | 155 | |
| | 156 | }//endif |
| | 157 | |
| | 158 | ?><option value="<?php echo $therecord["id"]?>"><?php echo $therecord["name"]?></option><?php |
| | 159 | |
| | 160 | }// end while |
| | 161 | |
| | 162 | }//end if |
| | 163 | ?> |
| | 164 | </select> |
| | 165 | <?php |
| 179 | | $uuid = getUuid($this->db, "tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3", $tabledefid); |
| 180 | | |
| 181 | | $querystatement = " |
| 182 | | SELECT |
| 183 | | id, |
| 184 | | name, |
| 185 | | userid |
| 186 | | FROM |
| 187 | | usersearches |
| 188 | | WHERE |
| 189 | | tabledefid = '".$uuid."' |
| 190 | | AND type='SCH' |
| 191 | | AND ( |
| 192 | | (userid = '' ".$securitywhere.") |
| 193 | | OR userid = '".$userid."') |
| 194 | | ORDER BY |
| 195 | | userid, |
| 196 | | name"; |
| 197 | | |
| 198 | | $queryresult = $this->db->query($querystatement); |
| 199 | | |
| 200 | | if(!$queryresult) |
| 201 | | $error = new appError(500,"Cannot retrieve saved search infromation"); |
| 202 | | |
| 203 | | $querystatement=" |
| 204 | | SELECT |
| 205 | | advsearchroleid |
| 206 | | FROM |
| 207 | | tabledefs |
| 208 | | WHERE id= '".$tabledefid."'"; |
| 209 | | |
| 210 | | $tabledefresult = $this->db->query($querystatement); |
| 211 | | |
| 212 | | if(!$tabledefresult) |
| 213 | | $error = new appError(500,"Cannot retrieve table definition information."); |
| 214 | | |
| 215 | | $tableinfo=$this->db->fetchArray($tabledefresult); |
| 216 | | |
| 217 | | ?> |
| 218 | | <table border="0" cellpadding="0" cellspacing="0"> |
| 219 | | <tr> |
| 220 | | <td valign="top"> |
| 221 | | <p> |
| 222 | | <label for="LSList">saved searches</label><br /> |
| 223 | | <?php $this->showSavedSearchList($queryresult)?> |
| 224 | | </p> |
| 225 | | </td> |
| 226 | | <td valign="top" width="100%"> |
| 227 | | <p> |
| 228 | | <label for="LSSelectedSearch">name</label><br /> |
| 229 | | <input type="text" id="LSSelectedSearch" size="10" readonly="readonly" class="uneditable" /> |
| 230 | | </p> |
| 231 | | <p> |
| 232 | | <textarea id="LSSQL" rows="8" cols="10" <?php if(!hasRights($tableinfo["advsearchroleid"])) echo " readonly=\"readonly\""?>></textarea> |
| 233 | | </p> |
| 234 | | </td> |
| 235 | | <td valign="top"> |
| 236 | | <p><br/><input id="LSLoad" type="button" onclick="LSRunSearch()" class="Buttons" disabled="disabled" value="run search"/></p> |
| 237 | | <p><input id="LSDelete" type="button" onclick="LSDeleteSearch('<?php echo APP_PATH ?>')" class="Buttons" disabled="disabled" value="delete"/></p> |
| 238 | | <div id="LSResults"> </div> |
| 239 | | </td> |
| 240 | | </tr> |
| 241 | | </table> |
| 242 | | <?php |
| | 179 | $uuid = getUuid($this->db, "tbld:5c9d645f-26ab-5003-b98e-89e9049f8ac3", $tabledefid); |
| | 180 | |
| | 181 | $querystatement = " |
| | 182 | SELECT |
| | 183 | id, |
| | 184 | name, |
| | 185 | userid |
| | 186 | FROM |
| | 187 | usersearches |
| | 188 | WHERE |
| | 189 | tabledefid = '".$uuid."' |
| | 190 | AND type='SCH' |
| | 191 | AND ( |
| | 192 | (userid = '' ".$securitywhere.") |
| | 193 | OR userid = '".$userid."') |
| | 194 | ORDER BY |
| | 195 | userid, |
| | 196 | name"; |
| | 197 | |
| | 198 | $queryresult = $this->db->query($querystatement); |
| | 199 | |
| | 200 | if(!$queryresult) |
| | 201 | $error = new appError(500,"Cannot retrieve saved search infromation"); |
| | 202 | |
| | 203 | $querystatement=" |
| | 204 | SELECT |
| | 205 | advsearchroleid |
| | 206 | FROM |
| | 207 | tabledefs |
| | 208 | WHERE id= '".$tabledefid."'"; |
| | 209 | |
| | 210 | $tabledefresult = $this->db->query($querystatement); |
| | 211 | |
| | 212 | if(!$tabledefresult) |
| | 213 | $error = new appError(500,"Cannot retrieve table definition information."); |
| | 214 | |
| | 215 | $tableinfo=$this->db->fetchArray($tabledefresult); |
| | 216 | |
| | 217 | ?> |
| | 218 | <table border="0" cellpadding="0" cellspacing="0"> |
| | 219 | <tr> |
| | 220 | <td valign="top"> |
| | 221 | <p> |
| | 222 | <label for="LSList">saved searches</label><br /> |
| | 223 | <?php $this->showSavedSearchList($queryresult)?> |
| | 224 | </p> |
| | 225 | </td> |
| | 226 | <td valign="top" width="100%"> |
| | 227 | <p> |
| | 228 | <label for="LSSelectedSearch">name</label><br /> |
| | 229 | <input type="text" id="LSSelectedSearch" size="10" readonly="readonly" class="uneditable" /> |
| | 230 | </p> |
| | 231 | <p> |
| | 232 | <textarea id="LSSQL" rows="8" cols="10" <?php if(!hasRights($tableinfo["advsearchroleid"])) echo " readonly=\"readonly\""?>></textarea> |
| | 233 | </p> |
| | 234 | </td> |
| | 235 | <td valign="top"> |
| | 236 | <p><br/><input id="LSLoad" type="button" onclick="LSRunSearch()" class="Buttons" disabled="disabled" value="run search"/></p> |
| | 237 | <p><input id="LSDelete" type="button" onclick="LSDeleteSearch('<?php echo APP_PATH ?>')" class="Buttons" disabled="disabled" value="delete"/></p> |
| | 238 | <div id="LSResults"> </div> |
| | 239 | </td> |
| | 240 | </tr> |
| | 241 | </table> |
| | 242 | <?php |
| 261 | | $securitywhere = ""; |
| 262 | | |
| 263 | | if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0){ |
| 264 | | |
| 265 | | $securitywhere = ""; |
| 266 | | |
| 267 | | foreach($_SESSION["userinfo"]["roles"] as $role) |
| 268 | | $securitywhere .= ", '".$role."'"; |
| 269 | | |
| 270 | | $securitywhere = " AND (`roleid` IN (''".$securitywhere.") OR `roleid` IS NULL)"; |
| 271 | | |
| 272 | | }//endif |
| 273 | | |
| 274 | | $thesearch->showLoad($_GET["tid"], $_SESSION["userinfo"]["uuid"], $securitywhere); |
| 275 | | break; |
| | 257 | $securitywhere = ""; |
| | 258 | |
| | 259 | if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0){ |
| | 260 | |
| | 261 | $securitywhere = ""; |
| | 262 | |
| | 263 | foreach($_SESSION["userinfo"]["roles"] as $role) |
| | 264 | $securitywhere .= ", '".$role."'"; |
| | 265 | |
| | 266 | $securitywhere = " AND (`roleid` IN (''".$securitywhere.") OR `roleid` IS NULL)"; |
| | 267 | |
| | 268 | }//endif |
| | 269 | |
| | 270 | $thesearch->showLoad($_GET["tid"], $_SESSION["userinfo"]["uuid"], $securitywhere); |
| | 271 | break; |