X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fgoogleapps.php;h=7b6360474c58d19fd5898754a870512613509487;hb=8752950c30a84d2971e84677be17052bc412191f;hp=0a22f86cbdd7a1e5eb1b2478a662b37d654cd62e;hpb=805f3d1679a53bb04fff34619c171a1381068612;p=platal.git diff --git a/modules/googleapps.php b/modules/googleapps.php index 0a22f86..7b63604 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -1,6 +1,6 @@ addJsLink('motdepasse.js'); $page->setTitle('Compte Google Apps'); - $account = new GoogleAppsAccount(S::user()); + $user = S::user(); + $account = new GoogleAppsAccount($user); // Fills up the 'is Google Apps redirection active' variable. $page->assign('redirect_active', false); $page->assign('redirect_unique', true); if ($account->active()) { - $redirect = new Redirect(S::user()); + $redirect = new Redirect($user); $page->assign('redirect_unique', !$redirect->other_active('googleapps')); - $storage = new EmailStorage(S::v('uid'), 'googleapps'); + $storage = new EmailStorage($user, 'googleapps'); $page->assign('redirect_active', $storage->active); } // Updates the Google Apps account as required. if ($action) { - if ($action == 'password') { - if ($subaction == 'sync') { + if ($action == 'password' && Post::has('pwsync')) { + S::assert_xsrf_token(); + if (Post::v('pwsync') == 'sync') { $account->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()) { @@ -179,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'); @@ -193,13 +194,27 @@ class GoogleAppsModule extends PLModule if ($user) { $account = new GoogleAppsAccount($user); - $storage = new EmailStorage($user->id(), 'googleapps'); + $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.