notify user if a requested resource rejects invitation when saving event
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 10 Sep 2009 16:11:12 +0000 (12:11 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 29 Sep 2009 20:53:53 +0000 (16:53 -0400)
kronolith/add.php
kronolith/edit.php
kronolith/lib/Kronolith.php

index 5b3f5e9..960e682 100644 (file)
@@ -39,6 +39,7 @@ if (!Horde_Util::getFormData('cancel')) {
 
             $notification->push(sprintf(_("There was an error adding the event: %s"), $message), 'horde.error');
         } else {
+            Kronolith::notifyOfResoruceRejection($event);
             if (Horde_Util::getFormData('sendupdates', false)) {
                 $event = Kronolith::getDriver()->getEvent($result);
                 if (is_a($event, 'PEAR_Error')) {
index d22356f..47ab29e 100644 (file)
@@ -19,6 +19,7 @@ function _save(&$event)
     } elseif (Horde_Util::getFormData('sendupdates', false)) {
         Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_REQUEST);
     }
+    Kronolith::notifyOfResoruceRejection($event);
 }
 
 function _check_max()
@@ -73,6 +74,7 @@ if ($exception = Horde_Util::getFormData('del_exception')) {
         if (($edit_recur = Horde_Util::getFormData('edit_recur')) &&
             $edit_recur != 'all' && $edit_recur != 'copy' &&
             _check_max()) {
+
             /* Get event details. */
             $kronolith_driver->open($source);
             $event = &$kronolith_driver->getEvent(Horde_Util::getFormData('eventID'));
index 1d82f7c..6495d3a 100644 (file)
@@ -1538,6 +1538,29 @@ class Kronolith
     }
 
     /**
+     * Check for resource declines and push notice to stack if found.
+     *
+     * @param Kronolith_Event #
+     */
+    public static function notifyOfResoruceRejection($event)
+    {
+        $declined = array();
+        foreach ($event->getResources() as $id => $resource) {
+            if ($resource['response'] == Kronolith::RESPONSE_DECLINED) {
+                $r = Kronolith::getDriver('Resource')->getResource($id);
+                $declined[] = $r->name;
+            }
+        }
+        if (count($declined)) {
+            $GLOBALS['notification']->push(sprintf(ngettext("The following resource has declined your request: %s",
+                                                            "The following resources have declined your request: %s",
+                                                            count($declined)),
+                                                    implode(", ", $declined)),
+                                           'horde.error');
+        }
+    }
+
+    /**
      * Returns whether a user wants email notifications for a calendar.
      *
      * @access private