Example #1
0
 /**
  * Finance list page controller
  *
  * @param array $params
  */
 public function index(array $params)
 {
     $service = BOL_BillingService::getInstance();
     $lang = OW::getLanguage();
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     $onPage = 20;
     $list = $service->getFinanceList($page, $onPage);
     $userIdList = array();
     foreach ($list as $sale) {
         if (isset($sale['userId']) && !in_array($sale['userId'], $userIdList)) {
             array_push($userIdList, $sale['userId']);
         }
     }
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIdList);
     $userNames = BOL_UserService::getInstance()->getUserNamesForList($userIdList);
     $this->assign('list', $list);
     $this->assign('displayNames', $displayNames);
     $this->assign('userNames', $userNames);
     $total = $service->countSales();
     // Paging
     $pages = (int) ceil($total / $onPage);
     $paging = new BASE_CMP_Paging($page, $pages, 10);
     $this->assign('paging', $paging->render());
     $this->assign('total', $total);
     $stats = $service->getTotalIncome();
     $this->assign('stats', $stats);
     OW::getDocument()->setHeading($lang->text('admin', 'page_title_finance'));
     OW::getDocument()->setHeadingIconClass('ow_ic_app');
 }
Example #2
0
    public function index()
    {
        $this->addComponent('menu', $this->getMenu('list'));
        $lang = OW::getLanguage();
        $limit = 20;
        $page = !empty($_GET['page']) ? abs((int) $_GET['page']) : 1;
        $offset = ($page - 1) * $limit;
        $sortFields = $this->service->getSortFields();
        $sortBy = !empty($_GET['sort']) && in_array($_GET['sort'], $sortFields) ? $_GET['sort'] : 'registerStamp';
        $sortOrder = !empty($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ? $_GET['order'] : 'desc';
        $sortUrls = array();
        $baseUrl = OW::getRouter()->urlForRoute('ocsaffiliates.admin') . '/?';
        foreach ($sortFields as $field) {
            $sortUrls[$field] = $baseUrl . 'sort=' . $field . '&order=' . ($sortBy != $field ? 'desc' : ($sortOrder == 'desc' ? 'asc' : 'desc'));
        }
        $this->assign('sortUrls', $sortUrls);
        $list = $this->service->getAffiliateList($offset, $limit, $sortBy, $sortOrder);
        $this->assign('list', $list);
        $total = $this->service->countAffiliates();
        $unverified = $this->service->countUnverifiedAffiliates();
        $this->assign('unverified', $unverified);
        // Paging
        $pages = (int) ceil($total / $limit);
        $paging = new BASE_CMP_Paging($page, $pages, $limit);
        $this->assign('paging', $paging->render());
        $billingService = BOL_BillingService::getInstance();
        $this->assign('currency', $billingService->getActiveCurrency());
        $logo = OW::getPluginManager()->getPlugin('ocsaffiliates')->getStaticUrl() . 'img/oxwallcandystore-logo.jpg';
        $this->assign('logo', $logo);
        $script = '$(".action_delete").click(function(){

            if ( !confirm(' . json_encode($lang->text('ocsaffiliates', 'delete_confirm')) . ') )
            {
                return false;
            }
            var affId = $(this).attr("affid");
            $.ajax({
                url: ' . json_encode(OW::getRouter()->urlForRoute('ocsaffiliates.action_delete')) . ',
                type: "POST",
                data: { affiliateId: affId },
                dataType: "json",
                success: function(data)
                {
                    if ( data.result == true )
                    {
                        document.location.reload();
                    }
                    else if ( data.error != undefined )
                    {
                        OW.warning(data.error);
                    }
                }
            });
        });';
        OW::getDocument()->addOnloadScript($script);
        // TODO: remove this code when a sale event is available
        $this->service->processUntrackedSales();
        OW::getDocument()->setHeading($lang->text('ocsaffiliates', 'admin_page_heading'));
    }
