MDL-42629 course: fixed up create category management actions

This commit is contained in:
Sam Hemelryk
2013-11-05 09:49:13 +08:00
parent 115e5f052f
commit 017518d4f8
3 changed files with 16 additions and 28 deletions
+8
View File
@@ -208,6 +208,14 @@ class helper {
);
}
if ($category->can_create_subcategory()) {
$actions['createnewsubcategory'] = array(
'url' => new \moodle_url('/course/editcategory.php', array('parent' => $category->id)),
'icon' => new \pix_icon('i/withsubcat', new \lang_string('createnewsubcategory')),
'string' => new \lang_string('createnewsubcategory')
);
}
// Resort.
if ($category->can_resort_subcategories() && $category->has_children()) {
$actions['resortbyname'] = array(
+6 -28
View File
@@ -257,39 +257,17 @@ class core_course_management_renderer extends plugin_renderer_base {
*/
public function category_listing_actions(coursecat $category = null) {
$actions = array();
$createtoplevel = coursecat::can_create_top_level_category();
$createsubcategory = $category && $category->can_create_subcategory();
$cancreatecategory = $category && $category->can_create_subcategory();
$cancreatecategory = $cancreatecategory || coursecat::can_create_top_level_category();
if ($category === null) {
$category = coursecat::get(0);
}
$hasitems = false;
if ($createtoplevel) {
$hasitems = true;
$menu = new action_menu;
if ($createtoplevel) {
$url = new moodle_url('/course/editcategory.php', array('parent' => 0));
$menu->add(new action_menu_link_secondary(
$url,
null,
get_string('toplevelcategory')
));
}
if ($createsubcategory) {
$url = new moodle_url('/course/editcategory.php', array('parent' => $category->id));
$attributes = array(
'title' => get_string('createsubcategoryof', 'moodle', $category->get_formatted_name())
);
$menu->add(new action_menu_link_secondary(
$url,
null,
get_string('subcategory'),
$attributes
));
}
$menu->actiontext = get_string('createnew');
$menu->actionicon = new pix_icon('t/contextmenu', ' ', 'moodle', array('class' => 'iconsmall', 'title' => ''));
$actions[] = $this->render($menu);
if ($cancreatecategory) {
$url = new moodle_url('/course/editcategory.php', array('parent' => $category->id));
$actions[] = html_writer::link($url, get_string('createnewcategory'));
}
if (coursecat::can_approve_course_requests()) {
$actions[] = html_writer::link(new moodle_url('/course/pending.php'), get_string('coursespending'));
+2
View File
@@ -377,6 +377,8 @@ $string['createaccount'] = 'Create my new account';
$string['createcategory'] = 'Create category';
$string['createfolder'] = 'Create a folder in {$a}';
$string['createnew'] = 'Create new';
$string['createnewcategory'] = 'Create new category';
$string['createnewsubcategory'] = 'Create new subcategory';
$string['createsubcategoryof'] = 'Create subcategory of {$a}';
$string['createuserandpass'] = 'Choose your username and password';
$string['createuser'] = 'Create user';