Merge remote branch 'origin/xorg/maint' into xorg/master
authorStéphane Jacob <sj@m4x.org>
Tue, 19 Apr 2011 14:56:48 +0000 (16:56 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 19 Apr 2011 14:56:48 +0000 (16:56 +0200)
1  2 
modules/admin.php

diff --combined modules/admin.php
@@@ -444,33 -444,20 +444,33 @@@ class AdminModule extends PLModul
          }
  
          // Account Form {{{
 +        require_once 'emails.inc.php';
          $to_update = array();
          if (Post::has('disable_weak_access')) {
              $to_update['weak_password'] = null;
          } else if (Post::has('update_account')) {
              if (!$user->hasProfile()) {
 -                if (Post::s('full_name') != $user->fullName()) {
 -                    $to_update['full_name'] = Post::s('full_name');
 +                $name_update = false;
 +                if (Post::s('lastname') != $user->lastname) {
 +                    $to_update['lastname'] = Post::s('lastname');
 +                    $name_update = true;
 +                }
 +                if (Post::s('type') != 'virtual' && Post::s('firstname') != $user->firstname) {
 +                    $to_update['firstname'] = Post::s('firstname');
 +                    $name_update = true;
 +                }
 +                if ($name_update) {
 +                    if (Post::s('type') != 'virtual') {
 +                        $to_update['full_name'] = Post::s('firstname') . ' ' . Post::s('lastname');
 +                        $to_update['directory_name'] = mb_strtoupper(Post::s('lastname')) . ' ' . Post::s('firstname');
 +                    } else {
 +                        $to_update['full_name'] = Post::s('lastname');
 +                        $to_update['directory_name'] = mb_strtoupper(Post::s('lastname'));
 +                    }
                  }
                  if (Post::s('display_name') != $user->displayName()) {
                      $to_update['display_name'] = Post::s('display_name');
                  }
 -                if (Post::s('directory_name') != $user->directoryName()) {
 -                    $to_update['directory_name'] = Post::s('directory_name');
 -                }
              }
              if (Post::s('sex') != ($user->isFemale() ? 'female' : 'male')) {
                  $to_update['sex'] = Post::s('sex');
              if (Post::t('comment') != $user->comment) {
                  $to_update['comment'] = Post::blank('comment') ? null : Post::t('comment');
              }
 -            if (!$user->checkPerms(User::PERM_MAIL) && Post::t('email') != $user->forlifeEmail()) {
 +            if (require_email_update($user, Post::t('email'))) {
                  $to_update['email'] = Post::t('email');
                  $listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
 +                update_alias_user($user->forlifeEmail(), Post::t('email'));
              }
          }
          if (!empty($to_update)) {
          // }}}
  
          // Email forwards form {{{
 -        require_once("emails.inc.php");
          $redirect = ($registered ? new Redirect($user) : null);
          if (Post::has('add_fwd')) {
              $email = Post::t('email');
                      $grad_year = $promotion;
                      $entry_year = $promotion - 3;
                      $promo = 'D (en cours)';
-                     $hrpromo = $promo;
+                     $hrpromo = 'D' . $promotion;
                      $type = 'phd';
                      break;
                    default:
                              XDB::execute('INSERT INTO  profile_education (id, pid, eduid, degreeid, entry_year, grad_year, flags)
                                                 VALUES  (100, {?}, {?}, {?}, {?}, {?}, \'primary\')',
                                           $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year);
 -                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
 -                                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
 -                                         $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $infos[1], $sex);
 +                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name,
 +                                                                 display_name, lastname, firstname, sex)
 +                                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
 +                                         $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName,
 +                                         $infos[1], $infos[0], $infos[1], $sex);
                              $uid = XDB::insertId();
                              XDB::execute('INSERT INTO  account_profiles (uid, pid, perms)
                                                 VALUES  ({?}, {?}, {?})',
                          if (!is_null($sex)) {
                              $fullName = $infos[1] . ' ' . $infos[0];
                              $directoryName = $infos[0] . ' ' . $infos[1];
 -                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state,
 -                                                                 email, full_name, directory_name,
 -                                                                 display_name, sex)
 -                                               VALUES  ({?}, {?}, {?}, {?},
 -                                                        {?}, {?}, {?}, {?}, {?})',
 -                                         $infos['hrid'], $type, 0, 'pending',
 -                                         $infos[2], $fullName, $directoryName, 
 -                                         $infos[1], $sex);
 +                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, email, full_name, directory_name,
 +                                                                 display_name, lastname, firstname, sex)
 +                                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
 +                                         $infos['hrid'], $type, 0, 'pending', $infos[2], $fullName, $directoryName,
 +                                         $infos[1], $infos[0], $infos[1], $sex);
                              $newAccounts[$infos['hrid']] = $infos[1] . ' ' . $infos[0];
                          }
                      }
          if (Post::has('create_account')) {
              S::assert_xsrf_token();
              $firstname = Post::t('firstname');
 -            $lastname = strtoupper(Post::t('lastname'));
 +            $lastname = mb_strtoupper(Post::t('lastname'));
              $sex = Post::s('sex');
              $email = Post::t('email');
              $type = Post::s('type');
                  $directory_name = $lastname . ' ' . $firstname;
                  XDB::execute("INSERT INTO  accounts (hruid, type, state, password,
                                                       registration_date, email, full_name,
 -                                                     display_name, sex, directory_name)
 -                                   VALUES  ({?}, {?}, 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})",
 +                                                     display_name, sex, directory_name,
 +                                                     lastname, firstname)
 +                                   VALUES  ({?}, {?}, 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})",
                               $login, $type, Post::s('pwhash'), $email, $full_name, $full_name, $sex,
 -                             $directory_name);
 +                             $directory_name, $lastname, $firstname);
              }
          }