X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fnomusage.inc.php;h=0bc76cd4c2f445bf6895f24e3bf8e8a42df218be;hb=90862af65777b54eb2830b501729236fe50aa110;hp=15f3e8e40ee78e66ff1de63fcf1b8c332688e364;hpb=32d8754be017db3aa656812fca2a92704ebe29ae;p=platal.git diff --git a/include/validations/nomusage.inc.php b/include/validations/nomusage.inc.php index 15f3e8e..0bc76cd 100644 --- a/include/validations/nomusage.inc.php +++ b/include/validations/nomusage.inc.php @@ -44,20 +44,24 @@ class UsageReq extends Validate // }}} // {{{ 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(); } @@ -93,7 +97,7 @@ class UsageReq extends Validate } if ($globals->mailstorage->googleapps_domain) { require_once 'googleapps.inc.php'; - $account = new GoogleAppsAccount($this->uid, $this->forlife); + $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"; } @@ -110,9 +114,9 @@ class UsageReq extends Validate 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; }