From: Guillaume Bandet Date: Fri, 20 Jun 2008 11:29:32 +0000 (+0200) Subject: Changes how is displayed networking information X-Git-Tag: xorg/1.0.0~332^2~557 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=92c3f9e5a1c480d9c25dd98aff56e792c378d0fe;p=platal.git Changes how is displayed networking information --- diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 2b615e8..4e16e29 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -113,39 +113,38 @@ function removeSearchName(i) function addNetworking() { var i = 0; - var nw = 'networking_'; - while (document.getElementById(nw + i) != null) { + var nws = 'networking_'; + while (document.getElementById(nws + i) != null) { i++; } - var cb = document.forms.prof_annu['nw_type']; - var id = cb.value; - var text = cb.options[cb.selectedIndex].text; + var namefirst = ''; var html = '' - + ' ' - + ' ' - + ' ' - + ' site public' - + '  ' - + ' ' - + ' ' - + ' ' + text + '' - + ' ' - + text - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' cross' - + ' ' + + ' ' + + '
' + + ' ' + + ' ' + + ' site public' + + '  ' + + ' ' + + ' ' + + '
' + + '
' + + ' ' + + ' ' + + ' cross' + + ' ' + + '
' + ' ' + ''; - if (i == 0) { - $('#networking').after(html); - } else { - $('#networking_'+(i-1)).after(html); - } + $('#networking').before(html); } function removeNetworking(id) @@ -153,14 +152,14 @@ function removeNetworking(id) $('#networking_' + id).remove(); } -function updateNetworking() +function updateNetworking(i) { - var val = document.forms.prof_annu['nw_type'].value; - if (val == '') { - document.getElementById('nw_add').style.display = 'none'; - } else { - document.getElementById('nw_add').style.display = ''; + var name = document.getElementById('networking_name_' + i); + var type = document.getElementById('networking_type_' + i); + if (type != null && name != null) { + name.value = type.options[type.selectedIndex].text; } + } // Addresses diff --git a/modules/profile.php b/modules/profile.php index a62c930..89a4d56 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -833,6 +833,7 @@ class ProfileModule extends PLModule $page->assign('xorg_title', 'Polytechnique.org - Administration - Format d\'affichage des numéros de téléphone '); $page->assign('title', 'Gestion des formats d\'affichage des numéros de téléphone'); $table_editor = new PLTableEditor('admin/phones_format_display', 'phone_formats', 'phoneprf',true); + $table_editor->describe('phoneprf', 'Préfixe International', true); $table_editor->describe('format', 'format d\'Affichage (ex: (+p) ### ## ## ##)', true); if ($action == 'update') { if ((Post::has('phoneprf')) && (Post::v('phoneprf') == $id)) { diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index ccff9a1..1351848 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -179,22 +179,26 @@ class ProfileNetworking implements ProfileSetting } $success = true; foreach($value as $i=>&$network) { - if(!isset($network['pub'])) { - $network['pub'] = 'private'; - } - $network['error'] = false; - $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s); - $s = true; - if ($filters[$network['type']] == 'web') { - $network['address'] = $this->web->value($page, 'address', $network['address'], $s); - } elseif ($filters[$network['type']] == 'email') { - $network['address'] = $this->email->value($page, 'address', $network['address'], $s); - } elseif ($filters[$network['type']] == 'number') { - $network['address'] = $this->number->value($page, 'address', $network['address'], $s); - } - if (!$s) { - $success = false; - $network['error'] = true; + if (!trim($network['address'])) { + unset($value[$i]); + } else { + if (!isset($network['pub'])) { + $network['pub'] = 'private'; + } + $network['error'] = false; + $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s); + $s = true; + if ($filters[$network['type']] == 'web') { + $network['address'] = $this->web->value($page, 'address', $network['address'], $s); + } elseif ($filters[$network['type']] == 'email') { + $network['address'] = $this->email->value($page, 'address', $network['address'], $s); + } elseif ($filters[$network['type']] == 'number') { + $network['address'] = $this->number->value($page, 'address', $network['address'], $s); + } + if (!$s) { + $success = false; + $network['error'] = true; + } } } return $value; diff --git a/modules/search.php b/modules/search.php index 55e5d20..97f8773 100644 --- a/modules/search.php +++ b/modules/search.php @@ -168,11 +168,6 @@ class SearchModule extends PLModule $page->assign('advanced',1); $page->addJsLink('jquery.autocomplete.js'); - $res = XDB::iterator("SELECT nw.network_type AS type, nw.name - FROM profile_networking_enum AS nw - ORDER BY name ;"); - $page->assign('network_list', $res->fetchAllAssoc()); - if (!Env::has('rechercher') && $action != 'geoloc') { $this->form_prepare(); } else { @@ -182,6 +177,8 @@ class SearchModule extends PLModule 'secteur' => array('field' => 'id', 'table' => 'emploi_secteur', 'text' => 'label', 'exact' => false), 'nationalite' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'nat', 'exact' => 'false'), 'binet' => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false), + 'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum', + 'text' => 'name', 'exact' => false), 'groupex' => array('field' => 'id', 'table' => 'groupex.asso', 'text' => "(a.cat = 'GroupesX' OR a.cat = 'Institutions') AND pub = 'public' AND nom", 'exact' => false), @@ -272,6 +269,13 @@ class SearchModule extends PLModule $beginwith = false; $realid = '`binets_def`.`id`'; break; + case 'networking_typeTxt': + $db = '`profile_networking_enum` INNER JOIN + `profile_networking` ON(`profile_networking`.`network_type` = `profile_networking_enum`.`network_type`)'; + $field = '`profile_networking_enum`.`name`'; + $unique = 'uid'; + $realid = '`profile_networking_enum`.`network_type`'; + break; case 'city': $db = '`geoloc_city` INNER JOIN `adresses` ON(`geoloc_city`.`id` = `adresses`.`cityid`)'; @@ -424,6 +428,11 @@ class SearchModule extends PLModule case 'binet': $db = '`binets_def`'; break; + case 'networking_type': + $db = '`profile_networking_enum`'; + $field = '`name`'; + $id = '`network_type`'; + break; case 'country': $db = '`geoloc_pays`'; $field = '`pays`'; diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 6eab490..8113380 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -515,6 +515,19 @@ class PhoneSField extends RefSField } } +class IndexSField extends RefSField +{ + function IndexSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition) + { + $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true); + } + + function get_request() + { + $this->value = trim(Env::v($this->fieldFormName)); + } +} + class MapSField extends RefSField { var $mapId; diff --git a/modules/search/search.inc.php b/modules/search/search.inc.php index e621ca2..7db59a7 100644 --- a/modules/search/search.inc.php +++ b/modules/search/search.inc.php @@ -75,9 +75,9 @@ function advancedSearchFromInput() $nwAddressField = new RefSField('networking_address', array('nw.address'), 'profile_networking', 'nw', 'nw.uid=u.user_id', false); if (Env::v('networking_address') == '') { - $nwTypeField = new RefSField('networking_type', array('nwe.name'), array('profile_networking', 'profile_networking_enum'), array('nw', 'nwe'), array('nw.uid = u.user_id', 'nwe.network_type = nw.network_type'), true); + $nwTypeField = new IndexSField('networking_type', array('nwe.network_type'), array('profile_networking', 'profile_networking_enum'), array('nw', 'nwe'), array('nw.uid = u.user_id', 'nwe.network_type = nw.network_type')); } else { - $nwTypeField = new RefSField('networking_type', array('nwe.name'), 'profile_networking_enum', 'nwe', 'nwe.network_type = nw.network_type', true); + $nwTypeField = new IndexSField('networking_type', array('nwe.network_type'), 'profile_networking_enum', 'nwe', 'nwe.network_type = nw.network_type'); } $nwPhoneField = new PhoneSField('phone_number', array('t.search_tel'), 'telephone', 't', 't.uid=u.user_id'); return array( diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 64be0cb..36dbf56 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -109,7 +109,7 @@   |   Networking   |   - Format d'affichage des numéros de téléphone + Téléphone diff --git a/templates/profile/general.networking.tpl b/templates/profile/general.networking.tpl index e7f7f28..97474a8 100644 --- a/templates/profile/general.networking.tpl +++ b/templates/profile/general.networking.tpl @@ -21,25 +21,27 @@ {**************************************************************************} - - - - {icon name="flag_green" title="site public"} -   - - - {nw.name} - {$nw.name} - - - - - {icon name=cross title="Supprimer cet élément"} - + +
+ + + {icon name="flag_green" title="site public"} +   + + + {$nw.name} + {$nw.name} +
+
+ + + {icon name=cross title="Supprimer cet élément"} + +
diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 0ecaefc..9eebac8 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -290,25 +290,38 @@ Messageries, networking et sites web - - - Type à ajouter - - - - - - {foreach from=$networking item=network key=id} {include file="profile/general.networking.tpl" nw=$network i=$id} {/foreach} + + + +
+ + {icon name=add title="Ajouter une adresse"} Ajouter une adresse + +
+ + +
diff --git a/templates/profile/profile.tpl b/templates/profile/profile.tpl index 405987f..9ddee57 100644 --- a/templates/profile/profile.tpl +++ b/templates/profile/profile.tpl @@ -51,7 +51,7 @@ function chgMainWinLoc(strPage)
{$x.gpxs_join|smarty:nodefaults}
{/if} {/if} {if $x.networking} -

Messageries, networking et sites web :

+

Sur le web...

{foreach from=$x.networking item=network} {$network.name} {if $network.filter == 'web'} diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index 5e61843..abee6af 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -409,31 +409,22 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont - Messageries, networking et sites webs - - - - Adresse - - - - - - - - Type + + Networking et sites webs - + + + + + +
+ + + + + {icon name="table" title="Tous les types d'adresse"} +
{if $smarty.session.auth ge AUTH_COOKIE}