Can create accounts with school or fx permission in addition to those with
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 22 Sep 2010 07:53:11 +0000 (09:53 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 22 Sep 2010 07:53:11 +0000 (09:53 +0200)
ax permission in admin/accounts.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/admin.php
templates/admin/accounts.tpl

index 04d17b8..e0c5d04 100644 (file)
@@ -1151,9 +1151,10 @@ class AdminModule extends PLModule
             S::assert_xsrf_token();
             $firstname = Post::t('firstname');
             $lastname = strtoupper(Post::t('lastname'));
-            $sex = Post::b('sex') ? User::GENDER_FEMALE : User::GENDER_FEMALE;
+            $sex = Post::b('sex') ? User::GENDER_FEMALE : User::GENDER_MALE;
             $email = Post::t('email');
-            $login = PlUser::makeHrid($firstname, $lastname, 'ax');
+            $type = Post::s('type');
+            $login = PlUser::makeHrid($firstname, $lastname, $type);
             if (!isvalid_email($email)) {
                 $page->trigError("Invalid email address: $email");
             } else if (strlen(Post::s('pwhash')) != 40) {
@@ -1164,14 +1165,14 @@ class AdminModule extends PLModule
                 XDB::execute("INSERT INTO  accounts (hruid, type, state, password,
                                                      registration_date, email, full_name,
                                                      display_name, sex, directory_name)
-                                   VALUES  ({?}, 'ax', 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})",
-                             $login, Post::s('pwhash'), $email, $full_name, $full_name, $sex,
+                                   VALUES  ({?}, {?}, 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})",
+                             $login, $type, Post::s('pwhash'), $email, $full_name, $full_name, $sex,
                              $directory_name);
             }
         }
 
-        $uf = new UserFilter(new UFC_AccountType('ax'));
-        $page->assign('users', $uf->iterUsers(new PlLimit(10)));
+        $uf = new UserFilter(new UFC_AccountType('ax', 'school', 'fx'));
+        $page->assign('users', $uf->iterUsers());
 
     }
 
index 5488d05..a61bc3b 100644 (file)
@@ -71,6 +71,16 @@ function add_user_to_url(f) {
       {xsrf_token_field}
       <table style="width: 75%; margin-left: auto; margin-right: auto">
         <tr>
+          <td class="titre">Type de compte</td>
+          <td>
+            <select name="type">
+              <option value="ax">Personnel de l'AX</option>
+              <option value="fx">Personnel de la FS</option>
+              <option value="school">Personnel de l'Ecole</option>
+            </select>
+          </td>
+        </tr>
+        <tr>
           <td class="titre">Nom</td>
           <td><input type="text" name="firstname" size=60 maxlength="255" value="" /></td>
         </tr>