delete.php 2.49 KB
Newer Older
1
2
3
<?php
/**
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
4
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * 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
21
 * @author     Catalyst IT Ltd
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
23
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
24
25
26
27
28
29
30
31
32
33
 *
 */

define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/views');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('pieforms/pieform.php');
require_once('view.php');
$viewid = param_integer('id');

34
$view = new View($viewid, null);
35

36
if (!$view || !$USER->can_edit_view($view)) {
37
38
    throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
}
39
$groupid = $view->get('group');
40
$institution = $view->get('institution');
41

42
define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title')));
43
44
45
46
47
48
49
50
51
52

$form = pieform(array(
    'name' => 'deleteview',
    'autofocus' => false,
    'method' => 'post',
    'elements' => array(
        'submit' => array(
            'type' => 'submitcancel',
            'title' => get_string('deleteviewconfirm', 'view'),
            'value' => array(get_string('yes'), get_string('no')),
53
            'goto' => get_config('wwwroot') . 'view/'
54
55
56
57
58
59
60
61
62
63
        )
    ),
));

$smarty = smarty();
$smarty->assign('heading', TITLE);
$smarty->assign('form', $form);
$smarty->display('view/delete.tpl');

function deleteview_submit(Pieform $form, $values) {
64
	global $SESSION, $viewid, $groupid, $insitution;
65
66
67
68
    $view = new View($viewid, null);
    $view->delete();
    handle_event('deleteview', $viewid);
    $SESSION->add_ok_msg(get_string('viewdeleted', 'view'));
69
70
71
    if ($groupid) {
        redirect('/view/groupviews.php?group='.$groupid);
    }
72
73
74
    if ($institution) {
        redirect('/view/institutionviews.php?institution='.$institution);
    }
75
    redirect('/view/');
76
77
}
?>