Commit | Line | Data |
---|---|---|
cccf3cc0 SJ |
1 | <?php |
2 | /*************************************************************************** | |
9f5bd98e | 3 | * Copyright (C) 2003-2010 Polytechnique.org * |
cccf3cc0 SJ |
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 ReminderPromotionMl extends Reminder | |
23 | { | |
24 | public function HandleAction($action) | |
25 | { | |
5fb8451c | 26 | $user = S::user(); |
cccf3cc0 SJ |
27 | switch ($action) { |
28 | case 'yes': | |
29 | $res = XDB::query('SELECT id | |
eb41eda9 | 30 | FROM groups |
2d4a96e1 | 31 | WHERE diminutif = {?}', |
5fb8451c | 32 | $user->profile()->yearPromo()); |
cccf3cc0 | 33 | $asso_id = $res->fetchOneCell(); |
eb41eda9 | 34 | XDB::execute('REPLACE INTO group_members (uid, asso_id) |
cccf3cc0 | 35 | VALUES ({?}, {?})', |
5fb8451c FB |
36 | $user->id(), $asso_id); |
37 | $mmlist = new MMList($user); | |
38 | $mmlist->subscribe('promo' . $user->profile()->yearPromo()); | |
cccf3cc0 SJ |
39 | |
40 | $this->UpdateOnYes(); | |
41 | break; | |
42 | ||
43 | case 'dismiss': | |
44 | $this->UpdateOnDismiss(); | |
45 | break; | |
46 | ||
47 | case 'no': | |
48 | $this->UpdateOnNo(); | |
49 | break; | |
50 | } | |
51 | } | |
52 | ||
4b0cb388 | 53 | public function text() |
cccf3cc0 SJ |
54 | { |
55 | return "La liste de diffusion de ta promotion permet de recevoir les | |
56 | informations plus spécifiques de ta promotion pour pouvoir | |
57 | participer plus facilement aux événements qu'elle organise. Tu | |
58 | seras aussi inscrit dans le groupe de la promotion " . | |
4b0cb388 VZ |
59 | $this->user->promo() . '.'; |
60 | } | |
61 | public function title() | |
62 | { | |
63 | return "Inscription à la liste de diffusion de ta promotion"; | |
cccf3cc0 SJ |
64 | } |
65 | ||
0e4b87b2 | 66 | public static function IsCandidate(User &$user, $candidate) |
cccf3cc0 SJ |
67 | { |
68 | // We only test if the user is in her promotion group for it is too | |
69 | // expensive to check if she is in the corresponding ML as well. | |
70 | $res = XDB::query('SELECT COUNT(*) | |
eb41eda9 | 71 | FROM group_members |
cccf3cc0 | 72 | WHERE uid = {?} AND asso_id = (SELECT id |
eb41eda9 | 73 | FROM groups |
cccf3cc0 | 74 | WHERE diminutif = {?})', |
5fb8451c | 75 | $user->id(), $user->profile()->yearPromo()); |
700b1cf1 SJ |
76 | $mlCount = $res->fetchOneCell(); |
77 | if ($mlCount) { | |
78 | Reminder::MarkCandidateAsAccepted($user->id(), $candidate); | |
79 | } | |
4b0cb388 | 80 | return ($mlCount == 0); |
cccf3cc0 SJ |
81 | } |
82 | } | |
83 | ||
84 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
85 | ?> |