Always use the resource default status
authorsstamer <s.stamer@metaways.de>
Thu, 10 Dec 2015 15:29:30 +0000 (16:29 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 21 Dec 2015 11:03:33 +0000 (12:03 +0100)
- on invite
- reset to default on reshedule
- only resource editors can change the status

Change-Id: If97006959a33afee9dc1bdbd758305695cdef434
Reviewed-on: http://gerrit.tine20.com/customers/2493
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Controller/Event.php

index 678833e..736c894 100644 (file)
@@ -2015,7 +2015,12 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         if ($attender->displaycontainer_id) {
             // check if user is allowed to set status
             if (! $preserveStatus && ! Tinebase_Core::getUser()->hasGrant($attender->displaycontainer_id, Tinebase_Model_Grants::GRANT_EDIT)) {
-                $attender->status = Calendar_Model_Attender::STATUS_NEEDSACTION;
+                if ($attender->user_type === Calendar_Model_Attender::USERTYPE_RESOURCE) {
+                    //If resource has an default status use this
+                    $attender->status = isset($resource->status) ? $resource->status : Calendar_Model_Attender::STATUS_NEEDSACTION;
+                } else {
+                    $attender->status = Calendar_Model_Attender::STATUS_NEEDSACTION;
+                }
             }
         }
 
@@ -2123,7 +2128,8 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
 
         // reset all status but calUser on reschedule except resources (Resources might have a configured default value)
         if ($isRescheduled && !$attender->isSame($this->getCalendarUser())) {
-            if ($attender->user_type == Calendar_Model_Attender::USERTYPE_RESOURCE) {
+            if ($attender->user_type === Calendar_Model_Attender::USERTYPE_RESOURCE) {
+                //If resource has a default status reset to this
                 $resource = Calendar_Controller_Resource::getInstance()->get($attender->user_id);
                 $attender->status = isset($resource->status) ? $resource->status : Calendar_Model_Attender::STATUS_NEEDSACTION;
             } else {