本文整理汇总了PHP中course_enrolment_manager::get_moodlepage方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::get_moodlepage方法的具体用法?PHP course_enrolment_manager::get_moodlepage怎么用?PHP course_enrolment_manager::get_moodlepage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_enrolment_manager
的用法示例。
在下文中一共展示了course_enrolment_manager::get_moodlepage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_user_enrolment_actions
/**
* Gets an array of the user enrolment actions
*
* @param course_enrolment_manager $manager
* @param stdClass $ue A user enrolment object
* @return array An array of user_enrolment_actions
*/
public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) {
$actions = array();
$context = $manager->get_context();
$instance = $ue->enrolmentinstance;
$params = $manager->get_moodlepage()->url->params();
$params['ue'] = $ue->id;
if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/database:unenrol', $context)) {
$url = new moodle_url('/enrol/unenroluser.php', $params);
$actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
}
return $actions;
}
示例2: 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;
}
示例3: get_paging_bar
/**
* Gets the paging bar instance for this table
*
* @return paging_bar
*/
public function get_paging_bar()
{
if ($this->pagingbar == null) {
$this->pagingbar = new paging_bar($this->totalusers, $this->page, $this->perpage, $this->manager->get_moodlepage()->url, self::PAGEVAR);
}
return $this->pagingbar;
}
示例4: get_users_for_display
/**
* Gets an array of users for display, this includes minimal user information
* as well as minimal information on the users roles, groups, and enrolments.
*
* @param core_enrol_renderer $renderer
* @param moodle_url $pageurl
* @param int $sort
* @param string $direction ASC or DESC
* @param int $page
* @param int $perpage
* @return array
*/
public function get_users_for_display(course_enrolment_manager $manager, $sort, $direction, $page, $perpage)
{
$pageurl = $manager->get_moodlepage()->url;
$users = $this->get_users($sort, $direction, $page, $perpage);
$now = time();
$straddgroup = get_string('addgroup', 'group');
$strunenrol = get_string('unenrol', 'enrol');
$stredit = get_string('edit');
$allroles = $this->get_all_roles();
$assignable = $this->get_assignable_roles();
$allgroups = $this->get_all_groups();
$context = $this->get_context();
$canmanagegroups = has_capability('moodle/course:managegroups', $context);
$url = new moodle_url($pageurl, $this->get_url_params());
$extrafields = get_extra_user_fields($context);
$enabledplugins = $this->get_enrolment_plugins(true);
$userdetails = array();
foreach ($users as $user) {
$details = $this->prepare_user_for_display($user, $extrafields, $now);
// Roles
$details['roles'] = array();
foreach ($this->get_user_roles($user->id) as $rid => $rassignable) {
$unchangeable = !$rassignable;
if (!is_siteadmin() and !isset($assignable[$rid])) {
$unchangeable = true;
}
$details['roles'][$rid] = array('text' => $allroles[$rid]->localname, 'unchangeable' => $unchangeable);
}
// Users
$usergroups = $this->get_user_groups($user->id);
$details['groups'] = array();
foreach ($usergroups as $gid => $unused) {
$details['groups'][$gid] = $allgroups[$gid]->name;
}
// Enrolments
$details['enrolments'] = array();
foreach ($this->get_user_enrolments($user->id) as $ue) {
if (!isset($enabledplugins[$ue->enrolmentinstance->enrol])) {
$details['enrolments'][$ue->id] = array('text' => $ue->enrolmentinstancename, 'period' => null, 'dimmed' => true, 'actions' => array());
continue;
} else {
if ($ue->timestart and $ue->timeend) {
$period = get_string('periodstartend', 'enrol', array('start' => userdate($ue->timestart), 'end' => userdate($ue->timeend)));
$periodoutside = $ue->timestart && $ue->timeend && ($now < $ue->timestart || $now > $ue->timeend);
} else {
if ($ue->timestart) {
$period = get_string('periodstart', 'enrol', userdate($ue->timestart));
$periodoutside = $ue->timestart && $now < $ue->timestart;
} else {
if ($ue->timeend) {
$period = get_string('periodend', 'enrol', userdate($ue->timeend));
$periodoutside = $ue->timeend && $now > $ue->timeend;
} else {
// If there is no start or end show when user was enrolled.
$period = get_string('periodnone', 'enrol', userdate($ue->timecreated));
$periodoutside = false;
}
}
}
}
$details['enrolments'][$ue->id] = array('text' => $ue->enrolmentinstancename, 'period' => $period, 'dimmed' => $periodoutside or $ue->status != ENROL_USER_ACTIVE or $ue->enrolmentinstance->status != ENROL_INSTANCE_ENABLED, 'actions' => $ue->enrolmentplugin->get_user_enrolment_actions($manager, $ue));
}
$userdetails[$user->id] = $details;
}
return $userdetails;
}
示例5: get_users_for_display
/**
* Gets an array of users for display, this includes minimal user information
* as well as minimal information on the users roles, groups, and enrolments.
*
* @param core_enrol_renderer $renderer
* @param moodle_url $pageurl
* @param int $sort
* @param string $direction ASC or DESC
* @param int $page
* @param int $perpage
* @return array
*/
public function get_users_for_display(course_enrolment_manager $manager, $sort, $direction, $page, $perpage)
{
$pageurl = $manager->get_moodlepage()->url;
$users = $this->get_users($sort, $direction, $page, $perpage);
$now = time();
$strnever = get_string('never');
$straddgroup = get_string('addgroup', 'group');
$strunenrol = get_string('unenrol', 'enrol');
$stredit = get_string('edit');
$allroles = $this->get_all_roles();
$assignable = $this->get_assignable_roles();
$allgroups = $this->get_all_groups();
$courseid = $this->get_course()->id;
$context = $this->get_context();
$canmanagegroups = has_capability('moodle/course:managegroups', $context);
$url = new moodle_url($pageurl, $this->get_url_params());
$extrafields = get_extra_user_fields($context);
$userdetails = array();
foreach ($users as $user) {
$details = array('userid' => $user->id, 'courseid' => $courseid, 'picture' => new user_picture($user), 'firstname' => fullname($user, true), 'lastseen' => $strnever, 'roles' => array(), 'groups' => array(), 'enrolments' => array());
foreach ($extrafields as $field) {
$details[$field] = $user->{$field};
}
if ($user->lastaccess) {
$details['lastseen'] = format_time($now - $user->lastaccess);
}
// Roles
foreach ($this->get_user_roles($user->id) as $rid => $rassignable) {
$details['roles'][$rid] = array('text' => $allroles[$rid]->localname, 'unchangeable' => !$rassignable || !isset($assignable[$rid]));
}
// Users
$usergroups = $this->get_user_groups($user->id);
foreach ($usergroups as $gid => $unused) {
$details['groups'][$gid] = $allgroups[$gid]->name;
}
// Enrolments
foreach ($this->get_user_enrolments($user->id) as $ue) {
if ($ue->timestart and $ue->timeend) {
$period = get_string('periodstartend', 'enrol', array('start' => userdate($ue->timestart), 'end' => userdate($ue->timeend)));
$periodoutside = $ue->timestart && $ue->timeend && $now < $ue->timestart && $now > $ue->timeend;
} else {
if ($ue->timestart) {
$period = get_string('periodstart', 'enrol', userdate($ue->timestart));
$periodoutside = $ue->timestart && $now < $ue->timestart;
} else {
if ($ue->timeend) {
$period = get_string('periodend', 'enrol', userdate($ue->timeend));
$periodoutside = $ue->timeend && $now > $ue->timeend;
} else {
$period = '';
$periodoutside = false;
}
}
}
$details['enrolments'][$ue->id] = array('text' => $ue->enrolmentinstancename, 'period' => $period, 'dimmed' => $periodoutside || $ue->status != ENROL_USER_ACTIVE, 'actions' => $ue->enrolmentplugin->get_user_enrolment_actions($manager, $ue));
}
$userdetails[$user->id] = $details;
}
return $userdetails;
}