コード例 #1
0
ファイル: service.php プロジェクト: hardikamutech/loov
 private function __construct()
 {
     $this->markDto = BOOKMARKS_BOL_MarkDao::getInstance();
     $this->notifyLogDao = BOOKMARKS_BOL_NotifyLogDao::getInstance();
 }
コード例 #2
0
 private function process($list)
 {
     $service = BOL_UserService::getInstance();
     $idList = array();
     $userList = array();
     foreach ($list as $dto) {
         $userList[] = array('dto' => $dto);
         $idList[] = $dto->getId();
     }
     $displayNameList = array();
     $questionList = array();
     $markList = array();
     if (!empty($idList)) {
         $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, true, true, false);
         $vatarsSrc = BOL_AvatarService::getInstance()->getAvatarsUrlList($idList, 2);
         foreach ($avatars as $userId => $avatarData) {
             $avatars[$userId]['src'] = $vatarsSrc[$userId];
             $displayNameList[$userId] = isset($avatarData['title']) ? $avatarData['title'] : '';
         }
         $usernameList = $service->getUserNamesForList($idList);
         $onlineInfo = $service->findOnlineStatusForUserList($idList);
         $showPresenceList = array();
         $ownerIdList = array();
         foreach ($onlineInfo as $userId => $isOnline) {
             $ownerIdList[$userId] = $userId;
         }
         $eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerIdList' => $ownerIdList, 'viewerId' => OW::getUser()->getId());
         $permissions = OW::getEventManager()->getInstance()->call('privacy_check_permission_for_user_list', $eventParams);
         foreach ($onlineInfo as $userId => $isOnline) {
             // Check privacy permissions
             if (isset($permissions[$userId]['blocked']) && $permissions[$userId]['blocked'] == true) {
                 $showPresenceList[$userId] = false;
                 continue;
             }
             $showPresenceList[$userId] = true;
         }
         if ($this->actions) {
             $actions = USEARCH_CLASS_EventHandler::getInstance()->collectUserListActions($idList);
             $this->assign('actions', $actions);
         }
         $this->assign('showPresenceList', $showPresenceList);
         $this->assign('fields', $this->getFields($idList));
         $this->assign('questionList', $questionList);
         $this->assign('usernameList', $usernameList);
         $this->assign('avatars', $avatars);
         $this->assign('displayNameList', $displayNameList);
         $this->assign('onlineInfo', $onlineInfo);
         $this->assign('page', $this->page);
         $activityShowLimit = OW::getConfig()->getValue('usearch', 'hide_user_activity_after');
         $this->assign('activityShowLimit', time() - (int) $activityShowLimit * 24 * 60 * 60);
         if (OW::getPluginManager()->isPluginActive('bookmarks') && OW::getUser()->isAuthenticated()) {
             $markList = BOOKMARKS_BOL_MarkDao::getInstance()->getMarkedListByUserId(OW::getUser()->getId(), $idList);
             $this->assign('bookmarkActive', TRUE);
             $contextActionList = array();
             foreach ($idList as $id) {
                 $label = !empty($markList[$id]) ? OW::getLanguage()->text('bookmarks', 'unmark_toolbar_label') : OW::getLanguage()->text('bookmarks', 'mark_toolbar_label');
                 $contextAction = new BASE_CMP_ContextAction();
                 $contextParentAction = new BASE_ContextAction();
                 $contextParentAction->setKey('userlist_menu');
                 $contextParentAction->setClass('ow_usearch_userlist_menu ow_newsfeed_context ');
                 $contextAction->addAction($contextParentAction);
                 $action = new BASE_ContextAction();
                 $action->setKey('bookmark');
                 $action->setLabel($label);
                 $action->addAttribute('data-user-id', $id);
                 $action->setClass('ow_ulist_big_avatar_bookmark usearch_bookmark download');
                 $action->setUrl('javascript://');
                 $action->setParentKey($contextParentAction->getKey());
                 $action->setOrder(1);
                 $contextAction->addAction($action);
                 $contextActionList[$id] = $contextAction->render();
             }
             $this->assign('itemMenu', $contextActionList);
         }
     }
     $this->assign('list', $userList);
     $this->assign('bookmarkList', $markList);
 }
コード例 #3
0
ファイル: event_handler.php プロジェクト: hardikamutech/loov
    public function usearchCollectUserActions(BASE_CLASS_EventCollector $event)
    {
        $params = $event->getParams();
        $userIdList = $params['userIdList'];
        $viewerId = OW::getUser()->getId();
        $languages = OW::getLanguage();
        $markList = BOOKMARKS_BOL_MarkDao::getInstance()->findAllBookmarkIdList($viewerId);
        $actions = array();
        foreach ($userIdList as $userId) {
            if ($userId == $viewerId) {
                continue;
            }
            $key = in_array($userId, $markList) ? 'unmark' : 'mark';
            $id = 'action_' . $key . '_' . $userId;
            $actions[$userId] = array('key' => $key, 'label' => $languages->text('bookmarks', $key . '_toolbar_label'), 'id' => $id, 'href' => 'javascript://', 'order' => 0, 'linkClass' => 'ow_ic_bookmark bookmark_action', 'attributes' => array('data-user-id' => $userId));
        }
        if (count($actions)) {
            OW::getDocument()->addScriptDeclaration(UTIL_JsGenerator::composeJsString(';$(document).on("click", ".bookmark_action", function( event )
                    {
                        var handler = $(this);

                        BOOKMARKS.markState(handler.attr("data-user-id"), function( data, textStatus, jqXHR )
                        {
                            if ( data.mark === true )
                            {
                                OW.info(\'<div class="clearfix bookmarks_wrap"><span>\' + {$markedNotifyMessage} + \'</span><span class="ow_left boomarks_ic_wrap bookmarks_ic_bookmark_white"></span></div>\');

                                var element;

                                if ( (element = $("#user-avatar-" + handler.attr("data-user-id") + " .ow_usearch_display_name")).length )
                                {
                                    $("<div>", {class: "ow_ic_bookmark ow_bookmark_icon_ulist", id: "bookmark-user-" + handler.attr("data-user-id")}).insertAfter(element);
                                }
                                else
                                {
                                    $("<div>", {class: "ow_ic_bookmark ow_bookmark_icon_ulist", id: "bookmark-user-" + handler.attr("data-user-id")}).appendTo(element);
                                }

                                handler.html({$unMarkLabel});
                            }
                            else
                            {
                                OW.info(\'<div class="clearfix bookmarks_wrap"><span>\' + {$unMarkedNotifyMessage} + \'</span><span class="ow_left boomarks_ic_wrap bookmarks_ic_bookmark_white"></span></div>\');
                                $("#bookmark-user-" + handler.attr("data-user-id")).remove();
                                handler.html({$markLabel});
                            }
                        });
                    });', array('markedNotifyMessage' => $languages->text('bookmarks', 'marked_notify_message', array('bookmarksListURL' => OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_LATEST)))), 'unMarkedNotifyMessage' => $languages->text('bookmarks', 'unmarked_notify_message', array('bookmarksListURL' => OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_LATEST)))), 'unMarkLabel' => $languages->text('bookmarks', 'unmark_toolbar_label'), 'markLabel' => $languages->text('bookmarks', 'mark_toolbar_label'))));
        }
        $event->add($actions);
    }