Exemple #1
0
 public function onConsolePagesCollect(BASE_CLASS_EventCollector $event)
 {
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'underscore-min.js', 'text/javascript', 3000);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'backbone-min.js', 'text/javascript', 3000);
     //        OW::getDocument()->addScript( OW::getPluginManager()->getPlugin('base')->getStaticJsUrl().'backbone.js', 'text/javascript', 3000 );
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('mailbox')->getStaticJsUrl() . 'mobile_mailbox.js', 'text/javascript', 3000);
     $userListUrl = OW::getRouter()->urlForRoute('mailbox_user_list');
     $convListUrl = OW::getRouter()->urlForRoute('mailbox_conv_list');
     $authorizationResponderUrl = OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'authorization');
     $pingResponderUrl = OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'ping');
     $getHistoryResponderUrl = OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'getHistory');
     $userId = OW::getUser()->getId();
     $displayName = BOL_UserService::getInstance()->getDisplayName($userId);
     $avatarUrl = BOL_AvatarService::getInstance()->getAvatarUrl($userId);
     if (empty($avatarUrl)) {
         $avatarUrl = BOL_AvatarService::getInstance()->getDefaultAvatarUrl();
     }
     $profileUrl = BOL_UserService::getInstance()->getUserUrl($userId);
     $lastSentMessage = MAILBOX_BOL_ConversationService::getInstance()->getLastSentMessage($userId);
     $lastMessageTimestamp = (int) ($lastSentMessage ? $lastSentMessage->timeStamp : 0);
     $params = array('getHistoryResponderUrl' => $getHistoryResponderUrl, 'pingResponderUrl' => $pingResponderUrl, 'authorizationResponderUrl' => $authorizationResponderUrl, 'userListUrl' => $userListUrl, 'convListUrl' => $convListUrl, 'pingInterval' => 5000, 'lastMessageTimestamp' => $lastMessageTimestamp, 'user' => array('userId' => $userId, 'displayName' => $displayName, 'profileUrl' => $profileUrl, 'avatarUrl' => $avatarUrl));
     $js = UTIL_JsGenerator::composeJsString('OWM.Mailbox = new MAILBOX_Mobile({$params});', array('params' => $params));
     OW::getDocument()->addOnloadScript($js, 'text/javascript', 3000);
     $event->add(array('key' => 'convers', 'cmpClass' => 'MAILBOX_MCMP_ConsoleConversationsPage', 'order' => 2));
 }
Exemple #2
0
 public function staticDocument($params)
 {
     $navService = BOL_NavigationService::getInstance();
     if (empty($params['documentKey'])) {
         throw new Redirect404Exception();
     }
     $language = OW::getLanguage();
     $documentKey = $params['documentKey'];
     $document = $navService->findDocumentByKey($documentKey);
     if ($document === null) {
         throw new Redirect404Exception();
     }
     $menuItem = $navService->findMenuItemByDocumentKey($document->getKey());
     if ($menuItem !== null) {
         if (!$menuItem->getVisibleFor() || $menuItem->getVisibleFor() == BOL_NavigationService::VISIBLE_FOR_GUEST && OW::getUser()->isAuthenticated()) {
             throw new Redirect403Exception();
         }
         if ($menuItem->getVisibleFor() == BOL_NavigationService::VISIBLE_FOR_MEMBER && !OW::getUser()->isAuthenticated()) {
             throw new AuthenticateException();
         }
     }
     $settings = BOL_MobileNavigationService::getInstance()->getItemSettings($menuItem);
     $title = $settings[BOL_MobileNavigationService::SETTING_TITLE];
     $this->assign('content', $settings[BOL_MobileNavigationService::SETTING_CONTENT]);
     $this->setPageHeading($settings[BOL_MobileNavigationService::SETTING_TITLE]);
     $this->setPageTitle($settings[BOL_MobileNavigationService::SETTING_TITLE]);
     $this->setDocumentKey($document->getKey());
     //OW::getEventManager()->bind(OW_EventManager::ON_BEFORE_DOCUMENT_RENDER, array($this, 'setCustomMetaInfo'));
 }
