public function getAllShareInfoFromCollaborator(AbstractEyeosPrincipal $collaborator, AbstractEyeosUser $owner = null, $classType = null) { try { $handlerClassName = null; $shareableObjectsHandlers = self::getAllShareableObjectsHandlers(); if ($classType !== null) { if (is_object($classType)) { $classType = get_class($classType); } foreach ($shareableObjectsHandlers as $handler) { if ($handler->checkType($classType)) { $handlerClassName = get_class($handler); break; } } if ($handlerClassName === null) { throw new EyeHandlerNotFoundException('Unable to find a ShareableObjectHandler for ' . $classType . '.'); } } //prepare query array $shareInfoQuery = array(self::SHAREINFO_KEY_COLLABORATORID => $collaborator->getId()); if ($owner !== null) { $shareInfoQuery[self::SHAREINFO_KEY_OWNERID] = $owner->getId(); } if ($handlerClassName !== null) { $shareInfoQuery[self::SHAREINFO_KEY_HANDLERCLASSNAME] = $handlerClassName; } $shareInfoList = $this->getProvider()->retrieveShareInfo($shareInfoQuery); $shareInfoObjectsList = array(); foreach ($shareInfoList as $shareInfo) { if (!isset($shareableObjectsHandlers[$shareInfo[self::SHAREINFO_KEY_HANDLERCLASSNAME]])) { throw new EyeHandlerNotFoundException('Cannot find handler ' . $shareInfo[self::SHAREINFO_KEY_HANDLERCLASSNAME] . '.'); } $shareableObjectHandler = $shareableObjectsHandlers[$shareInfo[self::SHAREINFO_KEY_HANDLERCLASSNAME]]; $shareableObject = $shareableObjectHandler->createShareableObject($shareInfo); // Retrieve the owner if dynamic (not passed in argument) if ($owner === null) { $owner = $shareableObject->getShareOwner(); } $shareInfoObjectsList[] = new BasicShareInfo($owner, $shareableObject, $collaborator, new SharePermission($shareInfo[self::SHAREINFO_KEY_PERMISSIONACTIONS]), $shareInfo[self::SHAREINFO_KEY_HANDLERCLASSNAME]); } return $shareInfoObjectsList; } catch (Exception $e) { self::$Logger->warn('Unable to retrieve all ShareInfo' . ($owner !== null ? ' from owner ' . $owner->getName() : '') . ' with collaborator ' . $collaborator->getName() . '.'); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false)); } throw $e; } }
public function confirmContact(AbstractEyeosUser $source, AbstractEyeosUser $target) { try { $this->contactManager->confirmContact($source->getId(), $target->getId()); $event = new PeopleEvent($source->getId(), $target->getId()); $this->fireEvent('contactConfirmed', $event); } catch (EyePeopleException $e) { throw new EyePeopleException($e->getMessage()); } }