From 21862dbac11341517bd85133a0c222881ddc28a2 Mon Sep 17 00:00:00 2001 From: disc5 Date: Tue, 2 Jun 2015 16:50:23 +0200 Subject: [PATCH] IO Issues resolved --- .../extensions/admin/models/DescribrModel.php | 6 ++++-- .../extensions/admin/routes/DescribrRoutes.php | 5 +++++ .../mobile_v1/routes/MobileFileSpaceRoutes.php | 6 +++--- .../extensions/users_v1/routes/UsersRoutes.php | 14 +------------- .../REST/RESTController/libs/RESTLib.php | 10 +++++----- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/models/DescribrModel.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/models/DescribrModel.php index 175fd712..2b0a1c8b 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/models/DescribrModel.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/models/DescribrModel.php @@ -15,8 +15,7 @@ require_once('./Services/Database/classes/class.ilAuthContainerMDB2.php'); -class DescribrModel -{ +class DescribrModel extends Libs\RESTModel { /** * Returns a description of an ILIAS object consisting of @@ -29,9 +28,12 @@ class DescribrModel */ public function describeIliasObject($obj_id) { + self::$app->log->debug('describe '.$obj_id); + $a_objdata = $this->getObjectData($obj_id); $owner_id = $a_objdata['owner']; + $a_usrdata = $this->getUserData($owner_id); foreach ($a_usrdata as $key => $value) { diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/routes/DescribrRoutes.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/routes/DescribrRoutes.php index 08854883..dae9c7d6 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/routes/DescribrRoutes.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/admin/routes/DescribrRoutes.php @@ -23,11 +23,16 @@ $request = $app->request(); $id_type = $request->params('id_type', 'ref_id'); + $app->log->debug('in route '.$id_type); + + $result = array('msg' => array()); $model = new DescribrModel(); if ($id_type == 'ref_id' || $id_type == 'obj_id') { if ($id_type == 'ref_id') { + $app->log->debug('in route id: '.$id); $obj_id = Libs\RESTLib::getObjIdFromRef($id); + $app->log->debug('in route id: '.$obj_id); $id_type = 'obj_id'; } diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/mobile_v1/routes/MobileFileSpaceRoutes.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/mobile_v1/routes/MobileFileSpaceRoutes.php index d4e7485b..0c9cd21c 100644 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/mobile_v1/routes/MobileFileSpaceRoutes.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/mobile_v1/routes/MobileFileSpaceRoutes.php @@ -73,7 +73,7 @@ 'execution_time' => $t_end - $t_start )); - } catch(LibExceptions\MissingParameter $e) { + } catch(Exceptions\MissingParameter $e) { $app->halt(422, $e->getFormatedMessage(), $e::ID); } }); @@ -107,7 +107,7 @@ $app->success(array( 'execution_time' => $t_end - $t_start )); - } catch(LibExceptions\MissingParameter $e) { + } catch(Exceptions\MissingParameter $e) { $app->halt(422, $e->getFormatedMessage(), $e::ID); } $response->send(); @@ -178,7 +178,7 @@ Libs\RESTLib::initAccessHandling(); $model = new Files\PersonalFileSpaceModel(); $model->deleteFromMyFileSpace($file_id, $user_id); - } catch(LibExceptions\MissingParameter $e) { + } catch(Exceptions\MissingParameter $e) { $app->halt(422, $e->getFormatedMessage(), $e::ID); } $t_end = microtime(); diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/users_v1/routes/UsersRoutes.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/users_v1/routes/UsersRoutes.php index 4502c24c..cdf8204e 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/users_v1/routes/UsersRoutes.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/users_v1/routes/UsersRoutes.php @@ -12,8 +12,6 @@ $app->get('/v1/users', '\RESTController\libs\OAuth2Middleware::TokenAdminAuth', function () use ($app) { - try { - $limit = 10; $offset = 0; @@ -47,14 +45,10 @@ $app->success($result); - } catch (\Exception $e) { - $app->halt(400, $e->getMessage()); - } }); $app->get('/v1/users/:user_id', '\RESTController\libs\OAuth2Middleware::TokenAuth', function ($user_id) use ($app) { - try { $id = $user_id; if ($user_id == "mine") { $auth = new Auth\Util(); @@ -68,14 +62,10 @@ $app->success($usr_basic_info); - } catch (\Exception $e) { - $app->halt(400, $e->getMessage()); - } }); $app->post('/v1/users', '\RESTController\libs\OAuth2Middleware::TokenRouteAuth', function () use ($app) { // create - try { // root only $request = $app->request(); $attribs = array("login", "passwd", "firstname", "lastname", "email", "gender", "auth_mode"); @@ -94,9 +84,7 @@ $user_id = $usr_model->addUser($user_data); $app->success($user_id); - } catch (\Exception $e) { - $app->halt(400, $e->getMessage()); - } + }); diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/libs/RESTLib.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/libs/RESTLib.php index 3efe567a..319ca747 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/libs/RESTLib.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/libs/RESTLib.php @@ -86,8 +86,6 @@ protected static function quoteParams($params) { $value = sprintf('(%s)', implode(', ', $value)); $result[] = $value; } - elseif (is_string($value)) - $result[] = $ilDB->quote($value, 'text'); elseif (is_int($value)) $result[] = $ilDB->quote($value, 'integer'); elseif (is_integer($value)) @@ -96,8 +94,10 @@ protected static function quoteParams($params) { $result[] = $ilDB->quote($value, 'float'); elseif (is_double($value)) $result[] = $ilDB->quote($value, 'float'); - elseif (is_numeric($value)) + elseif (is_numeric($value)) // TODO: could be improved $result[] = $ilDB->quote($value, 'float'); + elseif (is_string($value)) + $result[] = $ilDB->quote($value, 'text'); // Fallback solution else $result[] = $value; @@ -215,7 +215,7 @@ static public function authenticateViaIlias($username, $password) { static public function getObjIdFromRef($ref_id) { global $ilDB; - $sql = self::safeSQL('SELECT obj_id FROM object_reference WHERE object_reference.ref_id = %d', $ref_id); + $sql = self::safeSQL('SELECT obj_id FROM object_reference WHERE object_reference.ref_id = %d', intval($ref_id)); $query = $ilDB->query($sql); $row = $ilDB->fetchAssoc($query); @@ -233,7 +233,7 @@ static public function getObjIdFromRef($ref_id) { static public function getRefIdFromObj($obj_id) { global $ilDB; - $sql = self::safeSQL('SELECT ref_id FROM object_reference WHERE object_reference.obj_id = %d', $obj_id); + $sql = self::safeSQL('SELECT ref_id FROM object_reference WHERE object_reference.obj_id = %d', intval($obj_id)); $query = $ilDB->query($sql); $row = $ilDB->fetchAssoc($query);