From 6e32823cd4907b77bbaf4af85ef6e1be986fbeef Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Tue, 30 Dec 2008 00:44:48 +0100 Subject: [PATCH] Introduces search names, modifies name edition in the profile and adapts it to be more flexible and compatible with AX data. --- htdocs/javascript/profile.js | 64 ++++++++--- include/name.func.inc.php | 185 +++++++++++++++++++++++++++++++ modules/profile.php | 24 +++- modules/profile/general.inc.php | 168 ++++++++++++++++++---------- templates/profile/general.buildnames.tpl | 25 +++++ templates/profile/general.name.tpl | 120 -------------------- templates/profile/general.searchname.tpl | 67 +++++++---- templates/profile/general.tpl | 61 +++++++++- upgrade/newdirectory-0.0.1/00_names.sql | 135 +++++++++++++++------- upgrade/newdirectory-0.0.1/README | 1 + 10 files changed, 582 insertions(+), 268 deletions(-) create mode 100644 include/name.func.inc.php create mode 100644 templates/profile/general.buildnames.tpl delete mode 100644 templates/profile/general.name.tpl create mode 100644 upgrade/newdirectory-0.0.1/README diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 42921df..b8ea934 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -107,25 +107,63 @@ function prepareType(i) selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value); } +function displayNamesAdvanced() +{ + $('.names_advanced').show(); +} + function addSearchName() { - var i = 0; - while (document.getElementById('search_name_' + i) != null) { - i++; - } - $('#add_search_name').before('
'); - Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i,function(){ - $('#search_name_'+i+' input')[1].focus(); - }); + var i = 0; + while ($('#search_name_' + i).length != 0) { + i++; + } + Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){ + $('#searchname').before(data); + changeNameFlag(i); + }); } function removeSearchName(i) { - if (document.getElementById('search_name_'+i+'_new') != null) { - $('#search_name_'+i).remove(); - } else { - removeObject('search_name_'+i, 'search_name['+i+']'); - } + $('#search_name_' + i).remove(); + updateNameDisplay(); +} + +function changeNameFlag(i) +{ + $('#flag_' + i).remove(); + var typeid = $('#search_name_' + i).find('select').val(); + var type = $('#search_name_' + i).find('select :selected').text(); + if ($('[@name=sn_type_' + typeid + '_' + i + ']').val() > 0) { + $('#flag_cb_' + i).after(' ' + + 'site public' + + '' + + '' + + ''); + } else { + $('#flag_cb_' + i).after(' ' + + 'site privé' + + '' + + ''); + } +} + +function updateNameDisplay() +{ + var searchnames = ''; + for (var i = 0; i < 10; i++) { + if ($('#search_name_' + i).find(':text').val()) { + searchnames += $('#search_name_' + i).find('[name*=typeid]').val() + ';'; + searchnames += $('#search_name_' + i).find(':checked').length-1 + ';'; + searchnames += $('#search_name_' + i).find(':text').val() + ';;'; + } + } + Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){ + var name = data.split(';'); + $('#public_name').html(name[0]); + $('#private_name').html(name[0] + name[1]); + }); } function delNationality(i) diff --git a/include/name.func.inc.php b/include/name.func.inc.php new file mode 100644 index 0000000..049b715 --- /dev/null +++ b/include/name.func.inc.php @@ -0,0 +1,185 @@ +next()) { + $types[$sn_type['name']] = $sn_type['id']; + } + return $types; +} + +function build_full_name(&$search_names, &$sn_types) +{ + $name = ""; + if (isset($search_names[$sn_types['Nom usuel']])) { + $name .= $search_names[$sn_types['Nom usuel']][0] . " (" + . $search_names[$sn_types['Nom patronymique']][0] . ")"; + } else { + $name .= $search_names[$sn_types['Nom patronymique']][0]; + } + if (isset($search_names[$sn_types['Nom marital']]) + || isset($search_names[$sn_types['Pseudonyme (nom de plume)']])) { + if (isset($search_names[$sn_types['Nom marital']])) { + $user = S::user(); + if ($user->isFemale()) { + $name .= " (Mme "; + } else { + $name .= " (M "; + } + $name .= $search_names[$sn_types['Nom marital']][0]; + if (isset($search_names[$sn_types['Pseudonyme (nom de plume)']])) { + $name .= ", "; + } + } + if (isset($search_names[$sn_types['Pseudonyme (nom de plume)']])) { + $name .= $search_names[$sn_types['Pseudonyme (nom de plume)']][0]; + } + $name .= ")"; + } + return $name; +} + +function build_public_name(&$search_names, &$sn_types, $full_name) +{ + return $search_names[$sn_types['Prénom']][0] . " " . $full_name; +} + +function build_private_name(&$search_names, &$sn_types) +{ + $name = ""; + if (isset($search_names[$sn_types['Surnom']]) + || (isset($search_names[$sn_types['Autre prénom']]) + || isset($search_names[$sn_types['Autre nom']]))) { + $name .= " ("; + if (isset($search_names[$sn_types['Surnom']])) { + $name .= "alias " . $search_names[$sn_types['Surnom']][0]; + $i = 2; + while (isset($search_names[$sn_types['Surnom']][$i])) { + $name .= ", " . $search_names[$sn_types['Surnom']][$i]; + $i++; + } + if (isset($search_names[$sn_types['Autre prénom']]) + || isset($search_names[$sn_types['Autre nom']])) { + $name .= ", "; + } + } + if (isset($search_names[$sn_types['Autre prénom']])) { + $name .= "autres prénoms : " . $search_names[$sn_types['Autre prénom']][0]; + $i = 2; + while (isset($search_names[$sn_types['Autre prénom']][$i])) { + $name .= ", " . $search_names[$sn_types['Autre prénom']][$i]; + $i++; + } + if (isset($search_names[$sn_types['Autre nom']])) { + $name .= ", "; + } + } + if (isset($search_names[$sn_types['Autre nom']])) { + $name .= "autres noms : " . $search_names[$sn_types['Autre nom']][0]; + $i = 2; + while (isset($search_names[$sn_types['Autre nom']][$i])) { + $name .= ", " . $search_names[$sn_types['Autre nom']][$i]; + $i++; + } + } + $name .= ")"; + } + return $name; +} + +function build_directory_name(&$search_names, &$sn_types, $full_name) +{ + return $full_name . " " . $search_names[$sn_types['Prénom']][0]; +} + +function short_name(&$search_names, &$sn_types) +{ + $name = ""; + if (isset($search_names[$sn_types['Nom usuel']])) { + $name .= $search_names[$sn_types['Nom usuel']][0]; + } else { + $name .= $search_names[$sn_types['Nom patronymique']][0]; + } + $name = " "; + if (isset($search_names[$sn_types['Prénom usuel']])) { + $name .= $search_names[$sn_types['Prénom usuel']][0]; + } else { + $name .= $search_names[$sn_types['Prénom']][0]; + } + return $name; +} + +function sort_name(&$search_names, &$sn_types) +{ + $name = ""; + if (isset($search_names[$sn_types['Nom usuel']])) { + $name .= $search_names[$sn_types['Nom usuel']][1]; + } else { + $name .= $search_names[$sn_types['Nom patronymique']][1]; + } + $name .= $search_names[$sn_types['Prénom']][0]; + return $name; +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/profile.php b/modules/profile.php index 05af457..ef9bec9 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -42,6 +42,7 @@ class ProfileModule extends PLModule 'profile/ajax/ssecteur' => $this->make_hook('ajax_ssecteur', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE, 'user', NO_AUTH), + 'profile/ajax/buildnames' => $this->make_hook('ajax_buildnames', AUTH_COOKIE, 'user', NO_AUTH), 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE), 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE), 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC), @@ -374,7 +375,7 @@ class ProfileModule extends PLModule WHERE user_id = {?} AND naissance = '0000-00-00'", S::i('uid')); if ($res->numRows()) { $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser" - . " la procédure de récupération de mot de passe si un jour tu le perdais"); + . " la procédure de récupération de mot de passe si un jour tu le perdais."); } $page->setTitle('Mon Profil'); @@ -524,15 +525,26 @@ class ProfileModule extends PLModule } } - function handler_ajax_searchname(&$page, $snid) + function handler_ajax_searchname(&$page, $id) { header('Content-Type: text/html; charset=utf-8'); $page->changeTpl('profile/general.searchname.tpl', NO_SKIN); - $page->assign('i', $snid); - $page->assign('sn', array()); - $page->assign('newsn', true); + $res = XDB::query("SELECT id, name, FIND_IN_SET('public', flags) AS pub + FROM profile_name_search_enum + WHERE NOT FIND_IN_SET('not_displayed', flags) + AND NOT FIND_IN_SET('always_displayed', flags)"); + $page->assign('sn_type_list', $res->fetchAllAssoc()); + $page->assign('i', $id); + } + + function handler_ajax_buildnames(&$page, $data) + { + header('Content-Type: text/html; charset=utf-8'); + $page->changeTpl('profile/general.buildnames.tpl', NO_SKIN); + require_once 'name.func.inc.php'; + $page->assign('names', build_names_display($data)); } - + function handler_p_orange(&$page) { $page->changeTpl('profile/orange.tpl'); diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 945c54f..8008778 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -64,22 +64,6 @@ class ProfileNom implements ProfileSetting } } -class ProfileSearchName implements ProfileSetting -{ - - public function __construct() - { - } - - public function value(ProfilePage &$page, $field, $value, &$success) - { - } - - public function save(ProfilePage &$page, $field, $new_value) - { - } -} - class ProfileEdu implements ProfileSetting { public function __construct(){} @@ -255,8 +239,6 @@ class ProfileGeneral extends ProfilePage public function __construct(PlWizard &$wiz) { parent::__construct($wiz); - $this->settings['nom'] = $this->settings['prenom'] - = new ProfileNom(); $this->settings['naissance'] = new ProfileDate(); $this->settings['freetext_pub'] = $this->settings['photo_pub'] @@ -271,6 +253,7 @@ class ProfileGeneral extends ProfilePage = $this->settings['sort_name'] = $this->settings['tooltip_name'] = $this->settings['promo_display'] + = $this->settings['search_names'] = null; $this->settings['synchro_ax'] = new ProfileBool(); @@ -281,26 +264,24 @@ class ProfileGeneral extends ProfilePage $this->settings['networking'] = new ProfileNetworking(); $this->settings['tels'] = new ProfilePhones('user', 0); $this->settings['edus'] = new ProfileEdu(); - $this->watched= array('nom' => true, 'freetext' => true, 'tels' => true, + $this->watched= array('freetext' => true, 'tels' => true, 'networking' => true, 'edus' => true, 'nationalite' => true, 'nationalite2' => true, - 'nationalite3' => true, 'nick' => true); + 'nationalite3' => true); } protected function _fetchData() { // Checkout all data... $res = XDB::query("SELECT p.promo AS promo_display, e.entry_year AS entry_year, e.grad_year AS grad_year, - u.nom_usage, u.nationalite, u.nationalite2, u.nationalite3, u.naissance, + u.nationalite, u.nationalite2, u.nationalite3, u.naissance, t.display_tel as mobile, t.pub as mobile_pub, d.email_directory as email_directory, q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub, - q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax, - n.yourself, n.display AS display_name, n.sort AS sort_name, - n.tooltip AS tooltip_name + q.profile_from_ax as synchro_ax, u.matricule_ax, + p.public_name, p.private_name, p.yourself FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q ON (u.user_id = q.user_id) - INNER JOIN profile_names_display AS n ON (n.user_id = u.user_id) INNER JOIN profile_display AS p ON (p.pid = u.user_id) INNER JOIN profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags)) LEFT JOIN profile_phones AS t ON (u.user_id = t.uid AND link_type = 'user') @@ -321,12 +302,40 @@ class ProfileGeneral extends ProfilePage $this->values['nouvellephoto'] = $res->fetchOneCell(); // Retreive search names info - $this->values['search_names'] = XDB::iterator(" - SELECT sn.search_name, sn.name_type, sn.pub, sn.sn_id - FROM profile_names_search AS sn - WHERE sn.user_id = {?} - ORDER BY sn.name_type, search_score, search_name", - S::v('uid')); + $sn_all = XDB::iterator("SELECT IF(sn.particle = '', sn.name, CONCAT(sn.particle, ' ', sn.name)) AS name, + sn.particle, sn.typeid, e.name AS type, + FIND_IN_SET('has_particle', e.flags) AS has_particle, + FIND_IN_SET('always_displayed', e.flags) AS always_displayed, + FIND_IN_SET('public', e.flags) AS pub + FROM profile_name_search AS sn + INNER JOIN profile_name_search_enum AS e ON (e.id = sn.typeid) + WHERE sn.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags) + ORDER BY NOT FIND_IN_SET('always_displayed', e.flags), e.id, sn.name", + S::v('uid')); + + $sn_types = XDB::iterator("SELECT id, name, FIND_IN_SET('has_particle', flags) AS has_particle + FROM profile_name_search_enum + WHERE NOT FIND_IN_SET('not_displayed', flags) + AND FIND_IN_SET('always_displayed', flags) + ORDER BY id"); + + $this->values['search_names'] = array(); + $sn = $sn_all->next(); + while ($sn_type = $sn_types->next()) { + if ($sn_type['id'] == $sn['typeid']) { + $this->values['search_names'][] = $sn; + $sn = $sn_all->next(); + } else { + $this->values['search_names'][] = array('typeid' => $sn_type['id'], + 'type' => $sn_type['name'], + 'pub' => 1, + 'has_particle' => $sn_type['has_particle'], + 'always_displayed' => 1); + } + } + do { + $this->values['search_names'][] = $sn; + } while ($sn = $sn_all->next()); // Proposes choice for promo_display if ($this->values['entry_year'] != $this->values['grad_year'] - 3) { @@ -339,7 +348,7 @@ class ProfileGeneral extends ProfilePage protected function _saveData() { if ($this->changed['nationalite'] || $this->changed['nationalite2'] || $this->changed['nationalite3'] - || $this->changed['nom'] || $this->changed['prenom'] || $this->changed['naissance']) { + || $this->changed['naissance']) { if ($this->values['nationalite3'] == "") { $this->values['nationalite3'] = NULL; } @@ -354,20 +363,16 @@ class ProfileGeneral extends ProfilePage } XDB::execute("UPDATE auth_user_md5 - SET nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, nom={?}, prenom={?}, naissance={?} + SET nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, naissance={?} WHERE user_id = {?}", - $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'], - $this->values['nom'], $this->values['prenom'], - preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']), - S::v('uid')); + $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'], + preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']), + S::v('uid')); } - if ($this->changed['nick'] || $this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) { + if ($this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) { XDB::execute("UPDATE auth_user_quick - SET profile_nick= {?}, - profile_freetext={?}, - profile_freetext_pub={?}, profile_from_ax = {?} - WHERE user_id = {?}", - $this->values['nick'], + SET profile_freetext={?}, profile_freetext_pub={?}, profile_from_ax = {?} + WHERE user_id = {?}", $this->values['freetext'], $this->values['freetext_pub'], $this->values['synchro_ax'], S::v('uid')); } @@ -381,29 +386,72 @@ class ProfileGeneral extends ProfilePage VALUES ({?}, {?})", S::v('uid'), $new_email); } - if ($this->changed['nick']) { - require_once('user.func.inc.php'); - user_reindex(S::v('uid')); - } if ($this->changed['photo_pub']) { XDB::execute("UPDATE photo SET pub = {?} WHERE uid = {?}", $this->values['photo_pub'], S::v('uid')); } - if ($this->changed['yourself'] || $this->changed['sort_name'] || - $this-> changed['display_name'] || $this->changed['tooltip_name']) { - XDB::execute("UPDATE profile_names_display AS n - SET n.yourself = {?}, - n.sort = {?}, ". // SET - "n.display = {?}, ". // SET - "n.tooltip = {?} ". // SET - "WHERE n.user_id = {?}", - $this->values['yourself'], - $this->values['sort_name'], - $this->values['display_name'], - $this->values['tooltip_name'], - S::v('uid')); + + if ($this->changed['yourself'] || $this->changed['search_names']) { + if ($this->changed['search_names']) { + XDB::execute("DELETE FROM s + USING profile_name_search AS s + INNER JOIN profile_name_search_enum AS e ON (s.typeid = e.id) + WHERE s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)", + S::i('uid')); + $search_names = array(); + foreach ($this->values['search_names'] as $sn) { + if ($sn['name'] != '') { + if ($sn['particle']) { + list($particle, $name) = explode(' ', $sn['name'], 2); + if (!$name) { + list($particle, $name) = explode('\'', $sn['name'], 2); + } + } else { + $particle = ''; + $name = $sn['name']; + } + $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)); + } + } + } + + require_once 'name.func.inc.php'; + $sn_types_public = build_types('public'); + $sn_types_private = build_types('private'); + $full_name = build_full_name($search_names, $sn_types_public); + $directory_name = build_directory_name($search_names, $sn_types_public, $full_name); + $short_name = short_name($search_names, $sn_types_public); + $sort_name = short_name($search_names, $sn_types_public); + $this->values['public_name'] = build_public_name($search_names, $sn_types_public, $full_name); + $this->values['private_name'] = $public_name . build_private_name($search_names, $sn_types_private); + XDB::execute("UPDATE profile_display + SET yourself = {?}, public_name = {?}, private_name = {?}, + directory_name = {?}, short_name = {?}, sort_name = {?} + WHERE pid = {?}", + $this->values['yourself'], $this->values['public_name'], + $this->values['private_name'], $directory_name, $short_name, + $sort_name, S::v('uid')); + /*if ($this->changed['search_names']) { + require_once('user.func.inc.php'); + user_reindex(S::v('uid')); + }*/ + } else { + XDB::execute("UPDATE profile_display + SET yourself = {?} + WHERE pid = {?}", + $this->values['yourself'], S::v('uid')); + } } if ($this->changed['promo_display']) { XDB::execute("UPDATE profile_display diff --git a/templates/profile/general.buildnames.tpl b/templates/profile/general.buildnames.tpl new file mode 100644 index 0000000..0730de0 --- /dev/null +++ b/templates/profile/general.buildnames.tpl @@ -0,0 +1,25 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2008 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +{$names} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/general.name.tpl b/templates/profile/general.name.tpl deleted file mode 100644 index cce78c7..0000000 --- a/templates/profile/general.name.tpl +++ /dev/null @@ -1,120 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2008 Polytechnique.org *} -{* http://opensource.polytechnique.org/ *} -{* *} -{* This program is free software; you can redistribute it and/or modify *} -{* it under the terms of the GNU General Public License as published by *} -{* the Free Software Foundation; either version 2 of the License, or *} -{* (at your option) any later version. *} -{* *} -{* This program is distributed in the hope that it will be useful, *} -{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} -{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} -{* GNU General Public License for more details. *} -{* *} -{* You should have received a copy of the GNU General Public License *} -{* along with this program; if not, write to the Free Software *} -{* Foundation, Inc., *} -{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} -{* *} -{**************************************************************************} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Noms -
- Nom
-
- {$nom} - -
- Prénom
-
- {$prenom} - -
- Affichage de ton nom - - {if $tooltip_name}{$display_name}{else}{$display_name}{/if} - - {icon name="page_edit" title="Plus de détail"} - -
- -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/general.searchname.tpl b/templates/profile/general.searchname.tpl index 085915d..4e755d4 100644 --- a/templates/profile/general.searchname.tpl +++ b/templates/profile/general.searchname.tpl @@ -20,27 +20,46 @@ {* *} {**************************************************************************} - - - {icon name="flag_green" title="site public"} -  - - -{if $sn.pub neq 'always public'} - - {icon name=cross title="Supprimer ce nom de recherche"} - - {if $newsn} - - {else} - - {/if} -{else} - {icon name="null"} -{/if} + + + + + + + {if $sn.pub}{icon name="flag_green" title="site public"} + {else}{icon name="flag_red" title="site privé"}{/if} +   + {if $sn_type_list} + + {foreach from=$sn_type_list item=sn_type} + + {/foreach} + {else} + {$sn.type} + + + + {/if} + + + + + + {if $sn.has_particle} + {else} + {/if} + {if !$sn.always_displayed} + {icon name=cross title="Supprimer ce nom"} + {/if} + + + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 9c2e580..6ba9c16 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -20,8 +20,65 @@ {* *} {**************************************************************************} -{include file="profile/general.name.tpl display_name=$display_name tooltip_name=$tooltip_name prenom=$prenom - nom=$nom sort_name=$sort_name yourself=$yourself search_names=$search_names} + + + + + + + + + + + + + + + + + + + + + + {foreach from=$search_names item=sn key=id} + {include file="profile/general.searchname.tpl" i=$id sn=$sn class="names_advanced" style="display: none"} + {/foreach} + + + +
Noms
+ {icon name="flag_green" title="site public"} Affichage public + + {$public_name} + + + {icon name="page_edit" title="Plus de détail"} + +
+ {icon name="flag_red" title="site privé"} Affichage privé + + {$private_name} +
+ Comment t'appeller + sur le site, dans la lettre mensuelle... + + +
diff --git a/upgrade/newdirectory-0.0.1/00_names.sql b/upgrade/newdirectory-0.0.1/00_names.sql index bd0d888..5901128 100644 --- a/upgrade/newdirectory-0.0.1/00_names.sql +++ b/upgrade/newdirectory-0.0.1/00_names.sql @@ -1,45 +1,94 @@ -CREATE TABLE IF NOT EXISTS `profile_names_display` ( - `user_id` int(11) NOT NULL COMMENT 'id of alumni', - `display` varchar(100) NOT NULL COMMENT 'name to display', - `sort` varchar(100) NOT NULL COMMENT 'name used for sorting', - `tooltip` varchar(150) NOT NULL COMMENT 'text to explain display name if needed', - `firstname` varchar(50) NOT NULL COMMENT 'first name', - `lastname` varchar(50) NOT NULL COMMENT 'last name', - `yourself` varchar(100) NOT NULL COMMENT 'name we used to speak to him/her', - PRIMARY KEY (`user_id`), - KEY `sort` (`sort`) -) CHARSET=utf8 COMMENT='Alumnis'' names to display'; - -INSERT INTO `profile_names_display` ( - SELECT - `user_id`, - CONCAT(`prenom`, ' ',IF(`nom_usage` != '',CONCAT(`nom_usage`,' (',`nom`,')'),`nom`)), - CONCAT(IF(`nom_usage` != '',`nom_usage`,`nom`),', ',`prenom`), - '', - `prenom`, - IF(`nom_usage` != '',`nom_usage`,`nom`), - `prenom` - FROM `auth_user_md5`); - -UPDATE `profile_names_display` AS n INNER JOIN `auth_user_md5` AS u ON n.lastname = u.prenom -SET n.tooltip = CONCAT('Prénom : ', n.firstname,' - Nom : ', n.lastname); - -CREATE TABLE IF NOT EXISTS `profile_names_search` ( - `user_id` int(11) NOT NULL COMMENT 'id of alumni', - `sn_id` smallint(6) NOT NULL COMMENT 'id of this search name in all alumni''s search names', - `search_name` varchar(50) NOT NULL COMMENT 'name to search for', - `name_type` enum('firstname','lastname','surname') NOT NULL default 'lastname' COMMENT 'type of name', - `search_score` smallint(6) NOT NULL COMMENT 'used to sort search results', - `pub` enum('always public','public','private') NOT NULL default 'private' COMMENT 'searchable on public site or only on private', - PRIMARY KEY (`name_type`,`search_name`,`user_id`), - KEY `user_id` (`user_id`) -) CHARSET=utf8 COMMENT='Names of alumni (search table)'; - -INSERT INTO `profile_names_search` ( SELECT `user_id`, 0, `nom`, 'lastname', 10, 'always public' FROM `auth_user_md5` WHERE `nom` != ''); -INSERT INTO `profile_names_search` ( SELECT `user_id`, 1, `nom_usage`, 'lastname', 10, 'public' FROM `auth_user_md5` WHERE `nom` != `nom_usage` AND `nom_usage` != ''); -INSERT INTO `profile_names_search` ( SELECT `user_id`, 2, `nom_ini`, 'lastname', 7, 'private' FROM `auth_user_md5` WHERE `nom` != `nom_ini` AND `nom_ini` != '' AND `nom_ini` != `nom_usage`); -INSERT INTO `profile_names_search` ( SELECT `user_id`, 3, `prenom`, 'firstname', 8, 'always public' FROM `auth_user_md5` WHERE `prenom` != ''); -INSERT INTO `profile_names_search` ( SELECT `user_id`, 4, `prenom_ini`, 'firstname', 5, 'private' FROM `auth_user_md5` WHERE `prenom_ini` != `prenom` AND `prenom_ini` != ''); -INSERT INTO `profile_names_search` ( SELECT `user_id`, 5, `profile_nick`, 'surname', 7, 'private' FROM `auth_user_quick` WHERE `profile_nick` != ''); +ALTER TABLE profile_display ADD COLUMN yourself VARCHAR(255) NOT NULL, + ADD COLUMN public_name VARCHAR(255) NOT NULL, + ADD COLUMN private_name VARCHAR(255) NOT NULL, + ADD COLUMN directory_name VARCHAR(255) NOT NULL, + ADD COLUMN short_name VARCHAR(255) NOT NULL, + ADD COLUMN sort_name VARCHAR(255) NOT NULL, + CHANGE COLUMN uid pid INT(11), + CHANGE COLUMN promo_display promo VARCHAR(255); + +REPLACE INTO profile_display (pid, yourself, public_name, private_name, directory_name, short_name, sort_name) + SELECT u.user_id, u.prenom, + CONCAT(u.prenom, ' ', IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom)), + CONCAT(u.prenom, ' ', IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom), + IF(q.profile_nick != '', CONCAT(' (alias ', q.profile_nick, ')'), '')), + CONCAT(IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom), ', ', u.prenom), + CONCAT(u.prenom, ' ', IF(u.nom_usage != '', u.nom_usage, u.nom)), + CONCAT(IF(u.nom_usage != '', u.nom_usage, u.nom), ' ', u.prenom) + FROM auth_user_md5 AS u + LEFT JOIN auth_user_quick AS q ON (u.user_id = q.user_id); + + +DROP TABLE IF EXISTS profile_name_search_enum; + +CREATE TABLE IF NOT EXISTS profile_name_search_enum ( + id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + explanations VARCHAR(255) NOT NULL, + flags SET('has_particle', 'not_displayed', 'always_displayed', 'public') NOT NULL, + PRIMARY KEY (id), + UNIQUE (name) +) CHARSET=utf8; + +INSERT INTO profile_name_search_enum (name, flags) + VALUES ('Nom patronymique', 'has_particle,always_displayed,public'), + ('Nom marital', 'has_particle,always_displayed,public'), + ('Nom usuel', 'has_particle,always_displayed,public'), + ('Prénom', 'always_displayed,public'), + ('Pseudonyme (nom de plume)', 'always_displayed,public'), + ('Surnom', ''), + ('Prénom usuel', 'public'), + ('Autre prénom', ''), + ('Autre nom', ''), + ('Nom initial', 'has_particle,not_displayed,public'), + ('Prénom initial', 'has_particle,not_displayed,public'); + + +DROP TABLE IF EXISTS profile_name_search; + +CREATE TABLE IF NOT EXISTS profile_name_search ( + id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id of this name for this user', + pid INT(11) NOT NULL COMMENT 'id of alumni', + name VARCHAR(255) NOT NULL COMMENT 'name to search for', + particle VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'particle of the name to search for', + typeid TINYINT(2) UNSIGNED NOT NULL COMMENT 'type of name', + PRIMARY KEY (pid, id) +) CHARSET=utf8 COMMENT = 'Names of alumni (search table)'; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT u.user_id, u.nom, e.id + FROM auth_user_md5 AS u + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Nom patronymique') + WHERE nom != ''; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT u.user_id, u.nom_ini, e.id + FROM auth_user_md5 AS u + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Nom initial') + WHERE nom_ini != ''; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT u.user_id, u.prenom, e.id + FROM auth_user_md5 AS u + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Prénom') + WHERE prenom != ''; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT u.user_id, u.prenom_ini, e.id + FROM auth_user_md5 AS u + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Prénom initial') + WHERE prenom_ini != ''; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT u.user_id, u.nom_usage, e.id + FROM auth_user_md5 AS u + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Nom usuel') + WHERE nom_usage != ''; + +INSERT INTO profile_name_search (pid, name, typeid) + SELECT q.user_id, q.profile_nick, e.id + FROM auth_user_quick AS q + INNER JOIN profile_name_search_enum AS e ON (e.name = 'Surnom') + WHERE profile_nick != ''; -- vim:set syntax=mysql: diff --git a/upgrade/newdirectory-0.0.1/README b/upgrade/newdirectory-0.0.1/README new file mode 100644 index 0000000..ac47951 --- /dev/null +++ b/upgrade/newdirectory-0.0.1/README @@ -0,0 +1 @@ +Il faudra déplacer le yourself qui est mis dans profile_display dans le script 00_names.sql vers l'account. -- 2.1.4