Adds possibility for an Xnet animator to give a password to a xnet account.
authorStéphane Jacob <sj@m4x.org>
Thu, 5 Aug 2010 15:21:02 +0000 (17:21 +0200)
committerStéphane Jacob <sj@m4x.org>
Sat, 7 Aug 2010 17:31:39 +0000 (19:31 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/xnetpage.php
modules/xnetgrp.php
templates/xnetgrp/membres-edit.tpl

index 2a63e16..a50e1d7 100644 (file)
@@ -43,6 +43,8 @@ class XnetPage extends PlPage
         }
         $this->addJsLink('jquery.js');
         $this->addJsLink('overlib.js');
+        $this->addJsLink('secure_hash.js');
+        $this->addJsLink('sha1.js');
         $this->addJsLink('wiki.js');
         $this->addJsLink('xorg.js');
         $this->setTitle('Les associations polytechniciennes');
index 12585a6..7c7afc3 100644 (file)
@@ -894,6 +894,13 @@ class XnetGrpModule extends PLModule
                            Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
                            (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'),
                            (Post::t('type') == 'xnet') ? 'xnet' : 'virtual', $user->id());
+                // If user is of type xnet and new password is given.
+                if (!Post::blank('pwhash') && Post::t('type') == 'xnet') {
+                    XDB::query('UPDATE  accounts
+                                   SET  password = {?}
+                                 WHERE  uid = {?}',
+                               Post::t('pwhash'), $user->id());
+                }
             } else if (!$user->perms) {
                 XDB::query('UPDATE  accounts
                                SET  email = {?}
@@ -980,6 +987,7 @@ class XnetGrpModule extends PLModule
             }
         }
 
+        $page->addJsLink('password.js');
         $page->assign('user', $user);
         $page->assign('listes', $mmlist->get_lists($user->forlifeEmail()));
         $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true));
index aafe431..6a4192a 100644 (file)
@@ -28,6 +28,7 @@
       document.getElementById('prenom').style.display = state;
       document.getElementById('sexe').style.display = state;
       document.getElementById('make_X').style.display = state;
+      document.getElementById('password').style.display = state;
   }
 
   function showXInput(box)
       </td>
     </tr>
     {if $user->type eq 'xnet'}
+    <tr class="impair" id="password">
+      <td class="titre">Mot de passe&nbsp;:</td>
+      <td>
+        <div style="float: left">
+          <input type="text" name="new_plain_password" size="10" maxlength="256" value="********" />
+          <input type="hidden" name="pwhash" value="" />
+        </div>
+        <div style="float: left; margin-top: 5px;">
+          {checkpasswd prompt="new_plain_password" submit="dummy_none"}
+        </div>
+      </td>
+    </tr>
     <tr id="make_X">
       <td colspan="2">
         <span id="make_X_cb">
 
   <div class="center">
     <br />
-    <input type="submit" name='change' value="Valider ces changements" />
+    <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('new_plain_password', false, false);" />
     &nbsp;
     <input type="reset" value="Annuler ces changements" />
-  </div>                                                                      
+  </div>
 
 </form>