Commit 337e1044 authored by Penny Leach's avatar Penny Leach
Browse files

Introducing group/interactions.php - list of all interactions in a group for the group owner.

Changed the add/edit/delete pages to redirect there afterwards.
parent b70a490c
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage group-interactions
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'groups');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('docroot') . 'interaction/lib.php');
$id = param_integer('id');
if (!$group = get_record('group', 'id', $id)) {
throw new GroupNotFoundException('groupnotfound', 'group', $id);
}
if (!$group->owner == $USER->get('id')) {
throw new AccessDeniedException(get_string('notallowedtoeditinteraction', 'group'));
}
define('TITLE', get_string('groupinteractions', 'group'));
$interactiontypes = array_flip(
array_map(
create_function('$a', 'return $a->name;'),
plugins_installed('interaction')
)
);
if (!$interactions = get_records_select_array('interaction_instance',
'"group" = ? AND deleted = ?', array($id, 0),
'plugin, ctime', 'id, plugin, title')) {
$interactions = array();
}
$names = array();
foreach (array_keys($interactiontypes) as $plugin) {
$names[$plugin] = array(
'single' => get_string('name', 'interaction.' . $plugin),
'plural' => get_string('nameplural', 'interaction.' . $plugin)
);
}
foreach ($interactions as $i) {
if (!is_array($interactiontypes[$i->plugin])) {
$interactiontypes[$i->plugin] = array();
}
$interactiontypes[$i->plugin][] = $i;
}
$smarty = smarty();
$smarty->assign('group', $group);
$smarty->assign('data', $interactiontypes);
$smarty->assign('pluginnames', $names);
$smarty->assign('heading', TITLE);
$smarty->display('group/interactions.tpl');
?>
......@@ -56,7 +56,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'interaction/' . $instance->get('plugin') . '/index.php?group=' . $group->id
'goto' => get_config('wwwroot') . 'group/interactions.php?id=' . $group->id,
)
)
));
......
......@@ -64,7 +64,7 @@ $elements = array_merge(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('save'), get_string('cancel')),
'goto' => get_config('wwwroot') . 'group/view.php?id=' . $groupid,
'goto' => get_config('wwwroot') . 'group/interactions.php?id=' . $groupid,
)
)
);
......
......@@ -217,7 +217,7 @@ function delete_interaction_submit(Pieform $form, $values) {
$instance->delete();
global $SESSION;
$SESSION->add_ok_msg(get_string('interactiondeleted', 'group', get_string('name', 'interaction.' . $instance->get('plugin'))));
redirect('/interaction/' . $instance->get('plugin') . '/index.php?group=' . $instance->get('group'));
redirect('/group/interactions.php?id=' . $instance->get('group'));
}
......
......@@ -188,4 +188,5 @@ $string['interactionsaved'] = '%s saved successfully';
$string['deleteinteraction'] = 'Delete %s \'%s\'';
$string['deleteinteractionsure'] = 'Are you sure you want to do this? It cannot be undone.';
$string['interactiondeleted'] = '%s deleted successfully';
$string['addnewinteraction'] = 'Add new %s';
?>
{include file="header.tpl"}
{include file="sidebar.tpl"}
{include file="columnleftstart.tpl"}
<h2>{$group->name|escape}</h2>
<h3>{$heading|escape}</h3>
<ul>
{foreach from=$data item=interactions key=plugin}
<li><a href="{$WWWROOT}interaction/{$plugin}/index.php?group={$group->id}">{$pluginnames.$plugin.plural}</a></li>
{if $interactions}
<ul>
{foreach from=$interactions item=interaction}
<li>
<a href="{$WWWROOT}interaction/{$interaction->plugin|escape}/view.php?id={$interaction->id|escape}">{$interaction->title|escape}</a> [
<a href="{$WWWROOT}interaction/edit.php?id={$interaction->id}">{str tag='edit'}</a> |
<a href="{$WWWROOT}interaction/delete.php?id={$interaction->id}">{str tag='delete'}</a> ]
</li>
{/foreach}
<li> [ <a href="{$WWWROOT}interaction/edit.php?group={$group->id}&plugin={$plugin}">{str tag='addnewinteraction' args=$pluginnames.$plugin.single section='group'}</a> ]
</ul>
{/if}
{/foreach}
</ul>
{include file="columnleftend.tpl"}
{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