Exemple #3
0
 public function getMenu()
 {
     $language = OW::getLanguage();
     $menu = new BASE_CMP_ContentMenu();
     $menuItem = new BASE_MenuItem();
     $menuItem->setKey('all');
     $menuItem->setPrefix('questions');
     $menuItem->setLabel($language->text('equestions', 'list_all_tab'));
     $menuItem->setOrder(1);
     $menuItem->setUrl(OW::getRouter()->urlForRoute('equestions-all'));
     $menuItem->setIconClass('ow_ic_lens');
     $menu->addElement($menuItem);
     if (OW::getUser()->isAuthenticated()) {
         if (OW::getPluginManager()->isPluginActive('friends')) {
             $menuItem = new BASE_MenuItem();
             $menuItem->setKey('friends');
             $menuItem->setPrefix('questions');
             $menuItem->setLabel($language->text('equestions', 'list_friends_tab'));
             $menuItem->setOrder(2);
             $menuItem->setUrl(OW::getRouter()->urlForRoute('equestions-friends'));
             $menuItem->setIconClass('ow_ic_user');
             $menu->addElement($menuItem);
         }
         $menuItem = new BASE_MenuItem();
         $menuItem->setKey('my');
         $menuItem->setPrefix('questions');
         $menuItem->setLabel($language->text('equestions', 'list_my_tab'));
         $menuItem->setOrder(3);
         $menuItem->setUrl(OW::getRouter()->urlForRoute('equestions-my'));
         $menuItem->setIconClass('ow_ic_user');
         $menu->addElement($menuItem);
     }
     return $menu;
 }
 public function __construct($params)
 {
     parent::__construct();
     $this->visiblePhotoCount = !empty($params['photoCount']) ? (int) $params['photoCount'] : 8;
     $checkAuth = isset($params['checkAuth']) ? (bool) $params['checkAuth'] : true;
     $wrap = isset($params['wrapBox']) ? (bool) $params['wrapBox'] : true;
     $boxType = isset($params['boxType']) ? $params['boxType'] : '';
     $showTitle = isset($params['showTitle']) ? (bool) $params['showTitle'] : true;
     $uniqId = isset($params['uniqId']) ? $params['uniqId'] : uniqid();
     if ($checkAuth && !OW::getUser()->isAuthorized('photo', 'view')) {
         $this->setVisible(false);
         return;
     }
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $latest = $photoService->findPhotoList('latest', 1, $this->visiblePhotoCount, NULL, PHOTO_BOL_PhotoService::TYPE_PREVIEW);
     $this->assign('latest', $latest);
     $featured = $photoService->findPhotoList('featured', 1, $this->visiblePhotoCount, NULL, PHOTO_BOL_PhotoService::TYPE_PREVIEW);
     $this->assign('featured', $featured);
     $toprated = $photoService->findPhotoList('toprated', 1, $this->visiblePhotoCount, NULL, PHOTO_BOL_PhotoService::TYPE_PREVIEW);
     $this->assign('toprated', $toprated);
     $items = array('latest', 'toprated');
     if ($featured) {
         $items[] = 'featured';
     }
     $menuItems = $this->getMenuItems($items, $uniqId);
     $this->assign('items', $menuItems);
     $this->assign('wrapBox', $wrap);
     $this->assign('boxType', $boxType);
     $this->assign('showTitle', $showTitle);
     $this->assign('url', OW::getEventManager()->call('photo.getAddPhotoURL', array('')));
     $this->assign('uniqId', $uniqId);
     $this->setTemplate(OW::getPluginManager()->getPlugin('photo')->getMobileCmpViewDir() . 'index_photo_list.html');
 }
Exemple #5
0
 public function render()
 {
     $defaultAvatarUrl = BOL_AvatarService::getInstance()->getDefaultAvatarUrl();
     $this->assign('defaultAvatarUrl', $defaultAvatarUrl);
     $js = "OW.Mailbox.conversationController = new MAILBOX_ConversationView();";
     OW::getDocument()->addOnloadScript($js, 3006);
     //TODO check this config
     $enableAttachments = OW::getConfig()->getValue('mailbox', 'enable_attachments');
     $this->assign('enableAttachments', $enableAttachments);
     $replyToMessageActionPromotedText = '';
     $isAuthorizedReplyToMessage = OW::getUser()->isAuthorized('mailbox', 'reply_to_message');
     $isAuthorizedReplyToMessage = $isAuthorizedReplyToMessage || OW::getUser()->isAuthorized('mailbox', 'send_chat_message');
     if (!$isAuthorizedReplyToMessage) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', 'reply_to_message');
         if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
             $replyToMessageActionPromotedText = $status['msg'];
         }
     }
     $this->assign('isAuthorizedReplyToMessage', $isAuthorizedReplyToMessage);
     $isAuthorizedReplyToChatMessage = OW::getUser()->isAuthorized('mailbox', 'reply_to_chat_message');
     if (!$isAuthorizedReplyToChatMessage) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', 'reply_to_chat_message');
         if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
             $replyToMessageActionPromotedText = $status['msg'];
         }
     }
     $this->assign('isAuthorizedReplyToChatMessage', $isAuthorizedReplyToChatMessage);
     $this->assign('replyToMessageActionPromotedText', $replyToMessageActionPromotedText);
     if ($isAuthorizedReplyToMessage) {
         $text = new WysiwygTextarea('mailbox_message');
         $text->setId('conversationTextarea');
         $this->assign('mailbox_message', $text->renderInput());
     }
     return parent::render();
 }
Exemple #6
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     if (!OW::getUser()->isAdmin()) {
         throw new AuthenticateException();
     }
     if (!OW::getRequest()->isAjax()) {
         $document = OW::getDocument();
         $document->setMasterPage(new ADMIN_CLASS_MasterPage());
         $this->setPageTitle(OW::getLanguage()->text('admin', 'page_default_title'));
     }
     BOL_PluginService::getInstance()->checkManualUpdates();
     $plugin = BOL_PluginService::getInstance()->findNextManualUpdatePlugin();
     $handlerParams = OW::getRequestHandler()->getHandlerAttributes();
     // TODO refactor shortcut below
     if (!defined('OW_PLUGIN_XP') && $plugin !== null) {
         if ($handlerParams['controller'] === 'ADMIN_CTRL_Plugins' && $handlerParams['action'] === 'manualUpdateRequest') {
             //action
         } else {
             throw new RedirectException(OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'manualUpdateRequest', array('key' => $plugin->getKey())));
         }
     }
     // TODO temp admin pge inform event
     function admin_check_if_admin_page()
     {
         return true;
     }
     OW::getEventManager()->bind('admin.check_if_admin_page', 'admin_check_if_admin_page');
 }