Example #3
0
 public function __construct(array $params)
 {
     parent::__construct();
     $this->videoService = IVIDEO_BOL_Service::getInstance();
     $listType = isset($params['type']) ? $params['type'] : '';
     $count = isset($params['count']) ? $params['count'] : 5;
     $tag = isset($params['tag']) ? $params['tag'] : '';
     $userId = isset($params['userId']) ? $params['userId'] : null;
     $category = isset($params['category']) ? $params['category'] : null;
     $page = isset($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1;
     $videosPerPage = (int) OW::getConfig()->getValue('ivideo', 'resultsPerPage');
     if ($userId) {
         $videos = $this->videoService->findUserVideosList($userId, $page, $videosPerPage);
         $records = $this->videoService->findUserVideosCount($userId);
     } else {
         if (strlen($tag)) {
             $videos = $this->videoService->findTaggedVideosList($tag, $page, $videosPerPage);
             $records = $this->videoService->findTaggedVideosCount($tag);
         } else {
             if (strlen($category)) {
                 $videos = $this->videoService->findCategoryVideosList($category, $page, $videosPerPage);
                 $records = $this->videoService->findCategoryVideosCount($category);
             } else {
                 $videos = $this->videoService->findVideosList($listType, $page, $videosPerPage);
                 $records = $this->videoService->findVideosCount($listType);
             }
         }
     }
     $this->assign('listType', $listType);
     if ($videos) {
         $this->assign('no_content', null);
         $this->assign('videos', $videos);
         $userIds = array();
         foreach ($videos as $video) {
             if (!in_array($video['owner'], $userIds)) {
                 array_push($userIds, $video['owner']);
             }
         }
         $names = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
         $this->assign('displayNames', $names);
         $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
         $this->assign('usernames', $usernames);
         $pages = (int) ceil($records / $videosPerPage);
         $paging = new BASE_CMP_Paging($page, $pages, 10);
         $this->assign('paging', $paging->render());
         $this->assign('count', $count);
     } else {
         $this->assign('no_content', OW::getLanguage()->text('ivideo', 'no_video_found'));
     }
     $this->assign('getUserFilesUrl', OW::getPluginManager()->getPlugin('ivideo')->getUserFilesUrl());
     $this->assign('videoPreviewWidth', OW::getConfig()->getValue('ivideo', 'videoPreviewWidth'));
     $this->assign('videoPreviewHeight', OW::getConfig()->getValue('ivideo', 'videoPreviewHeight'));
     $this->assign('posterImage', OW::getPluginManager()->getPlugin('ivideo')->getStaticUrl() . 'poster.jpg');
     $this->assign('defaultThumb', OW::getPluginManager()->getPlugin('ivideo')->getStaticUrl() . 'video.png');
 }
Example #4
0
 public function taglist(array $params = null)
 {
     $modPermissions = OW::getUser()->isAuthorized('eventx');
     if (!OW::getUser()->isAuthorized('eventx', 'view_event') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     if (!OW::getUser()->isAuthorized('eventx', 'add_event')) {
         $this->assign('noButton', true);
     }
     $contentMenu = $this->eventService->getContentMenu();
     $contentMenu->getElement('tagged')->setActive(true);
     $this->addComponent('contentMenu', $contentMenu);
     $listUrl = OW::getRouter()->urlForRoute('eventx_tag_list');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('eventx')->getStaticJsUrl() . 'eventx_tag_search.js');
     $objParams = array('listUrl' => $listUrl);
     $script = "\$(document).ready(function(){\n                     var itemSearch = new itemTagSearch(" . json_encode($objParams) . ");\n                   });";
     OW::getDocument()->addOnloadScript($script);
     $tag = !empty($params['tag']) ? trim(htmlspecialchars(urldecode($params['tag']))) : '';
     if (strlen($tag)) {
         $this->assign('tag', $tag);
         $page = isset($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1;
         $itemsPerPage = 10;
         $items = $this->eventService->findTaggedItemsList($tag, $page, $itemsPerPage);
         $records = $this->eventService->findTaggedItemsCount($tag);
         if (empty($items)) {
             $this->assign('no_events', true);
         }
         $pages = (int) ceil($records / $itemsPerPage);
         $paging = new BASE_CMP_Paging($page, $pages, 10);
         $this->assign('paging', $paging->render());
         $this->assign('events', $this->eventService->getListingDataWithToolbar($items, array()));
         $this->setPageTitle(OW::getLanguage()->text('eventx', 'meta_description_item_tagged_as', array('tag' => $tag)));
         $this->setPageHeading(OW::getLanguage()->text('eventx', 'meta_description_item_tagged_as', array('tag' => $tag)));
     } else {
         $tags = new BASE_CMP_EntityTagCloud('eventx');
         $tags->setRouteName('eventx_view_tagged_list');
         $this->addComponent('tags', $tags);
         $this->setPageTitle(OW::getLanguage()->text('eventx', 'meta_title_item_tagged'));
         $tagsArr = BOL_TagService::getInstance()->findMostPopularTags('eventx', 20);
         foreach ($tagsArr as $t) {
             $labels[] = $t['label'];
         }
         $tagStr = $tagsArr ? implode(', ', $labels) : '';
         $this->setPageTitle(OW::getLanguage()->text('eventx', 'meta_title_item_tagged'));
         $this->setPageHeading(OW::getLanguage()->text('eventx', 'meta_description_item_tagged'));
     }
     OW::getDocument()->setHeadingIconClass('ow_ic_tag');
 }
Example #5
0
 /**
  * Class constructor
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $listType = isset($params['type']) ? $params['type'] : '';
     $count = isset($params['count']) ? $params['count'] : 5;
     $tag = isset($params['tag']) ? $params['tag'] : '';
     $userId = isset($params['userId']) ? $params['userId'] : null;
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $clipsPerPage = $this->clipService->getClipPerPageConfig();
     if ($userId) {
         $clips = $this->clipService->findUserClipsList($userId, $page, $clipsPerPage);
         $records = $this->clipService->findUserClipsCount($userId);
     } else {
         if (strlen($tag)) {
             $clips = $this->clipService->findTaggedClipsList($tag, $page, $clipsPerPage);
             $records = $this->clipService->findTaggedClipsCount($tag);
         } else {
             $clips = $this->clipService->findClipsList($listType, $page, $clipsPerPage);
             $records = $this->clipService->findClipsCount($listType);
         }
     }
     $this->assign('listType', $listType);
     if ($clips) {
         $this->assign('no_content', null);
         $this->assign('clips', $clips);
         $userIds = array();
         foreach ($clips as $clip) {
             if (!in_array($clip['userId'], $userIds)) {
                 array_push($userIds, $clip['userId']);
             }
         }
         $names = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
         $this->assign('displayNames', $names);
         $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
         $this->assign('usernames', $usernames);
         // Paging
         $pages = (int) ceil($records / $clipsPerPage);
         $paging = new BASE_CMP_Paging($page, $pages, 10);
         $this->assign('paging', $paging->render());
         $this->assign('count', $count);
     } else {
         $this->assign('no_content', OW::getLanguage()->text('video', 'no_video_found'));
     }
 }
Example #6
0
 public function history()
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $creditService = USERCREDITS_BOL_CreditsService::getInstance();
     $lang = OW::getLanguage();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $limit = 20;
     $this->addComponent('items', new USERCREDITS_CMP_HistoryItems($page, $limit));
     $records = $creditService->countUserLogEntries(OW::getUser()->getId());
     // Paging
     $pages = (int) ceil($records / $limit);
     $paging = new BASE_CMP_Paging($page, $pages, 10);
     $this->assign('paging', $paging->render());
     $this->setPageHeading($lang->text('usercredits', 'credits_history_page_heading'));
     OW::getDocument()->setTitle($lang->text('usercredits', 'credits_history_page_heading'));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
 }
Example #7
0
 /**
  * Default action
  */
 public function index()
 {
     $language = OW::getLanguage();
     $giftsService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $perPage = $giftsService->getGiftsPerPageConfig();
     $gifts = $giftsService->findUserReceivedGifts(OW::getUser()->getId(), $page, $perPage, false);
     $toolbars = array();
     if ($gifts) {
         $users = array();
         foreach ($gifts as $gift) {
             if (!in_array($gift['dto']->senderId, $users)) {
                 array_push($users, $gift['dto']->senderId);
             }
         }
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($users);
         $this->assign('avatars', $avatars);
         foreach ($gifts as $gift) {
             $giftId = $gift['dto']->id;
             $senderId = $gift['dto']->senderId;
             $toolbars[$giftId][] = array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($avatars[$senderId]['url']) ? $avatars[$senderId]['url'] : null, 'label' => isset($avatars[$senderId]['title']) ? $avatars[$senderId]['title'] : null);
             if ($gift['dto']->private) {
                 $toolbars[$giftId][] = array('title' => $language->text('virtualgifts', 'private_gift_note'), 'label' => $language->text('virtualgifts', 'private_gift'));
             }
             $toolbars[$giftId][] = array('label' => UTIL_DateTime::formatSimpleDate($gift['dto']->sendTimestamp));
         }
     }
     $this->assign('gifts', $gifts);
     $this->assign('toolbars', $toolbars);
     $total = $giftsService->countUserReceivedGifts(OW::getUser()->getId(), false);
     $pages = (int) ceil($total / $perPage);
     $paging = new BASE_CMP_Paging($page, $pages, 10);
     $this->assign('paging', $paging->render());
     $this->setPageHeading(OW::getLanguage()->text('virtualgifts', 'my_gifts'));
     $this->setPageHeadingIconClass('ow_ic_heart');
     OW::getDocument()->setTitle($language->text('virtualgifts', 'meta_title_my_gifts'));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
     $url = OW::getPluginManager()->getPlugin('virtualgifts')->getStaticCssUrl() . 'style.css';
     OW::getDocument()->addStyleSheet($url);
 }
Example #8
0
 public function logs(array $params)
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $userId = OW::getUser()->getId();
     $type = isset($params['type']) ? $params['type'] : 'all';
     $page = isset($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1;
     $itemsPerPage = (int) $config->getValue('credits', 'logsPerPage');
     $totalLogsCount = CREDITS_BOL_Service::getInstance()->getCreditHistoryCount($userId, $type);
     $logs = CREDITS_BOL_Service::getInstance()->getCreditHistory($userId, $type, $page, $itemsPerPage);
     $pages = (int) ceil($totalLogsCount / $itemsPerPage);
     $paging = new BASE_CMP_Paging($page, $pages, 10);
     $this->assign('paging', $paging->render());
     $this->assign('logs', $logs);
     $this->assign('logType', $type);
     $this->assign('allLogUrl', OW::getRouter()->urlForRoute('credits_logs', array('type' => 'all')));
     $this->assign('sentLogUrl', OW::getRouter()->urlForRoute('credits_logs', array('type' => 'sent')));
     $this->assign('receivedLogUrl', OW::getRouter()->urlForRoute('credits_logs', array('type' => 'received')));
     if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('credits')) {
         $this->assign('adminLogUrl', 'NULL');
     } else {
         $this->assign('adminLogUrl', OW::getRouter()->urlForRoute('credits_admin_logs'));
     }
     if (!OW::getUser()->isAuthorized('credits', 'send')) {
         $this->assign('transferUrl', 'NULL');
     } else {
         $this->assign('transferUrl', OW::getRouter()->urlForRoute('credits_transfer'));
     }
     $this->assign('buyUrl', OW::getRouter()->urlFor('USERCREDITS_CTRL_BuyCredits', 'index'));
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('credits')->getStaticCssUrl() . 'style.css');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('credits')->getStaticJsUrl() . 'jquery.tablesorter.min.js');
     $this->setPageHeading($language->text('credits', 'your_credits_label'));
     $this->setPageTitle($language->text('credits', 'your_credits_label'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
 }
Example #9
0
 public function __construct(array $params)
 {
     parent::__construct();
     $this->forumService = FORUM_BOL_ForumService::getInstance();
     if (!isset($params['groupId']) || !($groupId = (int) $params['groupId'])) {
         $this->setVisible(false);
         return;
     }
     $groupInfo = $this->forumService->getGroupInfo($groupId);
     if (!$groupInfo) {
         $this->setVisible(false);
         return;
     }
     $forumSection = $this->forumService->findSectionById($groupInfo->sectionId);
     if (!$forumSection) {
         $this->setVisible(false);
         return;
     }
     $isHidden = $forumSection->isHidden;
     $userId = OW::getUser()->getId();
     if ($isHidden) {
         $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         $event = new OW_Event('forum.can_view', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId), true);
         OW::getEventManager()->trigger($event);
         $canView = $event->getData();
         $eventParams = array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId, 'action' => 'add_topic');
         $event = new OW_Event('forum.check_permissions', $eventParams);
         OW::getEventManager()->trigger($event);
         $canEdit = $event->getData();
     } else {
         $isModerator = OW::getUser()->isAuthorized('forum');
         $canView = OW::getUser()->isAuthorized('forum', 'view');
         $canEdit = OW::getUser()->isAuthorized('forum', 'edit');
         $canEdit = $canEdit || $isModerator ? true : false;
     }
     if ($groupInfo->isPrivate) {
         if (!$userId) {
             $this->assign('authFailed', true);
             return;
         } else {
             if (!$isModerator) {
                 if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($groupInfo->roles))) {
                     $this->assign('authFailed', true);
                     return;
                 }
             }
         }
     }
     if (!$canView) {
         $this->assign('authFailed', true);
         return;
     }
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     if (!$groupInfo) {
         $forumUrl = OW::getRouter()->urlForRoute('forum-default');
         OW::getApplication()->redirect($forumUrl);
     }
     $topicList = $this->forumService->getGroupTopicList($groupId, $page);
     $topicCount = $this->forumService->getGroupTopicCount($groupId);
     $userIds = array();
     $topicIds = array();
     foreach ($topicList as $topic) {
         array_push($topicIds, $topic['id']);
         if (isset($topic['lastPost']) && !in_array($topic['lastPost']['userId'], $userIds)) {
             array_push($userIds, $topic['lastPost']['userId']);
         }
     }
     $attachments = FORUM_BOL_PostAttachmentService::getInstance()->getAttachmentsCountByTopicIdList($topicIds);
     $this->assign('attachments', $attachments);
     $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
     $this->assign('usernames', $usernames);
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
     $this->assign('displayNames', $displayNames);
     $perPage = $this->forumService->getTopicPerPageConfig();
     $pageCount = $topicCount ? ceil($topicCount / $perPage) : 1;
     $paging = new BASE_CMP_Paging($page, $pageCount, $perPage);
     $this->assign('paging', $paging->render());
     $addTopicUrl = OW::getRouter()->urlForRoute('add-topic', array('groupId' => $groupId));
     $this->assign('addTopicUrl', $addTopicUrl);
     $this->assign('canEdit', $canEdit);
     $this->assign('groupId', $groupId);
     $this->assign('topicList', $topicList);
     $this->assign('isHidden', $isHidden);
     $showCaption = !empty($params['caption']) ? $params['caption'] : false;
     if ($showCaption) {
         $groupName = htmlspecialchars($groupInfo->name);
         OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum_page_heading', array('forum' => $groupName)));
         OW::getDocument()->setHeadingIconClass('ow_ic_forum');
         OW::getDocument()->setTitle($groupName);
         OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'group_meta_description', array('group' => $groupName)));
         if ($isHidden) {
             $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId));
             OW::getEventManager()->trigger($event);
             $eventData = $event->getData();
             $componentForumCaption = $eventData['component'];
             if (!empty($componentForumCaption)) {
                 $this->assign('componentForumCaption', $componentForumCaption->render());
             } else {
                 $componentForumCaption = false;
                 $this->assign('componentForumCaption', $componentForumCaption);
             }
             OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
             OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
         } else {
             $bcItems = array(array('href' => OW::getRouter()->urlForRoute('forum-default'), 'label' => OW::getLanguage()->text('forum', 'forum_index')), array('href' => OW::getRouter()->urlForRoute('section-default', array('sectionId' => $groupInfo->sectionId)), 'label' => $forumSection->name), array('label' => $groupInfo->name));
             $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
             $this->addComponent('breadcrumb', $breadCrumbCmp);
         }
     }
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'group', 'groupId' => $groupId)));
     $this->assign('showCaption', $showCaption);
 }
