root/trunk/inc/my.inc.php

Revision 24, 3.6 KB (checked in by alexx, 7 years ago)
  • add Meta Album feature (to link .node profile with external album on Flickr or interAlbum.com)
  • change method to find BASEPATH (to be more reliable)
  • add Meta Album link to profile page (to be modified later)
  • modify default data for db (old data isn't good with cache)
  • add is_valid function to .... valid things ;)
  • add config param for flickr api_key
  • DB: modify database structure to add metalbum table
    CREATE TABLE `metalbum` (
    `id` varchar(32) NOT NULL default '',
    `type` varchar(16) NOT NULL default '',
    `login` varchar(64) NOT NULL default '',
    `nb_items` int(10) unsigned default NULL,
    PRIMARY KEY  (`id`,`type`,`login`)
    ) TYPE=MyISAM;
    
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/*
26header('content-type: text/plain');
27print_r($menu);
28print_r($smenu);
29print_r($ssmenu);
30exit();
31*/
32$_SMARTY['Title'] =  'Home';
33
34$idx = 0;
35
36$nyrk['total'] = $db->getOne('SELECT value FROM global_data WHERE name=?', array('nb_nodians'));
37$nyrk['actually'] = $db->getOne('SELECT value FROM global_data WHERE name=?', array('actually'));
38
39$my['info'] = get_cache_user_info($_SESSION['my_id']);
40$my['info']['nb_unread_messages'] = $db->getOne('SELECT COUNT(id) FROM message WHERE id=? AND flag=? AND box=?', array($_SESSION['my_id'], 'new', 'inbox'));
41
42
43if($_SESSION['nb_foaf_timestamp'] < time() - 86400)
44{
45    $foaf_id = $db->getCol('SELECT DISTINCT ( id_friend ) FROM relation WHERE id IN (\'!\') GROUP BY id_friend', 0, array(implode("','", $my['info']['friends_id'])));
46
47    foreach($foaf_id as $ids)
48                $foaf[$ids]=1;
49
50    foreach($_SESSION['my_friends_id'] as $ids)
51                $foaf[$ids]=1;
52   
53    $my['info']['nb_friends_of_friends'] = count($foaf)-1;
54
55    $_SESSION['nb_foaf'] = $my['info']['nb_friends_of_friends'];
56    $_SESSION['nb_foaf_timestamp']=time();
57}
58else
59    $my['info']['nb_friends_of_friends'] = $_SESSION['nb_foaf'];
60
61error_log($config['domain'].' | '.$_SESSION['my_login'].' | network size ==> '.$_SESSION['nb_foaf']);
62
63$idx=0;
64foreach($my['info']['friends_id'] as $friend_id)
65{
66    if($idx>9)
67        break;
68        $my['friends'][$friend_id] =& get_cache_user_info($friend_id);
69        $my['friends'][$friend_id]['photo'] = build_thumb_url($friend_id);
70    $idx++;
71}
72
73// Recup des infos pour les amis du profile
74if($my['info']['communities_id'])
75{
76    $my_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($_SESSION['my_id']));
77    while($my_comm = $my_comm_r->fetchRow())
78    {
79        $my['communities'][$my_comm['id_comm']] = $my_comm;
80        $my['communities'][$my_comm['id_comm']]['photo'] = build_logo_thumb_url($my_comm['id'], $my_comm['id_comm']);
81    }
82}
83
84/************* menu *******************/
85$_SMARTY['leftmenu']["/profile/$url_id"] = 'View my own profile';
86
87if($my['info']['nb_photos'] > 0)
88        $_SMARTY['leftmenu']["/album/$url_id"] = 'Album';
89$_SMARTY['leftmenu']["/metalbum/$url_id"] = 'Meta Album';
90
91if($my['info']['nb_blogs'] > 0)
92        $_SMARTY['leftmenu']["/blog/$url_id"] = 'Blog';
93
94if($my['info']['nb_bookmarks'] > 0)
95        $_SMARTY['leftmenu']["/bookmarks/$url_id"] = 'Bookmarks';
96
97
98/************************************/
99
100$_SMARTY['my'] = $my;
101
102?>
Note: See TracBrowser for help on using the browser.