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 * This page lets users to manage site wide competencies. 19 * 20 * @package tool_lp 21 * @copyright 2015 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once(__DIR__ . '/../../../config.php'); 26 require_once($CFG->libdir.'/adminlib.php'); 27 28 $id = optional_param('id', 0, PARAM_INT); 29 $returntype = optional_param('return', null, PARAM_TEXT); 30 $pagecontextid = required_param('pagecontextid', PARAM_INT); // Reference to where we can from. 31 32 $framework = null; 33 if (!empty($id)) { 34 // Always use the context from the framework when it exists. 35 $framework = new \core_competency\competency_framework($id); 36 $context = $framework->get_context(); 37 } else { 38 $context = context::instance_by_id($pagecontextid); 39 } 40 41 // We check that we have the permission to edit this framework, in its own context. 42 require_login(null, false); 43 \core_competency\api::require_enabled(); 44 require_capability('moodle/competency:competencymanage', $context); 45 46 // Set up the framework page. 47 list($pagetitle, $pagesubtitle, $url, $frameworksurl) = tool_lp\page_helper::setup_for_framework($id, 48 $pagecontextid, $framework, $returntype); 49 $output = $PAGE->get_renderer('tool_lp'); 50 $form = new \tool_lp\form\competency_framework($url->out(false), array('context' => $context, 'persistent' => $framework)); 51 52 if ($form->is_cancelled()) { 53 redirect($frameworksurl); 54 } else if ($data = $form->get_data()) { 55 if (empty($data->id)) { 56 // Create new framework. 57 $data->contextid = $context->id; 58 $framework = \core_competency\api::create_framework($data); 59 $frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array( 60 'pagecontextid' => $pagecontextid, 61 'competencyframeworkid' => $framework->get('id') 62 )); 63 $messagesuccess = get_string('competencyframeworkcreated', 'tool_lp'); 64 redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS); 65 } else { 66 \core_competency\api::update_framework($data); 67 $messagesuccess = get_string('competencyframeworkupdated', 'tool_lp'); 68 redirect($frameworksurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS); 69 } 70 } 71 72 echo $output->header(); 73 echo $output->heading($pagetitle, 2); 74 echo $output->heading($pagesubtitle, 3); 75 $form->display(); 76 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body