本文整理汇总了PHP中PHOTO_BOL_PhotoService::findPhotoOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP PHOTO_BOL_PhotoService::findPhotoOwner方法的具体用法?PHP PHOTO_BOL_PhotoService::findPhotoOwner怎么用?PHP PHOTO_BOL_PhotoService::findPhotoOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHOTO_BOL_PhotoService
的用法示例。
在下文中一共展示了PHOTO_BOL_PhotoService::findPhotoOwner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPhotosContent
/**
* Method acts as ajax responder. Calls methods using ajax
*
* @return JSON encoded string
*
*/
public function getPhotosContent()
{
if (empty($_GET['photo_id']) || !$_GET['photo_id']) {
throw new Redirect404Exception();
exit;
}
$userId = OW::getUser()->getId();
$photoId = (int) $_GET['photo_id'];
$photo = $this->photoService->findPhotoById($photoId);
if (!$photo) {
exit(json_encode(array('result' => 'error')));
}
// is moderator
$moderatorMode = OW::getUser()->isAuthorized('photo');
$userId = OW::getUser()->getId();
$contentOwner = $this->photoService->findPhotoOwner($photoId);
$ownerMode = $contentOwner == $userId;
$canView = true;
$message = '';
if (!$ownerMode && !OW::getUser()->isAuthorized('photo', 'view')) {
$canView = false;
$message = OW::getLanguage()->text('base', 'authorization_failed_feedback');
}
$album = $this->photoAlbumService->findAlbumById($photo->albumId);
$ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
$photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
$photos = $this->photoService->getAlbumPhotos($photo->albumId, 1, $photoCount);
foreach ($photos as $item) {
$photosList[] = array('photo_id' => $item['id'], 'thumb' => $item['url'], 'src' => $this->photoService->getPhotoUrl($item['id']), 'active' => $item['id'] == $_GET['photo_id'], 'title' => '', 'description' => '');
}
//var_dump($photos);die;
exit(json_encode(array('photos' => $photosList, 'count' => $photoCount, 'album_title' => $album->name, 'album_href' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => $ownerName, 'album' => $photo->albumId)), 'owner_title' => BOL_UserService::getInstance()->getDisplayName($album->userId), 'owner_href' => BOL_UserService::getInstance()->getUserUrl($album->userId), 'authorized' => $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view'), 'message' => $message)));
}
示例2: view
public function view(array $params)
{
if (!isset($params['id']) || !($photoId = (int) $params['id'])) {
throw new Redirect404Exception();
}
$lang = OW::getLanguage();
$photo = $this->photoService->findPhotoById($photoId);
if (!$photo) {
throw new Redirect404Exception();
}
$album = $this->photoAlbumService->findAlbumById($photo->albumId);
$this->assign('album', $album);
$ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
$albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('album' => $album->id, 'user' => $ownerName));
$this->assign('albumUrl', $albumUrl);
// is owner
$contentOwner = $this->photoService->findPhotoOwner($photo->id);
$userId = OW::getUser()->getId();
$ownerMode = $contentOwner == $userId;
$this->assign('ownerMode', $ownerMode);
// is moderator
$modPermissions = OW::getUser()->isAuthorized('photo');
$this->assign('moderatorMode', $modPermissions);
$this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
$this->assign('authError', $status['msg']);
return;
}
// permissions check
if (!$ownerMode && !$modPermissions) {
$privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
$event = new OW_Event('privacy_check_permission', $privacyParams);
OW::getEventManager()->trigger($event);
}
$photo->description = UTIL_HtmlTag::autoLink($photo->description);
$this->assign('photo', $photo);
$fullsizeUrl = (int) OW::getConfig()->getValue('photo', 'store_fullsize') && $photo->hasFullsize ? $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash) : null;
$this->assign('fullsizeUrl', $fullsizeUrl);
$this->assign('nextPhoto', $this->photoService->getNextPhotoId($photo->albumId, $photo->id));
$this->assign('previousPhoto', $this->photoService->getPreviousPhotoId($photo->albumId, $photo->id));
$photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
$this->assign('photoCount', $photoCount);
$photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
$this->assign('photoIndex', $photoIndex);
$avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
$this->assign('avatar', $avatar[$contentOwner]);
$cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
$cmtParams->setEntityId($photo->id);
$cmtParams->setOwnerId($contentOwner);
$cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
$photoCmts = new BASE_MCMP_Comments($cmtParams);
$this->addComponent('comments', $photoCmts);
OW::getDocument()->setHeading($album->name);
$description = strip_tags($photo->description);
$description = mb_strlen($description) ? $description : $photo->id;
OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_view', array('title' => $description)));
}
示例3: getFloatbox
public function getFloatbox()
{
if (empty($_POST['photoId']) || !$_POST['photoId']) {
throw new Redirect404Exception();
}
$photoId = (int) $_POST['photoId'];
$service = PHOTO_BOL_PhotoService::getInstance();
$photo = $service->findPhotoById($photoId);
if (!$photo) {
exit(json_encode(array('result' => 'error')));
}
// is moderator
$moderatorMode = OW::getUser()->isAuthorized('photo');
$userId = OW::getUser()->getId();
$resp['result'] = "success";
if ($_POST['current'] == "true") {
$resp['current'] = $this->prepareMarkup($photoId);
$contentOwner = $this->photoService->findPhotoOwner($photoId);
$ownerMode = $contentOwner == $userId;
$resp['current']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
if ($_POST['prev'] == "true") {
$prevPhoto = $service->getPreviousPhoto($photo->albumId, $photo->id);
if ($prevPhoto) {
$resp['prev'] = $this->prepareMarkup($prevPhoto['dto']->id);
$resp['prev']['prev'] = $service->getPreviousPhotoId($photo->albumId, $prevPhoto['dto']->id);
$resp['prev']['next'] = $photo->id;
$resp['current']['prev'] = $prevPhoto['dto']->id;
$contentOwner = $this->photoService->findPhotoOwner($prevPhoto['dto']->id);
$ownerMode = $contentOwner == $userId;
$resp['prev']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
}
if ($_POST['next'] == "true") {
$nextPhoto = $service->getNextPhoto($photo->albumId, $photo->id);
if ($nextPhoto) {
$resp['next'] = $this->prepareMarkup($nextPhoto['dto']->id);
$resp['next']['prev'] = $photo->id;
$resp['next']['next'] = $service->getNextPhotoId($photo->albumId, $nextPhoto['dto']->id);
$resp['current']['next'] = $nextPhoto['dto']->id;
$contentOwner = $this->photoService->findPhotoOwner($nextPhoto['dto']->id);
$ownerMode = $contentOwner == $userId;
$resp['next']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
}
exit(json_encode($resp));
}
示例4: __construct
/**
* Class constructor
*
* @param string $listType
* @param int $count
* @param string $tag
*/
public function __construct(array $params)
{
parent::__construct();
$photoId = $params['photoId'];
$config = OW::getConfig();
$lang = OW::getLanguage();
$this->photoService = PHOTO_BOL_PhotoService::getInstance();
$this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$photo = $this->photoService->findPhotoById($photoId);
$album = $this->photoAlbumService->findAlbumById($photo->albumId);
$this->assign('album', $album);
// is owner
$contentOwner = $this->photoService->findPhotoOwner($photo->id);
$userId = OW::getUser()->getId();
$ownerMode = $contentOwner == $userId;
$this->assign('ownerMode', $ownerMode);
// is moderator
$modPermissions = OW::getUser()->isAuthorized('photo');
$this->assign('moderatorMode', $modPermissions);
$canView = true;
if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
$canView = false;
}
$this->assign('canView', $canView);
$cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
$cmtParams->setEntityId($photo->id);
$cmtParams->setOwnerId($contentOwner);
$cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
$photoCmts = new BASE_CMP_Comments($cmtParams);
$this->addComponent('comments', $photoCmts);
$photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner);
$this->addComponent('rate', $photoRates);
$photoTags = new BASE_CMP_EntityTagCloud('photo');
$photoTags->setEntityId($photo->id);
$photoTags->setRouteName('view_tagged_photo_list');
$this->addComponent('tags', $photoTags);
$description = $photo->description;
$photo->description = UTIL_HtmlTag::autoLink($photo->description);
$this->assign('photo', $photo);
$this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
$this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
$is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id);
if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) {
$this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
} else {
$this->assign('fullsizeUrl', null);
}
$action = new BASE_ContextAction();
$action->setKey('photo-moderate');
$context = new BASE_CMP_ContextAction();
$context->addAction($action);
$contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photoId, 'photoDto' => $photo));
OW::getEventManager()->trigger($contextEvent);
foreach ($contextEvent->getData() as $contextAction) {
$action = new BASE_ContextAction();
$action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
$action->setParentKey('photo-moderate');
$action->setLabel($contextAction['label']);
if (!empty($contextAction['id'])) {
$action->setId($contextAction['id']);
}
if (!empty($contextAction['order'])) {
$action->setOrder($contextAction['order']);
}
if (!empty($contextAction['class'])) {
$action->setClass($contextAction['class']);
}
if (!empty($contextAction['url'])) {
$action->setUrl($contextAction['url']);
}
$attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
foreach ($attributes as $key => $value) {
$action->addAttribute($key, $value);
}
$context->addAction($action);
}
if ($userId && !$ownerMode) {
$action = new BASE_ContextAction();
$action->setKey('flag');
$action->setParentKey('photo-moderate');
$action->setLabel($lang->text('base', 'flag'));
$action->setId('btn-photo-flag');
$action->addAttribute('rel', $photoId);
$action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
$context->addAction($action);
}
if ($ownerMode || $modPermissions) {
$action = new BASE_ContextAction();
$action->setKey('edit');
$action->setParentKey('photo-moderate');
$action->setLabel($lang->text('base', 'edit'));
$action->setId('btn-photo-edit');
$action->addAttribute('rel', $photoId);
//.........这里部分代码省略.........