Exemple #7
0
 /**
  * @return Constructor.
  */
 public function __construct($groupId)
 {
     parent::__construct();
     $service = GROUPS_BOL_Service::getInstance();
     $groupDto = $service->findGroupById($groupId);
     $group = array('title' => htmlspecialchars($groupDto->title), 'description' => $groupDto->description, 'time' => $groupDto->timeStamp, 'imgUrl' => empty($groupDto->imageHash) ? false : $service->getGroupImageUrl($groupDto), 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $groupDto->id)), "id" => $groupDto->id);
     $imageUrl = empty($groupDto->imageHash) ? '' : $service->getGroupImageUrl($groupDto);
     OW::getDocument()->addMetaInfo('image', $imageUrl, 'itemprop');
     OW::getDocument()->addMetaInfo('og:image', $imageUrl, 'property');
     $createDate = UTIL_DateTime::formatDate($groupDto->timeStamp);
     $adminName = BOL_UserService::getInstance()->getDisplayName($groupDto->userId);
     $adminUrl = BOL_UserService::getInstance()->getUserUrl($groupDto->userId);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#groups_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "groups+flags", {$ownerId});', array('entity' => GROUPS_BOL_Service::WIDGET_PANEL_NAME, 'id' => $groupDto->id, 'title' => $group['title'], 'href' => $group['url'], 'ownerId' => $groupDto->userId)));
     OW::getDocument()->addOnloadScript($js, 1001);
     $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_create_date', array('date' => $createDate))), array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_admin', array('name' => $adminName, 'url' => $adminUrl))));
     if ($service->isCurrentUserCanEdit($groupDto)) {
         $toolbar[] = array('label' => OW::getLanguage()->text('groups', 'edit_btn_label'), 'href' => OW::getRouter()->urlForRoute('groups-edit', array('groupId' => $groupId)));
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $groupDto->userId) {
         $toolbar[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'groups_toolbar_flag');
     }
     $event = new BASE_CLASS_EventCollector('groups.on_toolbar_collect', array('groupId' => $groupId));
     OW::getEventManager()->trigger($event);
     foreach ($event->getData() as $item) {
         $toolbar[] = $item;
     }
     $this->assign('toolbar', $toolbar);
     $this->assign('group', $group);
 }
Exemple #8
0
 public function beforeContentAdd(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if (!empty($data)) {
         return;
     }
     if (empty($params["status"]) && empty($params["data"])) {
         $event->setData(false);
         return;
     }
     $attachId = null;
     $content = array();
     if (!empty($params["data"])) {
         $content = $params["data"];
         if ($content['type'] == 'photo' && !empty($content['genId'])) {
             $content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId']));
             $attachId = $content['genId'];
         }
         if ($content['type'] == 'video') {
             $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
         }
     }
     $status = UTIL_HtmlTag::autoLink($params["status"]);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $params['feedType'], $params['feedId'], $params['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     $event->setData($out);
 }
Exemple #9
0
 /**
  * @return Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct($paramObj);
     $userId = $paramObj->additionalParamList['entityId'];
     // privacy check
     $viewerId = OW::getUser()->getId();
     $ownerMode = $userId == $viewerId;
     $modPermissions = OW::getUser()->isAuthorized('newsfeed');
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => NEWSFEED_BOL_Service::PRIVACY_ACTION_VIEW_MY_FEED, 'ownerId' => $userId, 'viewerId' => $viewerId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         try {
             OW::getEventManager()->trigger($event);
         } catch (RedirectException $e) {
             $this->setVisible(false);
             return;
         }
     }
     $feed = $this->createFeed('user', $userId);
     $isBloacked = BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId);
     if (OW::getUser()->isAuthenticated() && OW::getUser()->isAuthorized('base', 'add_comment')) {
         if ($isBloacked) {
             $feed->addStatusMessage(OW::getLanguage()->text("base", "user_block_message"));
         } else {
             $visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
             $feed->addStatusForm('user', $userId, $visibility);
         }
     }
     $feed->setDisplayType(NEWSFEED_CMP_Feed::DISPLAY_TYPE_ACTIVITY);
     $this->setFeed($feed);
 }
Exemple #10
0
 public function getData(BASE_CLASS_WidgetParameter $params)
 {
     $count = (int) $params->customParamList['count'];
     $userId = OW::getUser()->getId();
     $service = OCSFAVORITES_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $router = OW::getRouter();
     $multiple = OW::getConfig()->getValue('ocsfavorites', 'can_view') && OW::getUser()->isAuthorized('ocsfavorites', 'view_users');
     $toolbar = array();
     $lists = array();
     $resultList = array();
     $toolbar['my'] = array('label' => $lang->text('base', 'view_all'), 'href' => $router->urlForRoute('ocsfavorites.list'));
     $lists['my'] = $service->findFavoritesForUser($userId, 1, $count);
     if ($multiple) {
         $toolbar['me'] = array('label' => $lang->text('base', 'view_all'), 'href' => $router->urlForRoute('ocsfavorites.added_list'));
         $lists['me'] = $service->findUsersWhoAddedUserAsFavorite($userId, 1, $count);
         $toolbar['mutual'] = array('label' => $lang->text('base', 'view_all'), 'href' => $router->urlForRoute('ocsfavorites.mutual_list'));
         $lists['mutual'] = $service->findMutualFavorites($userId, 1, $count);
     }
     $this->setSettingValue(self::SETTING_TOOLBAR, array($toolbar['my']));
     $resultList['my'] = array('menu-label' => $lang->text('ocsfavorites', 'my'), 'menu_active' => true, 'userIds' => $this->getIds($lists['my'], 'favoriteId'), 'toolbar' => array($toolbar['my']));
     if ($multiple) {
         if ($lists['me']) {
             $resultList['me'] = array('menu-label' => $lang->text('ocsfavorites', 'who_added_me'), 'userIds' => $this->getIds($lists['me'], 'userId'), 'toolbar' => array($toolbar['me']));
         }
         if ($lists['mutual']) {
             $resultList['mutual'] = array('menu-label' => $lang->text('ocsfavorites', 'mutual'), 'userIds' => $this->getIds($lists['mutual'], 'userId'), 'toolbar' => array($toolbar['mutual']));
         }
     }
     return $resultList;
 }
Exemple #11
0
 public function profile($paramList)
 {
     $userService = BOL_UserService::getInstance();
     /* @var $userDao BOL_User */
     $userDto = $userService->findByUsername($paramList['username']);
     if ($userDto === null) {
         throw new Redirect404Exception();
     }
     if (!OW::getUser()->isAuthorized('base', 'view_profile')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('base', 'view_profile');
         $this->assign('permissionMessage', $status['msg']);
         return;
     }
     $eventParams = array('action' => 'base_view_profile', 'ownerId' => $userDto->id, 'viewerId' => OW::getUser()->getId());
     $displayName = BOL_UserService::getInstance()->getDisplayName($userDto->id);
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $ex) {
         throw new RedirectException(OW::getRouter()->urlForRoute('base_user_privacy_no_permission', array('username' => $displayName)));
     }
     $this->setPageTitle(OW::getLanguage()->text('base', 'profile_view_title', array('username' => $displayName)));
     $this->setPageHeading(OW::getLanguage()->text('base', 'profile_view_heading', array('username' => $displayName)));
     $this->setPageHeadingIconClass('ow_ic_user');
     $profileHeader = OW::getClassInstance("BASE_MCMP_ProfileHeader", $userDto->id);
     $this->addComponent("header", $profileHeader);
     //Profile Info
     $displayNameQuestion = OW::getConfig()->getValue('base', 'display_name_question');
     $profileInfo = OW::getClassInstance("BASE_MCMP_ProfileInfo", $userDto->id, false, array($displayNameQuestion, "birthdate"));
     $this->addComponent("info", $profileInfo);
     $this->addComponent('contentMenu', OW::getClassInstance("BASE_MCMP_ProfileContentMenu", $userDto->id));
     $this->addComponent('about', OW::getClassInstance("BASE_MCMP_ProfileAbout", $userDto->id, 80));
     $place = BOL_MobileWidgetService::PLACE_MOBILE_PROFILE;
     $this->initDragAndDrop($place, $userDto->id);
 }
 /**
  * Class constructor
  */
 public function __construct($typeId)
 {
     parent::__construct();
     if (!OW::getUser()->isAdmin()) {
         $this->setVisible(false);
         return;
     }
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $type = $service->findTypeById($typeId);
     if (!$type) {
         $this->setVisible(false);
         return;
     }
     $types = $service->getTypeList($type->accountTypeId);
     $availableTypes = array();
     if ($types) {
         foreach ($types as $mType) {
             if ($mType->id == $typeId) {
                 continue;
             }
             $availableTypes[$mType->id] = $service->getMembershipTitle($mType->roleId);
         }
     }
     $this->assign('availableTypes', $availableTypes);
     $form = new MEMBERSHIP_CLASS_DeleteMembershipForm();
     $this->addForm($form);
     $form->getElement('typeId')->setValue($typeId);
     if ($availableTypes) {
         $form->getElement('newTypeId')->addOptions($availableTypes);
     }
 }
