Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * prints the form to edit a dedicated item 19 * 20 * @author Andreas Grabs 21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 22 * @package mod_feedback 23 */ 24 25 require_once("../../config.php"); 26 require_once ("lib.php"); 27 28 feedback_init_feedback_session(); 29 30 $itemid = optional_param('id', false, PARAM_INT); 31 if (!$itemid) { 32 $cmid = required_param('cmid', PARAM_INT); 33 $typ = required_param('typ', PARAM_ALPHA); 34 } 35 36 if ($itemid) { 37 $item = $DB->get_record('feedback_item', array('id' => $itemid), '*', MUST_EXIST); 38 list($course, $cm) = get_course_and_cm_from_instance($item->feedback, 'feedback'); 39 $url = new moodle_url('/mod/feedback/edit_item.php', array('id' => $itemid)); 40 $typ = $item->typ; 41 } else { 42 $item = null; 43 list($course, $cm) = get_course_and_cm_from_cmid($cmid, 'feedback'); 44 $url = new moodle_url('/mod/feedback/edit_item.php', array('cmid' => $cm->id, 'typ' => $typ)); 45 $item = (object)['id' => null, 'position' => -1, 'typ' => $typ, 'options' => '']; 46 } 47 48 require_login($course, true, $cm); 49 $context = context_module::instance($cm->id); 50 require_capability('mod/feedback:edititems', $context); 51 $feedback = $PAGE->activityrecord; 52 53 $editurl = new moodle_url('/mod/feedback/edit.php', array('id' => $cm->id)); 54 55 $PAGE->set_url($url); 56 57 // If the typ is pagebreak so the item will be saved directly. 58 if (!$item->id && $typ === 'pagebreak') { 59 require_sesskey(); 60 feedback_create_pagebreak($feedback->id); 61 redirect($editurl->out(false)); 62 exit; 63 } 64 65 //get the existing item or create it 66 // $formdata->itemid = isset($formdata->itemid) ? $formdata->itemid : NULL; 67 if (!$typ || !file_exists($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php')) { 68 throw new \moodle_exception('typemissing', 'feedback', $editurl->out(false)); 69 } 70 71 require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php'); 72 73 $itemobj = feedback_get_item_class($typ); 74 75 $itemobj->build_editform($item, $feedback, $cm); 76 77 if ($itemobj->is_cancelled()) { 78 redirect($editurl); 79 exit; 80 } 81 if ($itemobj->get_data()) { 82 if ($item = $itemobj->save_item()) { 83 feedback_move_item($item, $item->position); 84 redirect($editurl); 85 } 86 } 87 88 //////////////////////////////////////////////////////////////////////////////////// 89 /// Print the page header 90 $strfeedbacks = get_string("modulenameplural", "feedback"); 91 $strfeedback = get_string("modulename", "feedback"); 92 93 navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php', 94 array('id' => $cm->id, 'do_show' => 'edit'))); 95 if ($item->id) { 96 $PAGE->navbar->add(get_string('edit_item', 'feedback')); 97 } else { 98 $PAGE->navbar->add(get_string('add_item', 'feedback')); 99 } 100 $PAGE->set_heading($course->fullname); 101 $PAGE->set_title($feedback->name); 102 $PAGE->activityheader->set_attrs([ 103 "hidecompletion" => true, 104 "description" => '' 105 ]); 106 echo $OUTPUT->header(); 107 108 /// print the tabs 109 $current_tab = 'edit'; 110 $id = $cm->id; 111 112 //print errormsg 113 if (isset($error)) { 114 echo $error; 115 } 116 $itemobj->show_editform(); 117 118 /// Finish the page 119 /////////////////////////////////////////////////////////////////////////// 120 /////////////////////////////////////////////////////////////////////////// 121 /////////////////////////////////////////////////////////////////////////// 122 123 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body