本文整理汇总了PHP中profile_definition_after_data函数的典型用法代码示例。如果您正苦于以下问题:PHP profile_definition_after_data函数的具体用法?PHP profile_definition_after_data怎么用?PHP profile_definition_after_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了profile_definition_after_data函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition_after_data
function definition_after_data()
{
global $CFG;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = get_record('user', 'id', $userid)) {
// remove description - this must be here because
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !record_exists('role_assignments', 'userid', $user->id)) {
if ($mform->elementExists('description')) {
$mform->removeElement('description');
}
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true));
} else {
$image_el->setValue(get_string('none'));
}
}
/// disable fields that are locked by auth plugins
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
}
}
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例2: definition_after_data
function definition_after_data()
{
global $USER, $CFG, $DB;
$mform =& $this->_form;
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id' => $userid));
} else {
$user = false;
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $userid);
}
示例3: definition_after_data
function definition_after_data()
{
global $USER, $CFG;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
$user = get_record('user', 'id', $userid);
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// admin must choose some password and supply correct email
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
$email_el =& $mform->getElement('email');
if ($email_el->getValue() == 'root@localhost') {
$email_el->setValue('');
}
}
// require password for new users
if ($userid == -1) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true));
} else {
$image_el->setValue(get_string('none'));
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform);
}
示例4: definition_after_data
/**
* Extend the form definition after the data has been parsed.
*/
public function definition_after_data()
{
global $CFG, $DB, $OUTPUT;
$mform = $this->_form;
$userid = $mform->getElementValue('id');
if ($user = $DB->get_record('user', array('id' => $userid))) {
// Remove description.
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description_editor');
}
// Print picture.
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
// Disable fields that are locked by auth plugins.
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
$customfields = $authplugin->get_custom_user_profile_fields();
$fields = array_merge($fields, $customfields);
foreach ($fields as $field) {
if ($field === 'description') {
// Hard coded hack for description field. See MDL-37704 for details.
$formfield = 'description_editor';
} else {
$formfield = $field;
}
if (!$mform->elementExists($formfield)) {
continue;
}
$value = $mform->getElementValue($formfield);
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $value);
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $value != '') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $value);
}
}
}
}
// Next the customisable profile fields.
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例5: definition_after_data
/**
* Extend the form definition after the data has been parsed.
*/
public function definition_after_data()
{
global $CFG, $DB, $OUTPUT;
$mform = $this->_form;
$userid = $mform->getElementValue('id');
// If language does not exist, use site default lang.
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// Check lang exists.
if (!get_string_manager()->translation_exists($lang, false)) {
$langel =& $mform->getElement('lang');
$langel->setValue($CFG->lang);
}
}
if ($user = $DB->get_record('user', array('id' => $userid))) {
// Remove description.
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description_editor');
}
// Print picture.
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
// Disable fields that are locked by auth plugins.
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
}
}
}
}
// Next the customisable profile fields.
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例6: definition_after_data
function definition_after_data() {
global $USER, $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id'=>$userid));
} else {
$user = false;
}
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// check lang exists
if (!get_string_manager()->translation_exists($lang, false)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// admin must choose some password and supply correct email
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
// require password for new users
if ($userid == -1) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
if ($user and is_mnet_remote_user($user)) {
// only local accounts can be suspended
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
if ($user and ($user->id == $USER->id or is_siteadmin($user))) {
// prevent self and admin mess ups
if ($mform->elementExists('suspended')) {
$mform->hardFreeze('suspended');
}
}
// print picture
if (!empty($CFG->gdversion) and empty($USER->newadminuser)) {
if ($user) {
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = ($fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg'));
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size'=>64));
} else {
$imagevalue = get_string('none');
}
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($user && $mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $userid);
}
示例7: definition_after_data
function definition_after_data()
{
global $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
if (strpos($lang, '_utf8') === false) {
$lang = $lang . '_utf8';
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($lang);
}
// check lang exists
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = $DB->get_record('user', array('id' => $userid))) {
// remove description
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$userpic = moodle_user_picture::make($user, SITEID);
$userpic->size = 64;
$image_el->setValue($OUTPUT->user_picture($userpic));
} else {
$image_el->setValue(get_string('none'));
}
}
/// disable fields that are locked by auth plugins
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
}
}
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例8: definition_after_data
/**
* Extend the form definition after data has been parsed.
*/
public function definition_after_data()
{
global $USER, $CFG, $DB, $OUTPUT;
$mform = $this->_form;
// Trim required name fields.
foreach (useredit_get_required_name_fields() as $field) {
$mform->applyFilter($field, 'trim');
}
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id' => $userid));
} else {
$user = false;
}
// User can not change own auth method.
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// Admin must choose some password and supply correct email.
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
// Require password for new users.
if ($userid > 0) {
if ($mform->elementExists('createpassword')) {
$mform->removeElement('createpassword');
}
}
if ($user and is_mnet_remote_user($user)) {
// Only local accounts can be suspended.
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
if ($user and ($user->id == $USER->id or is_siteadmin($user))) {
// Prevent self and admin mess ups.
if ($mform->elementExists('suspended')) {
$mform->hardFreeze('suspended');
}
}
// Print picture.
if (empty($USER->newadminuser)) {
if ($user) {
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
} else {
$imagevalue = get_string('none');
}
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($user && $mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
}
// Next the customisable profile fields.
profile_definition_after_data($mform, $userid);
}
示例9: definition_after_data
function definition_after_data()
{
global $USER, $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id' => $userid));
} else {
$user = false;
}
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// check lang exists
if (!get_string_manager()->translation_exists($lang, false)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// admin must choose some password and supply correct email
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// require password for new users
if ($userid == -1) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue($OUTPUT->user_picture($user, array('courseid' => SITEID)));
} else {
$image_el->setValue(get_string('none'));
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $userid);
}
示例10: definition_after_data
function definition_after_data()
{
global $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// check lang exists
if (!get_string_manager()->translation_exists($lang, false)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = $DB->get_record('user', array('id' => $userid))) {
// remove description
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description_editor');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue($OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64)));
} else {
$image_el->setValue(get_string('none'));
}
}
/// disable fields that are locked by auth plugins
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
}
}
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例11: definition_after_data
function definition_after_data()
{
global $USER, $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id' => $userid));
} else {
$user = false;
}
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
if (strpos($lang, '_utf8') === false) {
$lang = $lang . '_utf8';
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($lang);
}
// check lang exists
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// admin must choose some password and supply correct email
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// require password for new users
if ($userid == -1) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$userpic = moodle_user_picture::make($user, SITEID);
$userpic->alttext = true;
$image_el->setValue($OUTPUT->user_picture($userpic));
} else {
$image_el->setValue(get_string('none'));
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $userid);
}