From 864e2805d0b415a29694139fbf8a91ef1640d1ee Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 23 Apr 2010 09:13:19 +0000 Subject: [PATCH] MDL-21781 integrating cohorts into UI - admin tree and list of categories in edit mode (there is no other better place which shows all categories imho) --- admin/settings/users.php | 5 ++++- cohort/index.php | 14 +++++++------- course/index.php | 6 ++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/admin/settings/users.php b/admin/settings/users.php index 8feff1fd7e1c9..75741d80a465e 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -12,7 +12,9 @@ or has_capability('moodle/user:update', $systemcontext) or has_capability('moodle/user:delete', $systemcontext) or has_capability('moodle/role:manage', $systemcontext) - or has_capability('moodle/role:assign', $systemcontext)) { // speedup for non-admins, add all caps used on this page + or has_capability('moodle/role:assign', $systemcontext) + or has_capability('moodle/cohort:manage', $systemcontext) + or has_capability('moodle/cohort:view', $systemcontext)) { // speedup for non-admins, add all caps used on this page $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin')); @@ -75,6 +77,7 @@ $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers')); $ADMIN->add('accounts', new admin_externalpage('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.php", 'moodle/site:uploadusers')); $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); + $ADMIN->add('accounts', new admin_externalpage('cohorts', get_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view'))); // stuff under the "roles" subcategory diff --git a/cohort/index.php b/cohort/index.php index 8128b10631d6e..9d1d1f1319951 100644 --- a/cohort/index.php +++ b/cohort/index.php @@ -25,6 +25,7 @@ */ require('../config.php'); +require_once($CFG->libdir.'/adminlib.php'); $contextid = optional_param('contextid', 0, PARAM_INT); @@ -50,18 +51,17 @@ require_capability('moodle/cohort:view', $context); } -// TODO: use admin_external_page in system context - $strcohorts = get_string('cohorts', 'cohort'); -$PAGE->set_url('/cohort/index.php', array('contextid'=>$context->id)); -$PAGE->set_title($strcohorts); -$PAGE->set_context($context); - if ($category) { + $PAGE->set_url('/cohort/index.php', array('contextid'=>$context->id)); + $PAGE->set_title($strcohorts); + $PAGE->set_context($context); $PAGE->navbar->add($category->name, new moodle_url('/course/index.php', array('categoryedit'=>'1'))); + $PAGE->navbar->add($strcohorts); +} else { + admin_externalpage_setup('cohorts'); } -$PAGE->navbar->add($strcohorts); echo $OUTPUT->header(); diff --git a/course/index.php b/course/index.php index 7646d3db88993..ece2f2b1d1466 100644 --- a/course/index.php +++ b/course/index.php @@ -295,6 +295,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ $str->edit = get_string('editthiscategory'); $str->hide = get_string('hide'); $str->show = get_string('show'); + $str->cohorts = get_string('cohorts', 'cohort'); $str->spacer = ' '; } @@ -333,6 +334,11 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ ' src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$str->show.'" /> '; } + if (has_capability('moodle/cohort:manage', $category->context) or has_capability('moodle/cohort:view', $category->context)) { + echo ' '; + } + if ($up) { echo ' ';