Simplifies some of the GoogleApps hooks by using new "account" idioms.
authorVincent Zanotti <vincent.zanotti@m4x.org>
Sat, 11 Apr 2009 01:16:19 +0000 (03:16 +0200)
committerVincent Zanotti <vincent.zanotti@m4x.org>
Sat, 11 Apr 2009 01:16:19 +0000 (03:16 +0200)
Cleans up a bit the admin/user page, and adds a few TODOs.

Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
include/googleapps.inc.php
modules/admin.php
templates/admin/utilisateurs.tpl

index d107e5e..b90a749 100644 (file)
@@ -339,17 +339,7 @@ class GoogleAppsAccount
 
         if (!$this->pending_update_suspension) {
             if ($this->sync_password) {
-                $res = XDB::query(
-                    "SELECT  password
-                       FROM  accounts
-                      WHERE  uid = {?}", $this->user->id());
-                $password = ($res->numRows() > 0 ? $res->fetchOneCell() : false);
-            } else {
-                $password = false;
-            }
-
-            if ($password) {
-                $this->create_queue_job('u_update', array('suspended' => false, 'password' => $password));
+                $this->create_queue_job('u_update', array('suspended' => false, 'password' => $this->user->password()));
             } else {
                 $this->create_queue_job('u_update', array('suspended' => false));
             }
index ace6288..82344c7 100644 (file)
@@ -419,6 +419,11 @@ class AdminModule extends PLModule
             }
             if (!Post::blank('hashpass')) {
                 $to_update['password'] = Post::s('hashpass');
+                // TODO: Propagate the password update to GoogleApps, when required. Eg:
+                // $account = new GoogleAppsAccount($user);
+                // if ($account->active() && $account->sync_password) {
+                //     $account->set_password($pass_encrypted);
+                // }
             }
             if (!Post::blank('weak_password')) {
                 $to_update['weak_password'] = Post::s('weak_password');
@@ -450,6 +455,8 @@ class AdminModule extends PLModule
             }
         }
         if (!empty($to_update)) {
+            // TODO: fetch the initial values of the fields, and eventually send
+            // a summary of the changes to an admin.
             $set = array();
             foreach ($to_update as $k => $value) {
                 $set[] = XDB::format($k . ' = {?}', $value);
@@ -615,7 +622,6 @@ class AdminModule extends PLModule
             $page->assign('emails', $redirect->emails);
         }
 
-        $page->assign('mr', $mr);
         $page->assign('user', $user);
 
         // Displays forum bans.
index 9440b00..cf0beb8 100644 (file)
@@ -86,11 +86,13 @@ $(document).ready(function() {
 {/literal}
 
 <div id="tabs">
-<ul>
-  <li><a href="{$platal->pl_self()}#account"><span >Compte</span></a></li>
-  <li><a href="{$platal->pl_self()}#emails"><span>Emails</span></a></li>
-  <li><a href="{$platal->pl_self()}#forums"><span>Forums</span></a></li>
-</ul>
+  Compte de {$user->login()}.
+  <ul style="margin-top: 0">
+    <li><a href="{$platal->pl_self()}#account"><span >Compte</span></a></li>
+    <li><a href="{$platal->pl_self()}#emails"><span>Emails</span></a></li>
+    <li><a href="{$platal->pl_self()}#forums"><span>Forums</span></a></li>
+  </ul>
+</div>
 
 <div id="account">
 <form id="auth" method="post" action="admin/user/{$user->login()}#account">
@@ -101,7 +103,7 @@ $(document).ready(function() {
     depuis <strong>{$host}</strong>.
   </p>
 
-  <table class="tinybicol">
+  <table class="bicol">
     <tr>
       <th colspan="2">
         <div style="float: right; text-align: right">
@@ -215,19 +217,22 @@ $(document).ready(function() {
         <input type="text" name="comment" size="40" maxlength="64" value="{$user->comment}" />
       </td>
     </tr>
+    <tr class="impair">
+      <td colspan="2" class="center">
+        {* TODO: on 'update_account', update the hashpass field before sending the form. *}
+        <input type="submit" name="update_account" value="Mettre à jour" />
+        <input type="submit" name="su_account" value="Prendre l'identité" />
+        <input type="submit" name="log_account" value="Consulter les logs" />
+      </td>
+    </tr>
   </table>
-  <div class="center">
-    <input type="submit" name="update_account" value="Mettre à jour" /><br />
-    <input type="submit" name="su_account" value="Prendre l'identité" />
-    <input type="submit" name="log_account" value="Consulter les logs" />
-  </div>
 </form>
 
 <h1>Fiches associées au compte</h1>
 
 <form id="profiles" method="post" action="admin/user/{$user->login()}#account">
   {xsrf_token_field}
-  <table class="tinybicol">
+  <table class="bicol">
     <tr>
       <th></th>
       <th>Identifiant de la fiche</th>
@@ -394,11 +399,11 @@ Pour ceci changer ses permissions en 'disabled'.
 -->
 
 <div id="emails">
-<h1>Gestion de l'adresse X.org {$user->login()}</h1>
+<h1>Gestion de l'adresse X.org</h1>
 
 <form id="alias" method="post" action="admin/user/{$user->login()}#emails">
   {xsrf_token_field}
-  <table class="tinybicol" cellpadding="2" cellspacing="0">
+  <table class="bicol" cellpadding="2" cellspacing="0">
     <tr>
       <th class="alias" colspan="3">
         Alias email de l'utilisateur
@@ -474,7 +479,7 @@ Pour ceci changer ses permissions en 'disabled'.
       </td>
       <td>
         {if $mail->broken}<span style="color: #f00">{/if}
-        {if $mail->email == 'googleapps'}<a href="admin/googleapps/user/{$mr.hruid}">{/if}
+        {if $mail->email == 'googleapps'}<a href="admin/googleapps/user/{$user->login()}">{/if}
         {$mail->display_email}
         {if $mail->email == 'googleapps'}</a>{/if}
         {if $mail->broken}<em> (en panne)</em></span>{/if}
@@ -533,7 +538,7 @@ Pour ceci changer ses permissions en 'disabled'.
 
 <h1>Autres adresses de l'utilisateur</h1>
 
-<table class="tinybicol">
+<table class="bicol">
   <th>Virtual aliases auquel l'utilisateur appartient</th>
   {foreach from=$virtuals item=virtual}
   <tr class="{cycle values="impair,pair"}">
@@ -546,11 +551,11 @@ Pour ceci changer ses permissions en 'disabled'.
 
 <div id="forums">
 
-<h1>Gestion de l'accès au forums de {$user->login()}</h1>
+<h1>Gestion de l'accès au forums</h1>
 
 <form id="bans" method="post" action="admin/user/{$user->login()}#forums">
   {xsrf_token_field}
-  <table cellspacing="0" cellpadding="2" class="tinybicol">
+  <table class="bicol">
     <tr>
       <th colspan="4">
         Permissions sur les forums