Removes an undefined variable warning in AdminModule.
[platal.git] / modules / admin.php
index 9c84011..458d5d6 100644 (file)
@@ -363,6 +363,7 @@ class AdminModule extends PLModule
         }
 
         // Loads the user identity using the environment.
+        $user = null;
         if ($login) {
             $user = User::get($login);
         } else if (Env::has('user_id')) {
@@ -572,12 +573,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 avoiding transmitting
+                        // 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';
 
-                        // Emails the admins to notify the profile update.
+                        // 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());
@@ -693,13 +694,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)
@@ -740,9 +742,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');