throws exception if mandatory user object is missing
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Jun 2014 17:56:10 +0000 (19:56 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 19 Jun 2014 11:44:23 +0000 (13:44 +0200)
Change-Id: Ibfc71e7fcd692ee8a795376dd6ca5c67360f26b4
Reviewed-on: http://gerrit.tine20.com/customers/783
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Controller/Abstract.php
tine20/Tinebase/Core.php

index f4095f2..1b03fa6 100755 (executable)
@@ -59,6 +59,7 @@ abstract class Tinebase_Controller_Abstract implements Tinebase_Controller_Inter
      * @return  boolean
      * @throws  Tinebase_Exception_UnexpectedValue
      * @throws  Tinebase_Exception_AccessDenied
+     * @throws  Tinebase_Exception
      * 
      * @todo move that to *_Acl_Rights
      * @todo include Tinebase admin? atm only the application admin right is checked
@@ -69,6 +70,9 @@ abstract class Tinebase_Controller_Abstract implements Tinebase_Controller_Inter
         if (empty($this->_applicationName)) {
             throw new Tinebase_Exception_UnexpectedValue('No application name defined!');
         }
+        if (! is_object(Tinebase_Core::getUser())) {
+            throw new Tinebase_Exception('No user found for right check!');
+        }
         
         $right = strtoupper($_right);
         
index 88a47cc..ce6b3b5 100644 (file)
@@ -1344,11 +1344,23 @@ class Tinebase_Core
 
     /**
      * set a registry value
-     *
+     * 
+     * @throws Tinebase_Exception_InvalidArgument
      * @return mixed value
      */
     public static function set($index, $value)
     {
+        if ($index === self::USER) {
+            if ($value === null) {
+                throw new Tinebase_Exception_InvalidArgument('Invalid user object!');
+            }
+            if ($value instanceof Tinebase_Model_FullUser) {
+                Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Setting user ' . $value->accountLoginName);
+            } else {
+                Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Setting user ' . var_export($value, true));
+            }
+        }
+        
         Zend_Registry::set($index, $value);
     }