/** * Constructs the form. * @param null $action * @param null $customdata * @param string $method * @param string $target * @param null $attributes * @param bool $editable */ public function __construct($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true) { $customdata['categoryid'] = $customdata['category']->id; $customdata['parent'] = $customdata['category']->parent; unset($customdata['category']); parent::moodleform($action, $customdata, $method, $target, $attributes, $editable); }
$category = new stdClass(); $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)) {