resetDemodata
authorsstamer <s.stamer@metaways.de>
Thu, 16 Apr 2015 13:28:39 +0000 (15:28 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 21 Apr 2015 14:08:52 +0000 (16:08 +0200)
- restore rights

Change-Id: I6a74df64ce78c1c5e3fc0303b93b8a00d3e9d727
Reviewed-on: http://gerrit.tine20.com/customers/1857
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Setup/Frontend/Cli.php

index af28b6d..120d728 100644 (file)
@@ -306,6 +306,10 @@ class Setup_Frontend_Cli
             }
         }
         
             }
         }
         
+        //get set rights
+        $users = Tinebase_Acl_Roles::getInstance()->getRoleByName('user role');
+        $rights = Tinebase_Acl_Roles::getInstance()->getRoleRights($users->getId());
+        
         //Uninstall Applications
         try {
             $controller->uninstallApplications($applications->name);
         //Uninstall Applications
         try {
             $controller->uninstallApplications($applications->name);
@@ -319,6 +323,21 @@ class Setup_Frontend_Cli
         } catch (Tinebase_Exception_NotFound $e) {
         }
         
         } catch (Tinebase_Exception_NotFound $e) {
         }
         
+        //set rights
+        foreach ($applications as &$application) {
+            $newApplicationId = Tinebase_Application::getInstance()->getApplicationByName($application->name)->getId();
+            
+            foreach ($rights as &$right) {
+                if ($right['application_id'] == $application->id) {
+                    $right['application_id'] = $newApplicationId;
+                }
+            }
+            
+        }
+        
+        Tinebase_Acl_Roles::getInstance()->setRoleRights($users->getId(), $rights);
+        echo "Successfully restored user rights.\n";
+        
         //Clean up addressbooks
         $internalContacts = $userController->getDefaultInternalAddressbook();
         $containers = $containerController->getAll();
         //Clean up addressbooks
         $internalContacts = $userController->getDefaultInternalAddressbook();
         $containers = $containerController->getAll();