Skip to content

Commit

Permalink
Merge branch 'w29_MDL-28432_m22_cohortconfig' of git://github.com/sko…
Browse files Browse the repository at this point in the history
…dak/moodle
  • Loading branch information
Sam Hemelryk committed Jul 25, 2011
2 parents 08ad288 + 6df9761 commit 8306a37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions enrol/cohort/addinstance.php
Expand Up @@ -35,6 +35,7 @@

require_login($course);
require_capability('moodle/course:enrolconfig', $context);
require_capability('enrol/cohort:config', $context);

$PAGE->set_url('/enrol/cohort/addinstance.php', array('id'=>$course->id));
$PAGE->set_pagelayout('admin');
Expand Down
9 changes: 8 additions & 1 deletion enrol/cohort/ajax.php
Expand Up @@ -74,6 +74,7 @@
break;
case 'enrolcohort':
require_capability('moodle/course:enrolconfig', $context);
require_capability('enrol/cohort:config', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);

Expand All @@ -87,10 +88,16 @@
enrol_cohort_sync($manager->get_course()->id);
break;
case 'enrolcohortusers':
require_capability('moodle/course:enrolconfig', $context);
require_capability('enrol/manual:enrol', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);
$result = enrol_cohort_enrol_all_users($manager, $cohortid, $roleid);

$roles = $manager->get_assignable_roles();
$cohorts = enrol_cohort_get_cohorts($manager);
if (!array_key_exists($cohortid, $cohorts) || !array_key_exists($roleid, $roles)) {
throw new enrol_ajax_exception('errorenrolcohort');
}
if ($result === false) {
throw new enrol_ajax_exception('errorenrolcohortusers');
}
Expand Down
2 changes: 1 addition & 1 deletion enrol/cohort/lib.php
Expand Up @@ -163,7 +163,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
$button->strings_for_js('users', 'moodle');

// No point showing this at all if the user cant manually enrol users
$hasmanualinstance = has_capability('enrol/manual:manage', $manager->get_context()) && $manager->has_instance('manual');
$hasmanualinstance = has_capability('enrol/manual:enrol', $manager->get_context()) && $manager->has_instance('manual');

$modules = array('moodle-enrol_cohort-quickenrolment', 'moodle-enrol_cohort-quickenrolment-skin');
$function = 'M.enrol_cohort.quickenrolment.init';
Expand Down

0 comments on commit 8306a37

Please sign in to comment.