// {{{ 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';
}
// }}}
$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);
}
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 {?}
($flags & Profile::NETWORKING_ALL)) {
$nws[$id] = $nw;
++$nb;
- if ($nb >= $limit) {
+ if (isset($limit) && $nb >= $limit) {
break;
}
}
{
$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);
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);
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) {
$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) {
}
$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']);
}
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());
{if count($networking) > 0}
<h2>Sur le web...</h2>
{foreach from=$networking item=network}
- <img style="width: auto; padding: 0" src="profile/networking/{$network.network_type}" alt="{$network.name}" title="{$network.name}"/>
- {if $network.filter == 'web'}
- <a href="{$network.address}">{$network.address}</a>
- {elseif $network.link != ''}
- <a href="{$network.link}">{$network.address}</a>
+ <img style="width: auto; padding: 0" src="profile/networking/{$network.nwid}" alt="{$network.name}" title="{$network.name}"/>
+ {if $network.link}
+ <a href="{$network.link|replace:'%s':$network.address}">{$network.address}</a>
{else}
{$network.address}
{/if}