X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fgoogleapps.php;h=7b6360474c58d19fd5898754a870512613509487;hb=8752950c30a84d2971e84677be17052bc412191f;hp=0d868c751d719ddcfb49bd3ca0a47fcd50bb49d0;hpb=a0c034efcf0777541e087500e94853f515cda1ca;p=platal.git diff --git a/modules/googleapps.php b/modules/googleapps.php index 0d868c7..7b63604 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -1,6 +1,6 @@ set_password_sync(true); $account->set_password(S::v('password')); - pl_redirect('googleapps#password'); - } else if ($subaction == 'nosync') { + } else { $account->set_password_sync(false); - } else if (Post::has('response2') && !$account->sync_password) { - S::assert_xsrf_token(); - $account->set_password(Post::v('response2')); } + } elseif ($action == 'password' && Post::has('response2') && !$account->sync_password) { + S::assert_xsrf_token(); + $account->set_password(Post::v('response2')); } if ($action == 'suspend' && Post::has('suspend') && $account->active()) { @@ -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.