Update permission.php
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
//define the permission class
|
//define the permission class
|
||||||
class permission {
|
class permission {
|
||||||
|
|
||||||
//delete the permissions
|
|
||||||
//delete the permissions
|
//delete the permissions
|
||||||
function delete() {
|
function delete() {
|
||||||
|
|
||||||
@@ -112,7 +111,14 @@
|
|||||||
|
|
||||||
//restore the permissions
|
//restore the permissions
|
||||||
function restore() {
|
function restore() {
|
||||||
//delete the group permisisons
|
|
||||||
|
//if the are no groups add the default groups
|
||||||
|
$sql = "select * from v_groups ";
|
||||||
|
$sql .= "where domain_uuid is null ";
|
||||||
|
$database = new database;
|
||||||
|
$groups = $database->select($sql, null, 'all');
|
||||||
|
|
||||||
|
//delete the group permissions
|
||||||
$this->delete();
|
$this->delete();
|
||||||
|
|
||||||
//get the $apps array from the installed apps from the core and mod directories
|
//get the $apps array from the installed apps from the core and mod directories
|
||||||
@@ -132,19 +138,15 @@
|
|||||||
if ($permission['groups']) {
|
if ($permission['groups']) {
|
||||||
foreach ($permission['groups'] as $group_name) {
|
foreach ($permission['groups'] as $group_name) {
|
||||||
//check group protection
|
//check group protection
|
||||||
$sql = "select group_uuid, group_protected from v_groups ";
|
if (is_array($groups)) {
|
||||||
$sql .= "where group_name = :group_name ";
|
foreach ($groups as $group) {
|
||||||
$parameters['group_name'] = $group_name;
|
if ($group['group_name'] == $group_name) {
|
||||||
$database = new database;
|
$group_uuid = $group['group_uuid'];
|
||||||
$result = $database->select($sql, $parameters, 'row');
|
$group_protected = $group['group_protected'] == 'true' ? true : false;
|
||||||
if (is_array($result) && @sizeof($result) != 0) {
|
break;
|
||||||
$group_uuid = $result['group_uuid'];
|
}
|
||||||
$group_protected = $result['group_protected'] == 'true' ? true : false;
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$group_protected = false;
|
|
||||||
}
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
if (!$group_protected) {
|
if (!$group_protected) {
|
||||||
//if the item uuid is not currently in the db then add it
|
//if the item uuid is not currently in the db then add it
|
||||||
@@ -153,18 +155,17 @@
|
|||||||
$sql .= "and group_name = :group_name ";
|
$sql .= "and group_name = :group_name ";
|
||||||
$parameters['permission_name'] = $permission['name'];
|
$parameters['permission_name'] = $permission['name'];
|
||||||
$parameters['group_name'] = $group_name;
|
$parameters['group_name'] = $group_name;
|
||||||
|
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$num_rows = $database->select($sql, $parameters, 'column');
|
$num_rows = $database->select($sql, $parameters, 'column');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
//build default permissions insert array
|
//build default permissions insert array
|
||||||
$array['group_permissions'][$x]['group_permission_uuid'] = uuid();
|
$array['group_permissions'][$x]['group_permission_uuid'] = uuid();
|
||||||
$array['group_permissions'][$x]['permission_name'] = $permission['name'];
|
$array['group_permissions'][$x]['permission_name'] = $permission['name'];
|
||||||
$array['group_permissions'][$x]['group_name'] = $group_name;
|
$array['group_permissions'][$x]['group_name'] = $group_name;
|
||||||
if (is_uuid($group_uuid)) {
|
$array['group_permissions'][$x]['group_uuid'] = $group_uuid;
|
||||||
$array['group_permissions'][$x]['group_uuid'] = $group_uuid;
|
|
||||||
}
|
|
||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,6 +174,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($array) && @sizeof($array)) {
|
if (is_array($array) && @sizeof($array)) {
|
||||||
//grant temporary permissions
|
//grant temporary permissions
|
||||||
$p = new permissions;
|
$p = new permissions;
|
||||||
|
|||||||
Reference in New Issue
Block a user