[Customisation Database Commits] r261 - /trunk/titania/includes/objects/faq.php
Nathan Guse
exreaction at phpbb.com
Sat Jun 27 05:33:53 UTC 2009
Author: exreaction
Date: Sat Jun 27 05:33:47 2009
New Revision: 261
Log:
Move function for the FAQ
Modified:
trunk/titania/includes/objects/faq.php
Modified: trunk/titania/includes/objects/faq.php
==============================================================================
*** trunk/titania/includes/objects/faq.php (original)
--- trunk/titania/includes/objects/faq.php Sat Jun 27 05:33:47 2009
***************
*** 93,98 ****
--- 93,130 ----
}
/**
+ * Move a FAQ item
+ *
+ * @param string $direction (up|down)
+ */
+ public function move($direction)
+ {
+ $sql = 'SELECT order_id FROM ' . TITANIA_CONTRIB_FAQ_TABLE . '
+ WHERE faq_order_id ' . (($direction == 'up') ? '<' : '>') . $this->faq_order_id . '
+ ORDER BY faq_order_id ' . (($direction == 'up') ? 'ASC' : 'DESC');
+ phpbb::$db->sql_query_limit($sql, 1);
+ $new_order_id = phpbb::$db->sql_fetchfield('order_id');
+ phpbb::$db->sql_freeresult();
+
+ if ($new_order_id === false)
+ {
+ return false;
+ }
+
+ // Update the item in the position where want to move it to have the current position
+ $sql = 'UPDATE ' . TITANIA_CONTRIB_FAQ_TABLE . ' SET faq_order_id = ' . $this->faq_order_id . '
+ WHERE faq_order_id = ' . $new_order_id;
+ phpbb::$db->sql_query($sql);
+
+ // Update the current faq item to have the new position
+ $sql = 'UPDATE ' . TITANIA_CONTRIB_FAQ_TABLE . ' SET faq_order_id = ' . $new_order_id . '
+ WHERE faq_id = ' . $this->faq_id;
+ phpbb::$db->sql_query($sql);
+
+ return true;
+ }
+
+ /**
* Get faq data from the database
*
* @return void
More information about the customisationdb-commits
mailing list