public function getMediaItems($userId, $groupId, $albumId, $mediaItemIds, $collectionOptions, $fields, $token) { if (!class_exists('Album')) { throw new SocialSpiException("Not implemented", ResponseError::$NOT_IMPLEMENTED); } $first = $this->fixStartIndex($collectionOptions->getStartIndex()); $max = $this->fixCount($collectionOptions->getCount()); if (!is_object($userId)) { $userId = new UserId('userId', $userId); $groupId = new GroupId('self', 'all'); } $memberIds = $this->getIdSet($userId, $groupId, $token); if ($groupId->getType() !== 'self' || count($memberIds) !== 1) { throw new SocialSpiException("Bad Request", ResponseError::$BAD_REQUEST); } $memberId = $memberIds[0]; $albumObject = Doctrine::getTable('Album')->find($albumId); if (!$albumObject) { throw new SocialSpiException("Album Not Found", ResponseError::$BAD_REQUEST); } if ($albumObject->getMemberId() != $memberId && !($albumObject->getPublicFlag() === AlbumTable::PUBLIC_FLAG_SNS || $albumObject->getPublicFlag() === AlbumTable::PUBLIC_FLAG_OPEN)) { throw new SocialSpiException("Bad Request", ResponseError::$BAD_REQUEST); } $totalSize = 0; $query = Doctrine::getTable('AlbumImage')->createQuery()->where('album_id = ?', $albumObject->getId()); $totalSize = $query->count(); $query->offset($first); $query->limit($max); $objects = $query->execute(); $results = array(); // block check $isBlock = false; if ($token->getViewerId()) { $relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($memberId, $token->getViewerId()); if ($relation && $relation->getIsAccessBlock()) { $isBlock = true; } } if (!$isBlock) { foreach ($objects as $object) { $result['albumId'] = $object->getId(); $result['created'] = $object->getCreatedAt(); $result['description'] = opOpenSocialToolKit::convertEmojiForApi($object->getDescription()); $result['fileSize'] = $object->getFilesize(); $result['id'] = $object->getId(); $result['lastUpdated'] = $object->getUpdatedAt(); $result['thumbnailUrl'] = ''; $result['title'] = $object->getDescription(); $result['type'] = 'IMAGE'; $result['url'] = ''; if ($object->getFile()) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset', 'sfImage')); $result['thumbnailUrl'] = sf_image_path($object->getFile(), array('size' => '180x180'), true); $result['url'] = sf_image_path($object->getFile(), array(), true); } $results[] = $result; } } $collection = new RestfulCollection($results, $first, $totalSize); $collection->setItemsPerPage($max); return $collection; }
/** * get profile datas * * @param array $allowed * @return array */ public function getData($allowed = array()) { $result = array(); $allowed = array_merge($this->forceFields, $allowed); $isBlock = false; // check access block if ($this->viewer) { $relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($this->member->getId(), $this->viewer->getId()); if ($relation && $relation->getIsAccessBlock()) { $isBlock = true; } } foreach ($this->tableToOpenPNE as $k => $v) { $checkSupportMethodName = $this->getSupportedFieldExport()->getIsSupportedMethodName($k); if (in_array($k, $allowed) && $this->getSupportedFieldExport()->{$checkSupportMethodName}()) { if ($isBlock) { $result[$k] = ''; } else { $methodName = $this->getGetterMethodName($k); $result[$k] = opOpenSocialToolKit::convertEmojiForApi($this->{$methodName}()); } } } return $result; }