Merge commit 'origin/platal-0.10.0'
[platal.git] / modules / admin.php
index 152c65e..9b4e436 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -552,6 +552,10 @@ class AdminModule extends PLModule
                     // however suits our needs.
                     if ($perms == 'disabled' && $old_fields['perms'] != 'disabled') {
                         kill_sessions();
+
+                        // Also serve a reminder to the admin: disabling an account
+                        // does not deactivate email forwarding.
+                        $page->trigWarning("N'oubliez pas, le cas échéant, de désactiver les redirections et le compte GoogleApps de l'utilisateur.");
                     }
 
                     // Updates the user profile with the new values.
@@ -568,6 +572,12 @@ class AdminModule extends PLModule
                         user_reindex($user->id());
                         $new_fields = XDB::query($watch_query, $user->id())->fetchOneAssoc();
 
+                        // Redacts the password in the notification, to avoid transmitting
+                        // sensitive information by email.
+                        $new_fields['password'] = ($old_fields['password'] != $new_fields['password'] ? 'new' : 'old');
+                        $old_fields['password'] = 'old';
+
+                        // Notifies the admins of the profile update.
                         $mailer = new PlMailer("admin/useredit.mail.tpl");
                         $mailer->assign("admin", S::user()->login());
                         $mailer->assign("user", $user->login());
@@ -603,14 +613,6 @@ class AdminModule extends PLModule
                                 $account->set_password($pass_encrypted);
                             }
                         }
-
-                        // If the update did disable the user account, disables
-                        // the Google Apps account as well.
-                        if ($new_fields['perms'] == 'disabled' && $new_fields['perms'] != $old_fields['perms']) {
-                            require_once 'googleapps.inc.php';
-                            $account = new GoogleAppsAccount($user);
-                            $account->suspend();
-                        }
                     }
 
 
@@ -622,6 +624,7 @@ class AdminModule extends PLModule
 
                 // User re-registration.
                 case "u_kill":
+                    require_once('user.func.inc.php');
                     user_clear_all_subs($user->id());
                     $globals->updateNbIns();
                     $page->trigSuccess("'" . $user->id() . "' a été désinscrit !");
@@ -690,13 +693,14 @@ class AdminModule extends PLModule
         $page->assign('bans', $bans);
     }
 
-    function getHruid($line, $key)
+    function getHruid($line, $partial_result, $key)
     {
-        var_dump($line);
-        if (!isset($line['nom']) || !isset($line['prenom']) || !isset($line['promo'])) {
+        if (!isset($partial_result['nom']) ||
+            !isset($partial_result['prenom']) ||
+            !isset($partial_result['promo'])) {
             return null;
         }
-        return make_forlife($line['prenom'], $line['nom'], $line['promo']);
+        return make_forlife($partial_result['prenom'], $partial_result['nom'], $partial_result['promo']);
     }
 
     function getMatricule($line, $key)
@@ -737,9 +741,11 @@ class AdminModule extends PLModule
             $fields = array('hruid', 'nom', 'nom_ini', 'prenom', 'naissance_ini',
                             'prenom_ini', 'promo', 'promo_sortie', 'flags',
                             'matricule', 'matricule_ax', 'perms');
-            $importer->forceValue('hruid', array($this, 'getHruid'));
             $importer->forceValue('promo', $promo);
             $importer->forceValue('promo_sortie', $promo + 3);
+            // The hruid generation callback is set last, so that it is called once 'promo'
+            // has already been computed for that line.
+            $importer->forceValue('hruid', array($this, 'getHruid'));
             break;
           case 'ax':
             $fields = array('matricule', 'matricule_ax');