// }}}
// {{{ constructor
- public function __construct($_uid, $_usage, $_reason)
+ public function __construct(User &$_user, $_usage, $_reason)
{
- parent::__construct($_uid, true, 'usage');
- $this->nom_usage = $_usage;
+ parent::__construct($_user, true, 'usage');
+ $this->nom_usage = $_usage;
$this->reason = $_reason;
- require_once 'xorg.misc.inc.php';
- $this->alias = make_username($this->prenom, $this->nom_usage);
- if (!$this->nom_usage) $this->alias = "";
+
+ $res = XDB::query("SELECT prenom FROM auth_user_md5 WHERE user_id = {?}", $this->user->id());
+ $this->alias = make_username($res->fetchOneCell(), $this->nom_usage);
+ if (!$this->nom_usage) {
+ $this->alias = "";
+ }
$res = XDB::query("
SELECT e.alias, u.nom_usage, a.id
FROM auth_user_md5 as u
LEFT JOIN aliases as e ON(e.type='alias' AND FIND_IN_SET('usage',e.flags) AND e.id = u.user_id)
LEFT JOIN aliases as a ON(a.alias = {?} AND a.id != u.user_id)
- WHERE u.user_id = {?}", $this->alias, $this->uid);
+ WHERE u.user_id = {?}", $this->alias, $this->user->id());
list($this->oldalias, $this->oldusage, $this->homonyme) = $res->fetchOneRow();
}
if ($this->nom_usage) {
$res .= "\n\n Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
}
+ if ($globals->mailstorage->googleapps_domain) {
+ require_once 'googleapps.inc.php';
+ $account = new GoogleAppsAccount($this->user);
+ if ($account->active()) {
+ $res .= "\n\n Si tu utilises Google Apps, tu peux changer ton nom d'usage sur https://mail.google.com/a/polytechnique.org/#settings/accounts";
+ }
+ }
return $res;
} else {
return " La demande de changement de nom d'usage que tu avais faite a été refusée.";
public function commit()
{
require_once 'notifs.inc.php';
- register_watch_op($this->uid, WATCH_FICHE, 'nom');
+ register_watch_op($this->user->id(), WATCH_FICHE, '', 'nom');
require_once('user.func.inc.php');
- $this->bestalias = set_new_usage($this->uid, $this->nom_usage, $this->alias);
+ set_new_usage($this->user->id(), $this->nom_usage, $this->alias);
return true;
}