public function __construct($userId, $limit, $exclude) { parent::__construct(); $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance(); $user = BOL_UserService::getInstance()->findUserById($userId); $this->assign('username', $user->getUsername()); $albums = $this->photoAlbumService->findUserAlbumList($user->id, 1, $limit, $exclude, true); $this->assign('albums', $albums); foreach ($albums as $album) { array_push($exclude, $album['dto']->id); } $loadMore = $this->photoAlbumService->countUserAlbums($userId, $exclude); if (!$loadMore) { $script = "OWM.trigger('photo.hide_load_more', {});"; OW::getDocument()->addOnloadScript($script); } }
/** * Controller action for user albums list * * @param array $params * @throws Redirect404Exception */ public function userAlbums(array $params) { if (empty($params['user']) || !mb_strlen($username = trim($params['user']))) { throw new Redirect404Exception(); } $user = BOL_UserService::getInstance()->findByUsername($username); if (!$user) { throw new Redirect404Exception(); } $userId = $user->id; $ownerMode = $userId == OW::getUser()->getId(); // is moderator $modPermissions = OW::getUser()->isAuthorized('photo'); if (!OW::getUser()->isAuthorized('photo', 'view') && !$modPermissions && !$ownerMode) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } // permissions check if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId()); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $this->assign('username', $username); $displayName = BOL_UserService::getInstance()->getDisplayName($userId); $this->assign('displayName', $displayName); $total = $this->photoAlbumService->countUserAlbums($userId); $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1; $config = OW::getConfig(); $albumPerPage = $config->getValue('photo', 'photos_per_page'); $albums = $this->photoAlbumService->findUserAlbumList($userId, $page, $albumPerPage); $this->assign('albums', $albums); $this->assign('total', $total); $this->assign('userId', $userId); // Paging $pages = (int) ceil($total / $albumPerPage); $paging = new BASE_CMP_Paging($page, $pages, $albumPerPage); $this->assign('paging', $paging->render()); $this->assign('widthConfig', $config->getValue('photo', 'preview_image_width')); $this->assign('heightConfig', $config->getValue('photo', 'preview_image_height')); OW::getDocument()->setHeading(OW::getLanguage()->text('photo', 'page_title_user_albums', array('user' => $displayName))); OW::getDocument()->setHeadingIconClass('ow_ic_picture'); OW::getDocument()->setTitle(OW::getLanguage()->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName))); if ($albums) { $albumTitles = array(); $i = 0; foreach ($albums as $album) { $albumTitles[] = $album['dto']->name; if ($i == 10) { break; } $i++; } $albumTitles = implode(', ', $albumTitles); OW::getDocument()->setDescription(OW::getLanguage()->text('photo', 'meta_description_photo_useralbums', array('displayName' => $displayName, 'albums' => $albumTitles))); } }