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

Commit c5b6bab7 authored by tobyink's avatar tobyink

Group editing.

parent c40e3f28
<?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/User.php');
require_once('data/Group.php');
require_once('data/TagCloud.php');
if($logged_in == false)
{
$smarty->assign('error', 'Error!');
$smarty->assign('details', 'Not logged in! You shouldn\'t be here!');
$smarty->display('error.tpl');
die();
}
$group = new Group($_REQUEST['group']);
if ($group->owner->name != $_SESSION['user']->name)
{
$smarty->assign('error', 'Error!');
$smarty->assign('details', 'You don\'t own this group!');
$smarty->display('error.tpl');
die();
}
$errors = array();
if ($_POST['submit'])
{
if (!empty($_POST['homepage']))
{
# Need better URI validation, but this will do for now. I think
# PEAR has a suitable module to help out here.
if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['homepage']) )
$errors[] = "Homepage must be a URI.";
if ( preg_match('/\s/', $_POST['homepage']) )
$errors[] = "Homepage must be a URI. Valid URIs cannot contain whitespace.";
}
if (!empty($_POST['avatar_uri']))
{
# Need better URI validation, but this will do for now. I think
# PEAR has a suitable module to help out here.
if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['avatar_uri']) )
$errors[] = "Avatar must be a URI.";
if ( preg_match('/\s/', $_POST['avatar_uri']) )
$errors[] = "Avatar must be a URI. Valid URIs cannot contain whitespace.";
}
if (!isset($errors[0]))
{
$group->fullname = $_POST['fullname'];
$group->homepage = $_POST['homepage'];
$group->bio = $_POST['bio'];
$group->avatar_uri = $_POST['avatar_uri'];
$group->save();
header("Location: " . $group->getURL());
exit;
}
if (isset($errors[0]))
{
header("Content-Type: text/plain");
print_r($errors);
exit;
}
}
if(isset($group->name))
{
# Stuff which cannot be changed.
$smarty->assign('group', $group->name);
if ($_POST['submit'])
{
$smarty->assign('fullname', $_POST['fullname']);
$smarty->assign('bio', $_POST['bio']);
$smarty->assign('homepage', $_POST['homepage']);
$smarty->assign('avatar_uri', $_POST['avatar_uri']);
}
else
{
$smarty->assign('fullname', ($group->fullname));
$smarty->assign('bio', ($group->bio));
$smarty->assign('homepage', ($group->homepage));
$smarty->assign('avatar_uri', ($group->avatar_uri));
}
# And display the page.
$smarty->assign('errors', $errors);
$smarty->display('edit_group.tpl');
}
else
{
$smarty->assign('error', 'Group not found');
$smarty->assign('details', 'Shall I call in a missing peoples report? This shouldn\'t happen.');
$smarty->display('error.tpl');
}
{include file='header.tpl'}
<h2 property="dc:title">Edit your group</h2>
<p><strong>The form below is still <em>very</em> experimental. Using this may wreck your account!</strong></p>
<form action="{$base_url}/edit_group.php" method="post" class="notcrazy">
<table>
<tr>
<th align="right" valign="top"><label for="fullname">Full name:</label></th>
<td><input name="fullname" id="fullname" value="{$fullname|escape:'html':'UTF-8'}" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<th align="right" valign="top"><label for="homepage">Homepage URL:</label></th>
<td><input name="homepage" id="homepage" value="{$homepage|escape:'html':'UTF-8'}" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<th align="right" valign="top"><label for="avatar_uri">Logo URL:</label></th>
<td><input name="avatar_uri" id="avatar_uri" value="{$avatar_uri|escape:'html':'UTF-8'}" /></td>
<td><a href="#dfn_avatar_uri" rel="glossary">What's this?</a></td>
</tr>
<tr>
<th align="right" valign="top"><label for="bio">Description:</label></th>
<td><textarea name="bio" id="bio" rows="6" cols="30" style="width:100%;min-width:20em">{$bio|escape:'html':'UTF-8'}</textarea></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="Change" />
<input name="submit" value="1" type="hidden" />
<input name="group" value="{$group|escape:'html':'UTF-8'}" type="hidden" />
</td>
</tr>
</table>
</form>
<h3>Help</h3>
<dl>
<dt id="dfn_avatar_uri">Logo URL</dt>
<dd>The web address for a picture to represent your group on libre.fm. It should
not be more than 80x80 pixels. (64x64 is best.)</dd>
</dl>
{include file='footer.tpl'}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment