Skip to content

Commit

Permalink
MDL-28468 fix cohort assign check
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 5, 2011
1 parent 3fdc622 commit 50584dd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cohort/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}

$manager = has_capability('moodle/cohort:manage', $context);
$canassign = has_capability('moodle/cohort:assign', $context);
if (!$manager) {
require_capability('moodle/cohort:view', $context);
}
Expand Down Expand Up @@ -84,18 +85,17 @@
$line[] = get_string('pluginname', $cohort->component);
}

if ($manager) {
if (empty($cohort->component)) {
$buttons = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id, 'delete'=>1)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/delete'), 'alt'=>get_string('delete'), 'class'=>'iconsmall')));
$buttons .= ' ' . html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/edit'), 'alt'=>get_string('edit'), 'class'=>'iconsmall')));
$buttons .= ' ' . html_writer::link(new moodle_url('/cohort/assign.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/users'), 'alt'=>get_string('assign', 'core_cohort'), 'class'=>'iconsmall')));
} else {
$buttons = '';
$buttons = array();
if (empty($cohort->component)) {
if ($manager) {
$buttons[] = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id, 'delete'=>1)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/delete'), 'alt'=>get_string('delete'), 'class'=>'iconsmall')));
$buttons[] = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/edit'), 'alt'=>get_string('edit'), 'class'=>'iconsmall')));
}
if ($manager or $canassign) {
$buttons[] = html_writer::link(new moodle_url('/cohort/assign.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/users'), 'alt'=>get_string('assign', 'core_cohort'), 'class'=>'iconsmall')));
}
} else {
$buttons = '';
}
$line[] = $buttons;
$line[] = implode(' ', $buttons);

$data[] = $line;
}
Expand Down

0 comments on commit 50584dd

Please sign in to comment.