Example #10
0
 public function inSection(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;
         $sectionId = (int) $params['sectionId'];
         $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
         if (OW::getUser()->isAuthorized('forum')) {
             $excludeGroupIdList = array();
         } else {
             $excludeGroupIdList = $this->forumService->getPrivateUnavailableGroupIdList(OW::getUser()->getId());
         }
         $sortBy = !empty($_GET['sort']) && in_array($_GET['sort'], array('date', 'rel')) ? $_GET['sort'] : 'date';
         $topics = $this->forumService->searchInSection($token, $userToken, $sectionId, $page, $excludeGroupIdList, $sortBy);
         $authors = array();
         if ($topics) {
             foreach ($topics as &$topic) {
                 $topic['toolbar'] = array();
                 if (!isset($topic['posts'])) {
                     continue;
                 }
                 foreach ($topic['posts'] as $post) {
                     if (!in_array($post['userId'], $authors)) {
                         array_push($authors, $post['userId']);
                     }
                 }
             }
         }
         $this->assign('topics', $topics);
         // Paging
         $total = $this->forumService->countFoundTopicsInSection($token, $userToken, $sectionId, $excludeGroupIdList);
         $perPage = $this->forumService->getTopicPerPageConfig();
         $pages = (int) ceil($total / $perPage);
         $paging = new BASE_CMP_Paging($page, $pages, $perPage);
         $this->assign('paging', $paging->render());
         // Sort control
         $sortCtrl = new BASE_CMP_SortControl();
         $url = OW::getRouter()->urlForRoute('forum_search_section', array('sectionId' => $params['sectionId'])) . '?' . $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);
         $this->assign('avatars', BOL_AvatarService::getInstance()->getDataForUserAvatars($authors));
     } else {
         $this->redirect(OW::getRouter()->urlForRoute('forum-default'));
     }
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'section', 'sectionId' => $sectionId, 'token' => $token, 'userToken' => $userToken)));
     OW::getDocument()->setHeading($lang->text('forum', 'search_page_heading'));
     OW::getDocument()->setHeadingIconClass('ow_ic_forum');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum');
 }
Example #11
0
 public function index($params)
 {
     $username = !empty($params['user']) ? $params['user'] : '';
     $id = $params['id'];
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     $service = PostService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->assign('user', OW::getUser()->getId() !== null ? $userService->findUserById(OW::getUser()->getId()) : null);
     $post = $service->findById($id);
     if ($post === null) {
         throw new Redirect404Exception();
     }
     if ($post->isDraft() && $post->authorId != OW::getUser()->getId()) {
         throw new Redirect404Exception();
     }
     $post->post = BASE_CMP_TextFormatter::fromBBtoHtml($post->post);
     $post->setTitle(strip_tags($post->getTitle()));
     if (!OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $post->getAuthorId() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /* Check privacy permissions */
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     }
     /* */
     $parts = explode('<!--page-->', $post->getPost());
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     $count = count($parts);
     if (strlen($username) > 0) {
         $author = $userService->findByUsername($username);
     } else {
         $author = $userService->findUserById($post->getAuthorId());
         $isAuthorExists = !empty($author);
         if ($isAuthorExists) {
             $username = $author->getUsername();
         }
     }
     $this->assign('isAuthorExists', $isAuthorExists);
     if ($isAuthorExists) {
         $displayName = $userService->getDisplayName($author->getId());
         $this->assign('username', $userService->getUserName($author->getId()));
         $this->assign('displayname', $displayName);
         $url = OW::getRouter()->urlForRoute('user-blog', array('user' => $username));
         $this->setPageHeading(OW::getLanguage()->text('blogs', 'view_page_heading', array('url' => $url, 'name' => $displayName, 'postTitle' => htmlspecialchars($post->getTitle()))));
         $this->setPageHeadingIconClass('ow_ic_write');
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'blog_post_title', array('post_title' => htmlspecialchars($post->getTitle()), 'display_name' => $displayName)));
         $post_body = UTIL_String::truncate($post->getPost(), 200, '...');
         $postTagsArray = BOL_TagService::getInstance()->findEntityTags($post->getId(), 'blog-post');
         $postTags = "";
         foreach ($postTagsArray as $tag) {
             $postTags .= $tag->label . ", ";
         }
         $postTags = substr($postTags, 0, -2);
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'blog_post_description', array('post_body' => htmlspecialchars(strip_tags($post_body)), 'tags' => htmlspecialchars($postTags))));
         //OW::getDocument()->setKeywords(OW::getLanguage()->text('nav', 'page_default_keywords').", ".$postTags);
     }
     $info = array('dto' => $post, 'text' => $parts[$page - 1]);
     $this->assign('info', $info);
     if ($isAuthorExists) {
         //blog navigation
         $prev = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'prev');
         $next = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'next');
         if (!empty($prev)) {
             $prevUser = $userService->findUserById($prev->getAuthorId());
         }
         if (!empty($next)) {
             $nextUser = $userService->findUserById($next->getAuthorId());
         }
         $this->assign('adjasentUrl', array('next' => !empty($nextUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $next->getId(), 'user' => $nextUser->getUsername())) : '', 'prev' => !empty($prevUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $prev->getId(), 'user' => $prevUser->getUsername())) : '', 'index' => OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername()))));
     } else {
         $this->assign('adjasentUrl', null);
     }
     //~blog navigation
     //toolbar
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('blogs.collect_post_toolbar_items', array('postId' => $post->id, 'postDto' => $post));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && $post->getAuthorId() != OW::getUser()->getId()) {
         $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#blog_post_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "blogs+flags");', array('entity' => 'blog_post', 'id' => $post->getId(), 'title' => htmlspecialchars(json_encode($post->getTitle())), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $post->getId())))));
         OW::getDocument()->addOnloadScript($js, 1001);
         $tb[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'blog_post_toolbar_flag');
     }
     if (OW::getUser()->isAuthenticated() && (OW::getUser()->getId() == $post->getAuthorId() || BOL_AuthorizationService::getInstance()->isModerator(OW::getUser()->getId()))) {
         $tb[] = array('href' => OW::getRouter()->urlForRoute('post-save-edit', array('id' => $post->getId())), 'label' => OW::getLanguage()->text('blogs', 'toolbar_edit'));
         $tb[] = array('href' => OW::getRouter()->urlFor('BLOGS_CTRL_Save', 'delete', array('id' => $post->getId())), 'click' => "return confirm('" . OW::getLanguage()->text('base', 'are_you_sure') . "');", 'label' => OW::getLanguage()->text('blogs', 'toolbar_delete'));
     }
     $this->assign('tb', $tb);
     //~toolbar
     $paging = new BASE_CMP_Paging($page, $count, $count);
     //<ARCHIVE-NAVIGATOR>
     $this->assign('paging', $paging->render());
     if ($isAuthorExists) {
         $rows = $service->findUserArchiveData($author->getId());
         $archive = array();
         foreach ($rows as $row) {
             if (!array_key_exists($row['y'], $archive)) {
                 $archive[$row['y']] = array();
             }
             $archive[$row['y']][] = $row['m'];
         }
         $this->assign('archive', $archive);
     }
     //</ARCHIVE-NAVIGATOR>
     if ($isAuthorExists) {
         $this->assign('author', $author);
     }
     $this->assign('isModerator', OW::getUser()->isAuthorized('blogs'));
     if ($isAuthorExists) {
         $this->assign('userBlogUrl', OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername())));
     }
     /* Check comments privacy permissions */
     $allow_comments = true;
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_comment_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     /* */
     // additional components
     $cmpParams = new BASE_CommentsParams('blogs', 'blog-post');
     $cmpParams->setEntityId($post->getId())->setOwnerId($post->getAuthorId())->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $this->assign('avatarUrl', '');
     $tagCloud = new BASE_CMP_EntityTagCloud('blog-post', OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')));
     $tagCloud->setEntityId($post->getId());
     $rateInfo = new BASE_CMP_Rate('blogs', 'blog-post', $post->getId(), $post->getAuthorId());
     $this->addComponent('rate', $rateInfo);
     $this->addComponent('tagCloud', $tagCloud);
     //~ additional components
 }
