~ubuntu-branches/ubuntu/maverick/mahara/maverick-updates

« back to all changes in this revision

Viewing changes to htdocs/group/delete.php

  • Committer: Bazaar Package Importer
  • Author(s): Nigel McNie
  • Date: 2008-04-29 11:15:39 UTC
  • Revision ID: james.westby@ubuntu.com-20080429111539-b28eqkagavaub2zr
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
 
4
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 * @package    mahara
 
20
 * @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
define('INTERNAL', 1);
 
28
define('MENUITEM', 'groups');
 
29
require(dirname(dirname(__FILE__)) . '/init.php');
 
30
require_once('pieforms/pieform.php');
 
31
require('group.php');
 
32
$groupid = param_integer('id');
 
33
 
 
34
$group = get_record('group', 'id', $groupid, 'owner', $USER->get('id'), 'deleted', 0);
 
35
 
 
36
if (!$group) {
 
37
    throw new AccessDeniedException(get_string('cantdeletegroup', 'group'));
 
38
}
 
39
 
 
40
define('TITLE', get_string('deletespecifiedgroup', 'group', $group->name));
 
41
 
 
42
$views = count_records_sql(
 
43
    'SELECT COUNT(a.*)
 
44
    FROM {view_access_group} a
 
45
    WHERE a.group = ?',
 
46
    array($groupid)
 
47
);
 
48
 
 
49
$form = pieform(array(
 
50
    'name' => 'deletegroup',
 
51
    'renderer' => 'div',
 
52
    'autofocus' => false,
 
53
    'method' => 'post',
 
54
    'elements' => array(
 
55
        'submit' => array(
 
56
            'type' => 'submitcancel',
 
57
            'value' => array(get_string('yes'), get_string('no')),
 
58
            'goto' => get_config('wwwroot') . 'group/view.php?id=' . $groupid
 
59
        )
 
60
    ),
 
61
));
 
62
 
 
63
$smarty = smarty();
 
64
$smarty->assign('heading', TITLE);
 
65
$smarty->assign('message', $views ? get_string('groupconfirmdeletehasviews', 'group') : get_string('groupconfirmdelete', 'group'));
 
66
$smarty->assign('form', $form);
 
67
$smarty->display('group/delete.tpl');
 
68
 
 
69
function deletegroup_submit(Pieform $form, $values) {
 
70
    global $SESSION, $USER, $groupid;
 
71
    delete_group($groupid);
 
72
    $SESSION->add_ok_msg(get_string('deletegroup', 'group'));
 
73
    redirect('/group/mygroups.php');
 
74
}
 
75
?>