2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2015-03-05 10:37:37 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
include "root.php";
|
2013-07-06 08:03:27 +02:00
|
|
|
require_once "resources/require.php";
|
2014-12-26 07:37:07 +01:00
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
if (permission_exists('group_delete') || if_group("superadmin")) {
|
|
|
|
|
//access allowed
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//get the http value and set as a variable
|
2015-03-05 10:37:37 +01:00
|
|
|
$group_uuid = check_str($_GET["id"]);
|
|
|
|
|
|
|
|
|
|
//validate the uuid
|
|
|
|
|
if (is_uuid($group_uuid)) {
|
|
|
|
|
//get the group from v_groups
|
2015-03-05 13:34:48 +01:00
|
|
|
$sql = "select group_name from v_groups ";
|
2015-03-05 10:37:37 +01:00
|
|
|
$sql .= "where group_uuid = '".$group_uuid."' ";
|
2015-03-05 13:34:48 +01:00
|
|
|
$sql .= "and (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null); ";
|
2015-03-05 13:38:35 +01:00
|
|
|
//echo $sql . "\n";
|
2015-03-05 10:37:37 +01:00
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
foreach ($result as &$row) {
|
|
|
|
|
$group_name = $row["group_name"];
|
|
|
|
|
}
|
|
|
|
|
unset ($prep_statement);
|
|
|
|
|
|
|
|
|
|
//delete the group users
|
|
|
|
|
$sql = "delete from v_group_users ";
|
|
|
|
|
$sql .= "where group_uuid = '".$group_uuid."' ";
|
2015-03-05 13:38:35 +01:00
|
|
|
$sql .= "and (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null); ";
|
|
|
|
|
//echo $sql . "\n";
|
2015-03-05 10:37:37 +01:00
|
|
|
if (!$db->exec($sql)) {
|
|
|
|
|
$error = $db->errorInfo();
|
|
|
|
|
print_r($error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//delete the group permissions
|
|
|
|
|
if (strlen($group_name) > 0) {
|
|
|
|
|
$sql = "delete from v_group_permissions ";
|
|
|
|
|
$sql .= "where group_name = '".$group_name."' ";
|
2015-03-05 13:38:35 +01:00
|
|
|
$sql .= "and (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null); ";
|
|
|
|
|
//echo $sql . "\n";
|
2015-03-05 10:37:37 +01:00
|
|
|
if (!$db->exec($sql)) {
|
|
|
|
|
$error = $db->errorInfo();
|
|
|
|
|
print_r($error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//delete the group
|
|
|
|
|
$sql = "delete from v_groups ";
|
|
|
|
|
$sql .= "where group_uuid = '".$group_uuid."' ";
|
2015-03-05 13:38:35 +01:00
|
|
|
$sql .= "and (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null); ";
|
|
|
|
|
//echo $sql . "\n";
|
2015-03-05 10:37:37 +01:00
|
|
|
if (!$db->exec($sql)) {
|
|
|
|
|
$error = $db->errorInfo();
|
|
|
|
|
print_r($error);
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//redirect the user
|
2013-01-23 16:49:02 +01:00
|
|
|
header("Location: groups.php");
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-12-26 07:37:07 +01:00
|
|
|
?>
|