Example #12
0
 /**
  * Displays mailbox sent page
  */
 public function sent()
 {
     $language = OW::getLanguage();
     OW::getDocument()->setTitle($language->text('mailbox', 'sent_meta_tilte'));
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
         // TODO: Redirect to login page
     }
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     if (OW::getRequest()->isPost() && !empty($_POST['conversation']) && is_array($_POST['conversation'])) {
         $conversationList = $_POST['conversation'];
         if (isset($_POST['mark_as_read'])) {
             $count = $conversationService->markRead($conversationList, $userId);
             OW::getFeedback()->info($language->text('mailbox', 'mark_read_message', array('count' => $count)));
         } else {
             if (isset($_POST['mark_as_unread'])) {
                 $count = $conversationService->markUnread($conversationList, $userId);
                 OW::getFeedback()->info($language->text('mailbox', 'mark_unread_message', array('count' => $count)));
             } else {
                 if (isset($_POST['delete'])) {
                     $count = $conversationService->deleteConversation($conversationList, $userId);
                     OW::getFeedback()->info($language->text('mailbox', 'delete_message', array('count' => $count)));
                 }
             }
         }
         $this->redirect();
     }
     //paging
     $recordsToPage = $this->recordsToPage;
     $record = array();
     $recordsCount = (int) $conversationService->getSentConversationCount($userId);
     $pageCount = (int) ceil($recordsCount / $recordsToPage);
     $page = 1;
     if ($recordsCount > $recordsToPage) {
         if (isset($_GET['page'])) {
             if ((int) $_GET['page'] < 1) {
                 $this->redirect(OW::getRouter()->urlForRoute('mailbox_sent') . '?page=' . 1);
             }
             $page = (int) $_GET['page'];
         }
     }
     if (empty($pageCount) || $pageCount < 1) {
         $pageCount = 1;
     }
     if ($page > $pageCount) {
         $this->redirect(OW::getRouter()->urlForRoute('mailbox_sent') . '?page=' . $pageCount);
     }
     $paging = new BASE_CMP_Paging($page, $pageCount, $recordsToPage);
     $this->assign('paging', $paging->render());
     $startRecord = (int) (($page - 1) * $recordsToPage);
     $record['new'] = (int) $conversationService->getNewSentConversationCount($userId);
     $record['total'] = $recordsCount;
     $record['start'] = $startRecord + 1;
     $record['end'] = (int) $page * $recordsToPage <= $recordsCount ? (int) $page * $recordsToPage : $recordsCount;
     $this->assign('record', $record);
     //--
     $conversations = $conversationService->getSentConversationList($userId, $startRecord, $recordsToPage);
     $conversationList = array();
     $opponentsId = array();
     $conversationsId = array();
     foreach ($conversations as $value) {
         $conversation = array();
         $conversation['conversationId'] = $value['conversationId'];
         $conversation['userId'] = $userId;
         $conversation['read'] = false;
         $conversation['url'] = $conversationService->getConversationUrl($conversation['conversationId'], MAILBOX_CTRL_Mailbox::REDIRECT_TO_SENT);
         $conversation['deleteUrl'] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteSent', array("conversationId" => $conversation['conversationId'], "page" => $page));
         switch ($userId) {
             case $value['initiatorId']:
                 $conversation['opponentId'] = $value['interlocutorId'];
                 $conversation['isOpponentLastMessage'] = false;
                 if ($value['initiatorMessageId'] < $value['interlocutorMessageId']) {
                     $conversation['isOpponentLastMessage'] = true;
                 }
                 if ((int) $value['read'] & MAILBOX_BOL_ConversationDao::READ_INITIATOR) {
                     $conversation['read'] = true;
                 }
                 break;
             case $value['interlocutorId']:
                 $conversation['opponentId'] = $value['initiatorId'];
                 $conversation['isOpponentLastMessage'] = false;
                 if ($value['initiatorMessageId'] > $value['interlocutorMessageId']) {
                     $conversation['isOpponentLastMessage'] = true;
                 }
                 if ((int) $value['read'] & MAILBOX_BOL_ConversationDao::READ_INTERLOCUTOR) {
                     $conversation['read'] = true;
                 }
                 break;
         }
         $conversation['timeStamp'] = UTIL_DateTime::formatDate((int) $value['timeStamp']);
         $conversation['subject'] = $value['subject'];
         $short = mb_strlen($value['text']) > 100 ? mb_substr($value['text'], 0, 100) . '...' : $value['text'];
         //TODO:
         $short = UTIL_HtmlTag::autoLink($short);
         $event = new OW_Event('mailbox.message_render', array('conversationId' => $conversation['conversationId'], 'messageId' => $value['id'], 'senderId' => $conversation['userId'], 'recipientId' => $conversation['opponentId']), array('short' => $short, 'full' => $value['text']));
         OW::getEventManager()->trigger($event);
         $eventData = $event->getData();
         $conversation['text'] = $eventData['short'];
         $conversationList[] = $conversation;
         $opponentsId[] = $conversation['opponentId'];
         $conversationsId[] = $conversation['conversationId'];
     }
     $opponentsId = array_unique($opponentsId);
     $opponentsAvatar = BOL_AvatarService::getInstance()->getDataForUserAvatars($opponentsId);
     $opponentsUrl = BOL_UserService::getInstance()->getUserUrlsForList($opponentsId);
     $opponentsDisplayNames = BOL_UserService::getInstance()->getDisplayNamesForList($opponentsId);
     $attachmentsCount = $conversationService->getAttachmentsCountByConversationList($conversationsId);
     $this->assign('attachments', $attachmentsCount);
     $this->assign('opponentsAvatar', $opponentsAvatar);
     $this->assign('opponentsUrl', $opponentsUrl);
     $this->assign('opponentsDisplayNames', $opponentsDisplayNames);
     $this->assign('conversationList', $conversationList);
     $deleteConfirmMessage = OW::getLanguage()->text('mailbox', 'delete_confirm_message');
     //include js
     $onLoadJs = " \$( document ).ready( function(){\n\t\t\t\t\t\tvar sent = new mailboxConversationList( " . json_encode(array('responderUrl' => $this->responderUrl, 'deleteConfirmMessage' => $deleteConfirmMessage)) . " );\n\t\t\t\t\t\tsent.bindFunction();\n\t\t\t\t\t} ); ";
     OW::getDocument()->addOnloadScript($onLoadJs);
     OW::getDocument()->addScript($this->jsDirUrl . "mailbox.js");
 }
Example #13
0
 public function index($params)
 {
     $plugin = OW::getPluginManager()->getPlugin('links');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'links', 'main_menu_item');
     if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('links', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /*
      @var $service LinkService
     */
     $service = LinkService::getInstance();
     /*
      @var $userService BOL_UserService
     */
     $userService = BOL_UserService::getInstance();
     /*
      @var $author BOL_User
     */
     if (!empty($params['user'])) {
         $author = $userService->findByUsername($params['user']);
     } else {
         $author = $userService->findUserById(OW::getUser()->getId());
     }
     if (empty($author)) {
         throw new Redirect404Exception();
         return;
     }
     /* Check privacy permissions */
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $author->getId(), 'viewerId' => OW::getUser()->getId());
     OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     /* */
     $displayName = $userService->getDisplayName($author->getId());
     $this->assign('author', $author);
     $this->assign('username', $author->getUsername());
     $this->assign('displayname', $displayName);
     if ($author->getId() == OW::getUser()->getId()) {
         $this->setPageHeading(OW::getLanguage()->text('links', 'my_links'));
         $this->setPageHeadingIconClass('ow_ic_write');
         OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'my_links'));
     } else {
         $this->setPageHeading(OW::getLanguage()->text('links', 'user_link_page_heading', array('display_name' => $displayName)));
         $this->setPageHeadingIconClass('ow_ic_write');
         OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'user_links_title', array('display_name' => $displayName)));
     }
     OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'user_links_description', array('display_name' => $displayName)));
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $rpp = (int) OW::getConfig()->getValue('links', 'results_per_page');
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     $list = $service->findUserLinkList($author->getId(), $first, $count);
     $itemsCount = $service->countUserLinks($author->getId());
     $posts = array();
     $commentInfo = array();
     $idList = array();
     foreach ($list as $dto) {
         $idList[] = $dto->getId();
         $text = BASE_CMP_TextFormatter::fromBBtoHtml($dto->getDescription());
         $descLength = 120;
         $text = strip_tags($text);
         if (strlen($text) > $descLength) {
             $text = UTIL_String::truncate($text, $descLength, '...');
             $text .= ' <a href="' . OW::getRouter()->urlForRoute('link', array('id' => $dto->getId())) . '" class="ow_lbutton">' . OW::getLanguage()->text('base', 'more') . '</a>';
         }
         $posts[$dto->getId()] = array('id' => $dto->getId(), 'href' => $dto->getUrl(), 'title' => UTIL_String::truncate($dto->getTitle(), 65, '...'), 'text' => $text);
     }
     if (!empty($idList)) {
         $voteService = BOL_VoteService::getInstance();
         switch (OW::getConfig()->getValue('links', 'result_mode')) {
             case LinkService::RESULT_MODE_SUM:
                 $this->assign('mode', 'sum');
                 break;
             case LinkService::RESULT_MODE_DETAILED:
                 $this->assign('mode', 'detailed');
                 break;
         }
         $voteTotal = $voteService->findTotalVotesResultForList($idList, 'link');
         foreach ($voteTotal as $val) {
             $posts[$val['id']]['isVoted'] = true;
             $posts[$val['id']]['voteTotal'] = $val['sum'];
             $posts[$val['id']]['up'] = $val['up'];
             $posts[$val['id']]['down'] = $val['down'];
         }
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $this->assign('commentInfo', $commentInfo);
         $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('link', $idList);
         $this->assign('tagsInfo', $tagsInfo);
         $tb = array();
         foreach ($list as $dto) {
             $tb[$dto->getId()] = array(array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->getId())), 'label' => UTIL_DateTime::formatDate($dto->timestamp)));
             if ($commentInfo[$dto->getId()]) {
                 $tb[$dto->getId()][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->getId())) . "#comments", 'label' => '<span class="ow_outline">' . $commentInfo[$dto->getId()] . '</span> ' . OW::getLanguage()->text('links', 'toolbar_comments'));
             }
             if ($tagsInfo[$dto->getId()]) {
                 $tags =& $tagsInfo[$dto->getId()];
                 $t = OW::getLanguage()->text('links', 'tags');
                 for ($i = 0; $i < (count($tags) > 3 ? 3 : count($tags)); $i++) {
                     $t .= " <a href=\"" . OW::getRouter()->urlForRoute('links-by-tag', array('list' => 'browse-by-tag')) . "?tag={$tags[$i]}\">{$tags[$i]}</a>" . ($i != 2 ? ',' : '');
                 }
                 $tb[$dto->getId()][] = array('label' => mb_substr($t, 0, mb_strlen($t) - 1));
             }
         }
         $this->assign('tb', $tb);
         if (OW::getUser()->isAuthenticated()) {
             $userVotes = $voteService->findUserVoteForList($idList, 'link', OW::getUser()->getId());
             $this->assign('userVotes', $userVotes);
         }
     }
     $this->assign('list', $posts);
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->assign('paging', $paging->render());
     $this->assign('isAuthenticated', OW::getUser()->isAuthenticated());
 }