Exemple #13
0
 public function updateRate()
 {
     if (empty($_POST['entityId']) || empty($_POST['entityType']) || empty($_POST['rate']) || empty($_POST['ownerId'])) {
         exit(json_encode(array('errorMessage' => 'Invalid request')));
     }
     $service = BOL_RateService::getInstance();
     $entityId = (int) $_POST['entityId'];
     $entityType = trim($_POST['entityType']);
     $rate = (int) $_POST['rate'];
     $ownerId = (int) $_POST['ownerId'];
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated()) {
         exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'rate_cmp_auth_error_message'))));
     }
     if ($userId === $ownerId) {
         exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'rate_cmp_owner_cant_rate_error_message'))));
     }
     if (false) {
         //TODO add authorization error
         exit(json_encode(array('errorMessage' => 'Auth error')));
     }
     if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $ownerId)) {
         exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'user_block_message'))));
     }
     $rateItem = $service->findRate($entityId, $entityType, $userId);
     if ($rateItem === null) {
         $rateItem = new BOL_Rate();
         $rateItem->setEntityId($entityId)->setEntityType($entityType)->setUserId($userId)->setActive(true);
     }
     $rateItem->setScore($rate)->setTimeStamp(time());
     $service->saveRate($rateItem);
     $totalScoreCmp = new BASE_CMP_TotalScore($entityId, $entityType);
     exit(json_encode(array('totalScoreCmp' => $totalScoreCmp->render(), 'message' => OW::getLanguage()->text('base', 'rate_cmp_success_message'))));
 }
