From 0906f5bc85d79164865966d9e6c9b28822df7087 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 29 Mar 2018 11:52:41 +0200 Subject: [PATCH] - No permission type is needed anymore in controllers CallerLibrary and CallerModel - No permission type is anymore given as parameter to library CallerLib - Removed method checkLibraryPermission from library CallerLib - Adapted code in library CallerLib --- .../api/v1/system/CallerLibrary.php | 8 +-- .../controllers/api/v1/system/CallerModel.php | 8 +-- application/libraries/CallerLib.php | 61 +++---------------- 3 files changed, 17 insertions(+), 60 deletions(-) diff --git a/application/controllers/api/v1/system/CallerLibrary.php b/application/controllers/api/v1/system/CallerLibrary.php index 8d7c44677..594786384 100644 --- a/application/controllers/api/v1/system/CallerLibrary.php +++ b/application/controllers/api/v1/system/CallerLibrary.php @@ -33,7 +33,7 @@ class CallerLibrary extends APIv1_Controller public function getCall() { // Start me up! - $result = $this->callerlib->callLibrary($this->get(), PermissionLib::SELECT_RIGHT); + $result = $this->callerlib->callLibrary($this->get()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -45,7 +45,7 @@ class CallerLibrary extends APIv1_Controller public function postCall() { // Start me up! - $result = $this->callerlib->callLibrary($this->post(), PermissionLib::UPDATE_RIGHT); + $result = $this->callerlib->callLibrary($this->post()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -57,7 +57,7 @@ class CallerLibrary extends APIv1_Controller public function putCall() { // Start me up! - $result = $this->callerlib->callLibrary($this->put(), PermissionLib::INSERT_RIGHT); + $result = $this->callerlib->callLibrary($this->put()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -69,7 +69,7 @@ class CallerLibrary extends APIv1_Controller public function deleteCall() { // Start me up! - $result = $this->callerlib->callLibrary($this->delete(), PermissionLib::DELETE_RIGHT); + $result = $this->callerlib->callLibrary($this->delete()); // Print the result $this->response($result, REST_Controller::HTTP_OK); diff --git a/application/controllers/api/v1/system/CallerModel.php b/application/controllers/api/v1/system/CallerModel.php index 9caa7ee2f..68296aff8 100644 --- a/application/controllers/api/v1/system/CallerModel.php +++ b/application/controllers/api/v1/system/CallerModel.php @@ -33,7 +33,7 @@ class CallerModel extends APIv1_Controller public function getCall() { // Start me up! - $result = $this->callerlib->callModel($this->get(), PermissionLib::SELECT_RIGHT); + $result = $this->callerlib->callModel($this->get()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -45,7 +45,7 @@ class CallerModel extends APIv1_Controller public function postCall() { // Start me up! - $result = $this->callerlib->callModel($this->post(), PermissionLib::UPDATE_RIGHT); + $result = $this->callerlib->callModel($this->post()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -57,7 +57,7 @@ class CallerModel extends APIv1_Controller public function putCall() { // Start me up! - $result = $this->callerlib->callModel($this->put(), PermissionLib::INSERT_RIGHT); + $result = $this->callerlib->callModel($this->put()); // Print the result $this->response($result, REST_Controller::HTTP_OK); @@ -69,7 +69,7 @@ class CallerModel extends APIv1_Controller public function deleteCall() { // Start me up! - $result = $this->callerlib->callModel($this->delete(), PermissionLib::DELETE_RIGHT); + $result = $this->callerlib->callModel($this->delete()); // Print the result $this->response($result, REST_Controller::HTTP_OK); diff --git a/application/libraries/CallerLib.php b/application/libraries/CallerLib.php index d2387a723..287740d55 100644 --- a/application/libraries/CallerLib.php +++ b/application/libraries/CallerLib.php @@ -43,23 +43,23 @@ class CallerLib /** * Wrapper method for _call */ - public function callLibrary($callParameters, $permissionType) + public function callLibrary($callParameters) { - return $this->_call($callParameters, $permissionType); + return $this->_call($callParameters); } /** * Wrapper method for _call */ - public function callModel($callParameters, $permissionType) + public function callModel($callParameters) { - return $this->_call($callParameters, $permissionType); + return $this->_call($callParameters); } /** * Everything starts here... */ - private function _call($callParameters, $permissionType) + private function _call($callParameters) { $result = null; $parameters = $this->_getParameters($callParameters); @@ -87,26 +87,11 @@ class CallerLib // If not loaded then load it if ($isLoaded === false) { - // Checks if the operation is permitted by the API caller - // Only for libraries, permissions are automatically handled by models - $result = $this->checkLibraryPermission( - $parameters->resourcePath, - $parameters->resourceName, - $parameters->function, - $permissionType - ); - if (isError($result)) + // Try to load the library + $result = $this->_loadLibrary($parameters->resourcePath, $parameters->resourceName); + if (isSuccess($result)) { - $loaded = null; - } - else - { - // Try to load the library - $result = $this->_loadLibrary($parameters->resourcePath, $parameters->resourceName); - if (isSuccess($result)) - { - $loaded = $result->retval; - } + $loaded = $result->retval; } } // If it is already loaded $isLoaded contains the instance of the library @@ -244,34 +229,6 @@ class CallerLib return $result; } - /** - * Search for a valid permission for this library that should be present with this format: - * '..' => '' - */ - private function checkLibraryPermission($resourcePath, $resourceName, $function, $permissionType) - { - $result = null; - $permissionPath = ''; - - if ($resourcePath != '') - { - $permissionPath = $resourcePath; - } - - $permissionPath .= $resourceName.'.'.$function; - - if ($this->ci->permissionlib->isEntitled($permissionPath, $permissionType) === false) - { - $result = error(FHC_NORIGHT, FHC_NORIGHT); - } - else - { - $result = success('Has permission'); - } - - return $result; - } - /** * Loads a library using the given path and name *