Example #14
0
 /**
  * Controller's default action
  *
  * @param array $params
  * @throws AuthorizationException
  * @throws Redirect404Exception
  */
 public function index(array $params)
 {
     if (!isset($params['topicId']) || ($topicDto = $this->forumService->findTopicById($params['topicId'])) === null) {
         throw new Redirect404Exception();
     }
     if ($topicDto != FORUM_BOL_ForumService::STATUS_APPROVED) {
         //throw new Redirect404Exception();
     }
     $forumGroup = $this->forumService->findGroupById($topicDto->groupId);
     $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
     $isHidden = $forumSection->isHidden;
     $userId = OW::getUser()->getId();
     $isOwner = $topicDto->userId == $userId ? true : false;
     $postReplyPermissionErrorText = null;
     if ($isHidden) {
         $event = new OW_Event('forum.can_view', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId), true);
         OW::getEventManager()->trigger($event);
         $canView = $event->getData();
         $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         $params = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'edit_topic');
         $event = new OW_Event('forum.check_permissions', $params);
         OW::getEventManager()->trigger($event);
         $canEdit = $event->getData();
         $params = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic');
         $event = new OW_Event('forum.check_permissions', $params);
         OW::getEventManager()->trigger($event);
         $canPost = $event->getData();
         $postReplyPermissionErrorText = OW::getLanguage()->text($forumSection->entity, 'post_reply_permission_error');
         $canMoveToHidden = BOL_AuthorizationService::getInstance()->isActionAuthorized($forumSection->entity, 'move_topic_to_hidden') && $isModerator;
         //$eventParams = array('pluginKey' => $forumSection->entity, 'action' => 'add_post');
         //TODO Zaph:create action that will check if user allowed to delete post separately from topic
     } else {
         $isModerator = OW::getUser()->isAuthorized('forum');
         $canView = OW::getUser()->isAuthorized('forum', 'view');
         $canEdit = $isOwner || $isModerator;
         $canPost = OW::getUser()->isAuthorized('forum', 'edit');
         $canMoveToHidden = BOL_AuthorizationService::getInstance()->isActionAuthorized('forum', 'move_topic_to_hidden') && $isModerator;
         //$eventParams = array('pluginKey' => 'forum', 'action' => 'add_post');
     }
     $canLock = $canSticky = $isModerator;
     if (!$canView && !$isModerator) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('forum', 'view');
         throw new AuthorizationException($status['msg']);
     }
     if ($forumGroup->isPrivate) {
         if (!$userId) {
             throw new AuthorizationException();
         } else {
             if (!$isModerator) {
                 if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($forumGroup->roles))) {
                     throw new AuthorizationException();
                 }
             }
         }
     }
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     //update topic's view count
     $topicDto->viewCount += 1;
     $this->forumService->saveOrUpdateTopic($topicDto);
     //update user read info
     $this->forumService->setTopicRead($topicDto->id, $userId);
     $topicInfo = $this->forumService->getTopicInfo($topicDto->id);
     $postList = $this->forumService->getTopicPostList($topicDto->id, $page);
     OW::getEventManager()->trigger(new OW_Event('forum.topic_post_list', array('list' => $postList)));
     $this->assign('isHidden', $isHidden);
     // adds forum caption if any
     if ($isHidden) {
         $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId));
         OW::getEventManager()->trigger($event);
         $eventData = $event->getData();
         /** @var OW_Component $componentForumCaption */
         $componentForumCaption = $eventData['component'];
         if (!empty($componentForumCaption)) {
             $this->assign('componentForumCaption', $componentForumCaption->render());
         } else {
             $componentForumCaption = false;
             $this->assign('componentForumCaption', $componentForumCaption);
         }
         $eParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'edit_topic');
         $event = new OW_Event('forum.check_permissions', $eParams);
         OW::getEventManager()->trigger($event);
         if ($event->getData()) {
             $canLock = $canSticky = true;
         }
     }
     $this->assign('postReplyPermissionErrorText', $postReplyPermissionErrorText);
     $this->assign('isHidden', $isHidden);
     $this->assign('isOwner', $isOwner);
     $this->assign('canPost', $canPost);
     $this->assign('canLock', $canLock);
     $this->assign('canSticky', $canSticky);
     $this->assign('canSubscribe', OW::getUser()->isAuthorized('forum', 'subscribe'));
     $this->assign('isSubscribed', $userId && FORUM_BOL_SubscriptionService::getInstance()->isUserSubscribed($userId, $topicDto->id));
     if (!$postList) {
         throw new Redirect404Exception();
     }
     $toolbars = array();
     $lang = OW::getLanguage();
     $langQuote = $lang->text('forum', 'quote');
     $langFlag = $lang->text('base', 'flag');
     $langEdit = $lang->text('forum', 'edit');
     $langDelete = $lang->text('forum', 'delete');
     $iteration = 0;
     $userIds = array();
     $postIds = array();
     $flagItems = array();
     $firstTopicPost = $this->forumService->findTopicFirstPost($topicDto->id);
     foreach ($postList as &$post) {
         $post['text'] = UTIL_HtmlTag::autoLink($post['text']);
         $post['permalink'] = $this->forumService->getPostUrl($post['topicId'], $post['id'], true, $page);
         $post['number'] = ($page - 1) * $this->forumService->getPostPerPageConfig() + $iteration + 1;
         if ($iteration == 0) {
             $firstPostText = substr(htmlspecialchars(strip_tags($post['text'])), 0, 154);
         }
         // get list of users
         if (!in_array($post['userId'], $userIds)) {
             $userIds[$post['userId']] = $post['userId'];
         }
         $toolbar = array();
         array_push($toolbar, array('class' => 'post_permalink', 'href' => $post['permalink'], 'label' => '#' . $post['number']));
         if ($userId) {
             if (!$topicDto->locked && ($canEdit || $canPost)) {
                 array_push($toolbar, array('id' => $post['id'], 'class' => 'quote_post', 'href' => 'javascript://', 'label' => $langQuote));
             }
             if ($userId != (int) $post['userId']) {
                 $lagItemKey = 'flag_' . $post['id'];
                 $flagItems[$lagItemKey] = array('id' => $post['id'], 'title' => $post['text'], 'href' => $this->forumService->getPostUrl($post['topicId'], $post['id']));
                 array_push($toolbar, array('label' => $langFlag, 'href' => 'javascript://', 'id' => $lagItemKey, 'class' => 'post_flag_item'));
             }
         }
         if ($isModerator || $userId == (int) $post['userId'] && !$topicDto->locked) {
             $href = $iteration == 0 && $page == 1 ? OW::getRouter()->urlForRoute('edit-topic', array('id' => $post['topicId'])) : OW::getRouter()->urlForRoute('edit-post', array('id' => $post['id']));
             array_push($toolbar, array('id' => $post['id'], 'href' => $href, 'label' => $langEdit));
             if (!($iteration == 0 && $page == 1)) {
                 array_push($toolbar, array('id' => $post['id'], 'class' => 'delete_post', 'href' => 'javascript://', 'label' => $langDelete));
             }
             if ($iteration === 0 && !$isOwner && $isModerator && $topicInfo['status'] == FORUM_BOL_ForumService::STATUS_APPROVAL) {
                 $toolbar[] = array('id' => $topicInfo['id'], 'href' => OW::getRouter()->urlForRoute('forum_approve_topic', array('id' => $topicInfo['id'])), 'label' => OW::getLanguage()->text('forum', 'approve_topic'));
             }
         }
         $toolbars[$post['id']] = $toolbar;
         if (count($post['edited']) && !in_array($post['edited']['userId'], $userIds)) {
             $userIds[$post['edited']['userId']] = $post['edited']['userId'];
         }
         $iteration++;
         array_push($postIds, $post['id']);
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery-fieldselection.js');
     $js = UTIL_JsGenerator::newInstance()->newVariable('flagItems', $flagItems)->jQueryEvent('.post_flag_item a', 'click', 'var inf = flagItems[this.id];
             if (inf.id == ' . $firstTopicPost->id . ' ){
                 OW.flagContent("' . FORUM_BOL_ForumService::FEED_ENTITY_TYPE . '", ' . $firstTopicPost->topicId . ');
             }
             else{
                 OW.flagContent("' . FORUM_BOL_ForumService::FEED_POST_ENTITY_TYPE . '", inf.id);
             }');
     OW::getDocument()->addOnloadScript($js, 1001);
     $this->assign('toolbars', $toolbars);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIds);
     $this->assign('avatars', $avatars);
     $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
     $this->assign('enableAttachments', $enableAttachments);
     $uid = uniqid();
     $addPostForm = $this->generateAddPostForm($topicDto->id, $uid);
     $this->addForm($addPostForm);
     $addPostInputId = $addPostForm->getElement('text')->getId();
     if ($enableAttachments) {
         $attachments = FORUM_BOL_PostAttachmentService::getInstance()->findAttachmentsByPostIdList($postIds);
         $this->assign('attachments', $attachments);
         $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid);
         $this->addComponent('attachmentsCmp', $attachmentCmp);
     }
     $plugin = OW::getPluginManager()->getPlugin('forum');
     $indexUrl = OW::getRouter()->urlForRoute('forum-default');
     $groupUrl = OW::getRouter()->urlForRoute('group-default', array('groupId' => $topicDto->groupId));
     $deletePostUrl = OW::getRouter()->urlForRoute('delete-post', array('topicId' => $topicDto->id, 'postId' => 'postId'));
     $stickyTopicUrl = OW::getRouter()->urlForRoute('sticky-topic', array('topicId' => $topicDto->id, 'page' => $page));
     $lockTopicUrl = OW::getRouter()->urlForRoute('lock-topic', array('topicId' => $topicDto->id, 'page' => $page));
     $deleteTopicUrl = OW::getRouter()->urlForRoute('delete-topic', array('topicId' => $topicDto->id));
     $getPostUrl = OW::getRouter()->urlForRoute('get-post', array('postId' => 'postId'));
     $moveTopicUrl = OW::getRouter()->urlForRoute('move-topic');
     $subscribeTopicUrl = OW::getRouter()->urlForRoute('subscribe-topic', array('id' => $topicDto->id));
     $unsubscribeTopicUrl = OW::getRouter()->urlForRoute('unsubscribe-topic', array('id' => $topicDto->id));
     $topicInfoJs = json_encode(array('sticky' => $topicDto->sticky, 'locked' => $topicDto->locked, 'ishidden' => $isHidden && !$canMoveToHidden));
     $onloadJs = "\n\t\t\tForumTopic.deletePostUrl = '{$deletePostUrl}';\n\t\t\tForumTopic.stickyTopicUrl = '{$stickyTopicUrl}';\n\t\t\tForumTopic.lockTopicUrl = '{$lockTopicUrl}';\n\t\t\tForumTopic.subscribeTopicUrl = '{$subscribeTopicUrl}';\n\t\t\tForumTopic.unsubscribeTopicUrl = '{$unsubscribeTopicUrl}';\n\t\t\tForumTopic.deleteTopicUrl = '{$deleteTopicUrl}';\n\t\t\tForumTopic.getPostUrl = '{$getPostUrl}';\n\t\t\tForumTopic.add_post_input_id = '{$addPostInputId}';\n\t\t\tForumTopic.construct({$topicInfoJs});\n\t\t\t";
     OW::getDocument()->addOnloadScript($onloadJs);
     OW::getDocument()->addScript($plugin->getStaticJsUrl() . "forum.js");
     // add language keys for javascript
     $lang->addKeyForJs('forum', 'sticky_topic_confirm');
     $lang->addKeyForJs('forum', 'unsticky_topic_confirm');
     $lang->addKeyForJs('forum', 'lock_topic_confirm');
     $lang->addKeyForJs('forum', 'unlock_topic_confirm');
     $lang->addKeyForJs('forum', 'delete_topic_confirm');
     $lang->addKeyForJs('forum', 'delete_post_confirm');
     $lang->addKeyForJs('forum', 'edit_topic_title');
     $lang->addKeyForJs('forum', 'edit_post_title');
     $lang->addKeyForJs('forum', 'move_topic_title');
     $lang->addKeyForJs('forum', 'confirm_delete_attachment');
     $lang->addKeyForJs('forum', 'forum_quote');
     $lang->addKeyForJs('forum', 'forum_quote_from');
     // first topic's post
     $postDto = $firstTopicPost;
     //posts count on page
     $count = $this->forumService->getPostPerPageConfig();
     $postCount = $this->forumService->findTopicPostCount($topicDto->id);
     $pageCount = ceil($postCount / $count);
     $groupSelect = $this->forumService->getGroupSelectList($topicDto->groupId, $canMoveToHidden, $userId);
     $moveTopicForm = $this->generateMoveTopicForm($moveTopicUrl, $groupSelect, $topicDto);
     $this->addForm($moveTopicForm);
     $Paging = new BASE_CMP_Paging($page, $pageCount, $count);
     $this->assign('paging', $Paging->render());
     if ($isHidden) {
         OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
         OW::getDocument()->setHeading(OW::getLanguage()->text($forumSection->entity, 'topic_page_heading', array('topic' => $topicInfo['title'], 'group' => $topicInfo['groupName'], 'content' => '')));
         $bcItems = array(array('href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId())), 'label' => OW::getLanguage()->text($forumSection->entity, 'view_all_topics')));
         $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
         $this->addComponent('breadcrumb', $breadCrumbCmp);
     } else {
         $bcItems = array(array('href' => $indexUrl, 'label' => $lang->text('forum', 'forum_index')), array('href' => OW::getRouter()->urlForRoute('section-default', array('sectionId' => $topicInfo['sectionId'])), 'label' => $topicInfo['sectionName']), array('href' => $groupUrl, 'label' => $topicInfo['groupName']));
         $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems, $lang->text('forum', 'topic_location'));
         $this->addComponent('breadcrumb', $breadCrumbCmp);
         OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'topic_page_heading', array('topic' => $topicInfo['title'], 'content' => $topicInfo['status'] == FORUM_BOL_ForumService::STATUS_APPROVED ? '' : OW::getLanguage()->text('forum', 'pending_approval'))));
     }
     OW::getDocument()->setHeadingIconClass('ow_ic_script');
     $this->assign('indexUrl', $indexUrl);
     $this->assign('groupUrl', $groupUrl);
     $this->assign('topicInfo', $topicInfo);
     $this->assign('postList', $postList);
     $this->assign('page', $page);
     $this->assign('userId', $userId);
     $this->assign('isModerator', $isModerator);
     $this->assign('canEdit', $canEdit);
     $this->assign('canMoveToHidden', $canMoveToHidden);
     OW::getDocument()->setTitle($topicInfo['title']);
     OW::getDocument()->setDescription($firstPostText);
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'topic', 'topicId' => $topicDto->id)));
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('forum.collect_topic_toolbar_items', array('topicId' => $topicDto->id, 'topicDto' => $topicDto));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     $this->assign('tb', $tb);
 }