Exemple #14
0
 /**
  * Controller's default action
  *
  * @param array $params
  * @throws Redirect404Exception
  */
 public function index(array $params)
 {
     if (!isset($params['sectionId']) || !($sectionId = (int) $params['sectionId'])) {
         throw new Redirect404Exception();
     }
     $forumSection = $this->forumService->findSectionById($sectionId);
     if (!$forumSection || $forumSection->isHidden) {
         throw new Redirect404Exception();
     }
     $userId = OW::getUser()->getId();
     $bcItems = array(array('href' => OW::getRouter()->urlForRoute('forum-default'), 'label' => OW::getLanguage()->text('forum', 'forum_index')), array('label' => $forumSection->name));
     $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
     $this->addComponent('breadcrumb', $breadCrumbCmp);
     $sectionGroupList = $this->forumService->getSectionGroupList($userId, $sectionId);
     $authors = array();
     foreach ($sectionGroupList as $section) {
         foreach ($section['groups'] as $group) {
             if (!$group['lastReply']) {
                 continue;
             }
             $id = $group['lastReply']['userId'];
             if (!in_array($id, $authors)) {
                 array_push($authors, $id);
             }
         }
     }
     $this->assign('sectionGroupList', $sectionGroupList);
     $userNames = BOL_UserService::getInstance()->getUserNamesForList($authors);
     $this->assign('userNames', $userNames);
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($authors);
     $this->assign('displayNames', $displayNames);
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'section', 'sectionId' => $sectionId)));
     OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum'));
     OW::getDocument()->setHeadingIconClass('ow_ic_forum');
 }
    public function __construct($data)
    {
        $script = UTIL_JsGenerator::composeJsString('

        OWM.bind("mailbox.ready", function(readyStatus){
            if (readyStatus == 2){
                OWM.conversation = new MAILBOX_Conversation({$params});
                OWM.conversationView = new MAILBOX_MailConversationView({model: OWM.conversation});
            }
        });
        ', array('params' => $data));
        OW::getDocument()->addOnloadScript($script);
        OW::getLanguage()->addKeyForJs('mailbox', 'text_message_invitation');
        $form = new MAILBOX_MCLASS_NewMailMessageForm($data['conversationId'], $data['opponentId']);
        $this->addForm($form);
        $this->assign('data', $data);
        $this->assign('defaultAvatarUrl', BOL_AvatarService::getInstance()->getDefaultAvatarUrl());
        $firstMessage = MAILBOX_BOL_ConversationService::getInstance()->getFirstMessage($data['conversationId']);
        if (empty($firstMessage)) {
            $actionName = 'send_message';
        } else {
            $actionName = 'reply_to_message';
        }
        $isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName);
        if (!$isAuthorized) {
            $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
            if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
                $this->assign('sendAuthMessage', $status['msg']);
            } elseif ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
                $this->assign('sendAuthMessage', OW::getLanguage()->text('mailbox', $actionName . '_permission_denied'));
            }
        }
    }
Exemple #16
0
 /**
  * Adds new message to the conversation
  *
  * @param MAILBOX_BOL_Conversation $conversation
  * @param int $userId
  * @return boolean
  */
 public function process(MAILBOX_BOL_Conversation $conversation, $userId)
 {
     if (!isset($conversation) || empty($userId)) {
         return false;
     }
     $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message');
     if (!$isAuthorized) {
         return array('result' => false, 'error' => OW::getLanguage()->text('mailbox', 'write_permission_denied'));
     }
     $opponentId = $conversation->initiatorId == $userId ? $conversation->interlocutorId : $conversation->initiatorId;
     // credits check
     $eventParams = array('pluginKey' => 'mailbox', 'action' => 'send_message', 'extra' => array('senderId' => $userId, 'recipientId' => $opponentId));
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $error = OW::getEventManager()->call('usercredits.error_message', $eventParams);
         return array('result' => false, 'error' => $error);
     }
     $values = $this->getValues();
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $message = $conversationService->createMessage($conversation, $userId, $values['message']);
     $language = OW::getLanguage();
     OW::getFeedback()->info($language->text('mailbox', 'add_message'));
     if (isset($_FILES['attachments']) && count($_FILES['attachments'])) {
         $conversationService->addMessageAttachments($message->id, $_FILES['attachments']);
     }
     // credits track
     if ($credits === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     return array('result' => true);
 }
Exemple #17
0
 public function acceptWink($params)
 {
     $partnerId = OW::getUser()->getId();
     if (!$partnerId) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $service = WINKS_BOL_Service::getInstance();
     $userId = $params['userId'];
     /**
      * @var WINKS_BOL_Winks $wink
      */
     $wink = $service->findWinkByUserIdAndPartnerId($userId, $partnerId);
     if (empty($wink)) {
         throw new ApiResponseErrorException();
     }
     $wink->setStatus(WINKS_BOL_WinksDao::STATUS_ACCEPT);
     WINKS_BOL_WinksDao::getInstance()->save($wink);
     if (($_wink = $service->findWinkByUserIdAndPartnerId($partnerId, $userId)) !== NULL) {
         $_wink->setStatus(WINKS_BOL_WinksDao::STATUS_IGNORE);
         WINKS_BOL_WinksDao::getInstance()->save($_wink);
     }
     $params = array('userId' => $userId, 'partnerId' => $partnerId, 'content' => array('entityType' => 'wink', 'eventName' => 'renderWink', 'params' => array('winkId' => $wink->id, 'winkBackEnabled' => 1)));
     $event = new OW_Event('winks.onAcceptWink', $params);
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!empty($data['conversationId'])) {
         $wink->setConversationId($data['conversationId']);
         WINKS_BOL_WinksDao::getInstance()->save($wink);
     }
     $this->assign('result', true);
 }
Exemple #18
0
 public function getPemissions()
 {
     static $permissions = null;
     if (!empty($permissions)) {
         return $permissions;
     }
     $permissions = array('changeAvatar' => false, 'uploadPhotos' => false, 'selfMode' => false);
     $selfMode = $this->userId == OW::getUser()->getId();
     $permissions['selfMode'] = $selfMode;
     $permissions['changeSettings'] = $selfMode;
     $permissions['changeAvatar'] = $selfMode;
     $permissions['uploadPhotos'] = $selfMode;
     $permissions['viewAvatar'] = $this->avatarDto && $this->avatarDto->status == "active" || $selfMode || OW::getUser()->isAuthorized("base");
     $permissions['approveAvatar'] = OW::getUser()->isAuthorized("base");
     $permissions['view'] = $selfMode || OW::getUser()->isAuthorized("photo");
     if (!$permissions['view']) {
         $event = new OW_Event('privacy_check_permission', array('action' => "photo_view_album", 'ownerId' => $this->userId, 'viewerId' => OW::getUser()->getId()));
         try {
             OW::getEventManager()->trigger($event);
             $permissions['view'] = true;
         } catch (RedirectException $e) {
             // Pass
         }
     }
     return $permissions;
 }
