From: Petr Skoda Date: Fri, 5 Aug 2011 19:43:29 +0000 (+0200) Subject: MDL-28468 fix cohort assign check X-Git-Tag: v2.2.0-beta~590^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=50584dd3cc7681edf49cc1f4e33c5f8bfa5efb0b MDL-28468 fix cohort assign check --- diff --git a/cohort/index.php b/cohort/index.php index 0324c5ab6c0..62c472950e5 100644 --- a/cohort/index.php +++ b/cohort/index.php @@ -47,6 +47,7 @@ if ($context->contextlevel == CONTEXT_COURSECAT) { } $manager = has_capability('moodle/cohort:manage', $context); +$canassign = has_capability('moodle/cohort:assign', $context); if (!$manager) { require_capability('moodle/cohort:view', $context); } @@ -84,18 +85,17 @@ foreach($cohorts as $cohort) { $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; }