本文整理汇总了PHP中webservice::get_active_tokens方法的典型用法代码示例。如果您正苦于以下问题:PHP webservice::get_active_tokens方法的具体用法?PHP webservice::get_active_tokens怎么用?PHP webservice::get_active_tokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webservice
的用法示例。
在下文中一共展示了webservice::get_active_tokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $USER, $CFG;
$mform = $this->_form;
$mform->setDisableShortforms(true);
$mform->addElement('header', 'changepassword', get_string('changepassword'), '');
// visible elements
$mform->addElement('static', 'username', get_string('username'), $USER->username);
$policies = array();
if (!empty($CFG->passwordpolicy)) {
$policies[] = print_password_policy();
}
if (!empty($CFG->passwordreuselimit) and $CFG->passwordreuselimit > 0) {
$policies[] = get_string('informminpasswordreuselimit', 'auth', $CFG->passwordreuselimit);
}
if ($policies) {
$mform->addElement('static', 'passwordpolicyinfo', '', implode('<br />', $policies));
}
$mform->addElement('password', 'password', get_string('oldpassword'));
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$mform->addElement('password', 'newpassword1', get_string('newpassword'));
$mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword1', PARAM_RAW);
$mform->addElement('password', 'newpassword2', get_string('newpassword') . ' (' . get_String('again') . ')');
$mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword2', PARAM_RAW);
if (empty($CFG->passwordchangetokendeletion) and !empty(webservice::get_active_tokens($USER->id))) {
$mform->addElement('advcheckbox', 'signoutofotherservices', get_string('signoutofotherservices'));
$mform->addHelpButton('signoutofotherservices', 'signoutofotherservices');
$mform->setDefault('signoutofotherservices', 1);
}
// hidden optional params
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
// buttons
if (get_user_preferences('auth_forcepasswordchange')) {
$this->add_action_buttons(false);
} else {
$this->add_action_buttons(true);
}
}
示例2: definition
/**
* Define the form.
*/
public function definition()
{
global $USER, $CFG, $COURSE;
$mform = $this->_form;
$editoroptions = null;
$filemanageroptions = null;
if (!is_array($this->_customdata)) {
throw new coding_exception('invalid custom data for user_edit_form');
}
$editoroptions = $this->_customdata['editoroptions'];
$filemanageroptions = $this->_customdata['filemanageroptions'];
$user = $this->_customdata['user'];
$userid = $user->id;
// Accessibility: "Required" is bad legend text.
$strgeneral = get_string('general');
$strrequired = get_string('required');
// Add some extra hidden fields.
$mform->addElement('hidden', 'id');
$mform->setType('id', core_user::get_property_type('id'));
$mform->addElement('hidden', 'course', $COURSE->id);
$mform->setType('course', PARAM_INT);
// Print the required moodle fields first.
$mform->addElement('header', 'moodle', $strgeneral);
$auths = core_component::get_plugin_list('auth');
$enabled = get_string('pluginenabled', 'core_plugin');
$disabled = get_string('plugindisabled', 'core_plugin');
$authoptions = array($enabled => array(), $disabled => array());
$cannotchangepass = array();
$cannotchangeusername = array();
foreach ($auths as $auth => $unused) {
$authinst = get_auth_plugin($auth);
if (!$authinst->is_internal()) {
$cannotchangeusername[] = $auth;
}
$passwordurl = $authinst->change_password_url();
if (!($authinst->can_change_password() && empty($passwordurl))) {
if ($userid < 1 and $authinst->is_internal()) {
// This is unlikely but we can not create account without password
// when plugin uses passwords, we need to set it initially at least.
} else {
$cannotchangepass[] = $auth;
}
}
if (is_enabled_auth($auth)) {
$authoptions[$enabled][$auth] = get_string('pluginname', "auth_{$auth}");
} else {
$authoptions[$disabled][$auth] = get_string('pluginname', "auth_{$auth}");
}
}
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
$mform->addHelpButton('username', 'username', 'auth');
$mform->setType('username', PARAM_RAW);
if ($userid !== -1) {
$mform->disabledIf('username', 'auth', 'in', $cannotchangeusername);
}
$mform->addElement('selectgroups', 'auth', get_string('chooseauthmethod', 'auth'), $authoptions);
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
$mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
$mform->addHelpButton('suspended', 'suspended', 'auth');
$mform->addElement('checkbox', 'createpassword', get_string('createpassword', 'auth'));
$mform->disabledIf('createpassword', 'auth', 'in', $cannotchangepass);
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
$mform->addHelpButton('newpassword', 'newpassword');
$mform->setType('newpassword', core_user::get_property_type('password'));
$mform->disabledIf('newpassword', 'createpassword', 'checked');
$mform->disabledIf('newpassword', 'auth', 'in', $cannotchangepass);
// Check if the user has active external tokens.
if ($userid and empty($CFG->passwordchangetokendeletion)) {
if ($tokens = webservice::get_active_tokens($userid)) {
$services = '';
foreach ($tokens as $token) {
$services .= format_string($token->servicename) . ',';
}
$services = get_string('userservices', 'webservice', rtrim($services, ','));
$mform->addElement('advcheckbox', 'signoutofotherservices', get_string('signoutofotherservices'), $services);
$mform->addHelpButton('signoutofotherservices', 'signoutofotherservices');
$mform->disabledIf('signoutofotherservices', 'newpassword', 'eq', '');
$mform->setDefault('signoutofotherservices', 1);
}
}
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
$mform->disabledIf('preference_auth_forcepasswordchange', 'createpassword', 'checked');
// Shared fields.
useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user);
// Next the customisable profile fields.
profile_definition($mform, $userid);
if ($userid == -1) {
$btnstring = get_string('createuser');
} else {
$btnstring = get_string('updatemyprofile');
}
$this->add_action_buttons(false, $btnstring);
$this->set_data($user);
//.........这里部分代码省略.........