2 /***************************************************************************
3 * Copyright (C) 2003-2007 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 ***************************************************************************/
24 class UsageReq
extends Validate
28 public $unique = true
;
39 public $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
47 public function __construct($_uid, $_usage, $_reason)
49 parent
::__construct($_uid, true
, 'usage');
50 $this->nom_usage
= $_usage;
51 $this->reason
= $_reason;
52 require_once 'xorg.misc.inc.php';
53 $this->alias
= make_username($this->prenom
, $this->nom_usage
);
54 if (!$this->nom_usage
) $this->alias
= "";
57 SELECT e.alias, u.nom_usage, a.id
58 FROM auth_user_md5 as u
59 LEFT JOIN aliases as e ON(e.type='alias' AND FIND_IN_SET('usage',e.flags) AND e.id = u.user_id)
60 LEFT JOIN aliases as a ON(a.alias = {?} AND a.id != u.user_id)
61 WHERE u.user_id = {?}", $this->alias
, $this->uid
);
62 list($this->oldalias
, $this->oldusage
, $this->homonyme
) = $res->fetchOneRow();
66 // {{{ function formu()
68 public function formu()
70 return 'include/form.valid.nomusage.tpl';
74 // {{{ function _mail_subj()
76 protected function _mail_subj()
78 return "[Polytechnique.org/USAGE] Changement de nom d'usage";
82 // {{{ function _mail_body
84 protected function _mail_body($isok)
88 $res = " Le changement de nom d'usage que tu as demandé vient d'être effectué.";
89 if ($this->oldalias
) {
90 $res .= "\n\n Les alias {$this->oldalias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés.";
93 $res .= "\n\n Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
97 return " La demande de changement de nom d'usage que tu avais faite a été refusée.";
102 // {{{ function commit()
104 public function commit()
106 require_once('user.func.inc.php');
107 $this->bestalias
= set_new_usage($this->uid
, $this->nom_usage
, $this->alias
);
115 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: