Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-25027_stable_consistency_fix_m22' of git://github.c…

…om/nebgor/moodle into MOODLE_22_STABLE
  • Loading branch information...
commit 313f98c88a72d6a37eb34dbfde6dbabe3c820b47 2 parents 2e0d059 + d45c949
@stronk7 stronk7 authored
Showing with 11 additions and 8 deletions.
  1. +11 −8 user/externallib.php
View
19 user/externallib.php
@@ -86,6 +86,7 @@ public static function create_users_parameters() {
*/
public static function create_users($users) {
global $CFG, $DB;
+ require_once($CFG->dirroot."/lib/weblib.php");
require_once($CFG->dirroot."/user/lib.php");
require_once($CFG->dirroot."/user/profile/lib.php"); //required for customfields related function
//TODO: move the functions somewhere else as
@@ -134,18 +135,20 @@ public static function create_users($users) {
throw new invalid_parameter_exception('Invalid theme: '.$user['theme']);
}
- // make sure there is no data loss during truncation
- $truncated = truncate_userinfo($user);
- foreach ($truncated as $key=>$value) {
- if ($truncated[$key] !== $user[$key]) {
- throw new invalid_parameter_exception('Property: '.$key.' is too long: '.$user[$key]);
- }
- }
-
$user['confirmed'] = true;
$user['mnethostid'] = $CFG->mnet_localhost_id;
$user['id'] = user_create_user($user);
+ // Start of user info validation.
+ // Lets make sure we validate current user info as handled by current GUI. see user/editadvanced_form.php function validation()
+ if (!validate_email($user['email'])) {
+ throw new invalid_parameter_exception('Email address is invalid: '.$user['email']);
+ } else if ($DB->record_exists('user', array('email'=>$user['email'], 'mnethostid'=>$user['mnethostid']))) {
+ throw new invalid_parameter_exception('Email address already exists: '.$user['email']);
+ }
+ // End of user info validation.
+
+
// custom fields
if(!empty($user['customfields'])) {
foreach($user['customfields'] as $customfield) {
Please sign in to comment.
Something went wrong with that request. Please try again.