Group Manager: Fix group permission protection feature.
This commit is contained in:
@@ -31,15 +31,33 @@
|
|||||||
function delete() {
|
function delete() {
|
||||||
//set the variables
|
//set the variables
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
//delete the group permisisons
|
//get unprotected groups and their domain uuids (if any)
|
||||||
$sql = "delete from v_group_permissions ";
|
$sql = "select group_name, domain_uuid from v_groups where group_protected <> 'true' ";
|
||||||
if (!$db->exec($sql)) {
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
//echo $db->errorCode() . "<br>";
|
$prep_statement->execute();
|
||||||
$info = $db->errorInfo();
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
print_r($info);
|
$result_count = count($result);
|
||||||
// $info[0] == $db->errorCode() unified error code
|
if ($result_count > 0) {
|
||||||
// $info[1] is the driver specific error code
|
foreach($result as $row) {
|
||||||
// $info[2] is the driver specific error string
|
$unprotected_groups[$row['group_name']] = $row['domain_uuid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset ($prep_statement, $sql, $result, $result_count);
|
||||||
|
//delete unprotected group permissions
|
||||||
|
if (is_array($unprotected_groups) && sizeof($unprotected_groups) > 0) {
|
||||||
|
foreach ($unprotected_groups as $unprotected_group_name => $unprotected_domain_uuid) {
|
||||||
|
$sql = "delete from v_group_permissions where ";
|
||||||
|
$sql .= "group_name = '".$unprotected_group_name."' ";
|
||||||
|
$sql .= "and domain_uuid ".(($unprotected_domain_uuid != '') ? " = '".$unprotected_domain_uuid."' " : " is null ");
|
||||||
|
if (!$db->exec($sql)) {
|
||||||
|
//echo $db->errorCode() . "<br>";
|
||||||
|
$info = $db->errorInfo();
|
||||||
|
print_r($info);
|
||||||
|
// $info[0] == $db->errorCode() unified error code
|
||||||
|
// $info[1] is the driver specific error code
|
||||||
|
// $info[2] is the driver specific error string
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user