Example #1
0
 public function __construct()
 {
     parent::__construct();
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $sortCtrl = new BASE_CMP_SortControl();
     $sortCtrl->addItem(BOOKMARKS_BOL_Service::LIST_LATEST, OW::getLanguage()->text('bookmarks', 'latest'), OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_LATEST)));
     $sortCtrl->addItem(BOOKMARKS_BOL_Service::LIST_ONLINE, OW::getLanguage()->text('bookmarks', 'online'), OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_ONLINE)));
     $this->addComponent('sort', $sortCtrl);
     $this->service = BOOKMARKS_BOL_Service::getInstance();
 }
Example #2
0
 /**
  * Default action. Rules tab
  */
 public function index($params)
 {
     $userId = OW::getUser()->getId();
     if (OW::getRequest()->isAjax()) {
         exit;
     }
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'users_browse_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_chat');
     $this->setPageTitle($language->text('matchmaking', 'matches_index'));
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $perPage = (int) OW::getConfig()->getValue('base', 'users_on_page');
     $first = ($page - 1) * $perPage;
     $count = $perPage;
     $dtoList = $this->service->findMatchList($userId, $first, $count, $params['sortOrder']);
     $listCount = $this->service->findMatchCount($userId);
     $userService = BOL_UserService::getInstance();
     $idList = array();
     $compatibilityList = array();
     foreach ($dtoList as $id => $item) {
         $idList[] = (int) $item['id'];
         $compatibilityList[$item['id']] = $this->service->getCompatibilityByValue($item['compatibility']);
     }
     $userDataList = array();
     $fields = $this->service->getFieldsForMatchList($idList);
     foreach ($idList as $userId) {
         $userDataList[$userId] = array('info_gender' => !empty($fields[$userId]) ? $fields[$userId] : '', 'compatibility' => !empty($compatibilityList[$userId]) ? OW::getLanguage()->text('matchmaking', 'compatibility') . ': <span class="ow_txt_value">' . $compatibilityList[$userId] . '%</span>' : '');
     }
     $listCmp = OW::getClassInstance('BASE_CMP_Users', $userDataList, array(), $listCount);
     $listCmp->setDisplayActivity(false);
     $this->addComponent('listCmp', $listCmp);
     $sortControl = new BASE_CMP_SortControl();
     $sortControl->addItem('newest', OW::getLanguage()->text('matchmaking', 'newest_first'), OW::getRouter()->urlForRoute('matchmaking_members_page_sorted', array('sortOrder' => 'newest')));
     $sortControl->addItem('compatible', OW::getLanguage()->text('matchmaking', 'most_compatible_first'), OW::getRouter()->urlForRoute('matchmaking_members_page_sorted', array('sortOrder' => 'compatible')));
     $sortControl->setActive($params['sortOrder']);
     $this->addComponent('sortControl', $sortControl);
     $this->addComponent('paging', new BASE_CMP_Paging($page, ceil($listCount / $perPage), 5));
 }
