mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Update permissions.php
Use the new array structure.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2015 All Rights Reserved.
|
||||
Copyright (C) 2016 All Rights Reserved.
|
||||
|
||||
*/
|
||||
|
||||
@@ -28,78 +28,63 @@
|
||||
* @method string delete
|
||||
* @method string exists
|
||||
*/
|
||||
if (!class_exists('permissions')) {
|
||||
class permissions {
|
||||
if (!class_exists('permissions')) {
|
||||
class permissions {
|
||||
|
||||
/**
|
||||
* Add a permission
|
||||
* @var string $permission
|
||||
*/
|
||||
public function add($permission, $type = '') {
|
||||
if (!$this->exists($permission)) {
|
||||
//set the ordinal number
|
||||
$i = count($_SESSION["permissions"])+1;
|
||||
/**
|
||||
* Add a permission
|
||||
* @var string $permission
|
||||
*/
|
||||
public function add($permission, $type = '') {
|
||||
if (!$this->exists($permission)) {
|
||||
//set the ordinal number
|
||||
$i = count($_SESSION["permissions"])+1;
|
||||
|
||||
//set the permission
|
||||
$_SESSION["permissions"][$i]["permission_name"] = $permission;
|
||||
$_SESSION["permissions"][$i]["permission_type"] = "temp";
|
||||
}
|
||||
//set the permission
|
||||
$_SESSION["permissions"][$permission] = "temp";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the permission
|
||||
* @var string $permission
|
||||
*/
|
||||
public function delete($permission, $type = '') {
|
||||
if ($this->exists($permission)) {
|
||||
if ($type = "temp" && $_SESSION["permissions"][$permission] == "temp") {
|
||||
unset($_SESSION["permissions"][$permission]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the permission
|
||||
* @var string $permission
|
||||
*/
|
||||
public function delete($permission, $type = '') {
|
||||
if ($this->exists($permission)) {
|
||||
foreach($_SESSION["permissions"] as $key => $row) {
|
||||
if ($row['permission_name'] == $permission) {
|
||||
if ($row['permission_name'] == $permission) {
|
||||
if ($type == 'temp') {
|
||||
if ($row['permission_type'] == "temp") {
|
||||
unset($_SESSION["permissions"][$key]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unset($_SESSION["permissions"][$key]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
unset($_SESSION["permissions"][$permission]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the permission exists
|
||||
* @var string $permission
|
||||
*/
|
||||
function exists($permission) {
|
||||
//set default false
|
||||
$result = false;
|
||||
//search for the permission
|
||||
if (count($_SESSION["permissions"]) > 0) {
|
||||
foreach($_SESSION["permissions"] as $row) {
|
||||
if ($row['permission_name'] == $permission) {
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//return the result
|
||||
return $result;
|
||||
/**
|
||||
* Check to see if the permission exists
|
||||
* @var string $permission
|
||||
*/
|
||||
function exists($permission) {
|
||||
//set default false
|
||||
$result = false;
|
||||
//search for the permission
|
||||
if (is_array($_SESSION["permissions"]) && $_SESSION["permissions"][$permission] == true) {
|
||||
$result = true;
|
||||
}
|
||||
//return the result
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//examples
|
||||
/*
|
||||
//add the permission
|
||||
$p = new permissions;
|
||||
$p->add($permission);
|
||||
//delete the permission
|
||||
$p = new permissions;
|
||||
$p->delete($permission);
|
||||
*/
|
||||
//examples
|
||||
/*
|
||||
//add the permission
|
||||
$p = new permissions;
|
||||
$p->add($permission);
|
||||
//delete the permission
|
||||
$p = new permissions;
|
||||
$p->delete($permission);
|
||||
*/
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user