Branch 'kolab-webadmin-3.1' - lib/kolab_api_service.php

Aleksander Machniak machniak at kolabsys.com
Mon Nov 18 15:08:39 CET 2013


 lib/kolab_api_service.php |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 6ec6d398a0ee9379f24afea531fad7bf2ed36480
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Nov 18 15:07:06 2013 +0100

    Fix "invalid type id" exception when type id is provided (broken in last commit)

diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index ef0e8bf..1972cb0 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -84,14 +84,16 @@ abstract class kolab_api_service
             $object_types = $this->object_types($object_name);
         }
 
-        if ($type_id && empty($object_types[$type_id])) {
-            throw new Exception($this->controller->translate('api.invalidtypeid'), 35);
-        }
-        else if (count($object_types) == 1) {
-            $type_id = key($object_types);
+        if (empty($type_id)) {
+            if (count($object_types) == 1) {
+                $type_id = key($object_types);
+            }
+            else {
+                throw new Exception($this->controller->translate('api.notypeid'), 34);
+            }
         }
-        else {
-            throw new Exception($this->controller->translate('api.notypeid'), 34);
+        else if ($type_id && empty($object_types[$type_id])) {
+            throw new Exception($this->controller->translate('api.invalidtypeid'), 35);
         }
 
         $key_name = $object_types[$type_id]['key'];




More information about the commits mailing list