本文整理汇总了PHP中enrol_plugin类的典型用法代码示例。如果您正苦于以下问题:PHP enrol_plugin类的具体用法?PHP enrol_plugin怎么用?PHP enrol_plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了enrol_plugin类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: col_edit
/**
* Generate the edit column.
*
* @param \stdClass $tool event data.
* @return string
*/
public function col_edit($tool)
{
global $OUTPUT;
$buttons = array();
$instance = new \stdClass();
$instance->id = $tool->enrolid;
$instance->courseid = $tool->courseid;
$instance->enrol = 'lti';
$instance->status = $tool->status;
$strdelete = get_string('delete');
$strenable = get_string('enable');
$strdisable = get_string('disable');
$url = new \moodle_url('/enrol/lti/index.php', array('sesskey' => sesskey(), 'courseid' => $this->courseid));
if ($this->ltiplugin->can_delete_instance($instance)) {
$aurl = new \moodle_url($url, array('action' => 'delete', 'instanceid' => $instance->id));
$buttons[] = $OUTPUT->action_icon($aurl, new \pix_icon('t/delete', $strdelete, 'core', array('class' => 'iconsmall')));
}
if ($this->ltienabled && $this->ltiplugin->can_hide_show_instance($instance)) {
if ($instance->status == ENROL_INSTANCE_ENABLED) {
$aurl = new \moodle_url($url, array('action' => 'disable', 'instanceid' => $instance->id));
$buttons[] = $OUTPUT->action_icon($aurl, new \pix_icon('t/hide', $strdisable, 'core', array('class' => 'iconsmall')));
} else {
if ($instance->status == ENROL_INSTANCE_DISABLED) {
$aurl = new \moodle_url($url, array('action' => 'enable', 'instanceid' => $instance->id));
$buttons[] = $OUTPUT->action_icon($aurl, new \pix_icon('t/show', $strenable, 'core', array('class' => 'iconsmall')));
}
}
}
if ($this->ltienabled && $this->canconfig) {
$linkparams = array('courseid' => $instance->courseid, 'id' => $instance->id, 'type' => $instance->enrol, 'returnurl' => new \moodle_url('/enrol/lti/index.php', array('courseid' => $this->courseid)));
$editlink = new \moodle_url("/enrol/editinstance.php", $linkparams);
$buttons[] = $OUTPUT->action_icon($editlink, new \pix_icon('t/edit', get_string('edit'), 'core', array('class' => 'iconsmall')));
}
return implode(' ', $buttons);
}
示例2: update_instance
/**
* Update instance of enrol plugin.
* @param stdClass $instance
* @param stdClass $data modified instance fields
* @return boolean
*/
public function update_instance($instance, $data)
{
// In the form we are representing 2 db columns with one field.
if ($data->expirynotify == 2) {
$data->expirynotify = 1;
$data->notifyall = 1;
} else {
$data->notifyall = 0;
}
// Keep previous/default value of disabled expirythreshold option.
if (!$data->expirynotify) {
$data->expirythreshold = $instance->expirythreshold;
}
// Add previous value of newenrols if disabled.
if (!isset($data->customint6)) {
$data->customint6 = $instance->customint6;
}
return parent::update_instance($instance, $data);
}
示例3: get_enroller
/**
* Returns the user who is responsible for manual enrolments in given instance.
*
* Usually it is the first editing teacher - the person with "highest authority"
* as defined by sort_by_roleassignment_authority() having 'enrol/manual:manage'
* capability.
*
* @param int $instanceid enrolment instance id
* @return stdClass user record
*/
protected function get_enroller($instanceid)
{
global $DB;
if ($this->lasternollerinstanceid == $instanceid and $this->lasternoller) {
return $this->lasternoller;
}
$instance = $DB->get_record('enrol', array('id' => $instanceid, 'enrol' => $this->get_name()), '*', MUST_EXIST);
$context = context_course::instance($instance->courseid);
if ($users = get_enrolled_users($context, 'enrol/manual:manage')) {
$users = sort_by_roleassignment_authority($users, $context);
$this->lasternoller = reset($users);
unset($users);
} else {
$this->lasternoller = parent::get_enroller($instanceid);
}
$this->lasternollerinstanceid = $instanceid;
return $this->lasternoller;
}
示例4: update_status
/**
* Update instance status
*
* @param stdClass $instance
* @param int $newstatus ENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED
* @return void
*/
public function update_status($instance, $newstatus)
{
global $CFG;
parent::update_status($instance, $newstatus);
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $instance->courseid);
$trace->finished();
}
示例5: add_instance
/**
* Add new instance of enrol plugin.
* @param object $course
* @param array instance fields
* @return int id of new instance, null if can not be created
*/
public function add_instance($course, array $fields = NULL)
{
global $DB;
if ($DB->record_exists('enrol', array('courseid' => $course->id, 'enrol' => 'saml'))) {
// only one instance allowed, sorry
return NULL;
}
return parent::add_instance($course, $fields);
}
示例6: add_instance
/**
* Add new instance of enrol plugin.
* @param object $course
* @param array instance fields
* @return int id of new instance, null if can not be created
*/
public function add_instance($course, array $fields = NULL)
{
$fields = (array) $fields;
if (!isset($fields['password'])) {
$fields['password'] = '';
}
return parent::add_instance($course, $fields);
}
示例7: update_status
/**
* Update instance status
*
* @param stdClass $instance
* @param int $newstatus ENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED
* @return void
*/
public function update_status($instance, $newstatus)
{
global $CFG;
parent::update_status($instance, $newstatus);
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
enrol_cohort_sync($instance->courseid);
}
示例8: enrol_user
/**
* Enrol user into course via enrol instance.
*
* @param stdClass $instance
* @param int $userid
* @param int $roleid optional role id
* @param int $timestart 0 means unknown
* @param int $timeend 0 means forever
* @param int $status default to ENROL_USER_ACTIVE for new enrolments, no change by default in updates
* @param bool $recovergrades restore grade history
* @return void
*/
public function enrol_user(stdClass $instance, $userid, $roleid = null, $timestart = 0, $timeend = 0, $status = null, $recovergrades = null)
{
parent::enrol_user($instance, $userid, null, $timestart, $timeend, $status, $recovergrades);
if ($roleid) {
$context = context_course::instance($instance->courseid, MUST_EXIST);
role_assign($roleid, $userid, $context->id, 'enrol_' . $this->get_name(), $instance->id);
}
}
示例9: restore_instance
/**
* Restore instance and map settings.
*
* @param restore_enrolments_structure_step $step
* @param stdClass $data
* @param stdClass $course
* @param int $oldid
*/
public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid)
{
// We want to call the parent because we do not want to add an enrol_lti_tools row
// as that is done as part of the restore process.
$instanceid = parent::add_instance($course, (array) $data);
$step->set_mapping('enrol', $oldid, $instanceid);
}
示例10: add_instance
/**
* Ensures existence instance of enrol plugin.
*
* @param object $course
* @param array $fields
* @return int Id of instance, null if can not be created.
*/
public function add_instance($course, array $fields = null)
{
global $DB;
if ($result = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'invitation'))) {
// Instance already exists, so just give id.
return $result->id;
}
return parent::add_instance($course, $fields);
}
示例11: delete_instance
/**
* Intercepts the instance deletion call and gives some
* custom instructions before resuming the parent function
*/
public function delete_instance($instance)
{
global $DB;
if ($this->get_config('removegroups')) {
require_once "../group/lib.php";
$groups = $DB->get_records_sql("SELECT * FROM {groups} WHERE " . $DB->sql_like('idnumber', ':idnumber'), array('idnumber' => "autoenrol|{$instance->id}|%"));
foreach ($groups as $group) {
groups_delete_group($group);
}
}
parent::delete_instance($instance);
}
示例12: add_instance
/**
* Add new instance of enrol plugin.
* @param object $course
* @param array instance fields
* @return int id of new instance, null if can not be created
*/
public function add_instance($course, array $fields = null)
{
global $DB;
if ($DB->record_exists('enrol', array('courseid' => $course->id, 'enrol' => 'restxml'))) {
return null;
}
return parent::add_instance($course, $fields);
}