public function &getShareableObjectData(IShareable $object, array &$shareableObjectData)
 {
     if (!$object instanceof ICalendar) {
         throw new EyeInvalidClassException('$object must be an instance of ICalendar.');
     }
     try {
         CalendarManager::getInstance()->getCalendarById($object->getId());
     } catch (EyeCalendarNotFoundException $e) {
         throw new EyeSharingException('Unable to share non-existing calendar ' . $object->getId() . '.', 0, $e);
     }
     $shareableObjectData[self::OBJECTDATA_KEY_ID] = $object->getId();
     return $shareableObjectData;
 }
 public function notifySharingStopped(IShareable $object)
 {
     if (!$object instanceof IShareableFile) {
         throw new EyeInvalidClassException('$object must be an instance of IShareableFile.');
     }
     $object->removeFileListener(SharedFileListener::getInstance());
 }
Example #3
0
 public function updateCollaboratorPermission(IShareable $object, AbstractEyeosPrincipal $collaborator, IPermission $permission)
 {
     try {
         if ($object->getId() === null) {
             throw new EyeNullPointerException('$object ID cannot be null.');
         }
         $handlerClassName = null;
         foreach (self::getAllShareableObjectsHandlers() as $handler) {
             if ($handler->checkType($object)) {
                 $handlerClassName = get_class($handler);
                 break;
             }
         }
         if ($handlerClassName === null) {
             throw new EyeHandlerNotFoundException('Unable to find a ShareableObjectHandler for object of class ' . get_class($object) . '.');
         }
         $owner = $object->getShareOwner();
         SecurityManager::getInstance()->checkPermission($object, new SharePermission(array('updatecollaborator'), $collaborator));
         //prepare query array
         $shareInfoQuery = array(self::SHAREINFO_KEY_OWNERID => $owner->getId(), self::SHAREINFO_KEY_SHAREABLEID => $object->getId(), self::SHAREINFO_KEY_COLLABORATORID => $collaborator->getId(), self::SHAREINFO_KEY_PERMISSIONACTIONS => $permission->getActionsAsString(), self::SHAREINFO_KEY_HANDLERCLASSNAME => $handlerClassName);
         $this->getProvider()->updateShareInfo($owner, $shareInfoQuery);
         // TODO: we could also add the ShareInfo object containing the old permission as a
         // "related source" of the event
         $event = new SharingEvent(new BasicShareInfo($owner, $object, $collaborator, $permission, $handlerClassName));
         foreach ($this->listeners as $listener) {
             $listener->collaboratorPermissionUpdated($event);
         }
     } catch (Exception $e) {
         self::$Logger->warn('Unable to update collaborator ' . $collaborator->getName() . ' permissions for object of class ' . get_class($object) . '.');
         if (self::$Logger->isDebugEnabled()) {
             self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false));
         }
         throw $e;
     }
 }