X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fgoogleapps.php;h=246396626c9bea97ecb65e76c63b226da85e35fc;hb=06f4daf9ceb56712582d81330896848a1a262894;hp=de3d6681ce3718e105f604ddc91d6799f8f9ee73;hpb=2db80ab6f7d054ec274c66f7ba983f49596b81cf;p=platal.git diff --git a/modules/googleapps.php b/modules/googleapps.php index de3d668..2463966 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -1,6 +1,6 @@ $this->make_hook('index', AUTH_MDP), - 'admin/googleapps' => $this->make_hook('admin', AUTH_MDP. 'admin'), - 'admin/googleapps/job' => $this->make_hook('admin_job', AUTH_MDP, 'admin'), + 'googleapps' => $this->make_hook('index', AUTH_MDP), + 'admin/googleapps' => $this->make_hook('admin', AUTH_MDP, 'admin'), + 'admin/googleapps/job' => $this->make_hook('admin_job', AUTH_MDP, 'admin'), 'admin/googleapps/user' => $this->make_hook('admin_user', AUTH_MDP, 'admin'), ); } - function handler_index(&$page, $action = null, $subaction = null) + function handler_index(&$page, $action = null) { require_once("emails.inc.php"); require_once("googleapps.inc.php"); @@ -61,17 +61,17 @@ class GoogleAppsModule extends PLModule // 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()) { @@ -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,10 +196,23 @@ 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) { + $account->set_password($user->password()); + $page->trigSuccess('Le mot de passe est en cours de synchronisation.'); + } else if (Post::has('sync') && $account->active()) { $account->set_password($user->password()); - $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.