Add a setResources() method similar to setAttendees() for bulk setting
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 10 Sep 2009 14:13:52 +0000 (10:13 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 29 Sep 2009 20:53:52 +0000 (16:53 -0400)
the local resources array

kronolith/lib/Event.php

index 0af8f73..6ed3a61 100644 (file)
@@ -1542,7 +1542,7 @@ abstract class Kronolith_Event
     }
 
     /**
-     * Adds a Kronolith_Resource to this event.
+     * Adds a single Kronolith_Resource to this event.
      * No validation or acceptence/denial is done here...it should be done
      * when saving the Event.
      *
@@ -1560,6 +1560,18 @@ abstract class Kronolith_Event
     }
 
     /**
+     * Directly set/replace the _resources array. Called from Event::readForm
+     * to bulk load the resources from $_SESSION
+     *
+     * @param $resources
+     * @return unknown_type
+     */
+    public function setResources($resources)
+    {
+        $this->_resources = $resources;
+    }
+
+    /**
      * Remove a Kronolith_Resource from this event
      *
      * @param Kronolith_Resource $resource  The resource to remove
@@ -1645,6 +1657,11 @@ abstract class Kronolith_Event
             $this->setAttendees($_SESSION['kronolith']['attendees']);
         }
 
+        // Resources
+        if (isset($_SESSION['kronolith']['resources']) && is_array($_SESSION['kronolith']['resources'])) {
+            $this->setResources($_SESSION['kronolith']['resources']);
+        }
+
         // strptime() is locale dependent, i.e. %p is not always matching
         // AM/PM. Set the locale to C to workaround this, but grab the
         // locale's D_FMT before that.