Esempio n. 1
0
/** 
 *  deletes a item and also deletes all related values
 *  @param int $itemid
 *  @param boolean $renumber should the kept items renumbered Yes/No
 *  @return void
 */
function feedback_delete_item($itemid, $renumber = true)
{
    $item = get_record('feedback_item', 'id', $itemid);
    @delete_records("feedback_value", "item", $itemid);
    @delete_records("feedback_valuetmp", "item", $itemid);
    delete_records("feedback_item", "id", $itemid);
    if ($renumber) {
        feedback_renumber_items($item->feedback);
    }
}
Esempio n. 2
0
/**
 * this increased the position of the given item
 *
 * @global object
 * @param object $item
 * @return bool
 */
function feedback_movedown_item($item) {
    global $DB;

    $params = array('feedback'=>$item->feedback);
    if (!$items = $DB->get_records('feedback_item', $params, 'position')) {
        return false;
    }

    $movedownitem = null;
    foreach ($items as $i) {
        if (!is_null($movedownitem) AND $movedownitem->id == $item->id) {
            $movedownitem->position = $i->position;
            $i->position--;
            feedback_update_item($movedownitem);
            feedback_update_item($i);
            feedback_renumber_items($item->feedback);
            return true;
        }
        $movedownitem = $i;
    }
    return false;
}
Esempio n. 3
0
/**
 * deletes a item and also deletes all related values
 *
 * @global object
 * @param int $itemid
 * @param boolean $renumber should the kept items renumbered Yes/No
 * @return void
 */
function feedback_delete_item($itemid, $renumber = true)
{
    global $DB;
    $item = $DB->get_record('feedback_item', array('id' => $itemid));
    $DB->delete_records("feedback_value", array("item" => $itemid));
    $DB->delete_records("feedback_valuetmp", array("item" => $itemid));
    $DB->delete_records("feedback_item", array("id" => $itemid));
    if ($renumber) {
        feedback_renumber_items($item->feedback);
    }
}