<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
// }}}
// {{{ 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;
- $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 ($globals->mailstorage->googleapps_domain) {
require_once 'googleapps.inc.php';
- $account = new GoogleAppsAccount(User::get($this->uid));
+ $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";
}
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;
}