Exemple #19
0
function antibruteforce_core_after_route(OW_Event $event)
{
    if (OW::getUser()->isAuthenticated()) {
        return;
    }
    $classDir = OW::getPluginManager()->getPlugin('antibruteforce')->getClassesDir();
    $handler = OW::getRequestHandler()->getHandlerAttributes();
    if (OW::getConfig()->getValue('antibruteforce', 'authentication')) {
        include_once $classDir . 'sign_in.php';
        include_once $classDir . 'auth_result.php';
    }
    if (OW::getConfig()->getValue('antibruteforce', 'registration')) {
        if ($handler[OW_RequestHandler::ATTRS_KEY_CTRL] == 'BASE_CTRL_Join' && $handler[OW_RequestHandler::ATTRS_KEY_ACTION] == 'index') {
            OW::getEventManager()->bind(OW_EventManager::ON_FINALIZE, 'antibruteforce_core_finalize');
        } else {
            if ($handler[OW_RequestHandler::ATTRS_KEY_CTRL] == 'BASE_CTRL_Captcha' && $handler[OW_RequestHandler::ATTRS_KEY_ACTION] == 'ajaxResponder') {
                include_once $classDir . 'captcha.php';
            }
        }
    }
    if ($handler[OW_RequestHandler::ATTRS_KEY_CTRL] != 'ANTIBRUTEFORCE_CTRL_Antibruteforce') {
        if (ANTIBRUTEFORCE_BOL_Service::getInstance()->isLocked()) {
            ANTIBRUTEFORCE_BOL_Service::getInstance()->redirect();
        }
    }
}
Exemple #20
0
 public function __construct($groupId)
 {
     parent::__construct();
     $cover = GHEADER_BOL_Service::getInstance()->findCoverByGroupId($groupId);
     if (empty($cover)) {
         $this->assign('error', OW::getLanguage()->text('gheader', 'cover_not_found'));
         return;
     }
     $group = GROUPS_BOL_Service::getInstance()->findGroupById($cover->groupId);
     $src = GHEADER_BOL_Service::getInstance()->getCoverUrl($cover);
     $settings = $cover->getSettings();
     $height = $settings['dimensions']['height'];
     $width = $settings['dimensions']['width'];
     $top = 0;
     if ($height < self::MIN_HEIGHT) {
         $top = (self::MIN_HEIGHT - $height) / 2;
     }
     $this->assign('src', $src);
     $this->assign('top', $top);
     $this->assign('dimensions', $settings['dimensions']);
     $userId = OW::getUser()->getId();
     $cmtParams = new BASE_CommentsParams('gheader', GHEADER_CLASS_CommentsBridge::ENTITY_TYPE);
     $cmtParams->setEntityId($cover->id);
     $cmtParams->setAddComment(GHEADER_BOL_Service::getInstance()->isUserCanInteract($userId, $group->id));
     $cmtParams->setOwnerId($group->userId);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
 }
Exemple #21
0
 public function index(array $params)
 {
     echo "post_call->" . $_POST['post_id'];
     echo "call->" . $params['id'];
     echo "user_id->" . OW::getUser()->getId();
     echo "call";
     die;
     //        if (!$userId = OW::getUser()->getId()) {
     //            throw new AuthenticateException();
     //        }
     //        $page = (!empty($_GET['page']) && intval($_GET['page']) > 0 ) ? $_GET['page'] : 1;
     //        $lang = OW::getLanguage();
     //        $perPage = (int) OW::getConfig()->getValue('base', OW::getPluginManager()->isPluginActive('skadate') ? 'users_on_page' : 'users_count_on_page');
     //        $guests = OCSGUESTS2_BOL_Service::getInstance()->findGuestsForUser($userId, $page, $perPage);
     //        $guestList = array();
     //        if ($guests) {
     //            foreach ($guests as $guest) {
     //                $guestList[$guest->guestId] = array('last_visit' => $lang->text('skapi', 'visited') . ' ' . '<span class="ow_remark">' . $guest->visitTimestamp . '</span>');
     //            }
     //            $itemCount = OCSGUESTS2_BOL_Service::getInstance()->countGuestsForUser($userId);
     //
     //            if (OW::getPluginManager()->isPluginActive('skadate')) {
     //                $cmp = OW::getClassInstance('BASE_CMP_Users', $guestList, array(), $itemCount);
     //            } else {
     //                $guestsUsers = OCSGUESTS2_BOL_Service::getInstance()->findGuestUsers($userId, $page, $perPage);
     //                $cmp = new OCSGUESTS2_CMP_Users($guestsUsers, $itemCount, $perPage, true, $guestList);
     //            }
     //            $this->addComponent('guests', $cmp);
     //        } else {
     //            $this->assign('guests', null);
     //        }
     //        $this->setPageHeading($lang->text('skapi', 'viewed_profile'));
     //        $this->setPageTitle($lang->text('skapi', 'viewed_profile'));
     //  OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'base', 'dashboard');
 }
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $count = (int) $params->customParamList['count'];
     $service = SKAPI_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $guests = $service->findGuestsForUser($userId, 1, $count);
     if (!$guests) {
         $this->setVisible(false);
         return;
     }
     $userIdList = array();
     foreach ($guests as $guest) {
         array_push($userIdList, $guest->guestId);
     }
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIdList);
     foreach ($avatars as &$item) {
         $item['class'] = 'ow_guest_avatar';
     }
     $event = new OW_Event('bookmarks.is_mark', array(), $avatars);
     OW::getEventManager()->trigger($event);
     if ($event->getData()) {
         $avatars = $event->getData();
     }
     $this->assign('avatars', $avatars);
     $this->assign('guests', $guests);
     $total = $service->countGuestsForUser($userId);
     if ($total > $count) {
         $toolbar = array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('skapi.list'));
         $this->setSettingValue(self::SETTING_TOOLBAR, array($toolbar));
     }
 }
