2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 // class AliasReq {{{1
23 class AliasReq
extends Validate
28 public $unique = true
;
31 public $public = 'private';
33 public $rules = "Interdire ce qui peut nous servir (virus@, postmaster@…),
34 les alias vulgaires, et les prenom.nom (sauf si c'est pour l'utilisateur prenom.nom).
35 Pas de contrainte pour les tirets ou les points, en revanche le souligné (_) est interdit.";
38 public function __construct(User
$_user, $_alias, $_reason, $_public, $_old, $_stamp = 0)
41 parent
::__construct($_user, true
, 'alias', $_stamp);
42 $this->alias
= $_alias;
43 $this->reason
= $_reason;
44 $this->public = $_public;
48 // function get_request() {{{2
49 static public function get_request($uid)
51 return parent
::get_typed_request($uid, 'alias');
54 // function formu() {{{2
55 public function formu()
57 return 'include/form.valid.aliases.tpl';
60 // function _mail_subj {{{2
61 protected function _mail_subj()
64 return "[Polytechnique.org/MELIX] Demande de l'alias {$this->alias}@{$globals->mail->alias_dom}";
67 // function _mail_body {{{2
68 protected function _mail_body($isok)
72 return " L'adresse email {$this->alias}@{$globals->mail->alias_dom} que tu avais demandée vient d'être créée, tu peux désormais l'utiliser à ta convenance."
73 . ($this->public == 'public' ?
' À ta demande, cette adresse apparaît maintenant sur ta fiche.' : '');
75 return " La demande que tu avais faite pour l'alias {$this->alias}@{$globals->mail->alias_dom} a été refusée.";
79 // function commit() {{{2
80 public function commit()
82 if ($this->user
->hasProfile()) {
83 XDB
::execute('UPDATE profiles
86 $this->public, $this->user
->profile()->id());
90 $success = XDB
::execute('UPDATE email_source_account
92 WHERE uid = {?} AND type = \'alias_aux\'',
93 $this->alias
, $this->user
->id());
95 $success = XDB
::execute('INSERT INTO email_source_account (email, uid, domain, type, flags)
96 SELECT {?}, {?}, id, \'alias_aux\', \'\'
97 FROM email_virtual_domains
99 $this->alias
, $this->user
->id(), Platal
::globals()->mail
->alias_dom
);
103 // Update the local User object, to pick up the new bestalias.
104 fix_bestalias($this->user
);
105 $this->user
= User
::getSilentWithUID($this->user
->id());
112 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: