/** * Get context menu * * @param integer $userId * @return BASE_CMP_ContextAction */ public function getContextMenu($userId) { $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('block_user_' . $userId); $contextActionMenu->addAction($contextParentAction); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setKey('unblock_user'); $contextAction->setLabel(OW::getLanguage()->text('base', 'user_unblock_btn_lbl')); $url = OW::getRouter()->urlForRoute('users-blocked'); $contextAction->setUrl('javascript://'); $contextAction->addAttribute('onclick', "OW.postRequest('{$url}', {userId: {$userId}})"); $contextActionMenu->addAction($contextAction); return $contextActionMenu; }
public function onBeforeRender() { parent::onBeforeRender(); $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('question_list_order'); $contextParentAction->setLabel('<span class="ql-sort-btn">' . OW::getLanguage()->text('equestions', 'feed_order_' . $this->order) . '</span>'); $contextActionMenu->addAction($contextParentAction); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel('<span class="ql-sort-order-label">' . OW::getLanguage()->text('equestions', 'feed_order_' . EQUESTIONS_CMP_Feed::ORDER_LATEST) . '</span>'); $contextAction->setUrl('javascript://'); $contextAction->setKey(EQUESTIONS_CMP_Feed::ORDER_LATEST); $contextAction->setOrder(1); $contextAction->addAttribute('qorder', EQUESTIONS_CMP_Feed::ORDER_LATEST); $class = array('ql-sort-item'); if ($this->order == EQUESTIONS_CMP_Feed::ORDER_LATEST) { $class[] = 'ql-sort-item-checked'; } $contextAction->setClass(implode(' ', $class)); $contextActionMenu->addAction($contextAction); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel('<span class="ql-sort-order-label">' . OW::getLanguage()->text('equestions', 'feed_order_' . EQUESTIONS_CMP_Feed::ORDER_POPULAR) . '</span>'); $contextAction->setUrl('javascript://'); $contextAction->setKey(EQUESTIONS_CMP_Feed::ORDER_POPULAR); $contextAction->setOrder(2); $contextAction->addAttribute('qorder', EQUESTIONS_CMP_Feed::ORDER_POPULAR); $class = array('ql-sort-item'); if ($this->order == EQUESTIONS_CMP_Feed::ORDER_POPULAR) { $class[] = 'ql-sort-item-checked'; } $contextAction->setClass(implode(' ', $class)); $contextActionMenu->addAction($contextAction); $this->addComponent('sortControl', $contextActionMenu); }
public function getGroupMenu($group) { if (empty($group["toolbar"])) { return ""; } $contextActionMenu = new BASE_CMP_ContextAction(); $contextActionMenu->setClass("ow_profile_toolbar_group ow_context_action_value_block"); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey($group["key"]); $contextParentAction->setLabel($group["label"]); $contextActionMenu->addAction($contextParentAction); usort($group["toolbar"], array($this, "sortCallback")); foreach ($group["toolbar"] as $action) { $attrs = empty($action["attrsArr"]) ? array() : $action["attrsArr"]; $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($action["label"]); if (!empty($attrs["href"])) { $contextAction->setUrl($attrs["href"]); unset($attrs["href"]); } if (!empty($attrs["id"])) { $contextAction->setId($attrs["id"]); unset($attrs["id"]); } if (!empty($attrs["class"])) { $contextAction->setClass($attrs["class"]); unset($attrs["class"]); } foreach ($attrs as $name => $value) { $contextAction->addAttribute($name, $value); } $contextAction->setKey($action["key"]); $contextAction->setOrder($action["order"]); $contextActionMenu->addAction($contextAction); } return $contextActionMenu->render(); }
/** * Class constructor * * @param string $listType * @param int $count * @param string $tag */ public function __construct(array $params) { parent::__construct(); $photoId = $params['photoId']; $config = OW::getConfig(); $lang = OW::getLanguage(); $this->photoService = PHOTO_BOL_PhotoService::getInstance(); $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance(); $photo = $this->photoService->findPhotoById($photoId); $album = $this->photoAlbumService->findAlbumById($photo->albumId); $this->assign('album', $album); // is owner $contentOwner = $this->photoService->findPhotoOwner($photo->id); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; $this->assign('ownerMode', $ownerMode); // is moderator $modPermissions = OW::getUser()->isAuthorized('photo'); $this->assign('moderatorMode', $modPermissions); $canView = true; if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) { $canView = false; } $this->assign('canView', $canView); $cmtParams = new BASE_CommentsParams('photo', 'photo_comments'); $cmtParams->setEntityId($photo->id); $cmtParams->setOwnerId($contentOwner); $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST); $photoCmts = new BASE_CMP_Comments($cmtParams); $this->addComponent('comments', $photoCmts); $photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner); $this->addComponent('rate', $photoRates); $photoTags = new BASE_CMP_EntityTagCloud('photo'); $photoTags->setEntityId($photo->id); $photoTags->setRouteName('view_tagged_photo_list'); $this->addComponent('tags', $photoTags); $description = $photo->description; $photo->description = UTIL_HtmlTag::autoLink($photo->description); $this->assign('photo', $photo); $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash)); $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId)); $is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id); if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) { $this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash)); } else { $this->assign('fullsizeUrl', null); } $action = new BASE_ContextAction(); $action->setKey('photo-moderate'); $context = new BASE_CMP_ContextAction(); $context->addAction($action); $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photoId, 'photoDto' => $photo)); OW::getEventManager()->trigger($contextEvent); foreach ($contextEvent->getData() as $contextAction) { $action = new BASE_ContextAction(); $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']); $action->setParentKey('photo-moderate'); $action->setLabel($contextAction['label']); if (!empty($contextAction['id'])) { $action->setId($contextAction['id']); } if (!empty($contextAction['order'])) { $action->setOrder($contextAction['order']); } if (!empty($contextAction['class'])) { $action->setClass($contextAction['class']); } if (!empty($contextAction['url'])) { $action->setUrl($contextAction['url']); } $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes']; foreach ($attributes as $key => $value) { $action->addAttribute($key, $value); } $context->addAction($action); } if ($userId && !$ownerMode) { $action = new BASE_ContextAction(); $action->setKey('flag'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'flag')); $action->setId('btn-photo-flag'); $action->addAttribute('rel', $photoId); $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id))); $context->addAction($action); } if ($ownerMode || $modPermissions) { $action = new BASE_ContextAction(); $action->setKey('edit'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'edit')); $action->setId('btn-photo-edit'); $action->addAttribute('rel', $photoId); $context->addAction($action); $action = new BASE_ContextAction(); $action->setKey('delete'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'delete')); $action->setId('photo-delete'); $action->addAttribute('rel', $photoId); $context->addAction($action); } if ($modPermissions) { if ($is_featured) { $action = new BASE_ContextAction(); $action->setKey('unmark-featured'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('photo', 'remove_from_featured')); $action->setId('photo-mark-featured'); $action->addAttribute('rel', 'remove_from_featured'); $action->addAttribute('photo-id', $photoId); $context->addAction($action); } else { $action = new BASE_ContextAction(); $action->setKey('mark-featured'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('photo', 'mark_featured')); $action->setId('photo-mark-featured'); $action->addAttribute('rel', 'mark_featured'); $action->addAttribute('photo-id', $photoId); $context->addAction($action); } } $this->addComponent('contextAction', $context); $nextPhoto = $this->photoService->getNextPhoto($photo->albumId, $photo->id); $this->assign('nextPhoto', $nextPhoto); $previousPhoto = $this->photoService->getPreviousPhoto($photo->albumId, $photo->id); $this->assign('previousPhoto', $previousPhoto); $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId); $this->assign('photoCount', $photoCount); $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id); $this->assign('photoIndex', $photoIndex); $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false); $this->assign('avatar', $avatar[$contentOwner]); }
public function getContextMenu($userId) { if (!OW::getUser()->isAuthenticated()) { return null; } $isOwner = $this->groupDto->userId == OW::getUser()->getId(); $isGroupModerator = OW::getUser()->isAuthorized('groups'); $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('group_user_' . $userId); $contextActionMenu->addAction($contextParentAction); if (($isOwner || $isGroupModerator) && $userId != OW::getUser()->getId()) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setKey('delete_group_user'); $contextAction->setLabel(OW::getLanguage()->text('groups', 'delete_group_user_label')); if ($this->groupDto->userId != $userId) { $callbackUri = OW::getRequest()->getRequestUri(); $deleteUrl = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'deleteUser', array('groupId' => $this->groupDto->id, 'userId' => $userId)), array('redirectUri' => urlencode($callbackUri))); $contextAction->setUrl($deleteUrl); $contextAction->addAttribute('data-message', OW::getLanguage()->text('groups', 'delete_group_user_confirmation')); $contextAction->addAttribute('onclick', "return confirm(\$(this).data().message)"); } else { $contextAction->setUrl('javascript://'); $contextAction->addAttribute('data-message', OW::getLanguage()->text('groups', 'group_owner_delete_error')); $contextAction->addAttribute('onclick', "OW.error(\$(this).data().message); return false;"); } $contextActionMenu->addAction($contextAction); } return $contextActionMenu; }
private function prepareMarkup($photo, $layout = null) { $markup = array(); $photo->title = UTIL_HtmlTag::autoLink($photo->title); $photo->url = OW::getStorage()->getFileUrl($this->themeService->getUserfileImagesDir() . $photo->getFilename()); $photo->addDatetime = UTIL_DateTime::formatSimpleDate($photo->addDatetime, true); $markup['photo'] = $photo; $action = new BASE_ContextAction(); $action->setKey('photo-moderate'); $context = new BASE_CMP_ContextAction(); $context->addAction($action); $lang = OW::getLanguage(); $action = new BASE_ContextAction(); $action->setKey('delete'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'delete')); $action->setId('photo-delete'); $action->addAttribute('rel', $photo->id); $context->addAction($action); $markup['contextAction'] = $context->render(); $document = OW::getDocument(); $onloadScript = $document->getOnloadScript(); if (!empty($onloadScript)) { $markup['onloadScript'] = $onloadScript; } $scriptFiles = $document->getScripts(); if (!empty($scriptFiles)) { $markup['scriptFiles'] = $scriptFiles; } $css = $document->getStyleDeclarations(); if (!empty($css)) { $markup['css'] = $css; } $cssFiles = $document->getStyleSheets(); if (!empty($cssFiles)) { $markup['cssFiles'] = $cssFiles; } $meta = $document->getMeta(); if (!empty($meta)) { $markup['meta'] = $meta; } return $markup; }
public function itemHandler(BASE_CLASS_EventProcessCommentItem $e) { $language = OW::getLanguage(); $deleteButton = false; $cAction = null; $value = $e->getItem(); if ($this->isOwnerAuthorized || $this->isModerator || (int) OW::getUser()->getId() === (int) $value->getUserId()) { $deleteButton = true; } $flagButton = $value->getUserId() != OW::getUser()->getId(); if ($this->isBaseModerator || $deleteButton || $flagButton) { $cAction = new BASE_CMP_ContextAction(); $parentAction = new BASE_ContextAction(); $parentAction->setKey('parent'); $parentAction->setClass('ow_comments_context'); $cAction->addAction($parentAction); if ($deleteButton) { $flagAction = new BASE_ContextAction(); $flagAction->setLabel($language->text('base', 'contex_action_comment_delete_label')); $flagAction->setKey('udel'); $flagAction->setParentKey($parentAction->getKey()); $delId = 'del-' . $value->getId(); $flagAction->setId($delId); $this->actionArr['comments'][$delId] = $value->getId(); $cAction->addAction($flagAction); } if ($this->isBaseModerator && $value->getUserId() != OW::getUser()->getId()) { $modAction = new BASE_ContextAction(); $modAction->setLabel($language->text('base', 'contex_action_user_delete_label')); $modAction->setKey('cdel'); $modAction->setParentKey($parentAction->getKey()); $delId = 'udel-' . $value->getId(); $modAction->setId($delId); $this->actionArr['users'][$delId] = $value->getUserId(); $cAction->addAction($modAction); } if ($flagButton) { $flagAction = new BASE_ContextAction(); $flagAction->setLabel($language->text('base', 'flag')); $flagAction->setKey('cflag'); $flagAction->setParentKey($parentAction->getKey()); $flagAction->addAttribute("onclick", "var d = \$(this).data(); OW.flagContent(d.etype, d.eid);"); $flagAction->addAttribute("data-etype", "comment"); $flagAction->addAttribute("data-eid", $value->id); $cAction->addAction($flagAction); } } if ($this->params->getCommentPreviewMaxCharCount() > 0 && mb_strlen($value->getMessage()) > $this->params->getCommentPreviewMaxCharCount()) { $e->setDataProp('previewMaxChar', $this->params->getCommentPreviewMaxCharCount()); } $e->setDataProp('cnxAction', empty($cAction) ? '' : $cAction->render()); }
public function accountTypes($params = array()) { $serviceLang = BOL_LanguageService::getInstance(); $language = OW::getLanguage(); $currentLanguageId = OW::getLanguage()->getCurrentId(); // -- Get all section, questions and question values -- $questions = $this->questionService->findAllQuestionsBySectionForAccountType('all'); $section = null; $questionBySectionList = array(); $sectionDeleteUrlList = array(); $parentList = array(); $questionNameList = array(); $questionList = array(); $deleteEditButtonsContent = array(); $previewQuestionValuesContent = array(); $accountTypesCheckboxContent = array(); $sectionsNameList = array_keys($questions); $sectionDtoList = BOL_QuestionService::getInstance()->findSectionBySectionNameList($sectionsNameList); foreach ($questions as $section => $list) { $sectionDeleteUrlList[$section] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'deleteSection', array("sectionName" => $section)); $questionBySectionList[$section] = array(); foreach ($list as $question) { $questionList[$question['name']] = $question; //$question['questionEditUrl'] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $question['id'])); //$question['questionDeleteUrl'] = OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'deleteQuestion', array("questionId" => $question['id'])); if (!empty($question['parent'])) { $parent = $this->questionService->findQuestionByName($question['parent']); if (!empty($parent)) { $question['parentUrl'] = 'javascript://'; $question['parentLabel'] = $this->questionService->getQuestionLang($parent->name); $question['parentId'] = $parent->id; $parentList[$question['parent']][] = array('name' => $question['name'], 'editUrl' => 'javascript://'); } else { $question['parent'] = ''; } } $questionBySectionList[$section][] = $question; $questionNameList[] = $question['name']; $event = new OW_Event('admin.questions.get_edit_delete_question_buttons_content', array('question' => $question), null); OW::getEventManager()->trigger($event); $data = $event->getData(); $deleteEditButtonsContent[$question['name']] = $data; $event = new OW_Event('admin.questions.get_preview_question_values_content', array('question' => $question), null); OW::getEventManager()->trigger($event); $data = $event->getData(); $previewQuestionValuesContent[$question['name']] = $data; $event = new OW_Event('admin.questions.get_account_types_checkbox_content', array('question' => $question), null); OW::getEventManager()->trigger($event); $data = $event->getData(); $accountTypesCheckboxContent[$question['name']] = $data; } } $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList); foreach ($questionList as $sort => $question) { if (empty($question['name'])) { continue; } $text = $language->text('admin', 'questions_delete_question_confirmation'); if (array_key_exists($question['name'], $parentList)) { $questionStringList = array(); foreach ($parentList[$question['name']] as $child) { $questionStringList[] = BOL_QuestionService::getInstance()->getQuestionLang($child['name']); } $text = $language->text('admin', 'questions_delete_question_parent_confirmation', array('questions' => implode(', ', $questionStringList))); } $text = json_encode($text); OW::getDocument()->addOnloadScript("OW.registerLanguageKey('admin', 'questions_delete_question_confirmation_" . (int) $question['id'] . "', {$text});"); // ------------------------------------------------------------ $disableActionList = $this->questionService->getQuestionDisableActionList($questionDtoList[$question['name']]); $questionList[$sort] = array_merge($questionList[$sort], $disableActionList); // ------------------------------------------------------------ } $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList); $accountTypeDtoList = $this->questionService->findAllAccountTypes(); $accountTypeList = array(); $valueLabels = array(); foreach ($questionValues as $name => $value) { if (empty($valueLabels[$name])) { $valueLabels[$name] = array(); } /* @var $value BOL_QuestionValue */ foreach ($value['values'] as $item) { $valueLabels[$item->questionName][$item->value] = BOL_QuestionService::getInstance()->getQuestionValueLang($item->questionName, $item->value); } } foreach ($accountTypeDtoList as $dto) { $accountTypeList[$dto->name] = $dto->name; } $accountTypesToQuestionsDtoList = $this->getAccountTypesToQuestionsList(); $this->assign('questionList', $questionList); $this->assign('td_width', (int) (375 / (count($accountTypeDtoList) + 1))); $this->assign('div_width', (int) (375 / (count($accountTypeDtoList) + 1)) - 18); $this->assign('accountTypeDtoList', $accountTypeDtoList); $this->assign('accountTypesCount', count($accountTypeDtoList) + 1); $this->assign('tableColumnCount', count($accountTypeDtoList) + 5); $this->assign('accountTypesToQuestionsDtoList', $accountTypesToQuestionsDtoList); $this->assign('questionsBySections', $questionBySectionList); $this->assign('questionValues', $questionValues); $this->assign('valueLabels', $valueLabels); $this->assign('sectionDeleteUrlList', $sectionDeleteUrlList); $this->assign('propertiesUrl', OW::getRouter()->urlForRoute('questions_properties')); $this->assign('deleteEditButtons', $deleteEditButtonsContent); $this->assign('previewValues', $previewQuestionValuesContent); $this->assign('accountTypesCheckboxContent', $accountTypesCheckboxContent); $this->assign('sectionList', $sectionDtoList); $language->addKeyForJs('admin', 'questions_delete_section_confirmation'); $script = ' window.indexQuest = new indexQuestions( ' . json_encode(array('questions' => $questionList, 'ajaxResponderUrl' => $this->ajaxResponderUrl, 'accountTypes' => array_keys($accountTypeList))) . ' )'; OW::getDocument()->addOnloadScript($script); $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl(); OW::getDocument()->addScript($jsDir . "questions.js"); $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl(); OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js"); OW::getLanguage()->addKeyForJs('admin', 'questions_profile_question_sections_title'); OW::getLanguage()->addKeyForJs('admin', 'questions_edit_profile_question_title'); OW::getLanguage()->addKeyForJs('admin', 'questions_add_profile_question_title'); OW::getLanguage()->addKeyForJs('admin', 'questions_add_account_type_title'); OW::getLanguage()->addKeyForJs('admin', 'questions_edit_account_type_title'); OW::getLanguage()->addKeyForJs('admin', 'questions_account_type_was_added'); OW::getLanguage()->addKeyForJs('admin', 'questions_account_type_was_updated'); OW::getLanguage()->addKeyForJs('admin', 'questions_account_type_added_error'); OW::getLanguage()->addKeyForJs('admin', 'questions_delete_account_type_confirmation'); OW::getLanguage()->addKeyForJs('admin', 'questions_values_should_not_be_empty'); $contextAction = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('account_type_menu'); $contextParentAction->setClass('ow_newsfeed_context'); $contextAction->addAction($contextParentAction); $editAction = new BASE_ContextAction(); $editAction->setKey('edit'); $editAction->setLabel(OW::getLanguage()->text('admin', 'btn_label_edit')); $editAction->setParentKey($contextParentAction->getKey()); $editAction->setClass('question_edit_account_type_button'); $editAction->setUrl('javascript://'); $editAction->setOrder(1); $contextAction->addAction($editAction); $deleteAction = new BASE_ContextAction(); $deleteAction->setKey('delete'); $deleteAction->setLabel(OW::getLanguage()->text('admin', 'btn_label_delete')); $deleteAction->setParentKey($contextParentAction->getKey()); $deleteAction->setClass('question_delete_account_type_button'); $deleteAction->setUrl('javascript://'); $deleteAction->setOrder(2); $contextAction->addAction($deleteAction); $this->addComponent('accountTypeMenu', $contextAction); }
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); }
private function prepareMarkup($photoId, $layout = NULL) { $markup = array(); $photo = $this->photoService->findPhotoById($photoId); $album = $this->photoAlbumService->findAlbumById($photo->albumId); $layoutList = array('page' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, 'floatbox' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI); $userId = OW::getUser()->getId(); $ownerMode = $album->userId == $userId; $modPermissions = OW::getUser()->isAuthorized('photo'); $photo->addDatetime = UTIL_DateTime::formatDate($photo->addDatetime); $photo->description = UTIL_HtmlTag::autoLink($photo->description); $dim = !empty($photo->dimension) ? $photo->dimension : FALSE; $photo->url = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_MAIN, $photo->hash, $dim); if ($photo->hasFullsize) { $photo->urlFullscreen = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN, $photo->hash, $dim); } if (!empty($photo->description)) { $photo->description = $this->photoService->hashtagToDesc($photo->description); } $markup['photo'] = $photo; $markup['album'] = $album; $markup['albumUrl'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($album->userId), 'album' => $album->id)); $markup['photoCount'] = $this->photoAlbumService->countAlbumPhotos($photo->albumId); $markup['photoIndex'] = $this->photoService->getPhotoIndex($photo->albumId, $photo->id); $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($album->userId), TRUE, TRUE, TRUE, FALSE); $markup['avatar'] = $avatar[$album->userId]; $cmtParams = new BASE_CommentsParams('photo', 'photo_comments'); $cmtParams->setEntityId($photo->id); $cmtParams->setOwnerId($album->userId); $cmtParams->setWrapInBox(FALSE); $cmtParams->setDisplayType(array_key_exists($layout, $layoutList) ? $layoutList[$layout] : BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI); $cmtParams->setInitialCommentsCount(6); $cmtParams->setAddComment($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED); $customId = uniqid('photoComment'); $cmtParams->setCustomId($customId); $markup['customId'] = $customId; $comment = new BASE_CMP_Comments($cmtParams); $markup['comment'] = $comment->render(); $action = new BASE_ContextAction(); $action->setKey('photo-moderate'); $context = new BASE_CMP_ContextAction(); $context->addAction($action); $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photo->id, 'photoDto' => $photo)); OW::getEventManager()->trigger($contextEvent); foreach ($contextEvent->getData() as $contextAction) { $action = new BASE_ContextAction(); $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']); $action->setParentKey('photo-moderate'); $action->setLabel($contextAction['label']); if (!empty($contextAction['id'])) { $action->setId($contextAction['id']); } if (!empty($contextAction['order'])) { $action->setOrder($contextAction['order']); } if (!empty($contextAction['class'])) { $action->setClass($contextAction['class']); } if (!empty($contextAction['url'])) { $action->setUrl($contextAction['url']); } $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes']; foreach ($attributes as $key => $value) { $action->addAttribute($key, $value); } $context->addAction($action); } $lang = OW::getLanguage(); if ($userId && !$ownerMode && $photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) { $action = new BASE_ContextAction(); $action->setKey('flag'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'flag')); $action->setId('btn-photo-flag'); $action->addAttribute('rel', $photoId); $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id))); $context->addAction($action); } if ($ownerMode || $modPermissions) { $action = new BASE_ContextAction(); $action->setKey('edit'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'edit')); $action->setId('btn-photo-edit'); $action->addAttribute('rel', $photoId); $context->addAction($action); $action = new BASE_ContextAction(); $action->setKey('delete'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('base', 'delete')); $action->setId('photo-delete'); $action->addAttribute('rel', $photoId); $context->addAction($action); } if ($modPermissions) { if (PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id)) { $action = new BASE_ContextAction(); $action->setKey('unmark-featured'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('photo', 'remove_from_featured')); $action->setId('photo-mark-featured'); $action->addAttribute('rel', 'remove_from_featured'); $action->addAttribute('photo-id', $photoId); $context->addAction($action); } elseif ($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) { $action = new BASE_ContextAction(); $action->setKey('mark-featured'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('photo', 'mark_featured')); $action->setId('photo-mark-featured'); $action->addAttribute('rel', 'mark_featured'); $action->addAttribute('photo-id', $photoId); $context->addAction($action); } if ($photo->status != PHOTO_BOL_PhotoDao::STATUS_APPROVED) { $action = new BASE_ContextAction(); $action->setKey('mark-approved'); $action->setParentKey('photo-moderate'); $action->setLabel($lang->text('photo', 'approve_photo')); $action->setUrl(OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId))); // $action->setId('photo-approve'); // $action->addAttribute('url', OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId))); $context->addAction($action); } } $markup['contextAction'] = $context->render(); $eventParams = array('url' => OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)), 'image' => $photo->url, 'title' => $photo->description, 'entityType' => 'photo', 'entityId' => $photo->id); $event = new BASE_CLASS_EventCollector('socialsharing.get_sharing_buttons', $eventParams); OW::getEventManager()->trigger($event); $markup['share'] = @implode("\n", $event->getData()); $document = OW::getDocument(); $onloadScript = $document->getOnloadScript(); if (!empty($onloadScript)) { $markup['onloadScript'] = $onloadScript; } $scriptFiles = $document->getScripts(); if (!empty($scriptFiles)) { $markup['scriptFiles'] = $scriptFiles; } $css = $document->getStyleDeclarations(); if (!empty($css)) { $markup['css'] = $css; } $cssFiles = $document->getStyleSheets(); if (!empty($cssFiles)) { $markup['cssFiles'] = $cssFiles; } $meta = $document->getMeta(); if (!empty($meta)) { $markup['meta'] = $meta; } return $markup; }
/** * * @return BASE_CMP_ContextAction */ private function getContextToolbar() { $language = OW::getLanguage(); $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('uheaderToolbar'); $contextParentAction->setLabel($language->text("uheader", "admin_edit_cover_label")); $contextParentAction->setId('uh-toolbar-parent'); $contextActionMenu->addAction($contextParentAction); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('uheader', 'reposition_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhReposition'); $contextAction->setId('uhco-reposition'); $contextAction->setClass('uhco-item uhco-reposition'); $contextAction->setOrder(1); $contextActionMenu->addAction($contextAction); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('uheader', 'remove_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhRemove'); $contextAction->setId('uhco-remove'); $contextAction->setClass('uhco-item uhco-remove'); $contextAction->setOrder(2); $contextActionMenu->addAction($contextAction); return $contextActionMenu; }
/** * * @return BASE_CMP_ContextAction */ private function getContextToolbar() { $language = OW::getLanguage(); $permissions = $this->getPemissions(); $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('gheaderToolbar'); $contextParentAction->setLabel('<span class="uh-toolbar-add-label">' . $language->text('gheader', 'set_covet_label') . '</span><span class="uh-toolbar-edit-label">' . $language->text('gheader', 'change_covet_label') . '</span>'); $contextParentAction->setId('uh-toolbar-parent'); //$contextParentAction->setClass('ow_ic_picture'); $contextActionMenu->addAction($contextParentAction); if ($permissions['add']) { if (GHEADER_CLASS_PhotoBridge::getInstance()->isActive()) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('gheader', 'choose_from_photos_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhChoose'); $contextAction->setId('uhco-choose'); $contextAction->setClass('uhco-item uhco-choose'); $contextAction->setOrder(1); $contextActionMenu->addAction($contextAction); } $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel('<div class="uh-fake-file"><div>' . $language->text('gheader', 'upload_label') . '</div><input type="file" name="file" id="uh-upload-cover" size="1" /></div>'); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhUpload'); $contextAction->setClass('uhco-item uhco-upload'); $contextAction->setOrder(2); $contextActionMenu->addAction($contextAction); } if ($permissions['reposition']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('gheader', 'reposition_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhReposition'); $contextAction->setId('uhco-reposition'); $contextAction->setClass('uhco-item uhco-reposition'); $contextAction->setOrder(3); $contextActionMenu->addAction($contextAction); } if ($permissions['delete']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('gheader', 'remove_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhRemove'); $contextAction->setId('uhco-remove'); $contextAction->setClass('uhco-item uhco-remove'); $contextAction->setOrder(4); $contextActionMenu->addAction($contextAction); } return $contextActionMenu; }
/** * * @return BASE_CMP_ContextAction */ private function getContextToolbar() { $language = OW::getLanguage(); $permissions = $this->getPemissions(); $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('uheaderToolbar'); $contextParentAction->setLabel('<span class="uh-toolbar-add-label">' . $language->text('uheader', 'set_covet_label') . '</span><span class="uh-toolbar-edit-label">' . $language->text('uheader', 'change_covet_label') . '</span>'); $contextParentAction->setId('uh-toolbar-parent'); $contextActionMenu->addAction($contextParentAction); if ($permissions['choose']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text("uheader", "choose_from_gallery_label")); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhGallery'); $contextAction->setId('uhco-gallery'); $contextAction->setClass('uhco-item uhco-gallery'); $contextAction->setOrder(1); $contextActionMenu->addAction($contextAction); } if ($permissions['add']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel('<div class="uh-fake-file"><div>' . $language->text('uheader', 'upload_label') . '</div><input type="file" name="file" id="uh-upload-cover" size="1" /></div>'); //$contextAction->setLabel($language->text('uheader', 'upload_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhUpload'); $contextAction->setId('uhco-upload'); $contextAction->setClass('uhco-item uhco-upload'); $contextAction->setOrder(2); $contextActionMenu->addAction($contextAction); } if ($permissions['reposition']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('uheader', 'reposition_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhReposition'); $contextAction->setId('uhco-reposition'); $contextAction->setClass('uhco-item uhco-reposition'); $contextAction->setOrder(3); $contextActionMenu->addAction($contextAction); } if ($permissions['stick']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('uheader', 'stick_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhStick'); $contextAction->setId('uhco-stick'); $contextAction->setClass('uhco-item uhco-stick'); $contextAction->setOrder(4); $contextActionMenu->addAction($contextAction); } if ($this->defaultTemplatesCount > 0) { if ($permissions['restore']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text("uheader", "restore_default_label")); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhRestoreDefault'); $contextAction->setId('uhco-restore-default'); $contextAction->setClass('uhco-item uhco-restore-default'); $contextAction->setOrder(5); $contextActionMenu->addAction($contextAction); } } else { if ($permissions['delete']) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text("uheader", "remove_label")); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhRemove'); $contextAction->setId('uhco-remove'); $contextAction->setClass('uhco-item uhco-remove'); $contextAction->setOrder(5); $contextActionMenu->addAction($contextAction); } } /*if ( $permissions['delete'] ) { $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($language->text('uheader', 'remove_label')); $contextAction->setUrl('javascript://'); $contextAction->setKey('uhRemove'); $contextAction->setId('uhco-remove'); $contextAction->setClass('uhco-item uhco-remove'); $contextAction->setOrder(4); $contextActionMenu->addAction($contextAction); }*/ return $contextActionMenu; }
private function getFilterContextAction() { $context = new BASE_CMP_ContextAction(); $action = new BASE_ContextAction(); $action->setKey('forum-search'); $context->addAction($action); $action = new BASE_ContextAction(); $action->setKey('filter_by_user'); $action->setParentKey('forum-search'); $action->setLabel('Filter by user'); $action->setId('btn-filter-by-user'); $context->addAction($action); return $context; }
public function itemHandler(BASE_CLASS_EventProcessCommentItem $e) { $language = OW::getLanguage(); $deleteButton = false; $cAction = null; $value = $e->getItem(); if ($this->isOwnerAuthorized || $this->isModerator || (int) OW::getUser()->getId() === (int) $value->getUserId()) { $deleteButton = true; } if ($this->isBaseModerator || $deleteButton) { $cAction = new BASE_CMP_ContextAction(); $parentAction = new BASE_ContextAction(); $parentAction->setKey('parent'); $parentAction->setClass('ow_comments_context'); $cAction->addAction($parentAction); if ($deleteButton) { $delAction = new BASE_ContextAction(); $delAction->setLabel($language->text('base', 'contex_action_comment_delete_label')); $delAction->setKey('udel'); $delAction->setParentKey($parentAction->getKey()); $delId = 'del-' . $value->getId(); $delAction->setId($delId); $this->actionArr['comments'][$delId] = $value->getId(); $cAction->addAction($delAction); } if ($this->isBaseModerator && $value->getUserId() != OW::getUser()->getId()) { $modAction = new BASE_ContextAction(); $modAction->setLabel($language->text('base', 'contex_action_user_delete_label')); $modAction->setKey('cdel'); $modAction->setParentKey($parentAction->getKey()); $delId = 'udel-' . $value->getId(); $modAction->setId($delId); $this->actionArr['users'][$delId] = $value->getUserId(); $cAction->addAction($modAction); } } $e->setDataProp('cnxAction', empty($cAction) ? '' : $cAction->render()); }
protected function getContextMenu($data) { $contextActionMenu = new BASE_CMP_ContextAction(); $contextParentAction = new BASE_ContextAction(); $contextParentAction->setKey('newsfeed_context_menu_' . $this->autoId); $contextParentAction->setClass('ow_newsfeed_context'); $contextActionMenu->addAction($contextParentAction); $order = 1; foreach ($data['contextMenu'] as $action) { $action = array_merge(array('label' => null, 'order' => $order, 'class' => null, 'url' => null, 'id' => null, 'key' => uniqid($this->autoId . '_'), 'attributes' => array()), $action); $contextAction = new BASE_ContextAction(); $contextAction->setParentKey($contextParentAction->getKey()); $contextAction->setLabel($action['label']); $contextAction->setClass($action['class']); $contextAction->setUrl($action['url']); $contextAction->setId($action['id']); $contextAction->setKey($action['key']); $contextAction->setOrder($action['order']); foreach ($action['attributes'] as $key => $value) { $contextAction->addAttribute($key, $value); } $contextActionMenu->addAction($contextAction); $order++; } return $contextActionMenu->render(); }