Commit | Line | Data |
---|---|---|
bb0727ea VZ |
1 | <?php |
2 | /*************************************************************************** | |
3 | * Copyright (C) 2003-2008 Polytechnique.org * | |
4 | * http://opensource.polytechnique.org/ * | |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class GoogleAppsUnsuspendReq extends Validate | |
23 | { | |
24 | private $account; | |
25 | public $rules = "Bien faire attention à la raison de la suspension. Si le compte a été suspendu par Google, | |
26 | alors la raison s'affichera (mais seulement 24-48h après la suspension). | |
27 | Si l'utilisateur a désactivé lui-même son compte, la raison sera toujours vierge."; | |
28 | ||
5daf68f6 | 29 | public function __construct(User $_user) |
bb0727ea | 30 | { |
5daf68f6 | 31 | parent::__construct($_user, true, 'gapps-unsuspend'); |
bb0727ea VZ |
32 | } |
33 | ||
34 | public function sendmail($isok) | |
35 | { | |
36 | // Using overloading to prevent the validation from sending emails, as a valid | |
37 | // unsuspend will automatically generate an email when commited through | |
38 | // the Google Apps provisioning API. | |
39 | if (!$isok) { | |
40 | parent::sendmail($isok); | |
41 | } | |
42 | } | |
43 | ||
44 | public function formu() | |
45 | { | |
46 | return 'include/form.valid.gapps-unsuspend.tpl'; | |
47 | } | |
48 | ||
49 | protected function _mail_subj() | |
50 | { | |
51 | return "[Polytechnique.org] Demande de réactivation de ton compte Google Apps"; | |
52 | } | |
53 | ||
54 | protected function _mail_body($isok) | |
55 | { | |
56 | if (!$isok) { | |
57 | return " La demande que tu avais faite de réactivation de compte Google Apps a été refusée."; | |
58 | } | |
59 | } | |
60 | ||
61 | public function commit() | |
62 | { | |
63 | require_once dirname(__FILE__) . '/../googleapps.inc.php'; | |
5daf68f6 | 64 | $account = new GoogleAppsAccount($this->user); |
bb0727ea VZ |
65 | return $account->do_unsuspend(); |
66 | } | |
67 | ||
68 | public function suspension_reason() | |
69 | { | |
70 | $res = XDB::query( | |
71 | "SELECT g_suspension | |
72 | FROM gapps_accounts | |
73 | WHERE g_account_name = {?}", | |
5daf68f6 | 74 | $this->user->login()); |
bb0727ea VZ |
75 | return $res->fetchOneCell(); |
76 | } | |
77 | } | |
78 | ||
79 | /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker enc=utf-8: */ | |
80 | ?> |