Exemple #23
0
 public function index($params)
 {
     if (OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('base_index'));
     }
     parent::index($params);
     $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getMobileCtrlViewDir() . 'join_index.html');
     $urlParams = $_GET;
     if (is_array($params) && !empty($params)) {
         $urlParams = array_merge($_GET, $params);
     }
     /* @var $form JoinForm */
     $form = $this->joinForm;
     if (!empty($form)) {
         $this->joinForm->setAction(OW::getRouter()->urlFor('BASE_MCTRL_Join', 'joinFormSubmit', $urlParams));
         BASE_MCLASS_JoinFormUtlis::setLabels($form, $form->getSortedQuestionsList());
         BASE_MCLASS_JoinFormUtlis::setInvitations($form, $form->getSortedQuestionsList());
         BASE_MCLASS_JoinFormUtlis::setColumnCount($form);
         $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
         $this->assign('requiredPhotoUpload', $displayPhotoUpload == BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD);
         $this->assign('presentationToClass', $this->presentationToCssClass());
         $element = $this->joinForm->getElement('userPhoto');
         $this->assign('photoUploadId', 'userPhoto');
         if ($element) {
             $this->assign('photoUploadId', $element->getId());
         }
         BASE_MCLASS_JoinFormUtlis::addOnloadJs($form->getName());
     }
 }
Exemple #24
0
 public function sendPrivateMessageActionTool(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if (empty($params['userId'])) {
         return;
     }
     $userId = (int) $params['userId'];
     if (OW::getUser()->getId() == $userId) {
         return;
     }
     if (!OW::getUser()->isAuthorized('mailbox', 'send_message')) {
         return;
     }
     if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId)) {
         $linkId = 'mb' . rand(10, 1000000);
         $script = "\$('#" . $linkId . "').click(function(){\n\n                window.OW.error('" . OW::getLanguage()->text('base', 'user_block_message') . "');\n\n            });";
         OW::getDocument()->addOnloadScript($script);
     } else {
         $linkId = 'mb' . rand(10, 1000000);
         $script = "\$('#" . $linkId . "').click(function(){\n                \$form = \$('#create-conversation-div').children();\n\n                window.mailbox_send_message_floatbox = new OW_FloatBox({\n                    \$title: '" . OW::getLanguage()->text('mailbox', 'compose_message') . "',\n                    \$contents: \$form,\n                    'width': '480px',\n                    'class': 'ow_ic_add'\n                });\n\n                window.mailbox_send_message_floatbox.bind('show', function()\n                {\n                    var textarea = \$form.find('textarea[name=message]').get(0);\n                    textarea.htmlarea();\n                    textarea.htmlareaRefresh();\n                });\n            });";
         OW::getDocument()->addOnloadScript($script);
     }
     $resultArray = array(BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL => OW::getLanguage()->text('mailbox', 'create_conversation_button'), BASE_CMP_ProfileActionToolbar::DATA_KEY_CMP_CLASS => 'MAILBOX_CMP_CreateConversation', BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF => 'javascript://', BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID => $linkId, BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY => "mailbox.send_message");
     $event->add($resultArray);
 }
 public function index($params)
 {
     if (empty($params['documentKey'])) {
         throw new Redirect404Exception();
     }
     $language = OW::getLanguage();
     $documentKey = $params['documentKey'];
     $document = $this->navService->findDocumentByKey($documentKey);
     if ($document === null) {
         throw new Redirect404Exception();
     }
     $menuItem = $this->navService->findMenuItemByDocumentKey($document->getKey());
     if ($menuItem !== null) {
         if (!$menuItem->getVisibleFor() || $menuItem->getVisibleFor() == BOL_NavigationService::VISIBLE_FOR_GUEST && OW::getUser()->isAuthenticated()) {
             throw new Redirect403Exception();
         }
         if ($menuItem->getVisibleFor() == BOL_NavigationService::VISIBLE_FOR_MEMBER && !OW::getUser()->isAuthenticated()) {
             throw new AuthenticateException();
         }
     }
     $this->assign('content', $language->text('base', "local_page_content_{$document->getKey()}"));
     $this->setPageHeading($language->text('base', "local_page_title_{$document->getKey()}"));
     $this->setPageTitle($language->text('base', "local_page_title_{$document->getKey()}"));
     $this->documentKey = $document->getKey();
     $this->setDocumentKey($document->getKey());
     OW::getEventManager()->bind(OW_EventManager::ON_BEFORE_DOCUMENT_RENDER, array($this, 'setCustomMetaInfo'));
 }
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     if (!BOL_AuthorizationService::getInstance()->isModerator() && !OW::getUser()->isAdmin()) {
         $this->setVisible(false);
         return;
     }
     $uniqId = uniqid("mp-");
     $this->assign("uniqId", $uniqId);
     $event = new BASE_CLASS_EventCollector(self::EVENT_COLLECT_CONTENTS);
     OW::getEventManager()->trigger($event);
     $tplContents = array();
     $activeTab = null;
     foreach ($event->getData() as $content) {
         $tplContent = array_merge(array("name" => null, "content" => null, "active" => false), $content);
         $activeTab = $tplContent["active"] ? $tplContent["name"] : $activeTab;
         $tplContents[$tplContent["name"]] = $tplContent;
     }
     if (empty($tplContents)) {
         $this->setVisible(false);
         return;
     }
     if ($activeTab === null) {
         $firstTab = reset($tplContents);
         $activeTab = $firstTab["name"];
         $tplContents[$activeTab]["active"] = true;
     }
     $this->assign("items", $tplContents);
 }
