diff --git a/admin/settings/users.php b/admin/settings/users.php
index 8feff1fd7e1..75741d80a46 100644
--- a/admin/settings/users.php
+++ b/admin/settings/users.php
@@ -12,7 +12,9 @@ if ($hassiteconfig
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 @@ if ($hassiteconfig
$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 8128b10631d..9d1d1f13199 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 @@ if (!$manager) {
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 7646d3db889..ece2f2b1d14 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 '
';