librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1080] Starting user group page


From: Toby Inkster
Subject: [Librefm-commits] [1080] Starting user group page
Date: Thu, 30 Apr 2009 21:31:54 +0000

Revision: 1080
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1080
Author:   tobyink
Date:     2009-04-30 21:31:53 +0000 (Thu, 30 Apr 2009)
Log Message:
-----------
Starting user group page

Modified Paths:
--------------
    trunk/nixtape/data/Group.php

Added Paths:
-----------
    trunk/nixtape/user-groups.php

Modified: trunk/nixtape/data/Group.php
===================================================================
--- trunk/nixtape/data/Group.php        2009-04-30 20:30:51 UTC (rev 1079)
+++ trunk/nixtape/data/Group.php        2009-04-30 21:31:53 UTC (rev 1080)
@@ -113,13 +113,28 @@
                return 1;
        }
        
-       static function groupList ()
+       static function groupList ($user=false)
        {
                global $mdb2;
-               $res = $mdb2->query("SELECT g.groupname, g.owner, g.fullname, 
g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype, COUNT(*) 
AS member_count "
-                       ."FROM Groups g "
-                       ."LEFT JOIN Group_Members gm ON 
gm.groupname=g.groupname "
-                       ."GROUP BY g.groupname, g.owner, g.fullname, g.bio, 
g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype");
+
+               if ($user)
+               {
+                       $res = $mdb2->query("SELECT gc.* FROM "
+                               . "Group_Members m "
+                               ."INNER JOIN (SELECT g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count "
+                               ."FROM Groups g "
+                               ."LEFT JOIN Group_Members gm ON 
gm.groupname=g.groupname "
+                               ."GROUP BY g.groupname, g.owner, g.fullname, 
g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype) gc "
+                               ."ON m.groupname=gc.groupname "
+                               ."WHERE m.member=".$mdb2->quote($user->name, 
'text'));
+               }
+               else
+               {
+                       $res = $mdb2->query("SELECT g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count "
+                               ."FROM Groups g "
+                               ."LEFT JOIN Group_Members gm ON 
gm.groupname=g.groupname "
+                               ."GROUP BY g.groupname, g.owner, g.fullname, 
g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype");
+               }
                
                if(PEAR::isError($res))
                {

Added: trunk/nixtape/user-groups.php
===================================================================
--- trunk/nixtape/user-groups.php                               (rev 0)
+++ trunk/nixtape/user-groups.php       2009-04-30 21:31:53 UTC (rev 1080)
@@ -0,0 +1,80 @@
+<?php
+
+/* Libre.fm -- a free network service for sharing your music listening habits
+
+   Copyright (C) 2009 Libre.fm Project
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Affero General Public License as published by
+   the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+
+   You should have received a copy of the GNU Affero General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+require_once('database.php');
+require_once('templating.php');
+require_once('data/Group.php');
+require_once('data/User.php');
+require_once('data/TagCloud.php');
+require_once('data/Server.php');
+
+
+if(!isset($_GET['user']) && $logged_in == false) {
+       $smarty->assign('error', 'Error!');
+       $smarty->assign('details', 'User not set! You shouldn\'t be here!');
+       $smarty->display('error.tpl');
+       die();
+}
+
+$user = new User($_GET['user']);
+
+if(isset($user->name)) {
+
+       $smarty->assign('geo', Server::getLocationDetails($user->location_uri));
+       $smarty->assign('userlevel', $user->userlevel);
+       $smarty->assign('avatar', $user->getAvatar());
+       $aUserTagCloud =  TagCloud::GenerateTagCloud('Scrobbles', 'artist', 40, 
$user->name);
+       if (!PEAR::isError ($aUserTagCloud)) {
+               $smarty->assign('user_tagcloud',$aUserTagCloud);
+       }
+       $smarty->assign('isme', ($_SESSION['user']->name == $user->name));
+       $smarty->assign('me', $user);
+       $smarty->assign('profile', true);
+       
+       $smarty->assign('groups', Group::listGroups($user));
+
+       $smarty->assign('extra_head_links', array(
+                       array(
+                               'rel'=>'alternate',
+                               'type' => 'application/rss+xml' ,
+                               'title' => 'RSS 1.0 Feed (Recent plays)',
+                               'href' => 
$base_url.'/rdf.php?fmt=rss&page='.htmlentities(str_replace($base_url, '', 
$user->getURL('recent-tracks')))
+                               ),
+                       array(
+                               'rel' => 'meta',
+                               'type' => 'application/rdf+xml' ,
+                               'title' => 'FOAF',
+                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.htmlentities(str_replace($base_url, '', 
$user->getURL()))
+                               )
+               ));
+               
+       header('Content-Type: text/plain');
+       print_r(Group::listGroups($user));
+       exit;
+       
+       $smarty->display('user-groups.tpl');
+} else {
+       $smarty->assign('error', 'User not found');
+       $smarty->assign('details', 'Shall I call in a missing persons report?');
+       $smarty->display('error.tpl');
+}
+
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]