From b04882ff74e603c71accad830b26cd1c658305ea Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Thu, 3 Apr 2008 22:49:54 +0200 Subject: [PATCH] add name edition in profile --- htdocs/javascript/profile.js | 19 +++++ modules/profile.php | 10 +++ modules/profile/general.inc.php | 49 +++++++++++- templates/profile/general.searchname.tpl | 46 +++++++++++ templates/profile/general.tpl | 126 +++++++++++++++++++++++-------- 5 files changed, 218 insertions(+), 32 deletions(-) create mode 100644 templates/profile/general.searchname.tpl diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index d93cb4d..67bf48a 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -88,7 +88,26 @@ function selectType(selectCtrl, type) } } +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(); + }); +} +function removeSearchName(i) +{ + if (document.getElementById('search_name_'+i+'_new') != null) { + $('#search_name_'+i).remove(); + } else { + removeObject('search_name_'+i, 'search_name['+i+']'); + } +} // Addresses diff --git a/modules/profile.php b/modules/profile.php index 1346856..99695e0 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -38,6 +38,7 @@ class ProfileModule extends PLModule 'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/secteur' => $this->make_hook('ajax_secteur', 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), 'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE), 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE), 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC), @@ -427,6 +428,15 @@ class ProfileModule extends PLModule } } + function handler_ajax_searchname(&$page, $snid) + { + 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); + } + 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 11d3076..0bf8200 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -65,6 +65,22 @@ 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 ProfileAppli implements ProfileSetting { public function value(ProfilePage &$page, $field, $value, &$success) @@ -109,6 +125,10 @@ class ProfileGeneral extends ProfilePage $this->settings['freetext'] = $this->settings['nationalite'] = $this->settings['nick'] + = $this->settings['yourself'] + = $this->settings['display_name'] + = $this->settings['sort_name'] + = $this->settings['tooltip_name'] = null; $this->settings['synchro_ax'] = new ProfileBool(); @@ -130,9 +150,12 @@ class ProfileGeneral extends ProfilePage 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, IF(a1.aid IS NULL, -1, a1.aid) as appli_id1, a1.type as appli_type1, - IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2 + IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2, + n.yourself, n.display AS display_name, n.sort AS sort_name, + n.tooltip AS tooltip_name FROM auth_user_md5 AS u - INNER JOIN auth_user_quick AS q USING(user_id) + 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) LEFT JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0) LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1) WHERE u.user_id = {?}", S::v('uid', -1)); @@ -159,6 +182,14 @@ class ProfileGeneral extends ProfilePage WHERE type='photo' AND user_id = {?}", S::v('uid')); $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')); } protected function _saveData() @@ -195,6 +226,20 @@ class ProfileGeneral extends ProfilePage 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')); + } } public function _prepare(PlatalPage &$page, $id) diff --git a/templates/profile/general.searchname.tpl b/templates/profile/general.searchname.tpl new file mode 100644 index 0000000..085915d --- /dev/null +++ b/templates/profile/general.searchname.tpl @@ -0,0 +1,46 @@ +{**************************************************************************} +{* *} +{* 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 *} +{* *} +{**************************************************************************} + + + + {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} diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 37ca92d..131c3bd 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -33,43 +33,40 @@ - Nom - + Nom
- + {$nom} + - Prénom - + Prénom
- + {$prenom} + - Promotion + Affichage de ton nom - X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if} - modifier{if ($promo_sortie -3 == $promo)} pour les oranges{/if} + {if $tooltip_name}{$display_name}{else}{$display_name}{/if} + + {icon name="page_edit" title="Plus de détail"} + - Nom d'usage
- {if $smarty.session.sexe} - (Notamment nom d'épouse) - {else} - (si différent de {$nom} seulement) - {/if} + Promotion - {$nom_usage|default:"Aucun"} - modifier + X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if} + {icon name="page_edit" title="modifier"} @@ -119,6 +116,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + {if !$no_private_key} @@ -201,19 +280,6 @@ - - - -
- - - {icon name="flag_red" title="privé"} -   - Surnom - - -
Téléphone mobile -- 2.1.4