0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
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 UsageReq |
23 | |
24 | class UsageReq extends Validate |
25 | { |
26 | // {{{ properties |
27 | |
28 | var $unique = true; |
29 | |
30 | var $nom_usage; |
31 | var $alias = ''; |
32 | |
33 | var $oldusage; |
34 | var $oldalias; |
35 | |
36 | var $homonyme; |
21e9114c |
37 | var $reason; |
0337d704 |
38 | |
39 | var $rules = "Refuser |
40 | tout ce qui n'est visiblement pas un nom de famille (ce qui est |
41 | extremement rare car à peu près n'importe quoi peut être un nom de |
42 | famille...)"; |
43 | |
44 | // }}} |
45 | // {{{ constructor |
46 | |
21e9114c |
47 | function UsageReq($_uid, $_usage, $_reason) |
0337d704 |
48 | { |
0337d704 |
49 | $this->Validate($_uid, true, 'usage'); |
50 | $this->nom_usage = $_usage; |
21e9114c |
51 | $this->reason = $_reason; |
0337d704 |
52 | $this->alias = make_username($this->prenom, $this->nom_usage); |
53 | if (!$this->nom_usage) $this->alias = ""; |
54 | |
08cce2ff |
55 | $res = XDB::query(" |
0337d704 |
56 | SELECT e.alias, u.nom_usage, a.id |
57 | FROM auth_user_md5 as u |
58 | LEFT JOIN aliases as e ON(e.type='alias' AND FIND_IN_SET('usage',e.flags) AND e.id = u.user_id) |
59 | LEFT JOIN aliases as a ON(a.alias = {?} AND a.id != u.user_id) |
60 | WHERE u.user_id = {?}", $this->alias, $this->uid); |
61 | list($this->oldalias, $this->oldusage, $this->homonyme) = $res->fetchOneRow(); |
62 | } |
63 | |
64 | // }}} |
0337d704 |
65 | // {{{ function formu() |
66 | |
67 | function formu() |
68 | { return 'include/form.valid.nomusage.tpl'; } |
69 | |
70 | // }}} |
71 | // {{{ function _mail_subj() |
72 | |
73 | function _mail_subj() |
74 | { |
75 | return "[Polytechnique.org/USAGE] Changement de nom d'usage"; |
76 | } |
77 | |
78 | // }}} |
79 | // {{{ function _mail_body |
80 | |
81 | function _mail_body($isok) |
82 | { |
83 | global $globals; |
84 | if ($isok) { |
85 | $res = " La demande de changement de nom d'usage que tu as demandée vient d'être effectuée."; |
86 | if ($this->oldalias) { |
87 | $res .= "\n\n Les alias {$this->oldalias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés."; |
88 | } |
89 | if ($nom_usage) { |
90 | $res .= "\n\n Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !"; |
91 | } |
92 | return $res; |
93 | } else { |
94 | return " La demande de changement de nom d'usage que tu avais faite a été refusée."; |
95 | } |
96 | } |
97 | |
98 | // }}} |
99 | // {{{ function commit() |
100 | |
101 | function commit() |
102 | { |
74c55fd6 |
103 | require_once('user.func.inc.php'); |
0337d704 |
104 | set_new_usage($this->uid, $this->nom_usage, $this->alias); |
105 | return true; |
106 | } |
107 | |
108 | // }}} |
109 | } |
110 | // }}} |
111 | |
112 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
113 | ?> |