Kronolith::notifyOfResourceRejection PHP Method

notifyOfResourceRejection() public static method

Check for resource declines and push notice to stack if found.
public static notifyOfResourceRejection ( Kronolith_Event $event )
$event Kronolith_Event
    public static function notifyOfResourceRejection($event)
    {
        $accepted = $declined = array();
        foreach ($event->getResources() as $id => $resource) {
            if ($resource['response'] == self::RESPONSE_DECLINED) {
                $r = self::getDriver('Resource')->getResource($id);
                $declined[] = $r->get('name');
            } elseif ($resource['response'] == self::RESPONSE_ACCEPTED) {
                $r = self::getDriver('Resource')->getResource($id);
                $accepted[] = $r->get('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');
        }
        if (count($accepted)) {
            $GLOBALS['notification']->push(sprintf(ngettext("The following resource has accepted your request: %s", "The following resources have accepted your request: %s", count($accepted)), implode(", ", $accepted)), 'horde.success');
        }
    }

Usage Example

コード例 #1
0
ファイル: edit.php プロジェクト: jubinpatel/horde
/**
 * Copyright 1999-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Kronolith
 */
function _save(&$event)
{
    try {
        $event->save();
        if (Horde_Util::getFormData('sendupdates', false)) {
            Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_REQUEST);
        }
    } catch (Exception $e) {
        $GLOBALS['notification']->push(sprintf(_("There was an error editing the event: %s"), $e->getMessage()), 'horde.error');
    }
    Kronolith::notifyOfResourceRejection($event);
}
All Usage Examples Of Kronolith::notifyOfResourceRejection