Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-26992 fix broken upload users templates

  • Loading branch information...
commit 43070e6193fca66f034b8e0b3fdf325e34a47067 1 parent 92a387b
@skodak skodak authored
Showing with 46 additions and 20 deletions.
  1. +17 −6 admin/uploaduser.php
  2. +29 −14 admin/uploaduserlib.php
View
23 admin/uploaduser.php
@@ -307,6 +307,9 @@
// process templates
$user->$field = uu_process_template($formdata->$field, $user);
$formdefaults[$field] = true;
+ if (in_array($field, $upt->columns)) {
+ $upt->track($field, s($user->$field), 'normal');
+ }
}
}
foreach ($PRF_FIELDS as $field) {
@@ -614,7 +617,13 @@
$isinternalauth = $auth->is_internal();
- if ($DB->record_exists('user', array('email'=>$user->email))) {
+ if (empty($user->email)) {
+ $upt->track('email', get_string('invalidemail'), 'error');
+ $upt->track('status', $strusernotaddederror, 'error');
+ $userserrors++;
+ continue;
+
+ } else if ($DB->record_exists('user', array('email'=>$user->email))) {
if ($noemailduplicates) {
$upt->track('email', $stremailduplicate, 'error');
$upt->track('status', $strusernotaddederror, 'error');
@@ -898,11 +907,13 @@
$rowcols['status'][] = get_string('missingusername');
}
- if (!validate_email($rowcols['email'])) {
- $rowcols['status'][] = get_string('invalidemail');
- }
- if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
- $rowcols['status'][] = $stremailduplicate;
+ if (isset($rowcols['email'])) {
+ if (!validate_email($rowcols['email'])) {
+ $rowcols['status'][] = get_string('invalidemail');
+ }
+ if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
+ $rowcols['status'][] = $stremailduplicate;
+ }
}
$rowcols['status'] = implode('<br />', $rowcols['status']);
$data[] = $rowcols;
View
43 admin/uploaduserlib.php
@@ -248,33 +248,48 @@ function uu_process_template($template, $user) {
if (is_null($result)) {
return $template; //error during regex processing??
+ }
+
+ if (is_array($template)) {
+ $template['text'] = $result;
+ return $t;
} else {
- if (array($template)) {
- $template['text'] = $t;
- return $t;
- } else {
- return $t;
- }
+ return $result;
}
}
/**
* Internal callback function.
*/
-function uu_process_template_callback($block, $username, $firstname, $lastname) {
+function uu_process_template_callback($username, $firstname, $lastname, $block) {
$textlib = textlib_get_instance();
- $repl = $block[0];
switch ($block[3]) {
- case 'u': $repl = $username; break;
- case 'f': $repl = $firstname; break;
- case 'l': $repl = $lastname; break;
+ case 'u':
+ $repl = $username;
+ break;
+ case 'f':
+ $repl = $firstname;
+ break;
+ case 'l':
+ $repl = $lastname;
+ break;
+ default:
+ return $block[0];
}
+
switch ($block[1]) {
- case '+': $repl = $textlib->strtoupper($repl); break;
- case '-': $repl = $textlib->strtolower($repl); break;
- case '~': $repl = $textlib->strtotitle($repl); break;
+ case '+':
+ $repl = $textlib->strtoupper($repl);
+ break;
+ case '-':
+ $repl = $textlib->strtolower($repl);
+ break;
+ case '~':
+ $repl = $textlib->strtotitle($repl);
+ break;
}
+
if (!empty($block[2])) {
$repl = $textlib->substr($repl, 0 , $block[2]);
}
Please sign in to comment.
Something went wrong with that request. Please try again.