Skip to content

Commit

Permalink
MDL-21781 integrating cohorts into UI - admin tree and list of catego…
Browse files Browse the repository at this point in the history
…ries in edit mode (there is no other better place which shows all categories imho)
  • Loading branch information
skodak committed Apr 23, 2010
1 parent 7778e96 commit 864e280
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion admin/settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions cohort/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

require('../config.php');
require_once($CFG->libdir.'/adminlib.php');

$contextid = optional_param('contextid', 0, PARAM_INT);

Expand All @@ -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();

Expand Down
6 changes: 6 additions & 0 deletions course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
}

Expand Down Expand Up @@ -333,6 +334,11 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
' src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$str->show.'" /></a> ';
}

if (has_capability('moodle/cohort:manage', $category->context) or has_capability('moodle/cohort:view', $category->context)) {
echo '<a title="'.$str->cohorts.'" href="'.$CFG->wwwroot.'/cohort/index.php?contextid='.$category->context->id.'"><img'.
' src="'.$OUTPUT->pix_url('i/cohort') . '" class="iconsmall" alt="'.$str->cohorts.'" /></a> ';
}

if ($up) {
echo '<a title="'.$str->moveup.'" href="index.php?moveup='.$category->id.'&amp;sesskey='.sesskey().'"><img'.
' src="'.$OUTPUT->pix_url('t/up') . '" class="iconsmall" alt="'.$str->moveup.'" /></a> ';
Expand Down

0 comments on commit 864e280

Please sign in to comment.