Beispiel #1
0
 public function collectAlbumsForAvatar(BASE_CLASS_EventCollector $e)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $e->getParams();
     $userId = OW::getUser()->getId();
     $total = $this->albumService->countUserAlbums($userId);
     $albums = $this->albumService->findUserAlbums($userId, 0, $total);
     if (!$albums) {
         return;
     }
     foreach ($albums as $album) {
         $photoCount = $this->photoService->countAlbumPhotos($album->id, array());
         if (!$photoCount) {
             continue;
         }
         $photos = $this->photoService->getAlbumPhotos($album->id, 1, $params['limit']);
         $list = array();
         foreach ($photos as $photo) {
             $list[] = array('id' => $photo['id'], 'entityId' => $album->id, 'entityType' => 'photo_album', 'url' => $photo['url'], 'bigUrl' => $this->photoService->getPhotoUrlByType($photo['id'], PHOTO_BOL_PhotoService::TYPE_MAIN, $photo['dto']->hash, $photo['dto']->dimension));
         }
         $section = array('entityId' => $album->id, 'entityType' => 'photo_album', 'label' => $album->name, 'count' => $photoCount, 'list' => $list);
         $e->add($section);
     }
 }
Beispiel #2
0
    public function albums(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();
        }
        $ownerMode = $user->id == OW::getUser()->getId();
        // is moderator
        $modPermissions = OW::getUser()->isAuthorized('photo');
        if (!OW::getUser()->isAuthorized('photo', 'view') && !$modPermissions && !$ownerMode) {
            $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
            $this->assign('authError', $status['msg']);
            return;
        }
        $lang = OW::getLanguage();
        $limit = 6;
        $initialCmp = new PHOTO_MCMP_AlbumList($user->id, $limit, array());
        $this->addComponent('albums', $initialCmp);
        $total = $this->photoAlbumService->countUserAlbums($user->id);
        $this->assign('loadMore', $total > $limit);
        if (OW::getUser()->isAuthenticated() && !OW::getUser()->isAuthorized('photo', 'upload')) {
            $id = uniqid('photo_add');
            $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'upload');
            OW::getDocument()->addScriptDeclaration(UTIL_JsGenerator::composeJsString(';$("#" + {$btn}).on("click", function()
                {
                    OWM.authorizationLimitedFloatbox({$msg});
                });', array('btn' => $id, 'msg' => $status['msg'])));
            $this->assign('id', $id);
        } else {
            $this->assign('uploadUrl', OW::getRouter()->urlForRoute('photo_upload'));
        }
        $script = '
        OWM.bind("photo.hide_load_more", function(){
            $("#btn-photo-load-more").hide();
        });

        $("#btn-photo-load-more").click(function(){
            var node = $(this);
            node.addClass("owm_preloader");
            var exclude = $("li.owm_photo_album_list_item").map(function(){ return $(this).data("ref"); }).get();
            OWM.loadComponent(
                "PHOTO_MCMP_AlbumList",
                {userId: "' . $user->id . '", count:' . $limit . ', exclude: exclude},
                {
                    onReady: function(html){
                        $("#album-list-cont").append(html);
                        node.removeClass("owm_preloader");
                    }
                }
            );
        });';
        OW::getDocument()->addOnloadScript($script);
        $displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
        OW::getDocument()->setHeading($lang->text('photo', 'page_title_user_albums', array('user' => $displayName)));
        OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName)));
    }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
 /**
  * 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)));
     }
 }
Beispiel #5
0
    public function albums(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();
        }
        $lang = OW::getLanguage();
        $limit = 6;
        $initialCmp = new PHOTO_MCMP_AlbumList($user->id, $limit, array());
        $this->addComponent('albums', $initialCmp);
        $total = $this->photoAlbumService->countUserAlbums($user->id);
        $this->assign('loadMore', $total > $limit);
        $this->assign('uploadUrl', OW::getRouter()->urlForRoute('photo_upload'));
        $script = '
        OWM.bind("photo.hide_load_more", function(){
            $("#btn-photo-load-more").hide();
        });

        $("#btn-photo-load-more").click(function(){
            var node = $(this);
            node.addClass("owm_preloader");
            var exclude = $("li.owm_photo_album_list_item").map(function(){ return $(this).data("ref"); }).get();
            OWM.loadComponent(
                "PHOTO_MCMP_AlbumList",
                {userId: "' . $user->id . '", count:' . $limit . ', exclude: exclude},
                {
                    onReady: function(html){
                        $("#album-list-cont").append(html);
                        node.removeClass("owm_preloader");
                    }
                }
            );
        });';
        OW::getDocument()->addOnloadScript($script);
        $displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
        OW::getDocument()->setHeading($lang->text('photo', 'page_title_user_albums', array('user' => $displayName)));
        OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName)));
    }