From 1f5cd0048509cf752b1a95106367ca0b1a75683c Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Wed, 23 Jun 2010 00:40:41 +0200 Subject: [PATCH] Fix networking with new network_type issues introduced by previous commit --- classes/direnum.php | 4 ++-- classes/userfilter.php | 2 +- include/profilefields.inc.php | 4 ++-- modules/profile.php | 4 ++-- modules/profile/general.inc.php | 16 ++++++++-------- templates/profile/profile.tpl | 8 +++----- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/classes/direnum.php b/classes/direnum.php index 90fb331..e0b485d 100644 --- a/classes/direnum.php +++ b/classes/direnum.php @@ -617,12 +617,12 @@ class DE_JobDescription extends DirEnumeration // {{{ class DE_Networking class DE_Networking extends DirEnumeration { - protected $idfield = 'profile_networking_enum.network_type'; + protected $idfield = 'profile_networking_enum.nwid'; protected $valfield = 'profile_networking_enum.name'; protected $from = 'profile_networking_enum'; - protected $ac_join = 'INNER JOIN profile_networking ON (profile_networking.network_type = profile_networking_enum.network_type)'; + protected $ac_join = 'INNER JOIN profile_networking ON (profile_networking.nwid = profile_networking_enum.nwid)'; protected $ac_unique = 'profile_networking.pid'; } // }}} diff --git a/classes/userfilter.php b/classes/userfilter.php index 18bdadd..035ee25 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -1048,7 +1048,7 @@ class UFC_Networking implements UserFilterCondition $conds = array(); $conds[] = $sub . '.address ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value); if ($this->type != -1) { - $conds[] = $sub . '.network_type = ' . XDB::format('{?}', $this->type); + $conds[] = $sub . '.nwid = ' . XDB::format('{?}', $this->type); } return implode(' AND ', $conds); } diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index fc18b11..d2de132 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -477,7 +477,7 @@ class ProfileNetworking extends ProfileField public static function fetchData(array $pids, ProfileVisibility $visibility) { - $data = XDB::iterator('SELECT pid, id, address, pne.network_type, pne.filter, pne.link + $data = XDB::iterator('SELECT pid, id, address, pne.nwid, pne.network_type, pne.link, pne.name FROM profile_networking AS pn LEFT JOIN profile_networking_enum AS pne USING(nwid) WHERE pid IN {?} AND pub IN {?} @@ -502,7 +502,7 @@ class ProfileNetworking extends ProfileField ($flags & Profile::NETWORKING_ALL)) { $nws[$id] = $nw; ++$nb; - if ($nb >= $limit) { + if (isset($limit) && $nb >= $limit) { break; } } diff --git a/modules/profile.php b/modules/profile.php index dbfc7d2..beb6c5d 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -134,7 +134,7 @@ class ProfileModule extends PLModule { $res = XDB::query("SELECT icon FROM profile_networking_enum - WHERE network_type = {?}", + WHERE nwid = {?}", $mid); $img = dirname(__FILE__) . '/../htdocs/images/networking/' . $res->fetchOneCell(); $type = mime_content_type($img); @@ -758,7 +758,7 @@ class ProfileModule extends PLModule function handler_admin_networking(&$page, $action = 'list', $id = null) { $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking'); $page->assign('title', 'Gestion des types de networking'); - $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type'); + $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'nwid'); $table_editor->describe('name', 'intitulé', true); $table_editor->describe('icon', 'nom de l\'icône', false); $table_editor->describe('filter', 'filtre', true); diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index c7f780b..e80a593 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -334,16 +334,15 @@ class ProfileSettingNetworking implements ProfileSetting public function value(ProfilePage &$page, $field, $value, &$success) { if (is_null($value)) { - $value = XDB::fetchAllAssoc("SELECT n.address, n.network_type AS type, n.pub, m.name + $value = XDB::fetchAllAssoc("SELECT n.address, n.pub, n.nwid AS type FROM profile_networking AS n - INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type) WHERE n.pid = {?}", $page->pid()); } if (!is_array($value)) { $value = array(); } - $filters = XDB::fetchAllAssoc('type', 'SELECT filter, network_type AS type + $filters = XDB::fetchAllAssoc('type', 'SELECT filter, nwid AS type, name FROM profile_networking_enum;'); $success = true; foreach($value as $i=>&$network) { @@ -356,11 +355,12 @@ class ProfileSettingNetworking implements ProfileSetting $network['error'] = false; $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s); $s = true; - if ($filters[$network['type']] == 'web') { + $network['name'] = $filters[$network['type']]['name']; + if ($filters[$network['type']]['filter'] == 'web') { $network['address'] = $this->web->value($page, 'address', $network['address'], $s); - } elseif ($filters[$network['type']] == 'email') { + } elseif ($filters[$network['type']]['filter'] == 'email') { $network['address'] = $this->email->value($page, 'address', $network['address'], $s); - } elseif ($filters[$network['type']] == 'number') { + } elseif ($filters[$network['type']]['filter'] == 'number') { $network['address'] = $this->number->value($page, 'address', $network['address'], $s); } if (!$s) { @@ -382,7 +382,7 @@ class ProfileSettingNetworking implements ProfileSetting } $insert = array(); foreach ($value as $id=>$network) { - XDB::execute("INSERT INTO profile_networking (pid, nwid, network_type, address, pub) + XDB::execute("INSERT INTO profile_networking (pid, id, nwid, address, pub) VALUES ({?}, {?}, {?}, {?}, {?})", $page->pid(), $id, $network['type'], $network['address'], $network['pub']); } @@ -600,7 +600,7 @@ class ProfileSettingGeneral extends ProfilePage require_once "emails.combobox.inc.php"; fill_email_combobox($page, $this->owner, $this->profile); - $res = XDB::query("SELECT nw.network_type AS type, nw.name + $res = XDB::query("SELECT nw.nwid AS type, nw.name FROM profile_networking_enum AS nw ORDER BY name"); $page->assign('network_list', $res->fetchAllAssoc()); diff --git a/templates/profile/profile.tpl b/templates/profile/profile.tpl index 411a59f..1c8c058 100644 --- a/templates/profile/profile.tpl +++ b/templates/profile/profile.tpl @@ -66,11 +66,9 @@ function chgMainWinLoc(strPage) {if count($networking) > 0}

Sur le web...

{foreach from=$networking item=network} - {$network.name} - {if $network.filter == 'web'} - {$network.address} - {elseif $network.link != ''} - {$network.address} + {$network.name} + {if $network.link} + {$network.address} {else} {$network.address} {/if} -- 2.1.4