Commit 829dcd77 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Initial commit for Site and Institution Views pages

parent b0111575
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configsite/siteviews');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'siteviews');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'view.php');
require_once('pieforms/pieform.php');
$limit = param_integer('limit', 5);
$offset = param_integer('offset', 0);
$title = get_string('siteviews', 'admin');
define('TITLE', $title);
$smarty = smarty();
$smarty->assign('heading', $title);
$data = View::get_myviews_data($limit, $offset, null, 'mahara');
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'view/?',
'count' => $data->count,
'limit' => $limit,
'offset' => $offset,
'resultcounttextsingular' => get_string('view', 'view'),
'resultcounttextplural' => get_string('views', 'view')
));
$smarty->assign('views', $data->data);
$smarty->assign('institution', 'mahara');
$smarty->assign('pagination', $pagination['html']);
$smarty->display('view/index.tpl');
?>
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
{if $groupid} {if $groupid}
<h2>{$heading}</h2> <h2>{$heading}</h2>
{include file="group/tabstart.tpl" current="files"} {include file="group/tabstart.tpl" current="files"}
{else if $institution}
<h2>{$heading}</h2>
{$institutionselector}
{/if} {/if}
{str tag='fileinstructions' section='artefact.file'} {str tag='fileinstructions' section='artefact.file'}
<div id="myfiles"> <div id="myfiles">
......
...@@ -71,7 +71,9 @@ $string['editsitepagesdescription'] = 'Edit the content of various pages around ...@@ -71,7 +71,9 @@ $string['editsitepagesdescription'] = 'Edit the content of various pages around
$string['linksandresourcesmenu'] = 'Links and Resources Menu'; $string['linksandresourcesmenu'] = 'Links and Resources Menu';
$string['linksandresourcesmenudescription'] = 'Manage the links and files within the Links and Resources Menu'; $string['linksandresourcesmenudescription'] = 'Manage the links and files within the Links and Resources Menu';
$string['sitefiles'] = 'Site Files'; $string['sitefiles'] = 'Site Files';
$string['sitefilesdescription'] = 'Upload and administer files that can be put in the Links and Resources Menu'; $string['sitefilesdescription'] = 'Upload and administer files that can be put in the Links and Resources Menu and in Site Views';
$string['siteviews'] = 'Site Views';
$string['siteviewsdescription'] = 'Create and administer Views and View Templates for the entire site';
$string['networking'] = 'Networking'; $string['networking'] = 'Networking';
$string['networkingdescription'] = 'Configure networking for Mahara'; $string['networkingdescription'] = 'Configure networking for Mahara';
...@@ -94,6 +96,10 @@ $string['usersearchinstructions'] = 'You can search for users by clicking on the ...@@ -94,6 +96,10 @@ $string['usersearchinstructions'] = 'You can search for users by clicking on the
$string['institutionmembersdescription'] = 'Associate users with institutions'; $string['institutionmembersdescription'] = 'Associate users with institutions';
$string['institutionstaffdescription'] = 'Assign users Staff permissions'; $string['institutionstaffdescription'] = 'Assign users Staff permissions';
$string['institutionadminsdescription'] = 'Assign Institution Administrator access rights'; $string['institutionadminsdescription'] = 'Assign Institution Administrator access rights';
$string['institutionviews'] = 'Institution Views';
$string['institutionviewsdescription'] = 'Create and administer Views and View Templates for an Institution';
$string['institutionfiles'] = 'Institution Files';
$string['institutionfilesdescription'] = 'Upload and manage files for use in Institution Views';
$string['pluginadmin'] = 'Plugin Administration'; $string['pluginadmin'] = 'Plugin Administration';
$string['pluginadmindescription'] = 'Install and configure plugins'; $string['pluginadmindescription'] = 'Install and configure plugins';
......
...@@ -47,7 +47,7 @@ $string['ownerformatdescription'] = 'How do you want people who look at your Vie ...@@ -47,7 +47,7 @@ $string['ownerformatdescription'] = 'How do you want people who look at your Vie
$string['artefacts'] = 'Artefacts'; $string['artefacts'] = 'Artefacts';
$string['myviews'] = 'My Views'; $string['myviews'] = 'My Views';
$string['groupviews'] = 'Group Views'; $string['groupviews'] = 'Group Views';
$string['groupviewsfor'] = 'Group Views for %s'; $string['institutionviews'] = 'Institution Views';
$string['reallyaddaccesstoemptyview'] = 'Your View contains no artefacts. Do you really want to give these users access to the View?'; $string['reallyaddaccesstoemptyview'] = 'Your View contains no artefacts. Do you really want to give these users access to the View?';
$string['viewdeleted'] = 'View deleted'; $string['viewdeleted'] = 'View deleted';
$string['viewsubmitted'] = 'View submitted'; $string['viewsubmitted'] = 'View submitted';
......
...@@ -500,6 +500,7 @@ ...@@ -500,6 +500,7 @@
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="false" /> <FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="ownerformat" TYPE="text" NOTNULL="false" /> <FIELD NAME="ownerformat" TYPE="text" NOTNULL="false" />
<FIELD NAME="group" TYPE="int" LENGTH="10" NOTNULL="false" /> <FIELD NAME="group" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="institution" TYPE="char" LENGTH="255" NOTNULL="false" />
<FIELD NAME="startdate" TYPE="datetime" /> <FIELD NAME="startdate" TYPE="datetime" />
<FIELD NAME="stopdate" TYPE="datetime" /> <FIELD NAME="stopdate" TYPE="datetime" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" /> <FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
...@@ -515,6 +516,7 @@ ...@@ -515,6 +516,7 @@
<KEY NAME="submittedtofk" TYPE="foreign" FIELDS="submittedto" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="submittedtofk" TYPE="foreign" FIELDS="submittedto" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="layoutfk" TYPE="foreign" FIELDS="layout" REFTABLE="view_layout" REFFIELDS="id"/> <KEY NAME="layoutfk" TYPE="foreign" FIELDS="layout" REFTABLE="view_layout" REFFIELDS="id"/>
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" />
</KEYS> </KEYS>
</TABLE> </TABLE>
<TABLE NAME="view_tag"> <TABLE NAME="view_tag">
......
...@@ -1222,6 +1222,11 @@ function xmldb_core_upgrade($oldversion=0) { ...@@ -1222,6 +1222,11 @@ function xmldb_core_upgrade($oldversion=0) {
} }
if ($oldversion < 2008081100) {
execute_sql("ALTER TABLE {view} ADD COLUMN institution CHARACTER VARYING(255);");
execute_sql("ALTER TABLE {view} ADD CONSTRAINT {view_ins_fk} FOREIGN KEY (institution) REFERENCES {institution}(name);");
}
return $status; return $status;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
defined('INTERNAL') || die(); defined('INTERNAL') || die();
$config = new StdClass; $config = new StdClass;
$config->version = 2008080400; $config->version = 2008081100;
$config->release = '1.1.0alpha'; $config->release = '1.1.0alpha';
$config->minupgradefrom = 2007080700; $config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)'; $config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
...@@ -34,6 +34,7 @@ class View { ...@@ -34,6 +34,7 @@ class View {
private $owner; private $owner;
private $ownerformat; private $ownerformat;
private $group; private $group;
private $institution;
private $ctime; private $ctime;
private $mtime; private $mtime;
private $atime; private $atime;
...@@ -1312,7 +1313,7 @@ class View { ...@@ -1312,7 +1313,7 @@ class View {
public static function get_myviews_data($limit=5, $offset=0, $groupid=null) { public static function get_myviews_data($limit=5, $offset=0, $groupid=null, $institution=null) {
global $USER; global $USER;
$userid = $USER->get('id'); $userid = $USER->get('id');
...@@ -1324,6 +1325,13 @@ class View { ...@@ -1324,6 +1325,13 @@ class View {
WHERE v.group = ' . $groupid . ' WHERE v.group = ' . $groupid . '
ORDER BY v.title, v.id', '', $offset, $limit); ORDER BY v.title, v.id', '', $offset, $limit);
} }
else if ($institution) {
$count = count_records('view', 'institution', $institution);
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description
FROM {view} v
WHERE v.institution = ?
ORDER BY v.title, v.id', array($institution), $offset, $limit);
}
else { else {
$count = count_records('view', 'owner', $userid); $count = count_records('view', 'owner', $userid);
$viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, g.id AS groupid, g.name $viewdata = get_records_sql_array('SELECT v.id,v.title,v.startdate,v.stopdate,v.description, g.id AS groupid, g.name
......
...@@ -1489,6 +1489,18 @@ function admin_nav() { ...@@ -1489,6 +1489,18 @@ function admin_nav() {
'title' => get_string('institutionadmins', 'admin'), 'title' => get_string('institutionadmins', 'admin'),
'weight' => 40, 'weight' => 40,
), ),
array(
'path' => 'manageinstitutions/institutionviews',
'url' => 'view/institutionviews.php',
'title' => get_string('institutionviews', 'admin'),
'weight' => 50,
),
array(
'path' => 'manageinstitutions/institutionfiles',
'url' => 'artefact/file/institutionfiles.php',
'title' => get_string('institutionfiles', 'admin'),
'weight' => 60,
),
array( array(
'path' => 'configextensions', 'path' => 'configextensions',
'url' => 'admin/extensions/plugins.php', 'url' => 'admin/extensions/plugins.php',
......
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
<li><strong><a href="{$WWWROOT}admin/site/options.php">{str tag=siteoptions section=admin}</a></strong> - {str tag=siteoptionsdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/site/options.php">{str tag=siteoptions section=admin}</a></strong> - {str tag=siteoptionsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/pages.php">{str tag=editsitepages section=admin}</a></strong> - {str tag=editsitepagesdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/site/pages.php">{str tag=editsitepages section=admin}</a></strong> - {str tag=editsitepagesdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/menu.php">{str tag=linksandresourcesmenu section=admin}</a></strong> - {str tag=linksandresourcesmenudescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/site/menu.php">{str tag=linksandresourcesmenu section=admin}</a></strong> - {str tag=linksandresourcesmenudescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/files.php">{str tag=sitefiles section=admin}</a></strong> - {str tag=sitefilesdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/networking.php">{str tag=networking section=admin}</a></strong> - {str tag=networkingdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/site/networking.php">{str tag=networking section=admin}</a></strong> - {str tag=networkingdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/views.php">{str tag=siteviews section=admin}</a></strong> - {str tag=siteviewsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/files.php">{str tag=sitefiles section=admin}</a></strong> - {str tag=sitefilesdescription section=admin}</li>
</ul> </ul>
</li> </li>
<li><h3>{str tag=configusers section=admin}</h3> <li><h3>{str tag=configusers section=admin}</h3>
...@@ -53,6 +54,8 @@ ...@@ -53,6 +54,8 @@
<li><strong><a href="{$WWWROOT}admin/users/institutionusers.php">{str tag=institutionmembers section=admin}</a></strong> - {str tag=institutionmembersdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/users/institutionusers.php">{str tag=institutionmembers section=admin}</a></strong> - {str tag=institutionmembersdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/users/institutionstaff.php">{str tag=institutionstaff section=admin}</a></strong> - {str tag=institutionstaffdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/users/institutionstaff.php">{str tag=institutionstaff section=admin}</a></strong> - {str tag=institutionstaffdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/users/institutionadmins.php">{str tag=institutionadmins section=admin}</a></strong> - {str tag=institutionadminsdescription section=admin}</li> <li><strong><a href="{$WWWROOT}admin/users/institutionadmins.php">{str tag=institutionadmins section=admin}</a></strong> - {str tag=institutionadminsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}view/institutionviews.php">{str tag=institutionviews section=admin}</a></strong> - {str tag=institutionviewsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}artefact/file/institutionfiles.php">{str tag=institutionfiles section=admin}</a></strong> - {str tag=institutionfilesdescription section=admin}</li>
</ul> </ul>
</li> </li>
<li><h3>{str tag=configextensions section=admin}</h3> <li><h3>{str tag=configextensions section=admin}</h3>
......
...@@ -63,9 +63,11 @@ ...@@ -63,9 +63,11 @@
<input class="submit" type="submit" value="{str tag='next'}"> <input class="submit" type="submit" value="{str tag='next'}">
</form> </form>
{else} {else}
<form action="{$WWWROOT}view/{if $groupid}groupviews.php{/if}" method="GET"> <form action="{$WWWROOT}view/{if $groupid}groupviews.php{else if $institution}institutionviews.php{/if}" method="GET">
{if $groupid} {if $groupid}
<input type="hidden" name="group" value="{$groupid}"> <input type="hidden" name="group" value="{$groupid}">
{else if $institution}
<input type="hidden" name="institution" value="{$institution}">
{/if} {/if}
<input class="submit" type="submit" value="{str tag='done'}"> <input class="submit" type="submit" value="{str tag='done'}">
</form> </form>
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<span class="addicon fr"> <span class="addicon fr">
<a href="{$WWWROOT}view/edit.php{if $groupid}?group={$groupid}{/if}">{str tag="createview" section="view"}</a> <a href="{$WWWROOT}view/edit.php{if $groupid}?group={$groupid}{else if $institution}?institution={$institution}{/if}">{str tag="createview" section="view"}</a>
</span> </span>
<h2>{$heading}</h2> <h2>{$heading}</h2>
{if $groupid} {if $groupid}
{include file="group/tabstart.tpl" current="views"} {include file="group/tabstart.tpl" current="views"}
{else if $institution}
{$institutionselector}
{/if} {/if}
{if $views} {if $views}
<table id="myviewstable" class="groupviews"> <table id="myviewstable" class="groupviews">
...@@ -80,7 +82,7 @@ ...@@ -80,7 +82,7 @@
{else} {else}
<table id="myviewstable"{if $member} class="groupviews"{/if}> <table id="myviewstable"{if $member} class="groupviews"{/if}>
<tr> <tr>
<td>{if $groupid}{str tag="noviewstosee" section="group"}{else}{str tag="noviews" section="view"}{/if}</td> <td>{if $groupid}{str tag="noviewstosee" section="group"}{elseif $institution}{str tag="noviews"}{else}{str tag="noviews" section="view"}{/if}</td>
</tr> </tr>
</table> </table>
{/if} {/if}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{include file="columnfullstart.tpl"} {include file="columnfullstart.tpl"}
<h2>{if !$new}<a href="{$WWWROOT}view/view.php?id={$viewid}">{/if}{$viewtitle}{if !$new}</a>{/if} {str tag=by section=view} <a href="{$WWWROOT}{$ownerlink}">{$ownername}</a></h2> <h2>{if !$new}<a href="{$WWWROOT}view/view.php?id={$viewid}">{/if}{$viewtitle}{if !$new}</a>{/if}{if $ownername} {str tag=by section=view} <a href="{$WWWROOT}{$ownerlink}">{$ownername}</a>{/if}</h2>
{if $can_edit} {if $can_edit}
<div class="fr editview"> <div class="fr editview">
......
...@@ -38,6 +38,7 @@ require_once(get_config('docroot') . 'lib/group.php'); ...@@ -38,6 +38,7 @@ require_once(get_config('docroot') . 'lib/group.php');
$view = new View(param_integer('id')); $view = new View(param_integer('id'));
$group = $view->get('group'); $group = $view->get('group');
$institution = $view->get('institution');
$new = param_boolean('new'); $new = param_boolean('new');
if ($new) { if ($new) {
...@@ -47,7 +48,8 @@ else { ...@@ -47,7 +48,8 @@ else {
define('TITLE', get_string('editaccessforview', 'view', $view->get('title'))); define('TITLE', get_string('editaccessforview', 'view', $view->get('title')));
} }
if ($group && !group_user_can_edit_views($group)) { if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
...@@ -135,29 +137,27 @@ function editaccess_validate(Pieform $form, $values) { ...@@ -135,29 +137,27 @@ function editaccess_validate(Pieform $form, $values) {
} }
function editaccess_cancel_submit() { function editaccess_cancel_submit() {
global $view, $new, $group; global $view, $new, $group, $institution;
if ($new) { if ($new) {
$view->delete(); $view->delete();
} }
if ($group) { if ($group) {
redirect('/view/groupviews.php?group='.$group); redirect('/view/groupviews.php?group='.$group);
} }
if ($institution) {
redirect('/view/institutionviews.php?group='.$institution);
}
redirect('/view'); redirect('/view');
} }
function editaccess_submit(Pieform $form, $values) { function editaccess_submit(Pieform $form, $values) {
global $SESSION, $view, $new, $group; global $SESSION, $view, $new, $group, $institution;
if (param_boolean('back')) { if (param_boolean('back')) {
redirect('/view/blocks.php?id=' . $view->get('id') . '&new=' . $new); redirect('/view/blocks.php?id=' . $view->get('id') . '&new=' . $new);
} }
if ($group && !group_user_access($group)) {
$SESSION->add_error_msg(get_string('notamember', 'group'));
redirect('/view/groupviews.php?group='.$group);
}
$view->set_access($values['accesslist']); $view->set_access($values['accesslist']);
$view->set('startdate', $values['startdate']); $view->set('startdate', $values['startdate']);
...@@ -174,6 +174,9 @@ function editaccess_submit(Pieform $form, $values) { ...@@ -174,6 +174,9 @@ function editaccess_submit(Pieform $form, $values) {
if ($group) { if ($group) {
redirect('/view/groupviews.php?group='.$group); redirect('/view/groupviews.php?group='.$group);
} }
if ($institution) {
redirect('/view/institutionviews.php?group='.$institution);
}
redirect('/view/'); redirect('/view/');
} }
......
...@@ -35,6 +35,7 @@ require_once(get_config('docroot') . 'lib/group.php'); ...@@ -35,6 +35,7 @@ require_once(get_config('docroot') . 'lib/group.php');
$view = new View(param_integer('id')); $view = new View(param_integer('id'));
$group = $view->get('group'); $group = $view->get('group');
$institution = $view->get('institution');
// If the view has been submitted to a group, disallow editing // If the view has been submitted to a group, disallow editing
$submittedto = $view->get('submittedto'); $submittedto = $view->get('submittedto');
...@@ -51,7 +52,8 @@ else { ...@@ -51,7 +52,8 @@ else {
define('TITLE', get_string('editblocksforview', 'view', $view->get('title'))); define('TITLE', get_string('editblocksforview', 'view', $view->get('title')));
} }
if ($group && !group_user_can_edit_views($group)) { if ($group && !group_user_can_edit_views($group)
|| $institution && !$USER->can_edit_institution($institution)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
...@@ -61,6 +63,9 @@ if ($new && isset($_POST['cancel'])) { ...@@ -61,6 +63,9 @@ if ($new && isset($_POST['cancel'])) {
if ($group) { if ($group) {
redirect(get_config('wwwroot') . '/view/groupviews.php?group='.$group); redirect(get_config('wwwroot') . '/view/groupviews.php?group='.$group);
} }
if ($group) {
redirect(get_config('wwwroot') . '/view/institutionviews.php?institution='.$institution);
}
redirect(get_config('wwwroot') . '/view/'); redirect(get_config('wwwroot') . '/view/');
} }
...@@ -114,7 +119,8 @@ $smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php'); ...@@ -114,7 +119,8 @@ $smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category); $smarty->assign('category', $category);
$smarty->assign('new', $new); $smarty->assign('new', $new);
$smarty->assign('view', $view->get('id')); $smarty->assign('view', $view->get('id'));
$smarty->assign('groupid', $view->get('group')); $smarty->assign('groupid', $group);
$smarty->assign('institution', $institution);
$smarty->assign('can_change_layout', (!$USER->get_account_preference('addremovecolumns') || ($view->get('numcolumns') > 1 && $view->get('numcolumns') < 5))); $smarty->assign('can_change_layout', (!$USER->get_account_preference('addremovecolumns') || ($view->get('numcolumns') > 1 && $view->get('numcolumns') < 5)));
$smarty->display('view/blocks.tpl'); $smarty->display('view/blocks.tpl');
......
...@@ -38,12 +38,12 @@ $category = param_alpha('c', ''); ...@@ -38,12 +38,12 @@ $category = param_alpha('c', '');
$view = new View($id); $view = new View($id);
$numcolumns = $view->get('numcolumns'); $numcolumns = $view->get('numcolumns');
$group = $view->get('group'); $group = $view->get('group');
$institution = $view->get('institution');
$owner = $view->get('owner'); $owner = $view->get('owner');
if ($group && !group_user_can_edit_views($group)) { if ($group && !group_user_can_edit_views($group)
throw new AccessDeniedException(get_string('canteditdontown', 'view')); || $institution && !$USER->can_edit_institution($institution)
} || $owner && $owner != $USER->get('id')) {
else if ($owner && $owner != $USER->get('id')) {
throw new AccessDeniedException(get_string('canteditdontown', 'view')); throw new AccessDeniedException(get_string('canteditdontown', 'view'));
} }
......
...@@ -37,6 +37,7 @@ if (!$view || !$USER->can_edit_view($view)) { ...@@ -37,6 +37,7 @@ if (!$view || !$USER->can_edit_view($view)) {
throw new AccessDeniedException(get_string('cantdeleteview', 'view')); throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
} }
$groupid = $view->get('group'); $groupid = $view->get('group');
$institution = $view->get('institution');
define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title'))); define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title')));
...@@ -60,7 +61,7 @@ $smarty->assign('form', $form); ...@@ -60,7 +61,7 @@ $smarty->assign('form', $form);
$smarty->display('view/delete.tpl'); $smarty->display('view/delete.tpl');
function deleteview_submit(Pieform $form, $values) { function deleteview_submit(Pieform $form, $values) {
global $SESSION, $viewid, $groupid; global $SESSION, $viewid, $groupid, $insitution;
$view = new View($viewid, null); $view = new View($viewid, null);
$view->delete(); $view->delete();
handle_event('deleteview', $viewid); handle_event('deleteview', $viewid);
...@@ -68,6 +69,9 @@ function deleteview_submit(Pieform $form, $values) { ...@@ -68,6 +69,9 @@ function deleteview_submit(Pieform $form, $values) {
if ($groupid) { if ($groupid) {
redirect('/view/groupviews.php?group='.$groupid); redirect('/view/groupviews.php?group='.$groupid);
} }
if ($institution) {
redirect('/view/institutionviews.php?institution='.$institution);
}
redirect('/view/'); redirect('/view/');
} }
?> ?>
...@@ -41,6 +41,7 @@ $new = param_boolean('new'); ...@@ -41,6 +41,7 @@ $new = param_boolean('new');
if (empty($id)) { if (empty($id)) {
$new = true; $new = true;
$group = param_integer('group', null); $group = param_integer('group', null);
$institution = param_alphanum('institution', null);
} }
else { else {
$view = new View($id); $view = new View($id);
...@@ -55,9 +56,11 @@ else { ...@@ -55,9 +56,11 @@ else {
} }