root/trunk/inc/profile.inc.php

Revision 42, 4.5 KB (checked in by alexx, 7 years ago)

Remove hard coded condition (get information in global config vars instead)

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$_SMARTY['Title'] =  'Profile';
26
27$user['info'] =& get_cache_user_info($url_id, NULL, true);
28$user['photo'] = build_image_url($url_id);
29
30// Recup des infos pour les amis du profile
31$idx=0;
32foreach($user['info']['friends_id'] as $friend_id)
33{
34    if($idx>9)
35        break;;
36    $user['friends'][$friend_id] =& get_cache_user_info($friend_id);
37    $user['friends'][$friend_id]['photo'] = build_thumb_url($friend_id);
38    $idx++;
39}
40
41// Recup des infos pour les amis du profile
42if($user['info']['communities_id'])
43{
44        $user_comm_r = $db->query('SELECT c.id AS id, c.id_comm AS id_comm, c.name AS name, c.nb_members AS nb_members, c.moderated AS moderated, c.last_post_date AS last_post_date FROM community AS c LEFT JOIN user_comm AS u USING (id_comm) WHERE u.id=? ORDER BY c.last_post_date DESC LIMIT 0,10', array($url_id));
45        while($user_comm = $user_comm_r->fetchRow())
46        {
47        $user_comm['photo'] = build_logo_thumb_url($user_comm['id'], $user_comm['id_comm']);
48                $user['communities'][$user_comm['id_comm']] = $user_comm;
49        }
50}
51
52// Determination de la relation avec le user ...
53$user['path'] = array();
54
55if($url_id == $_SESSION['my_id'])
56{
57    $user['relation_type'] = 'myself';
58}
59elseif(in_array($url_id, $_SESSION['my_friends_id']) )
60{   
61    $user['relation_type'] = 'friends';
62    $user['path'][$_SESSION['my_id']] = $_SESSION['my_fname'];
63    $user['path'][$url_id] = $user['info']['fname'];
64    $db->query('UPDATE relation SET last_visit=? WHERE id=? AND id_friend=?', array(time(), $_SESSION['my_id'], $url_id));
65    $user['karma'] = $db->getRow('SELECT fan, fun, cool, sexy, level, type FROM relation WHERE id_friend=? AND id=?', array($url_id, $_SESSION['my_id']));
66}
67elseif($intermediaire = array_intersect($_SESSION['my_friends_id'], $user['info']['friends_id']))
68{
69    sort($intermediaire);
70    $user['relation_type'] = 'friends_of_friends';
71    $user['path'][$_SESSION['my_id']] = $_SESSION['my_fname'];
72    if($user['friends'][$intermediaire[0]]['fname'])
73        $user['path'][$intermediaire[0]] = $user['friends'][$intermediaire[0]]['fname'];
74    else
75    {
76        $gars = get_cache_user_info($intermediaire[0], 'fname');
77        $user['path'][$intermediaire[0]] = $gars['fname'];
78    }
79    $user['path'][$url_id] = $user['info']['fname'];
80}
81else
82    $user['relation_type'] = 'members';
83
84if($user['relation_type'] == 'friends' || $_SESSION['my_login'] == $config['admin_login'])
85{
86    $id_parent = $db->getOne('SELECT id_parent FROM user WHERE id=?', array($url_id));
87    if($_SESSION['my_id'] == $id_parent  || $_SESSION['my_login'] == $config['admin_login'])
88    {
89        $user['invitation']['done'] = $db->getOne('SELECT COUNT(id) FROM invitation_email WHERE id_invit=? AND status=?', array($url_id, 'done'));
90        $user['invitation']['waiting'] = $db->getOne('SELECT COUNT(id) FROM invitation_email WHERE id_invit=? AND status=?', array($url_id, 'doing'));
91        $user['invitation']['failed'] = $db->getOne('SELECT COUNT(id) FROM invitation_email WHERE id_invit=? AND status=?', array($url_id, 'stop'));
92    }
93}
94// Recuperation du profil demand�******************
95
96include('_profile/all.inc.php');
97
98if($url_id != $_SESSION['my_id'])
99{
100    $_SMARTY['leftmenu']["/messages/write/$url_id/contact"] = 'Send message';
101    if(!in_array($url_id, $_SESSION['my_friends_id']))
102        $_SMARTY['leftmenu']["/friends/$url_id/invitation"] = 'Add as a friend';
103    elseif($id_parent != $_SESSION['my_id'])
104        $_SMARTY['leftmenu']["/action/".$url_id."/friends/unlink"] = "Delete friendship' link";
105}
106
107$_SMARTY['leftmenu']['/metalbum/'.$url_id] = 'Meta Album';
108
109$_SMARTY['user'] = $user;
110
111?>
Note: See TracBrowser for help on using the browser.