Browse files

MDL-36990 mod_feedback - move ajax function into lib.php

  • Loading branch information...
1 parent 575c88c commit 3b4afad07ceaf66219f62747f8aad1d73c49c0c6 @grabs grabs committed Dec 11, 2012
Showing with 22 additions and 17 deletions.
  1. +1 −17 mod/feedback/ajax.php
  2. +21 −0 mod/feedback/lib.php
View
18 mod/feedback/ajax.php
@@ -5,6 +5,7 @@
}
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once("lib.php");
$id = required_param('id', PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
@@ -34,20 +35,3 @@
echo json_encode($return);
die;
-
-////////////////////////////////////////
-
-function feedback_ajax_saveitemorder($itemlist, $feedback) {
- global $DB;
-
- $result = true;
- $position = 0;
- foreach ($itemlist as $itemid) {
- $position++;
- $result = $result && $DB->set_field('feedback_item',
- 'position',
- $position,
- array('id'=>$itemid, 'feedback'=>$feedback->id));
- }
- return $result;
-}
View
21 mod/feedback/lib.php
@@ -3122,3 +3122,24 @@ function feedback_page_type_list($pagetype, $parentcontext, $currentcontext) {
$module_pagetype = array('mod-feedback-*'=>get_string('page-mod-feedback-x', 'feedback'));
return $module_pagetype;
}
+
+/**
+ * Move save the items of the given $feedback in the order of $itemlist.
+ * @param string $itemlist a comma separated list with item ids
+ * @param stdClass $feedback
+ * @return bool true if success
+ */
+function feedback_ajax_saveitemorder($itemlist, $feedback) {
+ global $DB;
+
+ $result = true;
+ $position = 0;
+ foreach ($itemlist as $itemid) {
+ $position++;
+ $result = $result && $DB->set_field('feedback_item',
+ 'position',
+ $position,
+ array('id'=>$itemid, 'feedback'=>$feedback->id));
+ }
+ return $result;
+}

0 comments on commit 3b4afad

Please sign in to comment.