From: Michael J. Rubinsky Date: Thu, 10 Sep 2009 16:11:12 +0000 (-0400) Subject: notify user if a requested resource rejects invitation when saving event X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=79c28d4533a4d50b7e92aa7a4c5dd4b4388c961a;p=horde.git notify user if a requested resource rejects invitation when saving event --- diff --git a/kronolith/add.php b/kronolith/add.php index 5b3f5e90f..960e68225 100644 --- a/kronolith/add.php +++ b/kronolith/add.php @@ -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')) { diff --git a/kronolith/edit.php b/kronolith/edit.php index d22356fcd..47ab29e3b 100644 --- a/kronolith/edit.php +++ b/kronolith/edit.php @@ -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')); diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 1d82f7c95..6495d3aec 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -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