Example #15
0
 public function popular()
 {
     $this->setTemplate(OW::getPluginManager()->getPlugin('ocsfundraising')->getCtrlViewDir() . 'project_projects.html');
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $limit = 9;
     $list = $service->getPopularGoalList($page, $limit);
     $this->assign('list', $list);
     $total = $service->getPopularGoalsCount();
     $pages = (int) ceil($total / $limit);
     $paging = new BASE_CMP_Paging($page, $pages, $limit);
     $this->assign('paging', $paging->render());
     $this->addComponent('categories', new OCSFUNDRAISING_CMP_Categories());
     $this->addComponent('menu', $this->getMenu());
     $this->assign('canAdd', OW::getUser()->isAuthorized('ocsfundraising', 'add_goal'));
     $script = '$("#btn-add-project").click(function(){
         document.location.href = ' . json_encode(OW::getRouter()->urlForRoute('ocsfundraising.add_goal')) . ';
     });';
     OW::getDocument()->addOnloadScript($script);
     $this->setPageHeading($lang->text('ocsfundraising', 'popular_projects'));
 }
Example #16
0
 public function userGifts(array $params)
 {
     if (empty($params['userName']) || !($user = BOL_UserService::getInstance()->findByUsername($params['userName']))) {
         throw new Redirect404Exception();
     }
     $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
     $perPage = $giftService->getGiftsPerPageConfig();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $gifts = $giftService->findUserReceivedGifts($user->id, $page, $perPage, true);
     $toolbars = array();
     if ($gifts) {
         $users = array();
         foreach ($gifts as $gift) {
             if (!in_array($gift['dto']->senderId, $users)) {
                 array_push($users, $gift['dto']->senderId);
             }
         }
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($users);
         $this->assign('avatars', $avatars);
         foreach ($gifts as $gift) {
             $giftId = $gift['dto']->id;
             $toolbars[$giftId][] = array('label' => UTIL_DateTime::formatSimpleDate($gift['dto']->sendTimestamp));
         }
     }
     $this->assign('gifts', $gifts);
     $this->assign('toolbars', $toolbars);
     $total = $giftService->countUserReceivedGifts($user->id, true);
     // Paging
     $pages = (int) ceil($total / $perPage);
     $paging = new BASE_CMP_Paging($page, $pages, 10);
     $this->assign('paging', $paging->render());
     $displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
     $this->setPageHeading(OW::getLanguage()->text('virtualgifts', 'user_gifts', array('user' => $displayName)));
     $this->setPageHeadingIconClass('ow_ic_heart');
     OW::getDocument()->setTitle(OW::getLanguage()->text('virtualgifts', 'meta_title_user_gifts', array('recipient' => $displayName)));
     OW::getDocument()->setDescription(OW::getLanguage()->text('virtualgifts', 'meta_description_user_gifts', array('recipient' => $displayName)));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
     $url = OW::getPluginManager()->getPlugin('virtualgifts')->getStaticCssUrl() . 'style.css';
     OW::getDocument()->addStyleSheet($url);
 }
