Commit 9ae8d8bb authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow group views to be deleted

parent 144f7f1e
......@@ -31,13 +31,14 @@ require_once('pieforms/pieform.php');
$viewid = param_integer('id');
$view = get_record('view', 'id', $viewid, 'owner', $USER->get('id'));
$view = new View($viewid, null);
if (!$view) {
if (!$view || !$USER->can_edit_view($view)) {
throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
$groupid = $view->get('group');
define('TITLE', get_string('deletespecifiedview', 'view', $view->title));
define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title')));
$form = pieform(array(
'name' => 'deleteview',
......@@ -59,11 +60,14 @@ $smarty->assign('form', $form);
function deleteview_submit(Pieform $form, $values) {
global $SESSION, $viewid;
global $SESSION, $viewid, $groupid;
$view = new View($viewid, null);
handle_event('deleteview', $viewid);
$SESSION->add_ok_msg(get_string('viewdeleted', 'view'));
if ($groupid) {
Supports Markdown
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