本文整理汇总了PHP中profile_validation函数的典型用法代码示例。如果您正苦于以下问题:PHP profile_validation函数的具体用法?PHP profile_validation怎么用?PHP profile_validation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了profile_validation函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
function validation($usernew, $files)
{
global $CFG, $DB;
$user = $DB->get_record('user', array('id' => $usernew['id']));
$err = array();
if (!empty($usernew)) {
$data = new stdClass();
foreach ($usernew as $akey => $aval) {
$data->{$akey} = $aval;
}
}
/// Next the customisable profile fields
$err += profile_validation($data, $files);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例2: validation
function validation($usernew, $files)
{
global $CFG, $DB;
$errors = parent::validation($usernew, $files);
$usernew = (object) $usernew;
$user = $DB->get_record('user', array('id' => $usernew->id));
// validate email
if (!isset($usernew->email)) {
// mail not confirmed yet
} else {
if (!validate_email($usernew->email)) {
$errors['email'] = get_string('invalidemail');
} else {
if ($usernew->email !== $user->email and $DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) {
$errors['email'] = get_string('emailexists');
}
}
}
if (isset($usernew->email) and $usernew->email === $user->email and over_bounce_threshold($user)) {
$errors['email'] = get_string('toomanybounces');
}
if (isset($usernew->email) and !empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) {
$errorstr = email_is_not_allowed($usernew->email);
if ($errorstr !== false) {
$errors['email'] = $errorstr;
}
}
/// Next the customisable profile fields
$errors += profile_validation($usernew, $files);
return $errors;
}
示例3: validation
function validation($usernew)
{
global $CFG;
$usernew = (object) $usernew;
$user = get_record('user', 'id', $usernew->id);
$err = array();
// validate email
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else {
if (stripslashes($usernew->email) !== $user->email and record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['email'] = get_string('emailexists');
}
}
if ($usernew->email === $user->email and over_bounce_threshold($user)) {
$err['email'] = get_string('toomanybounces');
}
/// Next the customisable profile fields
$err += profile_validation($usernew);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例4: validation
function validation($usernew, $files) {
global $CFG, $DB;
$usernew = (object)$usernew;
$usernew->username = trim($usernew->username);
$user = $DB->get_record('user', array('id'=>$usernew->id));
$err = array();
if (!empty($usernew->newpassword)) {
$errmsg = '';//prevent eclipse warning
if (!check_password_policy($usernew->newpassword, $errmsg)) {
$err['newpassword'] = $errmsg;
}
}
if (empty($usernew->username)) {
//might be only whitespace
$err['username'] = get_string('required');
} else if (!$user or $user->username !== $usernew->username) {
//check new username does not exist
if ($DB->record_exists('user', array('username'=>$usernew->username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
$err['username'] = get_string('usernameexists');
}
//check allowed characters
if ($usernew->username !== textlib::strtolower($usernew->username)) {
$err['username'] = get_string('usernamelowercase');
} else {
if ($usernew->username !== clean_param($usernew->username, PARAM_USERNAME)) {
$err['username'] = get_string('invalidusername');
}
}
}
if (!$user or $user->email !== $usernew->email) {
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else if ($DB->record_exists('user', array('email'=>$usernew->email, 'mnethostid'=>$CFG->mnet_localhost_id))) {
$err['email'] = get_string('emailexists');
}
}
/// Next the customisable profile fields
$err += profile_validation($usernew, $files);
if (count($err) == 0){
return true;
} else {
return $err;
}
}
示例5: validation
function validation($data, $files)
{
global $CFG, $DB;
$errors = parent::validation($data, $files);
$authplugin = get_auth_plugin($CFG->registerauth);
if ($DB->record_exists('user', array('username' => $data['username'], 'mnethostid' => $CFG->mnet_localhost_id))) {
$errors['username'] = get_string('usernameexists');
} else {
//check allowed characters
if ($data['username'] !== core_text::strtolower($data['username'])) {
$errors['username'] = get_string('usernamelowercase');
} else {
if ($data['username'] !== clean_param($data['username'], PARAM_USERNAME)) {
$errors['username'] = get_string('invalidusername');
}
}
}
//check if user exists in external db
//TODO: maybe we should check all enabled plugins instead
if ($authplugin->user_exists($data['username'])) {
$errors['username'] = get_string('usernameexists');
}
if (!validate_email($data['email'])) {
$errors['email'] = get_string('invalidemail');
} else {
if ($DB->record_exists('user', array('email' => $data['email']))) {
$errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>';
}
}
if (empty($data['email2'])) {
$errors['email2'] = get_string('missingemail');
} else {
if ($data['email2'] != $data['email']) {
$errors['email2'] = get_string('invalidemail');
}
}
if (!isset($errors['email'])) {
if ($err = email_is_not_allowed($data['email'])) {
$errors['email'] = $err;
}
}
$errmsg = '';
if (!check_password_policy($data['password'], $errmsg)) {
$errors['password'] = $errmsg;
}
if ($this->signup_captcha_enabled()) {
$recaptcha_element = $this->_form->getElement('recaptcha_element');
if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) {
$challenge_field = $this->_form->_submitValues['recaptcha_challenge_field'];
$response_field = $this->_form->_submitValues['recaptcha_response_field'];
if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) {
$errors['recaptcha'] = $result;
}
} else {
$errors['recaptcha'] = get_string('missingrecaptchachallengefield');
}
}
// Validate customisable profile fields. (profile_validation expects an object as the parameter with userid set)
$dataobject = (object) $data;
$dataobject->id = 0;
$errors += profile_validation($dataobject, $files);
return $errors;
}
示例6: validation
function validation($usernew, $files)
{
global $CFG;
$usernew = (object) $usernew;
$usernew->username = trim($usernew->username);
$user = get_record('user', 'id', $usernew->id);
$err = array();
if (!empty($usernew->newpassword)) {
$errmsg = '';
//prevent eclipse warning
if (!check_password_policy($usernew->newpassword, $errmsg)) {
$err['newpassword'] = $errmsg;
}
}
if (empty($usernew->username)) {
//might be only whitespace
$err['username'] = get_string('required');
} else {
if (!$user or $user->username !== stripslashes($usernew->username)) {
//check new username does not exist
if (record_exists('user', 'username', $usernew->username, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['username'] = get_string('usernameexists');
}
//check allowed characters
if ($usernew->username !== moodle_strtolower($usernew->username)) {
echo 'grrrr';
$err['username'] = get_string('usernamelowercase');
} else {
if (empty($CFG->extendedusernamechars)) {
$string = eregi_replace("[^(-\\.[:alnum:])]", '', $usernew->username);
if ($usernew->username !== $string) {
$err['username'] = get_string('alphanumerical');
}
}
}
}
}
if (!$user or $user->email !== stripslashes($usernew->email)) {
if (!validate_email(stripslashes($usernew->email))) {
$err['email'] = get_string('invalidemail');
} else {
if (record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['email'] = get_string('emailexists');
}
}
}
/// Next the customisable profile fields
$err += profile_validation($usernew, $files);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例7: validation
/**
* Validate the form data.
* @param array $usernew
* @param array $files
* @return array|bool
*/
public function validation($usernew, $files)
{
global $CFG, $DB;
$usernew = (object) $usernew;
$usernew->username = trim($usernew->username);
$user = $DB->get_record('user', array('id' => $usernew->id));
$err = array();
if (!$user and !empty($usernew->createpassword)) {
if ($usernew->suspended) {
// Show some error because we can not mail suspended users.
$err['suspended'] = get_string('error');
}
} else {
if (!empty($usernew->newpassword)) {
$errmsg = '';
// Prevent eclipse warning.
if (!check_password_policy($usernew->newpassword, $errmsg)) {
$err['newpassword'] = $errmsg;
}
} else {
if (!$user) {
$auth = get_auth_plugin($usernew->auth);
if ($auth->is_internal()) {
// Internal accounts require password!
$err['newpassword'] = get_string('required');
}
}
}
}
if (empty($usernew->username)) {
// Might be only whitespace.
$err['username'] = get_string('required');
} else {
if (!$user or $user->username !== $usernew->username) {
// Check new username does not exist.
if ($DB->record_exists('user', array('username' => $usernew->username, 'mnethostid' => $CFG->mnet_localhost_id))) {
$err['username'] = get_string('usernameexists');
}
// Check allowed characters.
if ($usernew->username !== core_text::strtolower($usernew->username)) {
$err['username'] = get_string('usernamelowercase');
} else {
if ($usernew->username !== clean_param($usernew->username, PARAM_USERNAME)) {
$err['username'] = get_string('invalidusername');
}
}
}
}
if (!$user or isset($usernew->email) && $user->email !== $usernew->email) {
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else {
if (empty($CFG->allowaccountssameemail) and $DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) {
$err['email'] = get_string('emailexists');
}
}
}
// Next the customisable profile fields.
$err += profile_validation($usernew, $files);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例8: validation
public function validation($usernew, $files)
{
global $CFG, $DB;
$usernew = (object) $usernew;
//$usernew->username = trim($usernew->username);
$user = $DB->get_record('user', array('id' => $usernew->id));
$err = array();
/* GWL : Phone no. validation For Moodle User Reg page */
if (!preg_match("/^[0-9]{10}\$/", $usernew->username)) {
$err['username'] = get_string('errorphonenum');
}
/* GWL : Phone no. validation For Moodle User Reg page */
if (!$user and !empty($usernew->createpassword)) {
if ($usernew->suspended) {
// Show some error because we can not mail suspended users.
$err['suspended'] = get_string('error');
}
} else {
if (!empty($usernew->newpassword)) {
$errmsg = '';
// Prevent eclipse warning.
if (!check_password_policy($usernew->newpassword, $errmsg)) {
$err['newpassword'] = $errmsg;
}
} else {
if (!$user) {
$auth = get_auth_plugin($usernew->auth);
if ($auth->is_internal()) {
// Internal accounts require password!
$err['newpassword'] = get_string('required');
}
}
}
}
// Code added by sumit
if ($usernew->managertype != 1 && $usernew->managertype != 3) {
//GWL : Add Instructor
if (empty($usernew->userregion)) {
$errors['userregion'] = get_string('selectregion', 'block_iomad_company_admin');
}
}
// End of code
if (empty($usernew->username)) {
// Might be only whitespace.
$err['username'] = get_string('required');
} else {
if (!$user or $user->username !== $usernew->username) {
// Check new username does not exist.
if ($DB->record_exists('user', array('username' => $usernew->username, 'mnethostid' => $CFG->mnet_localhost_id))) {
$err['username'] = get_string('phonenumexists');
//GWL : Change get_string('usernameexists') to 'phonenumexists'
}
/* GWL : For Phone No. Validation Remove Another Check for username */
/*
// Check allowed characters.
if ($usernew->username !== core_text::strtolower($usernew->username)) {
$err['username'] = get_string('usernamelowercase');
} else {
if ($usernew->username !== clean_param($usernew->username, PARAM_USERNAME)) {
$err['username'] = get_string('invalidusername');
}
}
*/
/* GWL : For Phone No. Validation Remove Another Check for username */
}
}
if (!$user or $user->email !== $usernew->email) {
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else {
if ($DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) {
$err['email'] = get_string('emailexists');
}
}
}
// Next the customisable profile fields.
$err += profile_validation($usernew, $files);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例9: validation
function validation($usernew, $files)
{
global $CFG;
$errors = parent::validation($usernew, $files);
$usernew = (object) $usernew;
$user = get_record('user', 'id', $usernew->id);
// validate email
if (!validate_email($usernew->email)) {
$errors['email'] = get_string('invalidemail');
} else {
if ($usernew->email !== $user->email and record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$errors['email'] = get_string('emailexists');
}
}
if ($usernew->email === $user->email and over_bounce_threshold($user)) {
$errors['email'] = get_string('toomanybounces');
}
/// Next the customisable profile fields
$errors += profile_validation($usernew, $files);
return $errors;
}
示例10: signup_validate_data
/**
* Validates the standard sign-up data (except recaptcha that is validated by the form element).
*
* @param array $data the sign-up data
* @param array $files files among the data
* @return array list of errors, being the key the data element name and the value the error itself
* @since Moodle 3.2
*/
function signup_validate_data($data, $files)
{
global $CFG, $DB;
$errors = array();
$authplugin = get_auth_plugin($CFG->registerauth);
if ($DB->record_exists('user', array('username' => $data['username'], 'mnethostid' => $CFG->mnet_localhost_id))) {
$errors['username'] = get_string('usernameexists');
} else {
// Check allowed characters.
if ($data['username'] !== core_text::strtolower($data['username'])) {
$errors['username'] = get_string('usernamelowercase');
} else {
if ($data['username'] !== core_user::clean_field($data['username'], 'username')) {
$errors['username'] = get_string('invalidusername');
}
}
}
// Check if user exists in external db.
// TODO: maybe we should check all enabled plugins instead.
if ($authplugin->user_exists($data['username'])) {
$errors['username'] = get_string('usernameexists');
}
if (!validate_email($data['email'])) {
$errors['email'] = get_string('invalidemail');
} else {
if ($DB->record_exists('user', array('email' => $data['email']))) {
$errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>';
}
}
if (empty($data['email2'])) {
$errors['email2'] = get_string('missingemail');
} else {
if ($data['email2'] != $data['email']) {
$errors['email2'] = get_string('invalidemail');
}
}
if (!isset($errors['email'])) {
if ($err = email_is_not_allowed($data['email'])) {
$errors['email'] = $err;
}
}
$errmsg = '';
if (!check_password_policy($data['password'], $errmsg)) {
$errors['password'] = $errmsg;
}
// Validate customisable profile fields. (profile_validation expects an object as the parameter with userid set).
$dataobject = (object) $data;
$dataobject->id = 0;
$errors += profile_validation($dataobject, $files);
return $errors;
}
示例11: validation
function validation($usernew, $files)
{
global $CFG;
$usernew = (object) $usernew;
$usernew->username = trim($usernew->username);
$user = get_record('user', 'id', $usernew->id);
$err = array();
if (!empty($usernew->newpassword)) {
$errmsg = '';
//prevent eclipse warning
if (!check_password_policy($usernew->newpassword, $errmsg)) {
$err['newpassword'] = $errmsg;
}
}
// Added by SMS 8/7/2011: To make sure the password does not include special
// characters that may result in issues when synching the password with vms
if (!isValidPassword($usernew->newpassword)) {
$err['newpassword'] .= 'Your password cannot contain the following characters: " / \\ [ ] : ; | = , + * ? < > @ & !';
}
if (empty($usernew->username)) {
//might be only whitespace
$err['username'] = get_string('required');
} else {
if (!$user or $user->username !== $usernew->username) {
//check new username does not exist
if (record_exists('user', 'username', $usernew->username, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['username'] = get_string('usernameexists');
}
//check allowed characters
if ($usernew->username !== moodle_strtolower($usernew->username)) {
$err['username'] = get_string('usernamelowercase');
} else {
if (empty($CFG->extendedusernamechars)) {
$string = eregi_replace("[^(-\\.[:alnum:])]", '', $usernew->username);
if ($usernew->username !== $string) {
$err['username'] = get_string('alphanumerical');
}
// Validates the username for Windows requirements - 22.05.2011 - jam
$oldusername = stripslashes($usernew->username);
if (!isValidUsername($usernew->username) || strcmp($usernew->username, $oldusername)) {
$err['username'] = 'Your username cannot contain the following characters: " / \\ [ ] : ; | = , + * ? < > @ and can only be 20 characters long.';
}
}
}
}
}
if (!$user or $user->email !== stripslashes($usernew->email)) {
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else {
if (record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['email'] = get_string('emailexists');
}
}
}
/// Next the customisable profile fields
$err += profile_validation($usernew, $files);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}