Support admin: links.
[platal.git] / modules / googleapps.php
index e75ce5c..dd3e97e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -29,19 +29,18 @@ class GoogleAppsModule extends PLModule
         }
 
         return array(
-            'googleapps'            => $this->make_hook('index',      AUTH_MDP),
+            'googleapps'            => $this->make_hook('index',      AUTH_MDP, 'mail'),
             '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)
+    function handler_index($page, $action = null)
     {
         require_once("emails.inc.php");
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/index.tpl');
-        $page->addJsLink('motdepasse.js');
         $page->setTitle('Compte Google Apps');
 
         $user = S::user();
@@ -69,9 +68,9 @@ class GoogleAppsModule extends PLModule
                 } else {
                     $account->set_password_sync(false);
                 }
-            } elseif ($action == 'password' && Post::has('response2') && !$account->sync_password) {
+            } elseif ($action == 'password' && Post::has('pwhash') && Post::t('pwhash') && !$account->sync_password) {
                 S::assert_xsrf_token();
-                $account->set_password(Post::v('response2'));
+                $account->set_password(Post::t('pwhash'));
             }
 
             if ($action == 'suspend' && Post::has('suspend') && $account->active()) {
@@ -102,9 +101,9 @@ class GoogleAppsModule extends PLModule
                 $password_sync = Post::b('password_sync');
                 $redirect_mails = Post::b('redirect_mails');
                 if ($password_sync) {
-                    $password = S::v('password');
+                    $password = $user->password();
                 } else {
-                    $password = Post::v('response2');
+                    $password = Post::t('pwhash');
                 }
 
                 $account->create($password_sync, $password, $redirect_mails);
@@ -115,7 +114,7 @@ class GoogleAppsModule extends PLModule
         $page->assign('account', $account);
     }
 
-    function handler_admin(&$page, $action = null) {
+    function handler_admin($page, $action = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.tpl');
         $page->setTitle('Administration Google Apps');
@@ -161,7 +160,7 @@ class GoogleAppsModule extends PLModule
         $page->assign('failed_requests', $res);
     }
 
-    function handler_admin_job(&$page, $job = null) {
+    function handler_admin_job($page, $job = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.job.tpl');
         $page->setTitle('Administration Google Apps');
@@ -180,7 +179,7 @@ class GoogleAppsModule extends PLModule
         }
     }
 
-    function handler_admin_user(&$page, $user = null) {
+    function handler_admin_user($page, $user = null) {
         require_once("emails.inc.php");
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.user.tpl');