Skip to content

Commit

Permalink
MDL-36990 mod_feedback - move ajax function into lib.php
Browse files Browse the repository at this point in the history
  • Loading branch information
grabs committed Mar 9, 2013
1 parent 575c88c commit 3b4afad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
18 changes: 1 addition & 17 deletions mod/feedback/ajax.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
21 changes: 21 additions & 0 deletions mod/feedback/lib.php
Expand Up @@ -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.