Group Permissions Class: Modify restore() method to include group_uuid when restoring group permissions.
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Copyright (C) 2013
|
Portions created by the Initial Developer are Copyright (C) 2013-2020
|
||||||
All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
$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
|
||||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach ($config_list as &$config_path) {
|
foreach ($config_list as &$config_path) {
|
||||||
include($config_path);
|
include($config_path);
|
||||||
@@ -85,23 +85,29 @@
|
|||||||
foreach ($row['permissions'] as $permission) {
|
foreach ($row['permissions'] as $permission) {
|
||||||
//set the variables
|
//set the variables
|
||||||
if ($permission['groups']) {
|
if ($permission['groups']) {
|
||||||
foreach ($permission['groups'] as $group) {
|
foreach ($permission['groups'] as $group_name) {
|
||||||
//check group protection
|
//check group protection
|
||||||
$sql = "select count(*) from v_groups ";
|
$sql = "select group_uuid, group_protected from v_groups ";
|
||||||
$sql .= "where group_name = :group_name ";
|
$sql .= "where group_name = :group_name ";
|
||||||
$sql .= "and group_protected = 'true'";
|
$parameters['group_name'] = $group_name;
|
||||||
$parameters['group_name'] = $group;
|
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$num_rows = $database->select($sql, $parameters, 'column');
|
$result = $database->select($sql, $parameters, 'row');
|
||||||
|
if (is_array($result) && @sizeof($result) != 0) {
|
||||||
|
$group_uuid = $result['group_uuid'];
|
||||||
|
$group_protected = $result['group_protected'] == 'true' ? true : false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$group_protected = false;
|
||||||
|
}
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
if ($num_rows == 0) {
|
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
|
||||||
$sql = "select count(*) from v_group_permissions ";
|
$sql = "select count(*) from v_group_permissions ";
|
||||||
$sql .= "where permission_name = :permission_name ";
|
$sql .= "where permission_name = :permission_name ";
|
||||||
$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;
|
$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);
|
||||||
@@ -110,7 +116,10 @@
|
|||||||
//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;
|
$array['group_permissions'][$x]['group_name'] = $group_name;
|
||||||
|
if (is_uuid($group_uuid)) {
|
||||||
|
$array['group_permissions'][$x]['group_uuid'] = $group_uuid;
|
||||||
|
}
|
||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user