X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuser.php;h=f24a8dc4911e891ace1343e56757f2a99987b0e3;hb=86668a58a94fc57493a335eb75a37171238c0220;hp=976da5530fbd49ec4b6b481eafa9879492e976f4;hpb=f67c8d9a660207c5be75d4d079b7f740e5318a6c;p=platal.git diff --git a/classes/user.php b/classes/user.php index 976da55..f24a8dc 100644 --- a/classes/user.php +++ b/classes/user.php @@ -159,7 +159,7 @@ class User extends PlUser $uids = array_map(array('XDB', 'escape'), $uids); - return XDB::iterator('SELECT a.uid, a.hruid, a.registration_date, h.uid IS NOT NULL AS homonym, + return XDB::iterator('SELECT a.uid, a.hruid, a.registration_date, h.uid IS NOT NULL AS homonym, a.firstname, a.lastname, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', mf.name)) AS forlife, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate, IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias, @@ -292,6 +292,14 @@ class User extends PlUser return $this->profile()->fullName($with_promo); } + public function shortName($with_promo = false) + { + if (!$this->hasProfile()) { + return $this->full_name; + } + return $this->profile()->shortName($with_promo); + } + public function directoryName() { if (!$this->hasProfile()) { @@ -300,6 +308,11 @@ class User extends PlUser return $this->profile()->directory_name; } + static public function compareDirectoryName($a, $b) + { + return strcasecmp(replace_accent($a->directoryName()), replace_accent($b->directoryName())); + } + /** Return the main profile attached with this account if any. */ public function profile($forceFetch = false, $fields = 0x0000, $visibility = null) @@ -701,7 +714,7 @@ class User extends PlUser } $tables = array('account_auth_openid', 'announce_read', 'contacts', - 'email_send_save', 'email_virtual', + 'email_send_save', 'forum_innd', 'forum_profiles', 'forum_subs', 'group_announces_read', 'group_members', 'group_member_sub_requests', 'reminder', 'requests', @@ -714,6 +727,9 @@ class User extends PlUser XDB::execute('DELETE FROM email_redirect_account WHERE uid = {?} AND type != \'homonym\'', $this->id()); + XDB::execute('DELETE FROM email_virtual + WHERE redirect = {?}', + $this->forlifeEmail()); foreach (array('gapps_accounts', 'gapps_nicknames') as $t) { XDB::execute('DELETE FROM ' . $t . ' @@ -761,11 +777,13 @@ class User extends PlUser $this->forlifeEmail(), $newuser->id()); // Reftech new user so its forlifeEmail will be correct. - $newuser = getSilentWithUID($newuser->id()); + $newuser = self::getSilentWithUID($newuser->id()); } // Change email used in mailing lists. if ($this->forlifeEmail() != $newuser->forlifeEmail()) { + // The super user is the user who has the right to do the modification. + $super_user = S::user(); // group mailing lists $group_domains = XDB::fetchColumn('SELECT g.mail_domain FROM groups AS g @@ -773,11 +791,11 @@ class User extends PlUser WHERE g.mail_domain != \'\' AND gm.uid = {?}', $this->id()); foreach ($group_domains as $mail_domain) { - $mmlist = new MMList($this, $mail_domain); + $mmlist = new MMList($super_user, $mail_domain); $mmlist->replace_email_in_all($this->forlifeEmail(), $newuser->forlifeEmail()); } // main domain lists - $mmlist = new MMList($this); + $mmlist = new MMList($super_user); $mmlist->replace_email_in_all($this->forlifeEmail(), $newuser->forlifeEmail()); } } @@ -857,7 +875,7 @@ class User extends PlUser $is_main_domain = false; foreach (self::$sub_mail_domains as $sub_domain) { - $is_main_domain = $is_main_domain || $domain == ($sub_domain . $globals->mail->domain) && $domain == ($sub_domain . $globals->mail->domain2); + $is_main_domain = $is_main_domain || $domain == ($sub_domain . $globals->mail->domain) || $domain == ($sub_domain . $globals->mail->domain2); } return $is_main_domain; }