Example #3
0
 public function inTopic(array $params = null)
 {
     $plugin = OW::getPluginManager()->getPlugin('forum');
     $this->setTemplate($plugin->getCtrlViewDir() . 'search_result.html');
     $lang = OW::getLanguage();
     $token = !empty($_GET['q']) && is_string($_GET['q']) ? urldecode(htmlspecialchars(trim($_GET['q']))) : null;
     $userToken = !empty($_GET['u']) && is_string($_GET['u']) ? urldecode(htmlspecialchars(trim($_GET['u']))) : null;
     if ($token || $userToken) {
         $this->assign('token', $token);
         $this->assign('userToken', $userToken);
         $tokenQuery = $token ? '&q=' . $token : null;
         $userTokenQuery = $userToken ? '&u=' . $userToken : null;
         $topicId = (int) $params['topicId'];
         $userId = OW::getUser()->getId();
         $topic = $this->forumService->findTopicById($topicId);
         $forumGroup = $this->forumService->findGroupById($topic->groupId);
         $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
         if ($forumSection && $forumSection->isHidden) {
             $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId));
             OW::getEventManager()->trigger($event);
             $eventData = $event->getData();
             $componentForumCaption = $eventData['component'];
             $this->addComponent('componentForumCaption', $componentForumCaption);
             $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         } else {
             $isModerator = OW::getUser()->isAuthorized('forum');
         }
         if ($forumGroup->isPrivate) {
             if (!$userId) {
                 $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
                 return;
             } else {
                 if (!$isModerator) {
                     if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($forumGroup->roles))) {
                         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
                         return;
                     }
                 }
             }
         }
         $sortBy = !empty($_GET['sort']) && in_array($_GET['sort'], array('date', 'rel')) ? $_GET['sort'] : 'date';
         $topics = $this->forumService->searchInTopic($token, $userToken, $topicId, $sortBy);
         if ($topics) {
             $authors = array();
             foreach ($topics as &$topic) {
                 if (!in_array($topic['userId'], $authors)) {
                     array_push($authors, $topic['userId']);
                 }
                 if (!isset($topic['posts'])) {
                     continue;
                 }
                 foreach ($topic['posts'] as $post) {
                     if (!in_array($post['userId'], $authors)) {
                         array_push($authors, $post['userId']);
                     }
                 }
             }
             $this->assign('avatars', BOL_AvatarService::getInstance()->getDataForUserAvatars($authors));
         }
         $this->assign('topics', $topics);
         // Sort control
         $sortCtrl = new BASE_CMP_SortControl();
         $url = OW::getRouter()->urlForRoute('forum_search_topic', array('topicId' => $topicId)) . '?' . $tokenQuery . $userTokenQuery;
         $sortCtrl->addItem('date', $lang->text('forum', 'sort_by_date'), $url . '&sort=date', !$sortBy || $sortBy == 'date');
         $sortCtrl->addItem('relevance', $lang->text('forum', 'sort_by_relevance'), $url . '&sort=rel', $sortBy == 'rel');
         $this->addComponent('sort', $sortCtrl);
     } else {
         $this->redirect(OW::getRouter()->urlForRoute('forum-default'));
     }
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'topic', 'token' => $token, 'userToken' => $userToken, 'topicId' => $topicId)));
     OW::getDocument()->setHeading($lang->text('forum', 'search_page_heading'));
     OW::getDocument()->setHeadingIconClass('ow_ic_forum');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum');
 }