Exemple #27
0
 public function grantCredits()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $form = new USERCREDITS_CLASS_GrantCreditsForm();
     if ($form->isValid($_POST)) {
         $lang = OW::getLanguage();
         $creditService = USERCREDITS_BOL_CreditsService::getInstance();
         $grantorId = OW::getUser()->getId();
         $values = $form->getValues();
         $userId = (int) $values['userId'];
         $amount = abs((int) $values['amount']);
         $granted = $creditService->grantCredits($grantorId, $userId, $amount);
         $credits = $creditService->getCreditsBalance($grantorId);
         if ($granted) {
             $data = array('amount' => $amount, 'grantorId' => $grantorId, 'userId' => $userId);
             $event = new OW_Event('usercredits.grant', $data);
             OW::getEventManager()->trigger($event);
             $data = array('message' => $lang->text('usercredits', 'credits_granted', array('amount' => $amount)), 'credits' => $credits);
         } else {
             $data = array('error' => $lang->text('usercredits', 'credits_grant_error'));
         }
         exit(json_encode($data));
     }
 }
Exemple #28
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($this->user->id));
     $avatarDto = BOL_AvatarService::getInstance()->findByUserId($this->user->id);
     $owner = false;
     if (OW::getUser()->getId() == $this->user->getId()) {
         $owner = true;
     }
     $isModerator = OW::getUser()->isAuthorized('base') || OW::getUser()->isAdmin();
     $avatarData[$this->user->id]['src'] = BOL_AvatarService::getInstance()->getAvatarUrl($this->user->getId(), 1, null, true, !($owner || $isModerator));
     $default_avatar['src'] = BOL_AvatarService::getInstance()->getDefaultAvatarUrl(1);
     $user = array();
     $user["avatar"] = !empty($avatarData[$this->user->id]['src']) ? $avatarData[$this->user->id] : $default_avatar;
     $user["displayName"] = $avatarData[$this->user->id]["title"];
     $this->assign("user", $user);
     $this->addComponent('toolbar', OW::getClassInstance("BASE_MCMP_ProfileActionToolbar", $this->user->id));
     $eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerIdList' => array($this->user->id), 'viewerId' => OW::getUser()->getId());
     $permissions = OW::getEventManager()->getInstance()->call('privacy_check_permission_for_user_list', $eventParams);
     $showPresence = !(isset($permissions[$this->user->id]['blocked']) && $permissions[$this->user->id]['blocked'] == true);
     $this->assign("showPresence", $showPresence);
     $isOnline = null;
     $activityStamp = null;
     if ($showPresence) {
         $onlineInfo = BOL_UserService::getInstance()->findOnlineStatusForUserList(array($this->user->id));
         $isOnline = $onlineInfo[$this->user->id];
         $activityStamp = $this->user->activityStamp;
     }
     $this->assign("isOnline", $isOnline);
     $this->assign("avatarDto", $avatarDto);
     $this->assign("activityStamp", $activityStamp);
     $this->assign('owner', $owner);
     $this->assign('isModerator', $isModerator);
 }
Exemple #29
0
 public function getList($params)
 {
     $data = OW::getEventManager()->call("guests.get_guests_list", array("userId" => OW::getUser()->getId()));
     if (empty($data)) {
         $this->assign("list", array());
         return;
     }
     $idList = array();
     $viewedMap = array();
     $timeMap = array();
     foreach ($data as $item) {
         $idList[] = $item["userId"];
         $viewedMap[$item["userId"]] = $item["viewed"];
         $timeMap[$item["userId"]] = UTIL_DateTime::formatDate($item["timeStamp"]);
     }
     OW::getEventManager()->call("guests.mark_guests_viewed", array("userId" => OW::getUser()->getId(), "guestIds" => $idList));
     $bookmarkList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarkList = empty($bookmarkList) ? array() : $bookmarkList;
     $avatarList = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false);
     $onlineMap = BOL_UserService::getInstance()->findOnlineStatusForUserList($idList);
     foreach ($avatarList as $userId => $user) {
         $color = array('r' => '100', 'g' => '100', 'b' => '100');
         if (!empty($user['labelColor'])) {
             $_color = explode(', ', trim($user['labelColor'], 'rgba()'));
             $color = array('r' => $_color[0], 'g' => $_color[1], 'b' => $_color[2]);
         }
         $list[] = array("userId" => $userId, "displayName" => $user["title"], "avatarUrl" => $user["src"], "label" => $user["label"], "labelColor" => $color, "viewed" => $viewedMap[$userId], "online" => $onlineMap[$userId], "bookmarked" => !empty($bookmarkList[$userId]), "time" => $timeMap[$userId]);
     }
     $this->assign("list", $list);
 }
Exemple #30
0
 public function addLink($userId, $href, $title, $description, $thumbnailUrl, $text = null, $addToFeed = true)
 {
     if (!$this->isActive()) {
         return null;
     }
     OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
     $service = LinkService::getInstance();
     $url = mb_ereg_match('^http(s)?:\\/\\/', $href) ? $href : 'http://' . $href;
     $link = new Link();
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => OW::getUser()->getId());
     $privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams);
     if (!empty($privacy)) {
         $link->setPrivacy($privacy);
     }
     $link->setUserId($userId);
     $link->setTimestamp(time());
     $link->setUrl($url);
     $link->setDescription(strip_tags($description));
     $title = empty($title) ? $text : $title;
     $link->setTitle(strip_tags($title));
     $service->save($link);
     if ($addToFeed) {
         $content = array("format" => null, "vars" => array("status" => $text));
         if (!empty($thumbnailUrl)) {
             $content["format"] = "image_content";
             $content["vars"]["image"] = $thumbnailUrl;
             $content["vars"]["thumbnail"] = $thumbnailUrl;
         }
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $link->getId(), 'userId' => $link->getUserId()), array("content" => $content));
         OW::getEventManager()->trigger($event);
     }
     return $link->id;
 }