<?php
require_once('../phpFlickrSynch.php');
include '_include/header.php';
?>
<h1>
<span>phpFlickrSynch</span>
<a href="./index.php">Manage photo albums</a>
<a href="./groups.php" class="selected">Manage photo groups</a>
</h1>
<p class="introduction">Organize your photo albums into groups! In this screen, you can manage your groups: edit / add / delete.</p>
<?php
$DB = new TableFlickrGroup();
$ACTION = isset($_REQUEST['action']) ? $_REQUEST['action'] : NULL;
switch ($ACTION) {
case 'ADDGROUP':
$groupname = isset($_REQUEST['groupname']) ? trim($_REQUEST['groupname']) : NULL;
if (strlen($groupname) > 0) {
$id = $DB->createGroup($groupname);
if ($id > 0) {
echo '<div class="infoMsg"><div class="inner">Group created.</div></div>';
} else {
echo '<div class="warningMsg"><div class="inner">There was a problem when creating the group. Group not created.</div></div>';
}
}
break;
case 'DELETEGROUP':
$groupid = isset($_REQUEST['groupid']) ? (integer)$_REQUEST['groupid'] : 0;
if ($groupid > 0) {
if ($DB->deleteGroup($groupid)) {
echo '<div class="infoMsg"><div class="inner">Group deleted.</div></div>';
} else {
echo '<div class="warningMsg"><div class="inner">There was a problem when deleting the group. Group not deleted.</div></div>';
}
}
break;
}
$groups = $DB->getAllGroups();
?>
<button type="button" id="addgroup"><span>Add group</span></button>
<div id="creategroup" style="display:none;" class="formadd">
<form id="creategroupform" method="post" action="#">
<input type="hidden" name="action" value="ADDGROUP"/>
<label for="groupname">Group name:</label>
<input type="text" name="groupname" id="groupname"/>
<button type="submit" class="action">Add group</button>
<span id="creategroupcancel" class="link">Cancel</span>
</form>
</div>
<form id="deletegroupform" method="post" action="#">
<input type="hidden" name="action" value="DELETEGROUP"/>
<input type="hidden" name="groupid" id="deletegroupid" value="0"/>
</form>
<table>
<thead>
<tr>
<th>Group name</th>
<th style="width:50px">Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach ($groups as $key => $val) {
?>
<tr id="group-<?php echo $val['id'];?>" class="photogrouprow">
<td><span id="editgroupname-<?php echo $val['id'];?>"><?php echo $val['name'];?></span></td>
<td><img src="_images/delete.png" width="16" height="16" alt="Delete this group" title="Delete this group" id="deletegroup-<?php echo $val['id'];?>" class="icon"/></td>
</tr>
<?php
}
?>
</tbody>
</table>
<script type="text/javascript">
<!--
var pa = new PhotoGroups();
pa.init();
-->
</script>
<?php
include '_include/footer.php';
?>