From 04a94b1d89f180b66e0ed917ecc077a5e8e31b97 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 5 Mar 2009 22:33:42 +0100 Subject: [PATCH] Support of networking in profile. Signed-off-by: Florent Bruneau --- classes/profile.php | 39 +++++++++++++++++++++++++++++++++++++++ templates/include/minifiche.tpl | 7 ++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index 22f4833..d68c959 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -45,6 +45,11 @@ class Profile const JOBS_FINISHED = 0x004000; const JOBS_CURRENT = 0x008000; + const NETWORKING_ALL = 0x000000; + const NETWORKING_WEB = 0x010000; + const NETWORKING_IM = 0x020000; + const NETWORKING_SOCIAL = 0x040000; + private $pid; private $hrpid; private $data = array(); @@ -247,6 +252,40 @@ class Profile } + /** Networking + */ + + public function getNetworking($flags, $limit = null) + { + $where = XDB::format('pn.uid = {?}', $this->id()); + if ($flags & self::NETWORKING_WEB) { + $where .= ' AND pn.network_type = 0'; // XXX hardcoded reference to web site index + } + if ($this->visibility) { + $where .= ' AND pn.pub IN ' . XDB::formatArray($this->visibility); + } + $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit); + return XDB::iterator('SELECT pne.name, pne.icon, + IF (LENGTH(pne.link) > 0, REPLACE(pne.link, \'%s\', pn.address), + pn.address) AS address + FROM profile_networking AS pn + INNER JOIN profile_networking_enum AS pne ON (pn.network_type = pne.network_type) + WHERE ' . $where . ' + ORDER BY pn.network_type, pn.nwid + ' . $limit); + } + + public function getWebSite() + { + $site = $this->getNetworking(self::NETWORKING_WEB, 1); + if ($site->total() != 1) { + return null; + } + $site = $site->next(); + return $site['address']; + } + + public function owner() { return User::getSilent($this); diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 57a1ab3..4135d20 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -114,12 +114,13 @@
{if !$dead} {assign var=address value=$profile->getMainAddress()} - {if $c.web || $profile->mobile || $address.country || $c.entreprise || (!$dead && !$registered)} + {assign var=web value=$profile->getWebSite()} + {if $web || $profile->mobile || $address.country || $c.entreprise || (!$dead && !$registered)} - {if $c.web} + {if $web} - + {/if} {if $address.country} -- 2.1.4
Page web :{$c.web}{$web}