Typo.
[platal.git] / modules / admin.php
index 4d58460..92a6493 100644 (file)
@@ -433,13 +433,13 @@ class AdminModule extends PLModule
                                  Post::s('sex'), $user->profile()->id());
                 }
             }
-            if (!Post::blank('hashpass')) {
-                $to_update['password'] = Post::s('hashpass');
-                // TODO: Propagate the password update to GoogleApps, when required. Eg:
-                // $account = new GoogleAppsAccount($user);
-                // if ($account->active() && $account->sync_password) {
-                //     $account->set_password($pass_encrypted);
-                // }
+            if (!Post::blank('pwhash')) {
+                $to_update['password'] = Post::s('pwhash');
+                require_once 'googleapps.inc.php';
+                $account = new GoogleAppsAccount($user);
+                if ($account->active() && $account->sync_password) {
+                    $account->set_password(Post::s('pwhash'));
+                }
             }
             if (!Post::blank('weak_password')) {
                 $to_update['weak_password'] = Post::s('weak_password');
@@ -640,6 +640,7 @@ class AdminModule extends PLModule
 
         $page->addJsLink('jquery.ui.core.js');
         $page->addJsLink('jquery.ui.tabs.js');
+        $page->addJsLink('password.js');
 
         // Displays last login and last host information.
         $res = XDB::query("SELECT  start, host
@@ -778,7 +779,8 @@ class AdminModule extends PLModule
                     if ($infos = self::formatNewUser($page, $line, $separator, $promotion, 6)) {
                         $sex = self::formatSex($page, $infos[3], $line);
                         if (!is_null($sex)) {
-                            $name = $infos[1] . ' ' . $infos[0];
+                            $fullName = $infos[1] . ' ' . $infos[0];
+                            $directoryName = $infos[0] . ' ' . $infos[1];
                             $birthDate = self::formatBirthDate($infos[2]);
                             $xorgId = Profile::getXorgId($infos[4]);
                             if (is_null($xorgId)) {
@@ -799,13 +801,13 @@ class AdminModule extends PLModule
                             XDB::execute('INSERT INTO  profile_display (pid, yourself, public_name, private_name,
                                                                         directory_name, short_name, sort_name, promo)
                                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
-                                         $pid, $infos[1], $name, $name, $name, $name, $infos[0] . ' ' . $infos[1], $promo);
+                                         $pid, $infos[1], $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo);
                             XDB::execute('INSERT INTO  profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
                                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?})',
                                          $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
-                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, display_name, sex)
+                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
                                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
-                                         $infos['hrid'], $type, 0, 'active', $name, $infos[1], $sex);
+                                         $infos['hrid'], $type, 0, 'active', $fullName, $directoryName, $infos[1], $sex);
                             $uid = XDB::insertId();
                             XDB::execute('INSERT INTO  account_profiles (uid, pid, perms)
                                                VALUES  ({?}, {?}, {?})',
@@ -820,9 +822,11 @@ class AdminModule extends PLModule
                     if ($infos = self::formatNewUser($page, $line, $separator, $type, 4)) {
                         $sex = self::formatSex($page, $infos[3], $line);
                         if (!is_null($sex)) {
-                            XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, email, full_name, display_name, 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, 'active', $infos[2], $infos[1] . ' ' . $infos[0], $infos[1], $sex);
+                                         $infos['hrid'], $type, 0, 'active', $infos[2], $fullName, $directoryName, $infos[1], $sex);
                             $newAccounts[$infos['hrid']] = $infos[1] . ' ' . $infos[0];
                         }
                     }
@@ -946,15 +950,19 @@ class AdminModule extends PLModule
                                   WHERE  pd.promo = {?}', $promo);
             while (list($pid, $name, $death) = $res->next()) {
                 $val = Env::v('death_' . $pid);
-                if($val == $death || empty($val)) {
+                if ($val == $death) {
                     continue;
                 }
 
+                if (empty($val)) {
+                    $val = null;
+                }
                 XDB::execute('UPDATE  profiles
                                  SET  deathdate = {?}, deathdate_rec = NOW()
                                WHERE  pid = {?}', $val, $pid);
-                $page->trigSuccess('Ajout du décès de ' . $name . ' le ' . $val . '.');
-                if($death == '0000-00-00' || empty($death)) {
+
+                $page->trigSuccess('Édition du décès de ' . $name . ' (' . ($val ? $val : 'ressuscité') . ').');
+                if ($val && ($death == '0000-00-00' || empty($death))) {
                     $profile = Profile::get($pid);
                     $profile->clear();
                     $profile->owner()->clear(false);
@@ -967,7 +975,7 @@ class AdminModule extends PLModule
                           INNER JOIN  profile_display AS pd ON (p.pid = pd.pid)
                                WHERE  pd.promo = {?}
                             ORDER BY  pd.sort_name', $promo);
-        $page->assign('decedes', $res);
+        $page->assign('profileList', $res);
     }
 
     function handler_dead_but_active(&$page)
@@ -1137,7 +1145,7 @@ class AdminModule extends PLModule
     {
         if (S::hasAuthToken()) {
            $page->setRssLink('Changement Récents',
-                             '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::v('token'));
+                             '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::user()->token);
         }
 
         // update wiki perms