From efe597c5795234724bc3df508bd628f9860a9c32 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Mon, 5 Jan 2009 23:07:23 +0100 Subject: [PATCH] Let say... start porting module/profile.php Signed-off-by: Florent Bruneau --- classes/profile.php | 6 ++++++ include/userset.inc.php | 6 +++--- modules/profile.php | 32 +++++++++++++------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index fc819f6..a49a882 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -163,6 +163,12 @@ class Profile try { return new Profile($login); } catch (UserNotFoundException $e) { + /* Let say we can identify a profile using the identifiers of its owner. + */ + $user = User::getSilent($login); + if ($user && $user->hasProfile()) { + return $user->profile(); + } return null; } } diff --git a/include/userset.inc.php b/include/userset.inc.php index 6167647..1b427d7 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -161,11 +161,11 @@ class MinificheView extends MultipageView global $globals; $this->entriesPerPage = $globals->search->per_page; if (@$params['with_score']) { - $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence'); + $this->addSortKey('score', array('-score', '-date', '-d.promo', 'name_sort'), 'pertinence'); } $this->addSortKey('name', array('name_sort'), 'nom'); - $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); - $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification'); + $this->addSortKey('promo', array('-d.promo', 'name_sort'), 'promotion'); + $this->addSortKey('date_mod', array('-date', '-d.promo', 'name_sort'), 'dernière modification'); parent::__construct($set, $data, $params); } diff --git a/modules/profile.php b/modules/profile.php index 05af457..562ebc4 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -223,8 +223,11 @@ class ProfileModule extends PLModule return PL_NOT_FOUND; } - $login = S::logged() ? User::get($x) : User::getSilent($x); + $login = (!is_numeric($x) || S::has_perms()) ? Profile::get($x) : null; if (!$login) { + if (S::logged()) { + $page->trigError($x . ' inconnu dans l\'annuaire'); + } return PL_NOT_FOUND; } @@ -249,25 +252,25 @@ class ProfileModule extends PLModule WHERE user_id = {?}", $login->id()); if ($res->fetchOneCell()) { $new = Env::v('modif') == 'new'; - $user = get_user_details($login->login(), S::v('uid'), $view); + $user = get_user_details($login->hrid(), S::v('uid'), $view); } else { $new = false; $user = array(); if (S::logged()) { - pl_redirect('marketing/public/' . $login->login()); + pl_redirect('marketing/public/' . $login->hrid()); } } // Profile view are logged. if (S::logged()) { - S::logger()->log('view_profile', $login->login()); + S::logger()->log('view_profile', $login->hrid()); } // Sets the title of the html page. $page->setTitle($login->fullName()); // Prepares the display of the user's mugshot. - $photo = 'photo/' . $login->login() . ($new ? '/req' : ''); + $photo = 'photo/' . $login->hrid() . ($new ? '/req' : ''); if (!isset($user['photo_pub']) || !has_user_right($user['photo_pub'], $view)) { $photo = ""; } @@ -293,24 +296,15 @@ class ProfileModule extends PLModule // Determines and displays the virtual alias. global $globals; - $res = XDB::query( - "SELECT alias - FROM virtual - INNER JOIN virtual_redirect USING (vid) - INNER JOIN auth_user_quick ON (user_id = {?} AND emails_alias_pub = 'public') - WHERE (redirect={?} OR redirect={?}) - AND alias LIKE '%@{$globals->mail->alias_dom}'", - $login->id(), - $login->forlifeEmail(), - // TODO(vzanotti): get ride of all @m4x.org addresses in the - // virtual redirect base, and remove this über-ugly hack. - $login->login() . '@' . $globals->mail->domain2); - $page->assign('virtualalias', $res->fetchOneCell()); + $owner = $login->owner(); + if ($owner) { + $page->assign('virtualalias', $owner->emailAlias()); + } // Adds miscellaneous properties to the display. // Adds the global user property array to the display. $page->assign_by_ref('x', $user); - $page->assign_by_ref('user', $login); + $page->assign_by_ref('user', $owner); $page->assign('logged', has_user_right('private', $view)); $page->assign('view', $view); -- 2.1.4