We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

group.php 3.05 KB
Newer Older
tobyink's avatar
tobyink committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?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/TagCloud.php');
require_once('data/Server.php');

tobyink's avatar
tobyink committed
28 29
if (! $_GET['group'])
{
tobyink's avatar
tobyink committed
30 31 32 33 34 35
	$smarty->assign('groups', Group::groupList());
	$smarty->assign('extra_head_links', array(
			array(
				'rel' => 'meta',
				'type' => 'application/rdf+xml' ,
				'title' => 'FOAF',
36
				'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
tobyink's avatar
tobyink committed
37 38
				)
		));
39
	$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
40 41 42 43
	if (!PEAR::isError ($aTagCloud))
	{
		$smarty->assign('tagcloud', $aTagCloud);
	}
tobyink's avatar
tobyink committed
44
	$smarty->display('group-list.tpl');
tobyink's avatar
tobyink committed
45 46 47
	exit;
}

tobyink's avatar
tobyink committed
48 49
$group = new Group($_GET['group']);

50
if ($_GET['action'] && isset($this_user))
tobyink's avatar
tobyink committed
51
{
clint's avatar
clint committed
52 53 54 55 56
	if ($_GET['action'] == 'join')
		$group->memberJoin($this_user);
	elseif ($_GET['action'] == 'leave')
		$group->memberLeave($this_user);

elleo's avatar
elleo committed
57
	header('Location: ' . $group->getURL());
tobyink's avatar
tobyink committed
58 59 60 61
	exit;
}


tobyink's avatar
tobyink committed
62
if(isset($group->name)) {
tobyink's avatar
tobyink committed
63

elleo's avatar
elleo committed
64
	$smarty->assign('id', $group->id);
tobyink's avatar
tobyink committed
65 66 67 68 69
	$smarty->assign('group', $group->name);
	$smarty->assign('fullname', $group->fullname);
	$smarty->assign('bio', $group->bio);
	$smarty->assign('homepage', $group->homepage);
	$smarty->assign('avatar', $group->getAvatar());
tobyink's avatar
tobyink committed
70

71
	$aUserTagCloud = $group->tagCloudData();
tobyink's avatar
tobyink committed
72 73 74
	if (!PEAR::isError ($aUserTagCloud)) {
		$smarty->assign('group_tagcloud',$aUserTagCloud);
	}
clint's avatar
clint committed
75

tobyink's avatar
tobyink committed
76 77
	$smarty->assign('userlist', $group->getUsers());

78 79
	$smarty->assign('ismember', $group->memberCheck($this_user));
	$smarty->assign('isowner', ($group->owner->name==$this_user->name));
tobyink's avatar
tobyink committed
80 81 82
	$smarty->assign('link_join', $group->getURLAction('join'));
	$smarty->assign('link_leave', $group->getURLAction('leave'));
	$smarty->assign('link_edit', $base_url.'/edit_group.php?group='.$group->name);
tobyink's avatar
tobyink committed
83
	$smarty->assign('link', $group->getURL());
tobyink's avatar
tobyink committed
84

tobyink's avatar
tobyink committed
85 86 87 88 89
	$smarty->assign('extra_head_links', array(
			array(
				'rel' => 'meta',
				'type' => 'application/rdf+xml' ,
				'title' => 'FOAF',
90
				'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
tobyink's avatar
tobyink committed
91 92
				)
		));
clint's avatar
clint committed
93

tobyink's avatar
tobyink committed
94
	$smarty->assign('profile', true);
tobyink's avatar
tobyink committed
95 96
	$smarty->display('group.tpl');

tobyink's avatar
tobyink committed
97 98 99 100 101 102 103
} else {
	$smarty->assign('error', 'Group not found');
	$smarty->assign('details', 'Shall I call in a missing peoples report?');
	$smarty->display('error.tpl');
}

?>