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('<div id="search_name_' + i + '" style="padding:2px" class="center"></div>');
- 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('<span id="flag_' + i + '"> ' +
+ '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
+ '<input type="hidden" name="search_names[' + i + '][pub]" value="1"/>' +
+ '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
+ '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
+ } else {
+ $('#flag_cb_' + i).after('<span id="flag_' + i + '"> ' +
+ '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
+ '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
+ '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
+ }
+}
+
+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)
--- /dev/null
+<?php
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+function build_names_display($data)
+{
+ $data_array = explode(';;', $data);
+ $n = count($data_array);
+ $n--;
+ for ($i = 0; $i < $n; $i++) {
+ $searchname = explode(';', $data_array[$i]);
+ if ($searchname[1] != 0) {
+ list($particle, $name) = explode(' ', $searchname[2], 2);
+ if (!$name) {
+ list($particle, $name) = explode('\'', $searchname[2], 2);
+ }
+ } else {
+ $particle = '';
+ $name = $searchname[2];
+ }
+ if (!isset($search_names[$searchname[0]])) {
+ $search_names[$searchname[0]] = array($searchname[2], $name);
+ } else {
+ $search_names[$searchname[0]] = array_merge($search_names[$searchname[0]], array($name));
+ }
+ }
+ $sn_types_public = build_types('public');
+ $sn_types_private = build_types('private');
+ $full_name = build_full_name($search_names, $sn_types_public);
+ return build_public_name($search_names, $sn_types_public, $full_name) . ';' .
+ build_private_name($search_names, $sn_types_private);
+}
+
+function build_types($pub)
+{
+ if ($pub == 'public') {
+ $sql_pub = "AND FIND_IN_SET('public', flags)";
+ } elseif ($pub == 'private') {
+ $sql_pub = "AND NOT FIND_IN_SET('public', flags)";
+ } else {
+ $sql_pub = "";
+ }
+ $sql = "SELECT id, name
+ FROM profile_name_search_enum
+ WHERE NOT FIND_IN_SET('not_displayed', flags)" . $sql_pub;
+ $sn_types = XDB::iterator($sql);
+ $types = array();
+ while ($sn_type = $sn_types->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:
+?>
'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),
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');
}
}
- 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');
}
}
-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(){}
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']
= $this->settings['sort_name']
= $this->settings['tooltip_name']
= $this->settings['promo_display']
+ = $this->settings['search_names']
= null;
$this->settings['synchro_ax']
= new ProfileBool();
$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')
$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) {
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;
}
}
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'));
}
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
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* 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 *}
-{* *}
-{**************************************************************************}
-
-
-<table class="bicol" style="margin-bottom: 1em" summary="Profil : Noms">
- <tr>
- <th colspan="2">
- Noms
- </th>
- </tr>
- <tr>
- <td>
- <span class="titre">Nom</span><br/>
- </td>
- <td>
- {$nom}
- <input type='hidden' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
- </td>
- </tr>
- <tr>
- <td>
- <span class="titre">Prénom</span><br/>
- </td>
- <td>
- {$prenom}
- <input type='hidden' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
- </td>
- </tr>
- <tr>
- <td>
- <span class="titre">Affichage de ton nom</span>
- </td>
- <td>
- {if $tooltip_name}<span title="{$tooltip_name}" class="hint">{$display_name}</span>{else}{$display_name}{/if}
- <a href="profile/edit#names_advanced" onclick="$('.names_advanced').show();$(this).hide();document.location = document.location + '#names_advanced';return false">
- {icon name="page_edit" title="Plus de détail"}
- </a>
- </td>
- </tr>
- <tr class="names_advanced" style="display: none">
- <td>
- <span class="flags">
- <input type="checkbox" checked="checked" disabled="disabled" />
- {icon name="flag_green" title="site public"}
- </span>
- <span class="titre">Affichage courant de ton nom</span>
- <a class="popup3" href="Xorg/Profil#name_displayed">{icon name="information" title="aide"}</a>
- </td>
- <td>
- <input type="text" name="display_name" value="{$display_name}" size="40"/>
- </td>
- </tr>
- <tr class="names_advanced" style="display: none">
- <td>
- <span class="titre">explication</span>
- <a class="popup3" href="Xorg/Profil#name_tooltip">{icon name="information" title="aide"}</a>
- </td>
- <td>
- <input type="text" name="tooltip_name" value="{$tooltip_name}" size="40"/>
- </td>
- </tr>
- <tr class="names_advanced" style="display: none">
- <td>
- <span class="titre">ranger ce nom à</span>
- <a class="popup3" href="Xorg/Profil#name_order">{icon name="information" title="aide"}</a>
- </td>
- <td>
- <input type="text" name="sort_name" value="{$sort_name}" size="40"/>
- </td>
- </tr>
- <tr class="names_advanced" style="display: none">
- <td>
- <span class="flags">
- <input type="checkbox" checked="checked" disabled="disabled" />
- {icon name="flag_red" title="privé"}
- </span>
- <span class="titre">Comment on doit t'appeller</span>
- <a class="popup3" href="Xorg/Profil#name_yourself">{icon name="information" title="aide"}</a>
- </td>
- <td>
- <input type="text" name="yourself" value="{$yourself}" size="40"/>
- </td>
- </tr>
- <tr class="names_advanced" style="display: none">
- <td colspan="2">
- <span class="titre">Recherche</span><span class="smaller">, ta fiche apparaît quand on cherche un de ces noms</span>
- <a class="popup3" href="Xorg/Profil#name_search">{icon name="information" title="aide"}</a>
- {iterate from=$search_names item="sn"}
- <div id="search_name_{$sn.sn_id}" style="padding:2px" class="center">
- {include file="profile/general.searchname.tpl" i=$sn.sn_id sn=$sn}
- </div>
- {/iterate}
- <div id="add_search_name" class="center" style="clear: both">
- <a href="javascript:addSearchName()">
- {icon name=add title="Ajouter un nom de recherche"} Ajouter un nom
- </a>
- </div>
- </td>
-</table>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-<span class="flags">
- <input type="checkbox"
- {if $sn.pub neq 'private'} checked="checked"{/if}
- {if $sn.pub eq 'always public'} disabled="disabled"{else} name="search_name[{$i}][pub]"{/if}/>
- {icon name="flag_green" title="site public"}
-</span>
-<input type="text" name="search_name[{$i}][name]" value="{$sn.search_name}" size="30"/>
-<select name="search_name[{$i}][type]">
- <option value="firstname"{if $sn.name_type eq 'firstname'} selected="selected"{/if}>Prénom</option>
- <option value="lastname"{if $sn.name_type eq 'lastname'} selected="selected"{/if}>Nom de famille</option>
- <option value="surname"{if $sn.name_type eq 'surname'} selected="selected"{/if}>Surnom</option>
-</select>
-{if $sn.pub neq 'always public'}
- <a href="javascript:removeSearchName({$i})">
- {icon name=cross title="Supprimer ce nom de recherche"}
- </a>
- {if $newsn}
- <span style="display:none" id="search_name_{$i}_new">Nouveau</span>
- {else}
- <input type="hidden" name="search_name[{$i}][removed]" value=""/>
- {/if}
-{else}
- {icon name="null"}
-{/if}
+<tr id="search_name_{$i}"{if $class} class="{$class}" style="{$style}"{/if}>
+ <td>
+ <input type="hidden" name="search_names[{$i}][always_displayed]" value="{$sn.always_displayed}"/>
+ <input type="hidden" name="search_names[{$i}][has_particle]" value="{$sn.has_particle}"/>
+ <span class="flags">
+ <input id="flag_cb_{$i}" type="checkbox" checked="checked" disabled="disabled"/>
+ <span id="flag_{$i}">{if $sn.pub}{icon name="flag_green" title="site public"}
+ {else}{icon name="flag_red" title="site privé"}{/if}</span>
+ </span>
+ {if $sn_type_list}
+ <select id="search_name_select_{$i}" name="search_names[{$i}][typeid]" onchange="changeNameFlag({$i});updateNameDisplay();">
+ {foreach from=$sn_type_list item=sn_type}
+ <option value="{$sn_type.id}">{$sn_type.name}</option>
+ {/foreach}
+ </select>
+ {foreach from=$sn_type_list item=sn_type}
+ <input type="hidden" name="sn_type_{$sn_type.id}_{$i}" value="{$sn_type.pub}"/>
+ {/foreach}
+ {else}
+ {$sn.type}
+ <input type="hidden" name="search_names[{$i}][pub]" value="{$sn.pub}"/>
+ <input type="hidden" name="search_names[{$i}][type]" value="{$sn.type}"/>
+ <input type="hidden" name="search_names[{$i}][typeid]" value="{$sn.typeid}"/>
+ {/if}
+ </td>
+ <td>
+ <input type="text" name="search_names[{$i}][name]" value="{$sn.name}"
+ {if $sn.has_particle}title="Coche la case en bout de ligne si ton nom commence par une particle."{/if}
+ {if $sn.error} class="error"{/if} size="25" onkeyup="updateNameDisplay();"/>
+ </td>
+ <td>
+ {if $sn.has_particle}<input name="search_names[{$i}][particle]" type="checkbox"
+ title="Coche cette case si ton nom commence par une particle."
+ {if $sn.particle neq ''} checked="checked"{/if} onchange="updateNameDisplay();"/>
+ {else}
+ <input type="hidden" name="search_names[{$i}][particle]" value=""/>{/if}
+ {if !$sn.always_displayed}<a href="javascript:removeSearchName({$i})">
+ {icon name=cross title="Supprimer ce nom"}
+ </a>{/if}
+ </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-{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}
+<table class="bicol" style="margin-bottom: 1em" summary="Profil : Noms">
+ <tr>
+ <th colspan="3">Noms</th>
+ </tr>
+ <tr>
+ <td class="titre">
+ {icon name="flag_green" title="site public"} Affichage public
+ </td>
+ <td id="public_name">
+ {$public_name}
+ </td>
+ <td rowspan="2">
+ <a href="javascript:displayNamesAdvanced();">
+ {icon name="page_edit" title="Plus de détail"}
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td class="titre">
+ {icon name="flag_red" title="site privé"} Affichage privé
+ </td>
+ <td id="private_name">
+ {$private_name}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <span class="titre">Comment t'appeller</span>
+ <span class="smaller">sur le site, dans la lettre mensuelle...</span>
+ </td>
+ <td>
+ <input type="text" name="yourself" value="{$yourself}" size="25"/>
+ </td>
+ <td></td>
+ </tr>
+ <tr class="names_advanced" style="display: none">
+ <td colspan="3">
+ <span class="titre">Gestion de tes noms, prénoms, surnoms...</span>
+ <span class="smaller">Ils déterminent la façon dont ton nom apparaît sur les annuaires
+ en ligne et papier et ta fiche apparaitra quand on cherche un de ces noms. Pour plus
+ d'explications sur l'icône suivante
+ <a href="profile/name_info">{icon name="information" title="Plus d'infos"}</a>.</span><br/>
+ <div class="small center">Si un de tes noms commence par une particule,
+ coche la case en bout de ligne.</div>
+ </td>
+ </tr>
+ {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}
+ <tr class="names_advanced" id="searchname" style="display: none">
+ <td colspan="2">
+ <div id="sn_add" class="center">
+ <a href="javascript:addSearchName();">
+ {icon name=add title="Ajouter un nom"} Ajouter un nom
+ </a>
+ </div>
+ </td>
+ </tr>
+</table>
<table class="bicol" style="margin-bottom: 1em"
summary="Profil : Informations générales">
-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:
--- /dev/null
+Il faudra déplacer le yourself qui est mis dans profile_display dans le script 00_names.sql vers l'account.