Kronolith::countEvents PHP Метод

countEvents() публичный статический Метод

Returns the number of events in calendars that the current user owns.
public static countEvents ( ) : integer
Результат integer The number of events.
    public static function countEvents()
    {
        static $count;
        if (isset($count)) {
            return $count;
        }
        $kronolith_driver = self::getDriver();
        $calendars = self::listInternalCalendars(true, Horde_Perms::ALL);
        $current_calendar = $kronolith_driver->calendar;
        $count = 0;
        foreach (array_keys($calendars) as $calendar) {
            $kronolith_driver->open($calendar);
            try {
                $count += $kronolith_driver->countEvents();
            } catch (Exception $e) {
            }
        }
        /* Reopen last calendar. */
        $kronolith_driver->open($current_calendar);
        return $count;
    }

Usage Example

Пример #1
0
function _check_max()
{
    $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
    if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
        Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
        return false;
    }
    return true;
}
All Usage Examples Of Kronolith::countEvents