本文整理汇总了PHP中course_enrolment_manager::has_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::has_instance方法的具体用法?PHP course_enrolment_manager::has_instance怎么用?PHP course_enrolment_manager::has_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_enrolment_manager
的用法示例。
在下文中一共展示了course_enrolment_manager::has_instance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_manual_enrol_button
/**
* Returns a button to enrol a cohort or its users through the manual enrolment plugin.
*
* This function also adds a quickenrolment JS ui to the page so that users can be enrolled
* via AJAX.
*
* @param course_enrolment_manager $manager
* @return enrol_user_button
*/
public function get_manual_enrol_button(course_enrolment_manager $manager)
{
$course = $manager->get_course();
if (!$this->can_add_new_instances($course->id)) {
return false;
}
$cohorturl = new moodle_url('/enrol/cohort/edit.php', array('courseid' => $course->id));
$button = new enrol_user_button($cohorturl, get_string('enrolcohort', 'enrol'), 'get');
$button->class .= ' enrol_cohort_plugin';
$button->strings_for_js(array('enrol', 'synced', 'enrolcohort', 'enrolcohortusers'), 'enrol');
$button->strings_for_js(array('ajaxmore', 'cohortsearch'), 'enrol_cohort');
$button->strings_for_js('assignroles', 'role');
$button->strings_for_js('cohort', 'cohort');
$button->strings_for_js('users', 'moodle');
// No point showing this at all if the user cant manually enrol users.
$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';
$arguments = array('courseid' => $course->id, 'ajaxurl' => '/enrol/cohort/ajax.php', 'url' => $manager->get_moodlepage()->url->out(false), 'manualEnrolment' => $hasmanualinstance);
$button->require_yui_module($modules, $function, array($arguments));
return $button;
}