bug 324 admin du nom d'usage
authorPascal Corpet <pascal.corpet@m4x.org>
Tue, 28 Jun 2005 06:31:30 +0000 (06:31 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:29:27 +0000 (23:29 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-755

ChangeLog
htdocs/admin/utilisateurs.php
include/nomusage.inc.php [new file with mode: 0644]
include/validations/nomusage.inc.php
templates/admin/utilisateurs.tpl

index c0e7b1a..16c9477 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ Bug/Wish :
 
        * Admin :
                - #323: admin link in fiche opens out of the popup.                                     -Car
+               - #324: admin can modify the usage name.                                                        -Car
 
        * Profile :
                - User can delete his own melix.                                                                        -Car
index ce3117f..07f0946 100644 (file)
@@ -138,6 +138,10 @@ if ($login) {
 
                     $page->trig("updaté correctement.");
                 }
+                if (Env::get('nomusageN') != $mr['nom_usage']) {
+                    require_once('nomusage.inc.php');
+                    set_new_usage($mr['user_id'], Env::get('nomusageN'), make_username(Env::get('prenomN'), Env::get('nomusageN')));
+                }
                $r  = $globals->xdb->query("SELECT  *, a.alias AS forlife
                                               FROM  auth_user_md5 AS u
                                         INNER JOIN  aliases       AS a ON (u.user_id=a.id)
diff --git a/include/nomusage.inc.php b/include/nomusage.inc.php
new file mode 100644 (file)
index 0000000..a82d637
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+function set_new_usage($uid, $usage, $alias=false) { 
+    global $globals;
+
+    $globals->xdb->execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$usage ,$uid);
+    $globals->xdb->execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $uid);
+    if ($alias && $usage) {
+        $globals->xdb->execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $uid);
+        $globals->xdb->execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)",
+            $alias, $uid);
+    }
+    $r = $globals->xdb->query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $uid);
+    if ($r->fetchOneCell() == "") {
+        $globals->xdb->execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $uid);
+    }
+    require_once 'user.func.inc.php';
+    user_reindex($uid);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index e0b5a30..ef6662f 100644 (file)
@@ -107,21 +107,8 @@ class UsageReq extends Validate
 
     function commit()
     {
-        global $globals;
-
-        $globals->xdb->execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$this->nom_usage ,$this->uid);
-        $globals->xdb->execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $this->uid);
-        if ($this->alias) {
-            $globals->xdb->execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $this->uid);
-            $globals->xdb->execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)",
-                $this->alias, $this->uid);
-        }
-        $r = $globals->xdb->query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $this->uid);
-        if ($r->fetchOneCell() == "") {
-            $globals->xdb->execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $this->uid);
-        }
-        require_once 'user.func.inc.php';
-        user_reindex($this->uid);
+        require_once('nomusage.inc.php');
+        set_new_usage($this->uid, $this->nom_usage, $this->alias);
         return true;
     }
 
index 12a912e..fcbef9a 100644 (file)
@@ -133,6 +133,14 @@ function del_fwd(fwd) {
     </tr>
     <tr class="pair">
       <td class="titre">
+        Nom d'usage
+      </td>
+      <td>
+        <input type="text" name="nomusageN" size="20" maxlength="255" value="{$mr.nom_usage}" />
+      </td>
+    </tr>
+    <tr class="pair">
+      <td class="titre">
         Prénom
       </td>
       <td>