Example #4
0
 public function __construct($ownerMode, $album)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $handler = OW::getRequestHandler()->getHandlerAttributes();
     $isAuthenticated = OW::getUser()->isAuthenticated();
     $canUpload = !OW::getRequest()->isAjax() && OW::getUser()->isAuthorized('photo', 'upload');
     if ($isAuthenticated && $canUpload) {
         $language->addKeyForJs('photo', 'album_name');
         $language->addKeyForJs('photo', 'album_desc');
         $language->addKeyForJs('photo', 'create_album');
         $language->addKeyForJs('photo', 'newsfeed_album');
         $language->addKeyForJs('photo', 'newsfeed_album_error_msg');
         $language->addKeyForJs('photo', 'upload_photos');
         $language->addKeyForJs('photo', 'close_alert');
     } else {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'upload');
         if ($status['status'] != BOL_AuthorizationService::STATUS_DISABLED) {
             $this->assign('isPromo', true);
             $this->assign('promoMsg', json_encode($status['msg']));
         }
     }
     $this->assign('isAuthenticated', $isAuthenticated);
     $this->assign('canUpload', $canUpload);
     $this->assign('url', OW::getEventManager()->call('photo.getAddPhotoURL', array('albumId' => !empty($ownerMode) && !empty($album) ? $album->id : 0)));
     $menu = new BASE_CMP_SortControl();
     $menu->setTemplate(OW::getPluginManager()->getPlugin('photo')->getCmpViewDir() . 'sort_control.html');
     if (in_array($handler[OW_RequestHandler::ATTRS_KEY_ACTION], array('viewList', 'viewTaggedList'))) {
         $menu->addItem('latest', $language->text('photo', 'menu_latest'), OW::getRouter()->urlForRoute('view_photo_list', array('listType' => 'latest')));
         if (PHOTO_BOL_PhotoService::getInstance()->countPhotos('featured', PHOTO_BOL_PhotoService::getInstance()->countPhotos('featured'))) {
             $menu->addItem('featured', $language->text('photo', 'menu_featured'), OW::getRouter()->urlForRoute('view_photo_list', array('listType' => 'featured')));
         }
         $menu->addItem('toprated', $language->text('photo', 'menu_toprated'), OW::getRouter()->urlForRoute('view_photo_list', array('listType' => 'toprated')));
         $menu->addItem('most_discussed', $language->text('photo', 'menu_most_discussed'), OW::getRouter()->urlForRoute('view_photo_list', array('listType' => 'most_discussed')));
         if ($handler[OW_RequestHandler::ATTRS_KEY_ACTION] != 'viewTaggedList') {
             $menu->setActive(!empty($handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['listType']) ? $handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['listType'] : 'latest');
         }
         $menu->assign('initSearchEngine', TRUE);
     } else {
         if (!$ownerMode) {
             $user = BOL_UserService::getInstance()->findByUsername($handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['user']);
             $this->assign('user', $user);
             $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($user->id));
             $this->assign('avatar', $avatar[$user->id]);
             $onlineStatus = BOL_UserService::getInstance()->findOnlineStatusForUserList(array($user->id));
             $this->assign('onlineStatus', $onlineStatus[$user->id]);
         }
         $menu->addItem('userPhotos', $language->text('photo', 'menu_photos'), OW::getRouter()->urlForRoute('photo.user_photos', array('user' => $handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['user'])));
         $menu->addItem('userAlbums', $language->text('photo', 'menu_albums'), OW::getRouter()->urlForRoute('photo_user_albums', array('user' => $handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['user'])));
         if (in_array($handler[OW_RequestHandler::ATTRS_KEY_ACTION], array('userAlbums', 'userAlbum'))) {
             $menu->setActive('userAlbums');
         } else {
             $menu->setActive('userPhotos');
         }
     }
     $event = new BASE_CLASS_EventCollector(PHOTO_CLASS_EventHandler::EVENT_COLLECT_PHOTO_SUB_MENU);
     OW::getEventManager()->trigger($event);
     foreach ($event->getData() as $menuItem) {
         $menu->addItem($menuItem['sortOrder'], $menuItem['label'], $menuItem['url'], !empty($menuItem['isActive']) ? (bool) $menuItem['isActive'] : FALSE);
     }
     $this->addComponent('subMenu', $menu);
     if (OW::getUser()->isAuthenticated()) {
         $userObj = OW::getUser()->getUserObject();
         if (in_array($handler[OW_RequestHandler::ATTRS_KEY_ACTION], array('viewList', 'viewTaggedList')) || !empty($handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['user']) && $handler[OW_RequestHandler::ATTRS_KEY_VARLIST]['user'] == $userObj->username) {
             $menuItems = array();
             $item = new BASE_MenuItem();
             $item->setKey('menu_explore');
             $item->setLabel($language->text('photo', 'menu_explore'));
             $item->setUrl(OW::getRouter()->urlForRoute('view_photo_list'));
             $item->setIconClass('ow_ic_lens');
             $item->setOrder(0);
             $item->setActive(in_array($handler[OW_RequestHandler::ATTRS_KEY_ACTION], array('viewList', 'viewTaggedList')));
             array_push($menuItems, $item);
             $item = new BASE_MenuItem();
             $item->setKey('menu_my_photos');
             $item->setLabel($language->text('photo', 'menu_my_photos'));
             $item->setUrl(OW::getRouter()->urlForRoute('photo.user_photos', array('user' => $userObj->username)));
             $item->setIconClass('ow_ic_picture');
             $item->setOrder(1);
             $item->setActive($ownerMode);
             array_push($menuItems, $item);
             $this->addComponent('photoMenu', new BASE_CMP_ContentMenu($menuItems));
         }
     }
 }