Changeset 507109
- Timestamp:
- 02/18/2012 10:05:14 PM (14 years ago)
- File:
-
- 1 edited
-
tf-faq/trunk/faq-actions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tf-faq/trunk/faq-actions.php
r505658 r507109 2 2 global $wpdb; 3 3 4 /*** ** change the faq order *****/4 /*** sort the questions ***/ 5 5 6 if(isset($_GET['direction']) and isset($_GET['order-id'])) {6 if(isset($_GET['direction'])) { 7 7 8 $this_question = faq_get_question($_GET['order-id']); 8 $direction = ($_GET['direction'] == 'down') ? array('<', 'DESC') : array('>', 'ASC'); 9 $id = intval($_GET['order-id']); 10 $category = intval($_GET['cat']); 9 11 10 /*** determine change id ***/ 11 if($_GET['direction'] == 'down') { 12 $change_id_sql = "SELECT id FROM ".$wpdb->prefix."faq_questions WHERE id<".$this_question->id." AND category='".$this_question->category."' ORDER BY id DESC LIMIT 0,1"; 13 } else { 14 $change_id_sql = "SELECT id FROM ".$wpdb->prefix."faq_questions WHERE id>".$this_question->id." AND category='".$this_question->category."' ORDER BY id ASC LIMIT 0,1"; 15 } 16 $change_id = $wpdb->get_results($change_id_sql); 17 $change_id = $change_id[0]->id; 12 $sort_sql = "SELECT id FROM ".$wpdb->prefix."faq_questions WHERE id".$direction[0].$id." AND category='".$category."' ORDER BY id ".$direction[1]." LIMIT 0,1"; 13 $sort_id = $wpdb->get_results($sort_sql); 14 $sort_id = $sort_id[0]->id; 18 15 19 //change the questions 20 $temp = $wpdb->query("UPDATE ".$wpdb->prefix."faq_questions SET id='".(0-$change_id)."' WHERE id='".$change_id."'"); 21 $new = $wpdb->query("UPDATE ".$wpdb->prefix."faq_questions SET id='".$change_id."' WHERE id='".$this_question->id."'"); 22 $final = $wpdb->query("UPDATE ".$wpdb->prefix."faq_questions SET id='".$this_question->id."' WHERE id='".(0-$change_id)."'"); 23 } 16 $temp = $wpdb->update( $wpdb->prefix.'faq_questions', array('id' => (0-$sort_id)) , array('id' => $sort_id) ); 17 $new = $wpdb->update( $wpdb->prefix.'faq_questions', array('id' => absint($sort_id)), array('id' => $id) ); 18 $final = $wpdb->update( $wpdb->prefix.'faq_questions', array('id' => absint($id)), array('id' => (0-$sort_id)) ); 19 20 } /*** end if(isset($_GET['direction'])) ***/ 21 22 /*** end sort the questions ***/ 24 23 25 24 /***** process the changes in questions *****/
Note: See TracChangeset
for help on using the changeset viewer.