Example #17
0
    /**
     * Controller action for user album
     *
     * @param array $params
     * @throws Redirect404Exception
     */
    public function userAlbum(array $params)
    {
        if (!isset($params['user']) || !strlen($user = trim($params['user']))) {
            throw new Redirect404Exception();
        }
        if (!isset($params['album']) || !($albumId = (int) $params['album'])) {
            throw new Redirect404Exception();
        }
        // is owner
        $userDto = BOL_UserService::getInstance()->findByUsername($user);
        if ($userDto) {
            $ownerMode = $userDto->id == OW::getUser()->getId();
        } else {
            $ownerMode = false;
        }
        // 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;
        }
        $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
        $config = OW::getConfig();
        $photoPerPage = $config->getValue('photo', 'photos_per_page');
        $album = $this->photoAlbumService->findAlbumById($albumId);
        if (!$album) {
            throw new Redirect404Exception();
        }
        $this->assign('album', $album);
        // permissions check
        if (!$ownerMode && !$modPermissions) {
            $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $album->userId, 'viewerId' => OW::getUser()->getId());
            $event = new OW_Event('privacy_check_permission', $privacyParams);
            OW::getEventManager()->trigger($event);
        }
        $this->assign('userName', BOL_UserService::getInstance()->getUserName($album->userId));
        $displayName = BOL_UserService::getInstance()->getDisplayName($album->userId);
        $this->assign('displayName', $displayName);
        $photos = $this->photoService->getAlbumPhotos($albumId, $page, $photoPerPage);
        $this->assign('photos', $photos);
        $total = $this->photoAlbumService->countAlbumPhotos($albumId);
        $this->assign('total', $total);
        $lastUpdated = $this->photoAlbumService->getAlbumUpdateTime($albumId);
        $this->assign('lastUpdate', $lastUpdated);
        $this->assign('widthConfig', $config->getValue('photo', 'preview_image_width'));
        $this->assign('heightConfig', $config->getValue('photo', 'preview_image_height'));
        // Paging
        $pages = (int) ceil($total / $photoPerPage);
        $paging = new BASE_CMP_Paging($page, $pages, $photoPerPage);
        $this->assign('paging', $paging->render());
        OW::getDocument()->setHeading($album->name . ' <span class="ow_small">' . OW::getLanguage()->text('photo', 'photos_in_album', array('total' => $total)) . '</span>');
        OW::getDocument()->setHeadingIconClass('ow_ic_picture');
        // check permissions
        $canEdit = OW::getUser()->isAuthorized('photo', 'upload', $album->userId);
        $canModerate = OW::getUser()->isAuthorized('photo');
        $authorized = $canEdit || $canModerate;
        $this->assign('authorized', $canEdit || $canModerate);
        $this->assign('canUpload', $canEdit);
        $lang = OW::getLanguage();
        if ($authorized) {
            $albumEditForm = new albumEditForm();
            $albumEditForm->getElement('albumName')->setValue($album->name);
            $albumEditForm->getElement('id')->setValue($album->id);
            $this->addForm($albumEditForm);
            OW::getDocument()->addScript($this->pluginJsUrl . 'album.js');
            if (OW::getRequest()->isPost() && $albumEditForm->isValid($_POST)) {
                $res = $albumEditForm->process();
                if ($res['result']) {
                    OW::getFeedback()->info($lang->text('photo', 'photo_album_updated'));
                    $this->redirect();
                }
            }
            $lang->addKeyForJs('photo', 'confirm_delete_album');
            $lang->addKeyForJs('photo', 'edit_album');
            $objParams = array('ajaxResponder' => $this->ajaxResponder, 'albumId' => $albumId, 'uploadUrl' => OW::getRouter()->urlForRoute('photo_upload_album', array('album' => $album->id)));
            $script = "\$(document).ready(function(){\n                    var album = new photoAlbum( " . json_encode($objParams) . ");\n                }); ";
            OW::getDocument()->addOnloadScript($script);
        }
        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.bbq.min.js');
        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('photo')->getStaticJsUrl() . 'photo.js');
        OW::getLanguage()->addKeyForJs('photo', 'tb_edit_photo');
        OW::getLanguage()->addKeyForJs('photo', 'confirm_delete');
        OW::getLanguage()->addKeyForJs('photo', 'mark_featured');
        OW::getLanguage()->addKeyForJs('photo', 'remove_from_featured');
        $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'fbResponder' => OW::getRouter()->urlForRoute('photo.floatbox'));
        $script = '$("div.ow_photo_list_item_thumb a").on("click", function(e){
            e.preventDefault();
            var photo_id = $(this).attr("rel");

            if ( !window.photoViewObj ) {
                window.photoViewObj = new photoView(' . json_encode($objParams) . ');
            }
            
            window.photoViewObj.setId(photo_id);
        });
        
        $(window).bind( "hashchange", function(e) {
            var photo_id = $.bbq.getState("view-photo");
            if ( photo_id != undefined )
            {
                if ( window.photoFBLoading ) { return; }
                window.photoViewObj.showPhotoCmp(photo_id);
            }
        });';
        OW::getDocument()->addOnloadScript($script);
        OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbum', array('displayName' => $displayName, 'albumName' => $album->name)));
        OW::getDocument()->setDescription($lang->text('photo', 'meta_description_photo_useralbum', array('displayName' => $displayName, 'number' => $total)));
    }
Example #18
0
 public function index($params)
 {
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('blogs', 'view');
         throw new AuthorizationException($status['msg']);
         return;
     }
     /*
      @var $service PostService
     */
     $service = PostService::getInstance();
     /*
      @var $userService BOL_UserService
     */
     $userService = BOL_UserService::getInstance();
     /*
      @var $author BOL_User
     */
     if (!empty($params['user'])) {
         $author = $userService->findByUsername($params['user']);
     } else {
         $author = $userService->findUserById(OW::getUser()->getId());
     }
     if (empty($author)) {
         throw new Redirect404Exception();
         return;
     }
     /* Check privacy permissions */
     $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => OW::getUser()->getId());
     OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     /* */
     $displaySocialSharing = true;
     try {
         $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => 0);
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $ex) {
         $displaySocialSharing = false;
     }
     if ($displaySocialSharing && !BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser(0, 'blogs', 'view')) {
         $displaySocialSharing = false;
     }
     $this->assign('display_social_sharing', $displaySocialSharing);
     $displayName = $userService->getDisplayName($author->getId());
     $this->assign('author', $author);
     $this->assign('username', $author->getUsername());
     $this->assign('displayname', $displayName);
     $this->setPageHeading(OW::getLanguage()->text('blogs', 'user_blog_page_heading', array('name' => $author->getUsername())));
     $this->setPageHeadingIconClass('ow_ic_write');
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page');
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     if (!empty($_GET['month'])) {
         $archive_params = htmlspecialchars($_GET['month']);
         $arr = explode('-', $archive_params);
         $month = $arr[0];
         $year = $arr[1];
         $lb = mktime(null, null, null, $month, 1, $year);
         $ub = mktime(null, null, null, $month + 1, null, $year);
         $list = $service->findUserPostListByPeriod($author->getId(), $lb, $ub, $first, $count);
         $itemsCount = $service->countUserPostByPeriod($author->getId(), $lb, $ub);
         $l = OW::getLanguage();
         $arciveHeaderPart = ', ' . $l->text('base', "month_{$month}") . " {$year} " . $l->text('base', 'archive');
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_archive_title', array('month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_archive_description', array('year' => $year, 'month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName)));
     } else {
         $list = $service->findUserPostList($author->getId(), $first, $count);
         $itemsCount = $service->countUserPost($author->getId());
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_title', array('display_name' => $displayName)));
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_description', array('display_name' => $displayName)));
     }
     $this->assign('archiveHeaderPart', !empty($arciveHeaderPart) ? $arciveHeaderPart : '');
     $posts = array();
     $commentInfo = array();
     $idList = array();
     foreach ($list as $dto) {
         $idList[] = $dto->getId();
         $dto_post = BASE_CMP_TextFormatter::fromBBtoHtml($dto->getPost());
         $dto->setPost($dto_post);
         $parts = explode('<!--more-->', $dto->getPost());
         if (!empty($parts)) {
             $text = $parts[0];
             //$text = UTIL_HtmlTag::sanitize($text);
         } else {
             $text = $dto->getPost();
         }
         $posts[] = array('id' => $dto->getId(), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())), 'title' => UTIL_String::truncate($dto->getTitle(), 65, '...'), 'text' => $text, 'truncated' => count($parts) > 1 ? true : false);
     }
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $idList);
         $this->assign('commentInfo', $commentInfo);
         $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('blog-post', $idList);
         $this->assign('tagsInfo', $tagsInfo);
         $tb = array();
         foreach ($list as $dto) {
             $tb[$dto->getId()] = array(array('label' => UTIL_DateTime::formatDate($dto->timestamp)));
             //if ( $commentInfo[$dto->getId()] )
             //{
             $tb[$dto->getId()][] = array('href' => OW::getRouter()->urlForRoute('post', array('id' => $dto->getId())), 'label' => '<span class="ow_outline">' . $commentInfo[$dto->getId()] . '</span> ' . OW::getLanguage()->text('blogs', 'toolbar_comments'));
             //}
             if ($tagsInfo[$dto->getId()]) {
                 $tags =& $tagsInfo[$dto->getId()];
                 $t = OW::getLanguage()->text('blogs', 'tags');
                 for ($i = 0; $i < (count($tags) > 3 ? 3 : count($tags)); $i++) {
                     $t .= " <a href=\"" . OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')) . "?tag={$tags[$i]}\">{$tags[$i]}</a>" . ($i != 2 ? ',' : '');
                 }
                 $tb[$dto->getId()][] = array('label' => mb_substr($t, 0, mb_strlen($t) - 1));
             }
         }
         $this->assign('tb', $tb);
     }
     $this->assign('list', $posts);
     $info = array('lastPost' => $service->findUserLastPost($author->getId()), 'author' => $author);
     $this->assign('info', $info);
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->assign('paging', $paging->render());
     $rows = $service->findUserArchiveData($author->getId());
     $archive = array();
     foreach ($rows as $row) {
         if (!array_key_exists($row['y'], $archive)) {
             $archive[$row['y']] = array();
         }
         $archive[$row['y']][] = $row['m'];
     }
     $this->assign('archive', $archive);
     $this->assign('my_drafts_url', OW::getRouter()->urlForRoute('blog-manage-drafts'));
     if (OW::getUser()->isAuthenticated()) {
         $isOwner = $params['user'] == OW::getUser()->getUserObject()->getUsername() ? true : false;
     } else {
         $isOwner = false;
     }
     $this->assign('isOwner', $isOwner);
 }
