delete.php 1.79 KB
Newer Older
1
2
3
4
5
<?php
/**
 *
 * @package    mahara
 * @subpackage core
6
 * @author     Catalyst IT Ltd
7
8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
9
10
11
12
13
14
15
 *
 */

define('INTERNAL', 1);
define('MENUITEM', 'groups');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('pieforms/pieform.php');
16
require_once('group.php');
17
$groupid = param_integer('id');
18
define('GROUP', $groupid);
19

20
$group = get_record_sql("SELECT g.*
21
22
23
24
    FROM {group} g
    INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')
    WHERE g.id = ?
    AND g.deleted = 0", array($USER->get('id'), $groupid));
25
26

if (!$group) {
Clare Lenihan's avatar
Clare Lenihan committed
27
    throw new AccessDeniedException(get_string('cantdeletegroup', 'group'));
28
29
}

Clare Lenihan's avatar
Clare Lenihan committed
30
define('TITLE', get_string('deletespecifiedgroup', 'group', $group->name));
31
32
33

$form = pieform(array(
    'name' => 'deletegroup',
34
    'renderer' => 'div',
35
36
37
38
39
    'autofocus' => false,
    'method' => 'post',
    'elements' => array(
        'submit' => array(
            'type' => 'submitcancel',
Pat Kira's avatar
Pat Kira committed
40
            'class' => 'btn btn-default',
41
            'value' => array(get_string('yes'), get_string('no')),
42
            'goto' => group_homepage_url($group),
43
44
45
46
47
        )
    ),
));

$smarty = smarty();
48
$smarty->assign('subheading', TITLE);
49
$smarty->assign('message', get_string('groupconfirmdelete', 'group'));
50
51
52
53
$smarty->assign('form', $form);
$smarty->display('group/delete.tpl');

function deletegroup_submit(Pieform $form, $values) {
54
    require_once('embeddedimage.php');
Clare Lenihan's avatar
Clare Lenihan committed
55
    global $SESSION, $USER, $groupid;
56
    group_delete($groupid);
57
    EmbeddedImage::delete_embedded_images('group', $groupid);
Clare Lenihan's avatar
Clare Lenihan committed
58
    $SESSION->add_ok_msg(get_string('deletegroup', 'group'));
59
60
    redirect('/group/mygroups.php');
}