hasPermission() public static method

Returns whether the current user has certain permissions on a calendar.
public static hasPermission ( string $calendar, integer $perm ) : boolean
$calendar string A calendar id.
$perm integer A Horde_Perms permission mask.
return boolean True if the current user has the requested permissions.
Esempio n. 1
0
 /**
  * Returns the driver object for a calendar.
  *
  * @param string $cal  A calendar string in the format "type|name".
  *
  * @return Kronolith_Driver|boolean  A driver instance or false on failure.
  */
 protected function _getDriver($cal)
 {
     list($driver, $calendar) = explode('|', $cal);
     if ($driver == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) {
         $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
         return false;
     }
     try {
         $kronolith_driver = Kronolith::getDriver($driver, $calendar);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         return false;
     }
     if ($driver == 'remote') {
         $kronolith_driver->setParam('timeout', 15);
     }
     return $kronolith_driver;
 }
Esempio n. 2
0
 /**
  */
 public function davDeleteObject($collection, $object)
 {
     $dav = $GLOBALS['injector']->getInstance('Horde_Dav_Storage');
     $internal = $dav->getInternalCollectionId($collection, 'calendar') ?: $collection;
     if (!Kronolith::hasPermission($internal, Horde_Perms::DELETE)) {
         throw new Kronolith_Exception(_("Calendar does not exist or no permission to delete"));
     }
     try {
         $object = $dav->getInternalObjectId($object, $internal) ?: preg_replace('/\\.ics$/', '', $object);
     } catch (Horde_Dav_Exception $e) {
     }
     $kronolith_driver = Kronolith::getDriver(null, $internal);
     $event = $kronolith_driver->getEvent($object);
     $kronolith_driver->deleteEvent($object);
     try {
         $dav->deleteExternalObjectId($object, $internal);
     } catch (Horde_Dav_Exception $e) {
     }
     // Send iTip messages unless organizer is external.
     // Notifications will get lost, there is no way to return messages to
     // clients.
     if ($event->organizer && !Kronolith::isUserEmail($event->creator, $event->organizer)) {
         return;
     }
     Kronolith::sendITipNotifications($event, new Horde_Notification_Handler(new Horde_Notification_Storage_Object()), Kronolith::ITIP_CANCEL);
 }
Esempio n. 3
0
File: Api.php Progetto: horde/horde
 /**
  * Check for existing calendar or event locks.
  *
  * @param array $calendar  The calendar to check locks for.
  * @param array $event     The event to check locks for.
  *
  * @throws Kronolith_Exception
  */
 public function checkLocks($calendar, $event = null)
 {
     if (!Kronolith::hasPermission($calendar, Horde_Perms::READ)) {
         throw new Horde_Exception_PermissionDenied();
     }
     if (!empty($event)) {
         $uid = $calendar . ':' . $event;
     }
     return $GLOBALS['injector']->getInstance('Kronolith_Shares')->getShare($calendar)->checkLocks($GLOBALS['injector']->getInstance('Horde_Lock'), $uid);
 }
Esempio n. 4
0
 * Copyright 2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/apache.
 *
 * @author Jan Schneider <*****@*****.**>
 * @author Michael J Rubinsky <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
$source = Horde_Util::getFormData('source');
$key = Horde_Util::getFormData('key');
$filename = Horde_Util::getFormData('file');
$type = Horde_Util::getFormData('type');
list($driver_type, $calendar) = explode('|', $source);
if ($driver_type == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) {
    $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
    return false;
}
try {
    $driver = Kronolith::getDriver($driver_type, $calendar);
} catch (Exception $e) {
    $GLOBALS['notification']->push($e, 'horde.error');
    return false;
}
$event = $driver->getEvent($key);
/* Check permissions. */
if (!$event->hasPermission(Horde_Perms::READ)) {
    throw new Kronolith_Exception(_("You do not have permission to view this event."));
}
try {