Example #19
0
 public function index()
 {
     if (!OW::getUser()->isAuthorized('links', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $this->assign('addNew_isAuthorized', OW::getUser()->isAuthenticated() && OW::getUser()->isAuthorized('links', 'add'));
     switch (OW::getConfig()->getValue('links', 'result_mode')) {
         case LinkService::RESULT_MODE_SUM:
             $this->assign('mode', 'sum');
             break;
         case LinkService::RESULT_MODE_DETAILED:
             $this->assign('mode', 'detailed');
             break;
     }
     $this->setPageHeading(OW::getLanguage()->text('links', 'list_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_link');
     $plugin = OW::getPluginManager()->getPlugin('links');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $plugin->getKey(), 'main_menu_item');
     if (false === strstr($_SERVER['REQUEST_URI'], 'browse-by-tag')) {
         $isBrowseByTagCase = false;
     } else {
         $this->assign('tag', empty($_GET['tag']) ? '' : strip_tags($_GET['tag']));
         $isBrowseByTagCase = true;
     }
     $this->assign('isBrowseByTagCase', $isBrowseByTagCase);
     $tagCloud = new BASE_CMP_EntityTagCloud('link', OW::getRouter()->urlForRoute('links-by-tag'));
     if ($isBrowseByTagCase) {
         $tagCloud->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'big_tag_cloud.html');
     }
     $this->addComponent('tagCloud', $tagCloud);
     $tagSearch = new BASE_CMP_TagSearch(OW::getRouter()->urlForRoute('links-by-tag'));
     $this->addComponent('tagSearch', $tagSearch);
     //~~
     $menu = new BASE_CMP_ContentMenu($this->getMenuItems());
     $this->assign('menu', $menu->render());
     $service = LinkService::getInstance();
     $rpp = (int) OW::getConfig()->getValue('links', 'results_per_page');
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1;
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     $list = array();
     $itemsCount = 0;
     list($list, $itemsCount) = $this->getData($first, $count);
     $descLength = 120;
     //$this->assign('descLength', $descLength);
     $titleLength = 50;
     $this->assign('titleLength', $titleLength);
     $voteService = BOL_VoteService::getInstance();
     $idList = array();
     $links = array();
     $voteTotall = array();
     $authorIdList = array();
     $commentTotall = array();
     foreach ($list as $item) {
         $link = $item['dto'];
         $link->setUrl(strip_tags($link->getUrl()));
         $link->setTitle(strip_tags($link->getTitle()));
         $description = BASE_CMP_TextFormatter::fromBBtoHtml($link->getDescription());
         $description = strip_tags($description);
         if (strlen($description) > $descLength) {
             $description = UTIL_String::truncate($description, $descLength, '...');
             $description .= ' <a href="' . OW::getRouter()->urlForRoute('link', array('id' => $link->getId())) . '" class="ow_lbutton">' . OW::getLanguage()->text('base', 'more') . '</a>';
         }
         $link->setDescription($description);
         $links[$link->getId()] = array('dto' => $link);
         $idList[] = $link->getId();
         $authorIdList[] = $link->getUserId();
     }
     $ulist = BOL_UserService::getInstance()->getUserNamesForList($authorIdList);
     $nlist = BOL_UserService::getInstance()->getDisplayNamesForList($authorIdList);
     $this->assign('usernameList', $ulist);
     $this->assign('nameList', $nlist);
     if (!empty($idList)) {
         $commentTotall = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $voteTotall = $voteService->findTotalVotesResultForList($idList, 'link');
         $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('link', $idList);
         $this->assign('tagsInfo', $tagsInfo);
         $toolbars = array();
         foreach ($list as $item) {
             $dto = $item['dto'];
             $toolbars[$dto->id] = array();
             $userId = $dto->userId;
             $toolbars[$dto->id][] = array('class' => ' ow_icon_control ow_ic_user', 'label' => !empty($nlist[$userId]) ? $nlist[$userId] : OW::getLanguage()->text('base', 'deleted_user'), 'href' => !empty($ulist[$userId]) ? BOL_UserService::getInstance()->getUserUrlForUsername($ulist[$userId]) : '#');
             $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)), 'label' => UTIL_DateTime::formatDate($dto->timestamp));
             if ($commentTotall[$dto->id]) {
                 $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)) . "#comments", 'label' => '<span class="ow_txt_value">' . $commentTotall[$dto->id] . '</span> ' . OW::getLanguage()->text('links', 'toolbar_comments'));
             }
             if (empty($tagsInfo[$dto->id])) {
                 continue;
             }
             $value = OW::getLanguage()->text('links', 'tags') . ' ';
             $c = 0;
             foreach ($tagsInfo[$dto->id] as $tag) {
                 if ($c == 3) {
                     break;
                 }
                 $value .= '<a href="' . OW::getRouter()->urlForRoute('links-by-tag') . "?tag={$tag}" . "\">{$tag}</a>, ";
                 $c++;
             }
             $value = mb_substr($value, 0, mb_strlen($value) - 2);
             $toolbars[$dto->id][] = array('label' => $value);
         }
         if (OW::getUser()->isAuthenticated()) {
             $userVotes = $voteService->findUserVoteForList($idList, 'link', OW::getUser()->getId());
             $this->assign('userVotes', $userVotes);
         }
         $this->assign('tb', $toolbars);
     }
     foreach ($voteTotall as $val) {
         $links[$val['id']]['isVoted'] = true;
         $links[$val['id']]['voteTotal'] = $val['sum'];
         $links[$val['id']]['up'] = $val['up'];
         $links[$val['id']]['down'] = $val['down'];
     }
     $this->assign('commentTotall', $commentTotall);
     $this->assign('list', $links);
     $this->assign('url_new_link', OW::getRouter()->urlForRoute('link-save-new'));
     $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);
     $this->assign('paging', $paging->render());
     $this->assign('isAuthenticated', OW::getUser()->isAuthenticated());
 }
Example #20
0
 public function index()
 {
     $languageService = BOL_LanguageService::getInstance();
     if (empty($_GET['language'])) {
         $language = $languageService->getCurrent();
     } else {
         $language = $languageService->findByTag($_GET['language']);
     }
     $this->assign('label', $language->getLabel());
     $this->assign('tag', $language->getTag());
     $current = $languageService->getCurrent();
     $this->assign('origLabel', $current->getLabel());
     $this->assign('origTag', $current->getTag());
     $this->assign('languageSwitchUrl', OW::getRequest()->buildUrlQueryString(null, array('language' => null)));
     $this->assign('lang_switch_url', OW::getRequest()->buildUrlQueryString(null, array('langId' => null, 'page' => null)));
     $this->assign('section_switch_url', OW::getRequest()->buildUrlQueryString(null, array('prefix' => null, 'page' => null)));
     $this->assign('searchFormActionUrl', OW::getRequest()->buildUrlQueryString(null, array('prefix' => !empty($_GET['prefix']) ? $_GET['prefix'] : null, 'language' => !empty($_GET['language']) ? $_GET['language'] : null, 'search' => null, 'page' => null, 'in_keys' => null)));
     $this->assign('langs', $languageService->getLanguages());
     $this->assign('language', $language);
     if (isset($_POST['command']) && $_POST['command'] == 'edit-values') {
         $arr = empty($_POST['values']) ? array() : $_POST['values'];
         foreach ($arr as $key => $value) {
             if (strlen($value) < 1) {
                 continue;
             }
             /* @var $entity BOL_LanguageValue */
             $entity = $languageService->findValue($language->getId(), $key);
             $entity->setValue($value);
             $languageService->saveValue($entity, false);
         }
         $arr = empty($_POST['missing']) ? array() : $_POST['missing'];
         foreach ($arr as $prefixStr => $value) {
             foreach ($value as $key2 => $value2) {
                 if (strlen(trim($value2)) == 0) {
                     continue;
                 }
                 $keyDto = $languageService->findKey($prefixStr, $key2);
                 $dto = new BOL_LanguageValue();
                 $dto->setLanguageId($language->getId())->setValue($value2)->setKeyId($keyDto->getId());
                 $languageService->saveValue($dto, false);
             }
         }
         $languageService->generateCache($language->getId());
         OW::getFeedback()->info(OW::getLanguage()->text('admin', 'languages_values_updated'));
         $this->redirect();
     }
     $this->assign('prefixes', $languageService->getPrefixList());
     $this->assign('current_prefix', empty($_GET['prefix']) ? '' : $_GET['prefix']);
     $this->assign('current_search', isset($_GET['search']) && strlen($_GET['search']) ? $_GET['search'] : 'Search..');
     $this->assign('isSearchResults', empty($_GET['search']) ? false : true);
     $page = empty($_GET['page']) ? 1 : $_GET['page'];
     $rpp = 20;
     $first = ($page - 1) * $rpp;
     $count = $rpp;
     if (isset($_GET['search']) && strlen($_GET['search'])) {
         $search = $_GET['search'];
         if (!empty($_GET['in_keys'])) {
             $this->assign('searchInKeys', 'y');
             $list = $this->getReordered($languageService->findKeySearchResultKeyList($language->getId(), $first, $count, $search), $language->getId());
             $item_count = $languageService->countKeySearchResultKeys($language->getId(), $search);
         } else {
             $list = $this->getReordered($languageService->findSearchResultKeyList($language->getId(), $first, $count, $search), $language->getId());
             $item_count = $languageService->countSearchResultKeys($language->getId(), $search);
         }
     } elseif (!empty($_GET['prefix'])) {
         $prefix = $_GET['prefix'];
         switch ($prefix) {
             case 'missing-text':
                 $list = $this->getReordered($languageService->findMissingKeys($language->getId(), $first, $count), $language->getId());
                 $item_count = $languageService->findMissingKeyCount($language->getId());
                 break;
             case 'all':
                 $list = $this->getReordered($languageService->findLastKeyList($first, $count), $language->getId());
                 $item_count = $languageService->countAllKeys();
                 break;
             default:
                 $list = $this->getReordered($languageService->findLastKeyList($first, $count, $prefix), $language->getId());
                 $item_count = $languageService->countKeyByPrefix($prefix);
                 break;
         }
     } else {
         $list = $this->getReordered($languageService->findLastKeyList($first, $count), $language->getId());
         $item_count = $languageService->countAllKeys();
     }
     $pages = ceil($item_count / 20);
     $paging = new BASE_CMP_Paging($page, $pages, 5);
     $this->assign('paging', $paging->render());
     //~~
     $this->assign('list', $list);
     $prefixes = $languageService->getPrefixList();
     $this->assign('prefixes', $prefixes);
     $this->addForm(new AddKeyForm($prefixes, $language, $this->isDevMode()));
 }
Example #21
0
 public function log()
 {
     $service = OCSAFFILIATES_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     if (!$service->checkAccess()) {
         $this->redirect(OW::getRouter()->urlForRoute('ocsaffiliates.home'));
     }
     $affiliateId = $service->getAffiliateId();
     $menu = $this->getMenu('log');
     $this->addComponent('menu', $menu);
     $limit = 20;
     $page = !empty($_GET['page']) ? abs((int) $_GET['page']) : 1;
     $offset = ($page - 1) * $limit;
     $log = $service->getAffiliateEventsLog($affiliateId, $offset, $limit);
     $this->assign('log', $log);
     $total = $service->countAffiliateEventsLog($affiliateId);
     // Paging
     $pages = (int) ceil($total / $limit);
     $paging = new BASE_CMP_Paging($page, $pages, $limit);
     $this->assign('paging', $paging->render());
     $billingService = BOL_BillingService::getInstance();
     $this->assign('currency', $billingService->getActiveCurrency());
     $this->setPageHeading($lang->text('ocsaffiliates', 'affiliate_area'));
     $service->updateAffiliateActivity($affiliateId);
     // TODO: remove this code when a sale event is available
     $service->processUntrackedSales();
 }