root/trunk/inc_xml/foaf.inc.php

Revision 51, 2.6 KB (checked in by mat, 6 years ago)

Filtre tous les champs pour le FOAF. Pas terrible (copie du tableau tout ca)
mais on verra a faire mieux plus tard, au moins j'utilise une fonction qui
pourra etre re-utilisable.

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25$id = $user['info']['id'];
26$weight = 'everyone';
27
28$user['general'] = $db->getRow('SELECT birthday,description,web FROM user_general WHERE id=?', array($id));
29$user['professionel'] = $db->getRow('SELECT web FROM user_professional WHERE id=?', array($id));
30$user['contact'] = $db->getRow('SELECT email, phone, im, im_type, im2, im2_type FROM user_contact WHERE id=?', array($id));
31
32$access = array();
33$access['general'] = get_access_list($id, 'user_general');
34$access['professionel'] = get_access_list($id, 'user_professionel');
35$access['contact'] = get_access_list($id, 'user_contact');
36
37$user['contact']['email'] = 'mailto:' . $user['contact']['email'];
38$user['contact']['email_sha1'] = sha1($user['contact']['email']);
39
40// Filtre chaque partie du profile, ne laisse que les infos accessibles par tout
41// le monde
42$user['contact'] = filter_table_with_weight($user['contact'], $access['contact'], $weight);
43$user['professionel'] = filter_table_with_weight($user['professionel'], $access['professionel'], $weight);
44$user['general'] = filter_table_with_weight($user['general'], $access['general'], $weight);
45
46$friends_r = $db->query('SELECT user_contact.email AS email, user.fname AS fname, user.lname AS lname, user.login AS login, user.id AS id FROM user_contact LEFT JOIN user_general USING(id) LEFT JOIN user USING(id) LEFT JOIN  relation USING(id) WHERE relation.id_friend=?', array($id));
47if(DB::isError($friends_r))
48{
49    error_log(__FILE__.' | '.$friends_r->getUserInfo());
50    exit();
51}
52
53while($friend = $friends_r->fetchRow())
54{
55    $user['friends'][$friend['id']] = $friend;
56    $user['friends'][$friend['id']]['email_sha1'] = sha1('mailto:' . $friend['email']);
57}
58
59?>
Note: See TracBrowser for help on using the browser.