0013288: Calendar update fails with "no permission"
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 3 Jul 2017 09:11:25 +0000 (11:11 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 3 Jul 2017 10:29:00 +0000 (12:29 +0200)
* catch Access Denied exceptions when setting resource type

https://forge.tine20.org/view.php?id=13288

Change-Id: Ibe455acaafb5557e4a1c33f5e5e2b6675abb0e3a
Reviewed-on: http://gerrit.tine20.com/customers/4990
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Setup/Update/Release10.php

index c6a95ee..0132725 100644 (file)
@@ -32,7 +32,7 @@ class Calendar_Setup_Update_Release10 extends Setup_Update_Abstract
     }
 
     /**
     }
 
     /**
-     * fix displaycontainer in organizers attendee records
+     * add type and max_number_of_people columns to resources
      */
     public function update_2()
     {
      */
     public function update_2()
     {
@@ -58,14 +58,20 @@ class Calendar_Setup_Update_Release10 extends Setup_Update_Abstract
 
         $resourceController = Calendar_Controller_Resource::getInstance();
         $user = Setup_Update_Abstract::getSetupFromConfigOrCreateOnTheFly();
 
         $resourceController = Calendar_Controller_Resource::getInstance();
         $user = Setup_Update_Abstract::getSetupFromConfigOrCreateOnTheFly();
-        Tinebase_Core::set(Tinebase_Core::USER, $user);
-
-        $resources = $resourceController->getAll();
-        foreach ($resources as $resource) {
-            if ($resource->is_location) {
-                $resource->type = 'ROOM';
-
-                $resourceController->update($resource);
+        if ($user) {
+            Tinebase_Core::set(Tinebase_Core::USER, $user);
+
+            $resources = $resourceController->getAll();
+            foreach ($resources as $resource) {
+                if ($resource->is_location) {
+                    $resource->type = 'ROOM';
+
+                    try {
+                        $resourceController->update($resource);
+                    } catch (Tinebase_Exception_AccessDenied $tead) {
+                        Tinebase_Exception::log($tead);
+                    }
+                }
             }
         }
 
             }
         }