Changeset 507141
- Timestamp:
- 02/19/2012 01:00:51 AM (14 years ago)
- File:
-
- 1 edited
-
token-manager/trunk/json.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
token-manager/trunk/json.php
r502015 r507141 17 17 case 'attachedpagesadd' : $this->attachedpagesadd(); break; 18 18 case 'attachedpagesremove' : $this->attachedpagesremove(); break; 19 case 'moveup' : $this->moveup(); break; 20 case 'movedown' : $this->movedown(); break; 19 21 default : echo 'No feed with that name!'; break; 20 22 } … … 204 206 } 205 207 } 208 209 public function moveup() 210 { 211 global $wpdb, $_POST; 212 213 if(isset($_POST['tid']) && !empty($_POST['tid'])) 214 { 215 $tid = $wpdb->escape($_POST['tid']); 216 217 $tablename = $wpdb->base_prefix . 'tokenmanager'; 218 219 $corder = $wpdb->get_var("SELECT processorder FROM $tablename WHERE id = $tid AND active = 1;"); 220 $ntid = $wpdb->get_var("SELECT id FROM $tablename WHERE processorder > $corder AND active = 1 ORDER BY processorder ASC LIMIT 1;"); 221 $norder = $wpdb->get_var("SELECT processorder FROM $tablename WHERE id = $ntid AND active = 1;"); 222 223 if(isset($ntid) && isset($corder) && isset($norder) && $norder > $corder) 224 { 225 $wpdb->query("UPDATE $tablename SET processorder = $norder, lastupdated = UNIX_TIMESTAMP() WHERE id = '$tid' AND active = 1;"); 226 $wpdb->query("UPDATE $tablename SET processorder = $corder, lastupdated = UNIX_TIMESTAMP() WHERE id = '$ntid' AND active = 1;"); 227 228 echo "<jsonobject>Successfully moved token order.</jsonobject>"; 229 } 230 else 231 { 232 echo "<jsonobject>Cannot move token order.</jsonobject>"; 233 } 234 } 235 } 236 237 public function movedown() 238 { 239 global $wpdb, $_POST; 240 241 if(isset($_POST['tid']) && !empty($_POST['tid'])) 242 { 243 $tid = $wpdb->escape($_POST['tid']); 244 245 $tablename = $wpdb->base_prefix . 'tokenmanager'; 246 247 $corder = $wpdb->get_var("SELECT processorder FROM $tablename WHERE id = $tid AND active = 1;"); 248 $ntid = $wpdb->get_var("SELECT id FROM $tablename WHERE processorder < $corder AND active = 1 ORDER BY processorder DESC LIMIT 1;"); 249 $norder = $wpdb->get_var("SELECT processorder FROM $tablename WHERE id = $ntid AND active = 1;"); 250 251 if(isset($ntid) && isset($corder) && isset($norder) && $norder < $corder) 252 { 253 $wpdb->query("UPDATE $tablename SET processorder = $norder, lastupdated = UNIX_TIMESTAMP() WHERE id = '$tid' AND active = 1;"); 254 $wpdb->query("UPDATE $tablename SET processorder = $corder, lastupdated = UNIX_TIMESTAMP() WHERE id = '$ntid' AND active = 1;"); 255 256 echo "<jsonobject>Successfully moved token order.</jsonobject>"; 257 } 258 else 259 { 260 echo "<jsonobject>Cannot move token order.</jsonobject>"; 261 } 262 } 263 } 206 264 } 207 265
Note: See TracChangeset
for help on using the changeset viewer.