Exemplo n.º 1
0
    $category->id = 0;
    $category->parent = $parent;
    $strtitle = new lang_string("addnewcategory");
    $itemid = null;
    // Set this explicitly, so files for parent category should not get loaded in draft area.
    $title = "{$SITE->shortname}: " . get_string('addnewcategory');
    $fullname = $SITE->fullname;
}
require_capability('moodle/category:manage', $context);
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
$PAGE->set_heading($fullname);
$mform = new core_course_editcategory_form(null, array('categoryid' => $id, 'parent' => $category->parent, 'context' => $context, 'itemid' => $itemid));
$mform->set_data(file_prepare_standard_editor($category, 'description', $mform->get_description_editor_options(), $context, 'coursecat', 'description', $itemid));
$manageurl = new moodle_url('/course/management.php');
if ($mform->is_cancelled()) {
    if ($id) {
        $manageurl->param('categoryid', $id);
    } else {
        if ($parent) {
            $manageurl->param('categoryid', $parent);
        }
    }
    redirect($manageurl);
} else {
    if ($data = $mform->get_data()) {
        if (isset($coursecat)) {
            if ((int) $data->parent !== (int) $coursecat->parent && !$coursecat->can_change_parent($data->parent)) {
                print_error('cannotmovecategory');