From dd6fce1ea7c035ba242e5df7819469d1e3d6ce3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Fri, 9 Jan 2009 23:51:47 +0100 Subject: [PATCH] Uses the proper name for display and removes old related name references. --- bin/cron/checkdb.php | 22 +++++----------------- include/user.func.inc.php | 3 +-- include/userset.inc.php | 37 +++++++++++++++++-------------------- modules/profile/general.inc.php | 16 +++++++++------- 4 files changed, 32 insertions(+), 46 deletions(-) diff --git a/bin/cron/checkdb.php b/bin/cron/checkdb.php index c56a8b6..822cda5 100755 --- a/bin/cron/checkdb.php +++ b/bin/cron/checkdb.php @@ -188,25 +188,13 @@ check("SELECT matricule,nom,prenom,matricule_ax,COUNT(matricule_ax) AS c WHERE matricule_ax != '0' GROUP BY matricule_ax having c > 1", "à chaque personne de l'annuaire de l'AX (identification_ax) doit correspondre AU PLUS UNE personne de notre annuaire (auth_user_md5) -> si ce n'est pas le cas il faut regarder en manuel ce qui ne va pas !"); - -/* each alumni has one and only one display name by default and one and only one name when we talk to him directly */ -check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c - FROM `auth_user_md5` AS u - LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'default')) - GROUP BY u.`user_id` - HAVING c != 1", "chaque personne doit avoir un et un seul nom par défaut"); -check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c - FROM `auth_user_md5` AS u - LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'yourself')) - GROUP BY u.`user_id` - HAVING c != 1", "chaque personne doit avoir un et un seul nom quand on lui parle"); /* no alumni is allowed to have empty names */ -check("SELECT u.`user_id`, u.`nom`, u.`prenom` - FROM `auth_user_md5` AS u - INNER JOIN `profile_names_search` AS n USING(`user_id`) - WHERE n.`search_name` = ''", "liste des personnes qui ont un de leur nom de recherche vide"); - +check("SELECT s.uid, d.public_name + FROM profile_name_search AS s + INNER JOIN profile_display AS d ON (d.pid = s.uid) + WHERE name = ''", "liste des personnes qui ont un de leur nom de recherche vide"); + /* verifie qu'il n'y a pas d'utilisateurs ayant un compte Google Apps désactivé et une redirection encore active vers Google Apps */ check("SELECT a.alias, g.g_status, u.mail_storage FROM auth_user_md5 AS u diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 7225d82..58c41a8 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -271,7 +271,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') u.matricule_ax, m.expertise != '' AS is_referent, (COUNT(e.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif, - nd.display AS name_display, nd.tooltip AS name_tooltip + d.public_name, d.private_name FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q USING(user_id) INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = 'a_vie') @@ -285,7 +285,6 @@ function &get_user_details($login, $from_uid = '', $view = 'private') LEFT JOIN photo AS p ON (p.uid = u.user_id) LEFT JOIN profile_mentor AS m ON (m.uid = u.user_id) LEFT JOIN emails AS e ON (e.uid = u.user_id AND e.flags='active') - INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id) INNER JOIN profile_display AS d ON (d.pid = u.user_id) WHERE a.alias = {?} GROUP BY u.user_id"; diff --git a/include/userset.inc.php b/include/userset.inc.php index cbb93ed..d90dc3a 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', '-promo', 'sort_name'), '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('name', array('sort_name'), 'nom'); + $this->addSortKey('promo', array('-promo', 'sort_name'), 'promotion'); + $this->addSortKey('date_mod', array('-date', '-promo', 'sort_name'), 'dernière modification'); parent::__construct($set, $data, $params); } @@ -196,7 +196,7 @@ class MinificheView extends MultipageView edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3, adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region, (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif, - nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" . + d.directory_name, d.sort_name" . (S::logged() ? ", c.contact AS contact" : ''); } @@ -232,7 +232,6 @@ class MinificheView extends MultipageView LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active') - INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id) INNER JOIN profile_display AS d ON (d.pid = u.user_id)" . (S::logged() ? "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" : ""); @@ -267,9 +266,9 @@ class MentorView extends MultipageView { $this->entriesPerPage = 10; $this->addSortKey('rand', array('RAND(' . S::i('uid') . ')'), 'aléatoirement'); - $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('name', array('sort_name'), 'nom'); + $this->addSortKey('promo', array('-promo', 'sort_name'), 'promotion'); + $this->addSortKey('date_mod', array('-date', '-promo', 'sort_name'), 'dernière modification'); parent::__construct($set, $data, $params); } @@ -277,13 +276,12 @@ class MentorView extends MultipageView { return "m.uid, d.promo, u.hruid, m.expertise, mp.country, ms.sectorid, ms.subsectorid, - nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort"; + d.directory_name, d.sort_name"; } public function joins() { - return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id) - INNER JOIN profile_display AS d ON (d.pid = u.user_id)"; + return "INNER JOIN profile_display AS d ON (d.pid = u.user_id)"; } public function bounds() @@ -314,25 +312,24 @@ class TrombiView extends MultipageView public function __construct(PlSet &$set, $data, array $params) { $this->entriesPerPage = 24; - $this->order = explode(',', Env::v('order', 'name_sort')); + $this->order = explode(',', Env::v('order', 'sort_name')); if (@$params['with_score']) { - $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence'); + $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'sort_name'), 'pertinence'); } - $this->addSortKey('name', array('name_sort'), 'nom'); - $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); + $this->addSortKey('name', array('sort_name'), 'nom'); + $this->addSortKey('promo', array('-promo', 'sort_name'), 'promotion'); parent::__construct($set, $data, $params); } public function fields() { - return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, d.promo, u.hruid "; + return "u.user_id, d.directory_name, d.sort_name, u.promo, d.promo, u.hruid "; } public function joins() { - return "INNER JOIN photo AS p ON (p.uid = u.user_id) - INNER JOIN profile_display AS d ON (d.pid = u.user_id) - INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)"; + return "INNER JOIN photo AS p ON (p.uid = u.user_id) + INNER JOIN profile_display AS d ON (d.pid = u.user_id)"; } public function bounds() diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 20cf2f1..5ef6455 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -415,13 +415,15 @@ class ProfileGeneral extends ProfilePage $particle = trim($particle); $name = trim($name); $sn['name'] = trim($sn['name']); - XDB::execute("INSERT INTO profile_name_search (particle, name, typeid, pid) - VALUES ({?}, {?}, {?}, {?})", - $particle, $name, $sn['typeid'], S::i('uid')); - if (!isset($search_names[$sn['typeid']])) { - $search_names[$sn['typeid']] = array($sn['name'], $name); - } else { - $search_names[$sn['typeid']] = array_merge($search_names[$sn['typeid']], array($name)); + if ($sn['name'] != '') { + XDB::execute("INSERT INTO profile_name_search (particle, name, typeid, pid) + VALUES ({?}, {?}, {?}, {?})", + $particle, $name, $sn['typeid'], S::i('uid')); + if (!isset($search_names[$sn['typeid']])) { + $search_names[$sn['typeid']] = array($sn['name'], $name); + } else { + $search_names[$sn['typeid']] = array_merge($search_names[$sn['typeid']], array($name)); + } } } } -- 2.1.4