From: Vincent Zanotti Date: Fri, 10 Apr 2009 15:28:41 +0000 (+0200) Subject: Implements administrator actions on Google Apps accounts (password synchronization... X-Git-Tag: xorg/0.10.1~114 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=bf88be24007cb338b2d1be518e8ba65c929a010a;hp=fc6f30c08948b5a94e8a6e6b90d3f47e54ca9488;p=platal.git Implements administrator actions on Google Apps accounts (password synchronization, status change). Signed-off-by: Vincent Zanotti --- diff --git a/modules/googleapps.php b/modules/googleapps.php index 1419e22..7b63604 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -180,7 +180,7 @@ class GoogleAppsModule extends PLModule } } - function handler_admin_user(&$page, $user = null, $action = null) { + function handler_admin_user(&$page, $user = null) { require_once("emails.inc.php"); require_once("googleapps.inc.php"); $page->changeTpl('googleapps/admin.user.tpl'); @@ -196,11 +196,25 @@ class GoogleAppsModule extends PLModule $account = new GoogleAppsAccount($user); $storage = new EmailStorage($user, 'googleapps'); - // Force synchronization of plat/al and Google Apps passwords. - if ($action == 'forcesync' && $account->sync_password) { + // Apply requested actions. + if (Post::has('suspend') && $account->active() && !$account->pending_update_suspension) { + S::assert_xsrf_token(); + $account->suspend(); + $page->trigSuccess('Le compte est en cours de suspension.'); + } else if (Post::has('unsuspend') && $account->suspended() && !$account->pending_update_suspension) { + S::assert_xsrf_token(); + $account->do_unsuspend(); + $page->trigSuccess('Le compte est en cours de réactivation.'); + } else if (Post::has('forcesync') && $account->active() && $account->sync_password) { + $res = XDB::query("SELECT password FROM auth_user_md5 WHERE user_id = {?}", $user->id()); + $account->set_password($res->fetchOneCell()); + $page->trigSuccess('Le mot de passe est en cours de synchronisation.'); + } else if (Post::has('sync') && $account->active()) { $res = XDB::query("SELECT password FROM auth_user_md5 WHERE user_id = {?}", $user->id()); $account->set_password($res->fetchOneCell()); - $page->trigSuccess('Le mot de passe a été synchronisé.'); + $account->set_password_sync(true); + } else if (Post::has('nosync') && $account->active()) { + $account->set_password_sync(false); } // Displays basic account information. diff --git a/templates/googleapps/admin.user.tpl b/templates/googleapps/admin.user.tpl index 8d553f4..1663dbf 100644 --- a/templates/googleapps/admin.user.tpl +++ b/templates/googleapps/admin.user.tpl @@ -22,7 +22,7 @@

Compte Google Apps

-{if $account} +{if $account && $account->provisioned()} {assign var=a value=$account} @@ -53,11 +53,7 @@ {/if} - + @@ -77,6 +73,50 @@
Mots de passes synchronisés - {if $a->sync_password} - oui (lancer une synchronisation) - {else}non{/if} - {if $a->sync_password}oui{else}non{/if}
Redirection des emails{if $googleapps_storage}activée{else}désactivee{/if}

+
+ {xsrf_token_field} + + + + + + + + + + + + + + + + + + + + +
Actions sur le compte
Statut du compte
  + {if $a->pending_update_suspension} +
Le statut du compte est en cours de changement. Aucune opération n'est possible.
+ {elseif $a->active()} + + {elseif $a->suspended()} + + {/if} +
Mot de passe
  + {if !$a->active()} +
Aucune opération n'est possible sur un compte inactif.
+ {elseif $a->pending_update_password} +
Le mot de passe du compte est en cours de changement. Aucune opération n'est possible.
+ {elseif $a->sync_password} + + + {else} + + {/if} +

+
+ @@ -96,6 +136,8 @@ {/iterate}
Requêtes en attente
+{elseif $account} +

Cet utilisateur n'a pas de compte Google Apps.

{else}

Aucun utilisateur n'a été trouvé.

{/if}