}
}
+function addNetworking()
+{
+ var i = 0;
+ var nw = 'networking_';
+ while (document.getElementById(nw + i) != null) {
+ i++;
+ }
+ var cb = document.forms.prof_annu['nw_type'];
+ var id = cb.value;
+ var text = cb.options[cb.selectedIndex].text;
+ var html = '<tr id="networking_' + i + '">'
+ + ' <td>'
+ + ' <span class="flags">'
+ + ' <input type="checkbox" name="networking[' + i + '][pub]"/>'
+ + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
+ + ' </span> '
+ + ' <input type="hidden" name="networking[' + i + '][type]" value="' + id + '"/>'
+ + ' <input type="hidden" name="networking[' + i + '][name]" value="' + text + '"/>'
+ + ' <img src="profile/networking/' + id + '" alt="' + text + '" title="' + text + '" />'
+ + ' <span class="title">'
+ + text
+ + ' </span>'
+ + ' </td>'
+ + ' <td>'
+ + ' <input type="text" name="networking[' + i + '][address]" value="" size="30"/>'
+ + ' <a href="javascript:removeNetworking(' + i + ')">'
+ + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
+ + ' </a>'
+ + ' </td>'
+ + '</tr>';
+
+ if (i == 0) {
+ $('#networking').after(html);
+ } else {
+ $('#networking_'+(i-1)).after(html);
+ }
+}
+
+function removeNetworking(id)
+{
+ $('#networking_' + id).remove();
+}
+
+function updateNetworking()
+{
+ 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 = '';
+ }
+}
+
// Addresses
function removeObject(id, pref)
}
}
+ $user['networking'] = Array();
+ $res = XDB::iterator("SELECT n.address, n.pub, m.network_type AS type, m.name, m.filter
+ FROM profile_networking AS n
+ INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type)
+ WHERE n.uid = {?}", $uid);
+ while($network = $res->next())
+ {
+ if (has_user_right($network['pub'], $view)) {
+ $user['networking'][] = $network;
+ }
+ }
+
return $user;
}
// }}}
}
}
+class ProfileNetworking implements ProfileSetting
+{
+ private $email;
+ private $pub;
+ private $web;
+
+ public function __construct()
+ {
+ $this->email = new ProfileEmail();
+ $this->pub = new ProfilePub();
+ $this->web = new ProfileWeb();
+ }
+
+ public function value(ProfilePage &$page, $field, $value, &$success)
+ {
+ if (is_null($value)) {
+ $value = array();
+ $res = XDB::iterator("SELECT n.address, n.network_type AS type, n.pub, m.name
+ FROM profile_networking AS n
+ INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type)
+ WHERE n.uid = {?}",
+ S::i('uid'));
+ while($network = $res->next()) {
+ $value[] = $network;
+ }
+ }
+ if (!is_array($value)) {
+ $value = array();
+ }
+ $res = XDB::iterator("SELECT filter, network_type AS type
+ FROM profile_networking_enum;");
+ $filters = array();
+ while($filter = $res->next()) {
+ $filters[$filter['type']] = $filter['filter'];
+ }
+ $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);
+ }
+ if (!$s) {
+ $success = false;
+ $network['error'] = true;
+ }
+ }
+ return $value;
+ }
+
+ public function save(ProfilePage &$page, $field, $value)
+ {
+ XDB::execute("DELETE FROM profile_networking
+ WHERE uid = {?}",
+ S::i('uid'));
+ if (!count($value)) {
+ return;
+ }
+ $insert = array();
+ foreach ($value as $id=>$network) {
+ XDB::execute("INSERT INTO profile_networking (uid, nwid, network_type, address, pub)
+ VALUES ({?}, {?}, {?}, {?}, {?})",
+ S::i('uid'), $id, $network['type'], $network['address'], $network['pub']);
+ }
+ }
+}
+
class ProfileGeneral extends ProfilePage
{
protected $pg_template = 'profile/general.tpl';
= new ProfileBool();
$this->settings['mobile'] = new ProfileTel();
$this->settings['web'] = new ProfileWeb();
+ $this->settings['networking'] = new ProfileNetworking();
$this->settings['appli1']
= $this->settings['appli2']
= new ProfileAppli();
public function _prepare(PlatalPage &$page, $id)
{
require_once "applis.func.inc.php";
+
+ $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());
}
}
--- /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 *}
+{* *}
+{**************************************************************************}
+
+<tr id="networking_{$i}">
+ <td>
+ <span class="flags">
+ <input type="checkbox"
+ {if $nw.pub neq 'private'} checked="checked"{/if}
+ name="networking[{$i}][pub]"/>
+ {icon name="flag_green" title="site public"}
+ </span>
+ <input type="hidden" name="networking[{$i}][type]" value="{$nw.type}"/>
+ <input type="hidden" name="networking[{$i}][name]" value="{$nw.name}"/>
+ <img src="profile/networking/{$nw.type}" alt="{nw.name}" title="{nw.name}" />
+ <span class="title">{$nw.name}</span>
+ </td>
+ <td>
+ <input type="text" name="networking[{$i}][address]" value="{$nw.address}"
+ {if $nw.error} class="error" {/if}
+ size="30"/>
+ <a href="javascript:removeNetworking({$i})">
+ {icon name=cross title="Supprimer cet élément"}
+ </a>
+ </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
</td>
</tr>
<tr>
+ <td colspan="2">
+ <span class="titre">Messageries, networking et sites web</span>
+ </td>
+ </tr>
+ <tr id="networking">
<td>
- <span class="flags">
- <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
- {icon name="flag_green" title="site public"}
- </span>
- <span class="titre">Page web Perso</span>
+ <span class="titre" style="margin-left:1em;">Type à ajouter</span>
</td>
<td>
- <input type="text" size="35" maxlength="95" name="web"
- {if $errors.web}class="error"{/if} value="{$web}" />
+ <select name="nw_type" onchange="updateNetworking()">
+ <option value=""></option>
+ {foreach from=$network_list item=network}
+ <option value="{$network.type}">{$network.name}</option>
+ {/foreach}
+ </select>
+ <span id="nw_add" style="display: none">
+ <a href="javascript:addNetworking();">{icon name=add title="Ajouter cette adresse"}</a>
+ </span>
</td>
</tr>
+ {foreach from=$networking item=network key=id}
+ {include file="profile/general.networking.tpl" nw=$network i=$id}
+ {/foreach}
<tr class="pair">
<td>
<div>
{if $x.gpxs_join}<div><em class="intitule">Groupe{if count($x.gpxs) > 1}s{/if} et institution{if count($x.gpxs) > 1}s{/if} X : </em>
<span><br/>{$x.gpxs_join|smarty:nodefaults}</span></div>{/if}
{/if}
+ {if $x.networking}
+ <h2>Messageries, networking et sites web :</h2>
+ {foreach from=$x.networking item=network}
+ <img style="width: auto; padding: 0" src="profile/networking/{$network.type}" alt="{$network.name}" title="{$network.name}"/>
+ {if $network.filter == 'web'}
+ <a href="{$network.address}">{$network.address}</a>
+ {else}
+ {$network.address}
+ {/if}
+ <br/>
+ {/foreach}
+ {/if}
{if $x.freetext}
<h2>Commentaires :</h2>
<span>{$x.freetext|miniwiki|smarty:nodefaults}</span>
{if $logged}
{if $x.nickname} (alias {$x.nickname}){/if}
{/if}
- {if $x.web} <a href="{$x.web}">{icon name="world_go" title="Site Web"}</a>{/if}
{if $logged}
{if !$x.dcd}<a href="vcard/{$x.forlife}.vcf">{*
*}{icon name=vcard title="Afficher la carte de visite"}</a>{/if}
--- /dev/null
+CREATE TABLE IF NOT EXISTS `profile_networking_enum` (
+ `network_type` tinyint unsigned NOT NULL,
+ `name` varchar(30) NOT NULL,
+ `icon` varchar(50) NOT NULL COMMENT 'icon filename',
+ `filter` enum('email','web','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses',
+ PRIMARY KEY (`network_type`)
+) CHARSET=utf8 COMMENT='types of networking addresses';
+
+CREATE TABLE IF NOT EXISTS `profile_networking` (
+ `uid` smallint unsigned NOT NULL COMMENT 'user id',
+ `nwid` tinyint unsigned NOT NULL COMMENT 'number of the address for the user',
+ `network_type` tinyint unsigned NOT NULL,
+ `address` varchar(255) NOT NULL,
+ `pub` enum('private','public') NOT NULL DEFAULT 'private',
+ PRIMARY KEY (`uid`, `nwid`)
+) CHARSET=utf8 COMMENT='networking addresses';
+
+
+INSERT INTO `profile_networking_enum` (`network_type`, `name`, `icon`, `filter`)
+ VALUES (0, 'Page web', 'web.gif', 'web');
+
+INSERT INTO `profile_networking` (`uid`, `nwid`, `network_type`, `address`, `pub`)
+ SELECT `user_id`, 0, 0, `profile_web`, `profile_web_pub`
+ FROM `auth_user_quick`
+ WHERE `profile_web` <> "";
+