/** * 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'); }
/** * Controller's default action * * @param array $params */ public function index(array $params) { if (!isset($params['groupId']) || !($groupId = (int) $params['groupId'])) { throw new Redirect404Exception(); } $groupInfo = $this->forumService->getGroupInfo($groupId); if (!$groupInfo) { throw new Redirect404Exception(); } $forumSection = $this->forumService->findSectionById($groupInfo->sectionId); if (!$forumSection) { throw new Redirect404Exception(); } $this->addComponent('groupCmp', new FORUM_CMP_ForumGroup(array('groupId' => $params['groupId'], 'caption' => true))); }
/** * Returns class instance * * @return FORUM_BOL_ForumService */ public static function getInstance() { if (!isset(self::$classInstance)) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Controller's default action */ public function index() { $isModerator = OW::getUser()->isAuthorized('forum'); $viewPermissions = OW::getUser()->isAuthorized('forum', 'view'); if (!$viewPermissions && !$isModerator) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('forum', 'view'); throw new AuthorizationException($status['msg']); } $forumService = FORUM_BOL_ForumService::getInstance(); $this->assign('customizeUrl', OW::getRouter()->urlForRoute('customize-default')); $this->assign('isModerator', $isModerator); $userId = OW::getUser()->getId(); $sectionGroupList = $forumService->getSectionGroupList($userId); $singleForumMode = $forumService->isSingleForumMode($sectionGroupList); $this->assign('singleMode', $singleForumMode); if ($singleForumMode) { $firstSection = array_shift($sectionGroupList); $firstGroup = $firstSection['groups'][0]; $groupId = $firstGroup['id']; $this->addComponent('groupCmp', new FORUM_CMP_ForumGroup(array('groupId' => $groupId, 'caption' => false))); $groupName = htmlspecialchars($firstGroup['name']); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum_page_heading', array('forum' => $groupName))); OW::getDocument()->setTitle($groupName); OW::getDocument()->setDescription(htmlspecialchars($firstGroup['description'])); } else { $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); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum')); $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'all_forum'))); } $plugin = OW::getPluginManager()->getPlugin('forum'); $template = $plugin->getCtrlViewDir() . 'index.html'; $this->setTemplate($template); OW::getDocument()->setHeadingIconClass('ow_ic_forum'); OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'meta_description_forums')); }
public function onDelete(OW_Event $event) { $params = $event->getParams(); if ($params["entityType"] != self::ENTITY_TYPE && $params["entityType"] != self::POST_ENTITY_TYPE) { return; } if ($params["entityType"] == self::ENTITY_TYPE) { foreach ($params["entityIds"] as $topicId) { $this->service->deleteTopic($topicId); } } elseif ($params["entityType"] == self::POST_ENTITY_TYPE) { foreach ($params["entityIds"] as $postId) { $this->service->deletePost($postId); } } }
/** * Plugin uninstall action */ public function uninstall() { if (isset($_POST['action']) && $_POST['action'] == 'delete_content') { OW::getConfig()->saveConfig('forum', 'uninstall_inprogress', 1); FORUM_BOL_ForumService::getInstance()->setMaintenanceMode(true); $event = new OW_Event('forum.uninstall_plugin'); OW::getEventManager()->trigger($event); OW::getFeedback()->info(OW::getLanguage()->text('forum', 'plugin_set_for_uninstall')); $this->redirect(); } $this->setPageHeading(OW::getLanguage()->text('forum', 'page_title_uninstall')); $this->setPageHeadingIconClass('ow_ic_delete'); $this->assign('inprogress', (bool) OW::getConfig()->getValue('forum', 'uninstall_inprogress')); $js = new UTIL_JsGenerator(); $js->jQueryEvent('#btn-delete-content', 'click', 'if ( !confirm("' . OW::getLanguage()->text('forum', 'confirm_delete_forum') . '") ) return false;'); OW::getDocument()->addOnloadScript($js); }
/** * @param BASE_CLASS_WidgetParameter $paramObj * @return FORUM_CMP_LatestTopicsWidget */ public function __construct(BASE_CLASS_WidgetParameter $paramObj) { parent::__construct(); $confTopicCount = (int) $paramObj->customParamList['topicCount']; $this->entityId = (int) $paramObj->additionalParamList['entityId']; $this->entity = $paramObj->additionalParamList['entity']; $forumService = FORUM_BOL_ForumService::getInstance(); $forumGroup = $forumService->findGroupByEntityId($this->entity, $this->entityId); if (empty($forumGroup)) { $this->setVisible(false); return; } $topicList = $forumService->getGroupTopicList($forumGroup->getId(), 1, $confTopicCount); // get usernames list $userIds = array(); $topicIds = array(); foreach ($topicList as $topic) { array_push($topicIds, $topic['id']); if (isset($topic['lastPost']) && !in_array($topic['lastPost']['userId'], $userIds)) { array_push($userIds, $topic['lastPost']['userId']); } } $addTopicUrl = OW::getRouter()->urlForRoute('add-topic', array('groupId' => $forumGroup->getId())); $this->assign('addTopicUrl', $addTopicUrl); //$isModerator = OW::getUser()->isAuthorized($this->entity); //$canAdd = OW::getUser()->isAuthorized($this->entity, 'add_topic'); $params = array('entity' => $this->entity, 'entityId' => $this->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $params); OW::getEventManager()->trigger($event); $canAdd = $event->getData(); $this->assign('canAdd', $canAdd); $attachments = FORUM_BOL_PostAttachmentService::getInstance()->getAttachmentsCountByTopicIdList($topicIds); $this->assign('attachments', $attachments); $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds); $this->assign('usernames', $usernames); $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds); $this->assign('displayNames', $displayNames); $this->assign('topicList', $topicList); if ($canAdd) { $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('forum', 'add_new'), 'href' => OW::getRouter()->urlForRoute('add-topic', array('groupId' => $forumGroup->getId()))), array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId()))))); } else { $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId()))))); } }
public function feedOnItemRender(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); $language = OW::getLanguage(); if ($params['action']['entityType'] != 'forum-topic') { return; } $service = FORUM_BOL_ForumService::getInstance(); $postCount = $service->findTopicPostCount($params['action']['entityId']) - 1; if (!$postCount) { return; } $postIds = array(); foreach ($params['activity'] as $activity) { if ($activity['activityType'] == 'forum-post') { $postIds[] = $activity['data']['postId']; } } if (empty($postIds)) { return; } $postDto = null; foreach ($postIds as $pid) { $postDto = $service->findPostById($pid); if ($postDto !== null) { break; } } if ($postDto === null) { return; } $postUrlEmbed = '...'; $content = UTIL_String::truncate(strip_tags(str_replace(" ", "", $postDto->text)), 100, $postUrlEmbed); $usersData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($postDto->userId), true, true, true, false); $avatarData = $usersData[$postDto->userId]; //$postUrl = $service->getPostUrl($postDto->topicId, $postDto->id); if (is_array($data['content']) && !empty($data['content']['vars'])) { $data['content']['vars']['activity'] = array('title' => $language->text('forum', 'latest_reply_from', array('url' => $avatarData['url'], 'user' => $avatarData['title'])), 'avatarData' => $avatarData, 'description' => $content); } $event->setData($data); }
public function getService($pluginKey) { switch ($pluginKey) { case 'newsfeed': return NEWSFEED_BOL_Service::getInstance(); case 'blogs': return PostService::getInstance(); case 'groups': return GROUPS_BOL_Service::getInstance(); case 'event': return EVENT_BOL_EventService::getInstance(); case 'links': return LinkService::getInstance(); case 'video': return VIDEO_BOL_ClipService::getInstance(); case 'forum': return FORUM_BOL_ForumService::getInstance(); case 'photo': return PHOTO_BOL_PhotoService::getInstance(); } }
public function topicsDeleteProcess() { $config = OW::getConfig(); // check if uninstall is in progress if (!$config->getValue('forum', 'uninstall_inprogress')) { return; } // check if cron queue is not busy if ($config->getValue('forum', 'uninstall_cron_busy')) { return; } $config->saveConfig('forum', 'uninstall_cron_busy', 1); $forumService = FORUM_BOL_ForumService::getInstance(); $forumService->deleteTopics(self::TOPICS_DELETE_LIMIT); $mediaPanelService = BOL_MediaPanelService::getInstance(); $mediaPanelService->deleteImages('forum', self::MEDIA_DELETE_LIMIT); $config->saveConfig('forum', 'uninstall_cron_busy', 0); if ((int) $forumService->countAllTopics() + (int) $mediaPanelService->countGalleryImages('forum') == 0) { $config->saveConfig('forum', 'uninstall_inprogress', 0); BOL_PluginService::getInstance()->uninstall('forum'); FORUM_BOL_ForumService::getInstance()->setMaintenanceMode(false); } }
/** * Generates add forum form * * @param string $action * @return Form */ private function generateAddForumForm($action) { $language = OW::getLanguage(); $form = new Form('add-forum-form'); $form->setAction($action); $groupName = new TextField('group-name'); $groupName->setRequired(true); $sValidator = new StringValidator(1, 255); $sValidator->setErrorMessage($language->text('forum', 'chars_limit_exceeded', array('limit' => 255))); $groupName->addValidator($sValidator); $form->addElement($groupName); $sectionField = new SuggestField('section'); $sectionField->setRequired(true); $sectionField->setMinChars(1); $responderUrl = OW::getRouter()->urlFor('FORUM_CTRL_Customize', 'suggestSection'); $sectionField->setResponderUrl($responderUrl); $firstSection = FORUM_BOL_ForumService::getInstance()->getFirstSection(); if ($firstSection) { $sectionField->setValue($firstSection->name); } $form->addElement($sectionField->setLabel($language->text('forum', 'section'))); $description = new Textarea('description'); $description->setRequired(true); $sValidator = new StringValidator(1, 50000); $sValidator->setErrorMessage($language->text('forum', 'chars_limit_exceeded', array('limit' => 50000))); $description->addValidator($sValidator); $form->addElement($description); $isPrivate = new CheckboxField('is-private'); $form->addElement($isPrivate); $roles = new CheckboxGroup('roles'); $authService = BOL_AuthorizationService::getInstance(); $roleList = $authService->getRoleList(); $options = array(); foreach ($roleList as $role) { $options[$role->id] = $authService->getRoleLabel($role->name); } $roles->addOptions($options); $roles->setColumnCount(2); $form->addElement($roles); $submit = new Submit('add'); $submit->setValue($language->text('forum', 'add_new_forum_submit')); $form->addElement($submit); $form->setAjax(true); return $form; }
public function ajaxDeleteAttachment() { $result = array('result' => false); if (!isset($_POST['attachmentId'])) { exit(json_encode($result)); } $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $forumService = FORUM_BOL_ForumService::getInstance(); $lang = OW::getLanguage(); $attachment = $attachmentService->findPostAttachmentById((int) $_POST['attachmentId']); if ($attachment) { $userId = OW::getUser()->getId(); $isModerator = OW::getUser()->isAuthorized('forum'); $post = $forumService->findPostById($attachment->postId); if ($post) { if ($isModerator || $post->userId == $userId) { $attachmentService->deleteAttachment($attachment->id); $result = array('result' => true, 'msg' => $lang->text('forum', 'attachment_deleted')); } } } else { $result = array('result' => false); } exit(json_encode($result)); }
/** * Controller's default action * * @param array $params * @throws AuthorizationException * @throws AuthenticateException */ public function index(array $params = null) { $groupId = isset($params['groupId']) && (int) $params['groupId'] ? (int) $params['groupId'] : 0; $forumService = FORUM_BOL_ForumService::getInstance(); $forumGroup = $forumService->getGroupInfo($groupId); if ($forumGroup) { $forumSection = $forumService->findSectionById($forumGroup->sectionId); $isHidden = $forumSection->isHidden; } else { $isHidden = false; } if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } $userId = OW::getUser()->getId(); $this->assign('authMsg', null); if ($isHidden && isset($forumSection)) { $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $eventParams); OW::getEventManager()->trigger($event); if (!$event->getData()) { throw new AuthorizationException(); } if (!OW::getUser()->isAuthorized($forumSection->entity, 'add_topic')) { $status = BOL_AuthorizationService::getInstance()->getActionStatus($forumSection->entity, 'add_topic'); throw new AuthorizationException($status['msg']); } $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId)); OW::getEventManager()->trigger($event); $eventData = $event->getData(); /** @var OW_Component $componentForumCaption */ $componentForumCaption = $eventData['component']; if (!empty($componentForumCaption)) { $this->assign('componentForumCaption', $componentForumCaption->render()); } else { $componentForumCaption = false; $this->assign('componentForumCaption', $componentForumCaption); } $bcItems = array(array('href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId())), 'label' => OW::getLanguage()->text($forumSection->entity, 'view_all_topics'))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']); $groupSelect = array(array('label' => $forumGroup->name, 'value' => $forumGroup->getId(), 'disabled' => false)); OW::getDocument()->setHeading(OW::getLanguage()->text($forumSection->entity, 'create_new_topic', array('group' => $forumGroup->name))); } else { $canEdit = OW::getUser()->isAuthorized('forum', 'edit'); if (!$userId) { throw new AuthorizationException(); } else { if (!$canEdit) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('forum', 'edit'); throw new AuthorizationException($status['msg']); } } if (!OW::getRequest()->isAjax()) { OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum'); } $groupSelect = $forumService->getGroupSelectList(0, false, $userId); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'create_new_topic')); } OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'meta_description_add_topic')); OW::getDocument()->setTitle(OW::getLanguage()->text('forum', 'meta_title_add_topic')); OW::getDocument()->setHeadingIconClass('ow_ic_write'); $this->assign('isHidden', $isHidden); $uid = uniqid(); $form = $this->generateForm($groupSelect, $groupId, $isHidden, $uid); OW::getDocument()->addStyleDeclaration(' .disabled_option { color: #9F9F9F; } '); $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments'); if ($enableAttachments) { $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid); $this->addComponent('attachments', $attachmentCmp); } $this->assign('enableAttachments', $enableAttachments); if (OW::getRequest()->isPost() && $form->isValid($_POST)) { $data = $form->getValues(); if ($data['group']) { $topicDto = new FORUM_BOL_Topic(); $topicDto->userId = $userId; $topicDto->groupId = $data['group']; $topicDto->title = strip_tags($data['title']); $forumService->addTopic($topicDto); $postDto = new FORUM_BOL_Post(); $postDto->topicId = $topicDto->id; $postDto->userId = $userId; $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($data['text'], array('form', 'input', 'button'), null, true)); $postDto->createStamp = time(); $forumService->saveOrUpdatePost($postDto); $topicDto->lastPostId = $postDto->getId(); $forumService->saveOrUpdateTopic($topicDto); // subscribe author to new posts if ($data['subscribe']) { $subService = FORUM_BOL_SubscriptionService::getInstance(); $subs = new FORUM_BOL_Subscription(); $subs->userId = $userId; $subs->topicId = $topicDto->id; $subService->addSubscription($subs); } if ($enableAttachments) { $filesArray = BOL_AttachmentService::getInstance()->getFilesByBundleName('forum', $data['attachmentUid']); if ($filesArray) { $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $skipped = 0; foreach ($filesArray as $file) { $attachmentDto = new FORUM_BOL_PostAttachment(); $attachmentDto->postId = $postDto->id; $attachmentDto->fileName = $file['dto']->origFileName; $attachmentDto->fileNameClean = $file['dto']->fileName; $attachmentDto->fileSize = $file['dto']->size * 1024; $attachmentDto->hash = uniqid(); $added = $attachmentService->addAttachment($attachmentDto, $file['path']); if (!$added) { $skipped++; } } BOL_AttachmentService::getInstance()->deleteAttachmentByBundle('forum', $data['attachmentUid']); if ($skipped) { OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added')); } } } $topicUrl = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicDto->id)); //Newsfeed $params = array('pluginKey' => 'forum', 'entityType' => 'forum-topic', 'entityId' => $topicDto->id, 'userId' => $topicDto->userId); $event = new OW_Event('feed.action', $params); OW::getEventManager()->trigger($event); if ($isHidden && isset($forumSection)) { BOL_AuthorizationService::getInstance()->trackAction($forumSection->entity, 'add_topic'); $params = array('topicId' => $topicDto->id, 'entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'userId' => $topicDto->userId, 'topicUrl' => $topicUrl, 'topicTitle' => $topicDto->title, 'postText' => $postDto->text); $event = new OW_Event('forum.topic_add', $params); OW::getEventManager()->trigger($event); } else { BOL_AuthorizationService::getInstance()->trackAction('forum', 'edit'); } OW::getEventManager()->trigger(new OW_Event(FORUM_BOL_ForumService::EVENT_AFTER_TOPIC_ADD, array('topicId' => $topicDto->id))); $this->redirect($topicUrl); } else { $form->getElement('group')->addError(OW::getLanguage()->text('forum', 'select_group_error')); } } }
/** * Controller's default action * * @param array $params * @throws AuthenticateException */ public function index(array $params = null) { $groupId = isset($params['groupId']) && (int) $params['groupId'] ? (int) $params['groupId'] : 0; $forumService = FORUM_BOL_ForumService::getInstance(); $forumGroup = $forumService->getGroupInfo($groupId); if ($forumGroup) { $forumSection = $forumService->findSectionById($forumGroup->sectionId); $isHidden = $forumSection->isHidden; } else { $isHidden = false; } if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } $userId = OW::getUser()->getId(); $this->assign('authMsg', null); if ($isHidden) { //$isModerator = OW::getUser()->isAuthorized($forumSection->entity); //$canEdit = OW::getUser()->isAuthorized($forumSection->entity, 'add_topic'); $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $eventParams); OW::getEventManager()->trigger($event); if (!$event->getData()) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $eventParams = array('pluginKey' => $forumSection->entity, 'action' => 'add_post'); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams)); } $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId)); OW::getEventManager()->trigger($event); $eventData = $event->getData(); $componentForumCaption = $eventData['component']; if (!empty($componentForumCaption)) { $this->assign('componentForumCaption', $componentForumCaption->render()); } else { $componentForumCaption = false; $this->assign('componentForumCaption', $componentForumCaption); } $bcItems = array(array('href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId())), 'label' => OW::getLanguage()->text($forumSection->entity, 'view_all_topics'))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']); $groupSelect = array(array('label' => $forumGroup->name, 'value' => $forumGroup->getId(), 'disabled' => false)); OW::getDocument()->setHeading(OW::getLanguage()->text($forumSection->entity, 'create_new_topic', array('group' => $forumGroup->name))); } else { $canEdit = OW::getUser()->isAuthorized('forum', 'edit'); if (!$userId || !$canEdit) { $this->assign('authMsg', OW::getLanguage()->text('base', 'authorization_failed_feedback')); } $eventParams = array('pluginKey' => 'forum', 'action' => 'add_post'); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams)); } if (!OW::getRequest()->isAjax()) { OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum'); } $groupSelect = $forumService->getGroupSelectList(0, false, $userId); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'create_new_topic')); } OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'meta_description_add_topic')); OW::getDocument()->setTitle(OW::getLanguage()->text('forum', 'meta_title_add_topic')); OW::getDocument()->setHeadingIconClass('ow_ic_write'); $this->assign('isHidden', $isHidden); $form = $this->generateForm($groupSelect, $groupId, $isHidden); OW::getDocument()->addStyleDeclaration(' .disabled_option { color: #9F9F9F; } '); $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments'); $this->assign('enableAttachments', $enableAttachments); if (OW::getRequest()->isPost() && $form->isValid($_POST)) { $data = $form->getValues(); if ($data['group']) { $topicDto = new FORUM_BOL_Topic(); $topicDto->userId = $userId; $topicDto->groupId = $data['group']; $topicDto->title = strip_tags($data['title']); $forumService->saveOrUpdateTopic($topicDto); $postDto = new FORUM_BOL_Post(); $postDto->topicId = $topicDto->id; $postDto->userId = $userId; $postDto->text = trim($data['text']); $postDto->createStamp = time(); $forumService->saveOrUpdatePost($postDto); $topicDto->lastPostId = $postDto->getId(); $forumService->saveOrUpdateTopic($topicDto); // subscribe author to new posts if ($data['subscribe']) { $subService = FORUM_BOL_SubscriptionService::getInstance(); $subs = new FORUM_BOL_Subscription(); $subs->userId = $userId; $subs->topicId = $topicDto->id; $subService->addSubscription($subs); } $accepted = floatval(OW::getConfig()->getValue('forum', 'attachment_filesize') * 1024 * 1024); if (isset($data['attachments']) && count($data['attachments'])) { $filesArray = $data['attachments']; $filesCount = count($filesArray['name']); $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $skipped = 0; for ($i = 0; $i < $filesCount; $i++) { if (!strlen($filesArray['tmp_name'][$i])) { continue; } // skip unsupported extensions $ext = UTIL_File::getExtension($filesArray['name'][$i]); if (!$attachmentService->fileExtensionIsAllowed($ext)) { $skipped++; continue; } // skip too big files if ($filesArray['size'][$i] > $accepted) { $skipped++; continue; } $attachmentDto = new FORUM_BOL_PostAttachment(); $attachmentDto->postId = $postDto->id; $attachmentDto->fileName = htmlspecialchars($filesArray['name'][$i]); $attachmentDto->fileNameClean = UTIL_File::sanitizeName($attachmentDto->fileName); $attachmentDto->fileSize = $filesArray['size'][$i]; $attachmentDto->hash = uniqid(); $added = $attachmentService->addAttachment($attachmentDto, $filesArray['tmp_name'][$i]); if (!$added) { $skipped++; } } if ($skipped) { OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added')); } } $topicUrl = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicDto->id)); //Newsfeed $params = array('pluginKey' => 'forum', 'entityType' => 'forum-topic', 'entityId' => $topicDto->id, 'userId' => $topicDto->userId); $event = new OW_Event('feed.action', $params); OW::getEventManager()->trigger($event); if ($credits === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } if ($isHidden) { $params = array('topicId' => $topicDto->id, 'entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'userId' => $topicDto->userId, 'topicUrl' => $topicUrl, 'topicTitle' => $topicDto->title, 'postText' => $postDto->text); $event = new OW_Event('forum.topic_add', $params); OW::getEventManager()->trigger($event); } $this->redirect($topicUrl); } else { $form->getElement('group')->addError(OW::getLanguage()->text('forum', 'select_group_error')); } } }
public function countDiscussions() { return FORUM_BOL_ForumService::getInstance()->countAllTopics(); }
public function __construct(array $params) { parent::__construct(); $this->forumService = FORUM_BOL_ForumService::getInstance(); if (!isset($params['groupId']) || !($groupId = (int) $params['groupId'])) { $this->setVisible(false); return; } $groupInfo = $this->forumService->getGroupInfo($groupId); if (!$groupInfo) { $this->setVisible(false); return; } $forumSection = $this->forumService->findSectionById($groupInfo->sectionId); if (!$forumSection) { $this->setVisible(false); return; } $isHidden = $forumSection->isHidden; $userId = OW::getUser()->getId(); if ($isHidden) { $isModerator = OW::getUser()->isAuthorized($forumSection->entity); $event = new OW_Event('forum.can_view', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId), true); OW::getEventManager()->trigger($event); $canView = $event->getData(); $eventParams = array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $eventParams); OW::getEventManager()->trigger($event); $canEdit = $event->getData(); } else { $isModerator = OW::getUser()->isAuthorized('forum'); $canView = OW::getUser()->isAuthorized('forum', 'view'); $canEdit = OW::getUser()->isAuthorized('forum', 'edit'); $canEdit = $canEdit || $isModerator ? true : false; } if ($groupInfo->isPrivate) { if (!$userId) { $this->assign('authFailed', true); return; } else { if (!$isModerator) { if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($groupInfo->roles))) { $this->assign('authFailed', true); return; } } } } if (!$canView) { $this->assign('authFailed', true); return; } $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1; if (!$groupInfo) { $forumUrl = OW::getRouter()->urlForRoute('forum-default'); OW::getApplication()->redirect($forumUrl); } $topicList = $this->forumService->getGroupTopicList($groupId, $page); $topicCount = $this->forumService->getGroupTopicCount($groupId); $userIds = array(); $topicIds = array(); foreach ($topicList as $topic) { array_push($topicIds, $topic['id']); if (isset($topic['lastPost']) && !in_array($topic['lastPost']['userId'], $userIds)) { array_push($userIds, $topic['lastPost']['userId']); } } $attachments = FORUM_BOL_PostAttachmentService::getInstance()->getAttachmentsCountByTopicIdList($topicIds); $this->assign('attachments', $attachments); $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds); $this->assign('usernames', $usernames); $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds); $this->assign('displayNames', $displayNames); $perPage = $this->forumService->getTopicPerPageConfig(); $pageCount = $topicCount ? ceil($topicCount / $perPage) : 1; $paging = new BASE_CMP_Paging($page, $pageCount, $perPage); $this->assign('paging', $paging->render()); $addTopicUrl = OW::getRouter()->urlForRoute('add-topic', array('groupId' => $groupId)); $this->assign('addTopicUrl', $addTopicUrl); $this->assign('canEdit', $canEdit); $this->assign('groupId', $groupId); $this->assign('topicList', $topicList); $this->assign('isHidden', $isHidden); $showCaption = !empty($params['caption']) ? $params['caption'] : false; if ($showCaption) { $groupName = htmlspecialchars($groupInfo->name); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum_page_heading', array('forum' => $groupName))); OW::getDocument()->setHeadingIconClass('ow_ic_forum'); OW::getDocument()->setTitle($groupName); OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'group_meta_description', array('group' => $groupName))); if ($isHidden) { $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId)); OW::getEventManager()->trigger($event); $eventData = $event->getData(); $componentForumCaption = $eventData['component']; if (!empty($componentForumCaption)) { $this->assign('componentForumCaption', $componentForumCaption->render()); } else { $componentForumCaption = false; $this->assign('componentForumCaption', $componentForumCaption); } OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']); } else { $bcItems = array(array('href' => OW::getRouter()->urlForRoute('forum-default'), 'label' => OW::getLanguage()->text('forum', 'forum_index')), array('href' => OW::getRouter()->urlForRoute('section-default', array('sectionId' => $groupInfo->sectionId)), 'label' => $forumSection->name), array('label' => $groupInfo->name)); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems); $this->addComponent('breadcrumb', $breadCrumbCmp); } } $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'group', 'groupId' => $groupId))); $this->assign('showCaption', $showCaption); }
public function __construct() { parent::__construct(); $this->forumService = FORUM_BOL_ForumService::getInstance(); }
/** * Class constructor */ public function __construct(BASE_CLASS_WidgetParameter $paramObj) { parent::__construct(); if (false) { $this->setVisible(false); return; } $this->forumService = FORUM_BOL_ForumService::getInstance(); $confTopicCount = (int) $paramObj->customParamList['topicCount']; $confPostLength = (int) $paramObj->customParamList['postLength']; if (OW::getUser()->isAuthorized('forum')) { $excludeGroupIdList = array(); } else { $excludeGroupIdList = $this->forumService->getPrivateUnavailableGroupIdList(OW::getUser()->getId()); } $topics = $this->forumService->getLatestTopicList($confTopicCount, $excludeGroupIdList); if ($topics) { $this->assign('topics', $topics); $userIds = array(); $groupIds = array(); $toolbars = array(); foreach ($topics as $topic) { if (!in_array($topic['lastPost']['userId'], $userIds)) { array_push($userIds, $topic['lastPost']['userId']); } if (!in_array($topic['groupId'], $groupIds)) { array_push($groupIds, $topic['groupId']); } } $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIds, true, false); $this->assign('avatars', $avatars); $urls = BOL_UserService::getInstance()->getUserUrlsForList($userIds); // toolbars foreach ($topics as $key => $topic) { $userId = $topic['lastPost']['userId']; $toolbars[$topic['lastPost']['postId']][] = array('class' => 'ow_icon_control ow_ic_user', 'href' => !empty($urls[$userId]) ? $urls[$userId] : '#', 'label' => !empty($avatars[$userId]['title']) ? $avatars[$userId]['title'] : ''); $toolbars[$topic['lastPost']['postId']][] = array('label' => $topic['lastPost']['createStamp'], 'class' => 'ow_ipc_date'); } $this->assign('toolbars', $toolbars); $this->assign('postLength', $confPostLength); $groups = $this->forumService->findGroupByIdList($groupIds); $groupList = array(); $sectionIds = array(); foreach ($groups as $group) { $groupList[$group->id] = $group; if (!in_array($group->sectionId, $sectionIds)) { array_push($sectionIds, $group->sectionId); } } $this->assign('groups', $groupList); $sectionList = $this->forumService->findSectionsByIdList($sectionIds); $this->assign('sections', $sectionList); $tb = array(); if (OW::getUser()->isAuthorized('forum', 'edit')) { $tb[] = array('label' => OW::getLanguage()->text('forum', 'add_new'), 'href' => OW::getRouter()->urlForRoute('add-topic-default')); } $tb[] = array('label' => OW::getLanguage()->text('forum', 'goto_forum'), 'href' => OW::getRouter()->urlForRoute('forum-default')); $this->setSettingValue(self::SETTING_TOOLBAR, $tb); } else { if (!OW::getUser()->isAuthorized('forum', 'edit')) { $this->setVisible(false); return; } $this->assign('topics', null); } }
public function sosialSharingGetForumInfo(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); $data['display'] = false; if (empty($params['entityId'])) { return; } if ($params['entityType'] == 'forum_topic') { $topicDto = FORUM_BOL_ForumService::getInstance()->findTopicById($params['entityId']); $forumGroup = FORUM_BOL_ForumService::getInstance()->findGroupById($topicDto->groupId); $forumSection = FORUM_BOL_ForumService::getInstance()->findSectionById($forumGroup->sectionId); if (!empty($topicDto)) { $data['display'] = !$forumSection->isHidden && !$forumGroup->isPrivate && BOL_AuthorizationService::getInstance()->isActionAuthorizedForGuest('forum', 'view'); } $event->setData($data); } }
public function index(array $params = null) { $forumService = FORUM_BOL_ForumService::getInstance(); if (!isset($params['id']) || !($postId = (int) $params['id'])) { throw new Redirect404Exception(); } $postDto = $forumService->findPostById($postId); if (!$postDto) { throw new Redirect404Exception(); } $userId = OW::getUser()->getId(); $topicId = $postDto->topicId; $topicDto = $forumService->findTopicById($topicId); $forumGroup = $forumService->getGroupInfo($topicDto->groupId); $forumSection = $forumService->findSectionById($forumGroup->sectionId); $isHidden = $forumSection->isHidden; if ($isHidden) { $isModerator = OW::getUser()->isAuthorized($forumSection->entity); $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $eventParams); OW::getEventManager()->trigger($event); $canPost = $event->getData(); //check permissions $canEdit = OW::getUser()->isAuthorized($forumSection->entity, 'add_topic', $postDto->userId); } else { $isModerator = OW::getUser()->isAuthorized('forum'); $canPost = true; $canEdit = $postDto->userId == OW::getUser()->getId(); } if ((!$canEdit || !$canPost) && !$isModerator) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $this->assign('postId', $postId); $editPostForm = $this->generateEditPostForm($postDto); $this->addForm($editPostForm); $lang = OW::getLanguage(); $router = OW::getRouter(); if (OW::getRequest()->isPost() && $editPostForm->isValid($_POST)) { $values = $editPostForm->getValues(); $postId = (int) $values['post-id']; $text = $values['text']; $topicId = (int) $values['topic']; $topicUrl = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)); $postDto = $forumService->findPostById($postId); if ($postDto === null || $postDto->userId != $userId && !$isModerator) { $this->redirect($topicUrl); } //save post $postDto->text = $text; $forumService->saveOrUpdatePost($postDto); //save post edit info $editPostDto = $forumService->findEditPost($postId); if ($editPostDto === null) { $editPostDto = new FORUM_BOL_EditPost(); } $editPostDto->postId = $postId; $editPostDto->userId = $userId; $editPostDto->editStamp = time(); $forumService->saveOrUpdateEditPost($editPostDto); if (isset($_FILES['attachments']) && count($_FILES['attachments'])) { $filesArray = $_FILES['attachments']; $filesCount = count($filesArray['name']); $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $skipped = 0; $accepted = floatval(OW::getConfig()->getValue('forum', 'attachment_filesize') * 1024 * 1024); for ($i = 0; $i < $filesCount; $i++) { if (!strlen($filesArray['tmp_name'][$i])) { continue; } // skip unsupported extensions $ext = UTIL_File::getExtension($filesArray['name'][$i]); if (!$attachmentService->fileExtensionIsAllowed($ext)) { $skipped++; continue; } // skip too big files if ($filesArray['size'][$i] > $accepted) { $skipped++; continue; } $attachmentDto = new FORUM_BOL_PostAttachment(); $attachmentDto->postId = $postDto->id; $attachmentDto->fileName = htmlspecialchars($filesArray['name'][$i]); $attachmentDto->fileNameClean = UTIL_File::sanitizeName($attachmentDto->fileName); $attachmentDto->fileSize = $filesArray['size'][$i]; $attachmentDto->hash = uniqid(); $added = $attachmentService->addAttachment($attachmentDto, $filesArray['tmp_name'][$i]); if (!$added) { $skipped++; } } if ($skipped) { OW::getFeedback()->warning($lang->text('forum', 'not_all_attachments_added')); $this->redirect(); } } $this->redirect($forumService->getPostUrl($topicId, $postId, true)); } $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments'); $this->assign('enableAttachments', $enableAttachments); if ($enableAttachments) { $attachments = FORUM_BOL_PostAttachmentService::getInstance()->findAttachmentsByPostIdList(array($postId)); $this->assign('attachments', $attachments); } $topicInfo = $forumService->getTopicInfo($topicId); $groupUrl = $router->urlForRoute('group-default', array('groupId' => $topicDto->groupId)); $topicUrl = $forumService->getPostUrl($topicId, $postId); $lang->addKeyForJs('forum', 'confirm_delete_attachment'); OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'edit_post_title')); OW::getDocument()->setHeadingIconClass('ow_ic_edit'); $this->assign('isHidden', $isHidden); if ($isHidden) { $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId)); OW::getEventManager()->trigger($event); $eventData = $event->getData(); $componentForumCaption = $eventData['component']; if (!empty($componentForumCaption)) { $this->assign('componentForumCaption', $componentForumCaption->render()); } else { $componentForumCaption = false; $this->assign('componentForumCaption', $componentForumCaption); } $bcItems = array(array('href' => OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)), 'label' => OW::getLanguage()->text('forum', 'back_to_topic'))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']); } else { $bcItems = array(array('href' => $router->urlForRoute('forum-default'), 'label' => $lang->text('forum', 'forum_index')), array('href' => $router->urlForRoute('forum-default') . '#section-' . $topicInfo['sectionId'], 'label' => $topicInfo['sectionName']), array('href' => $groupUrl, 'label' => $topicInfo['groupName']), array('href' => $topicUrl, 'label' => htmlspecialchars($topicDto->title))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems, $lang->text('forum', 'post_location')); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum'); } }
/** * Controller's default action * * @param array $params * @throws AuthorizationException * @throws Redirect404Exception */ public function index(array $params = null) { $forumService = FORUM_BOL_ForumService::getInstance(); if (!isset($params['id']) || !($topicId = (int) $params['id'])) { throw new Redirect404Exception(); } $topicDto = $forumService->findTopicById($topicId); if (!$topicDto) { throw new Redirect404Exception(); } $forumGroup = $forumService->getGroupInfo($topicDto->groupId); $forumSection = $forumService->findSectionById($forumGroup->sectionId); $isHidden = $forumSection->isHidden; $userId = OW::getUser()->getId(); if ($isHidden) { $isModerator = OW::getUser()->isAuthorized($forumSection->entity); $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic'); $event = new OW_Event('forum.check_permissions', $eventParams); OW::getEventManager()->trigger($event); $canPost = $event->getData(); //check permissions $canEdit = OW::getUser()->isAuthorized($forumSection->entity, 'add_topic') && $userId == $topicDto->userId; if (!$isModerator) { if (!$canPost) { throw new AuthorizationException(); } else { if (!$canEdit) { $status = BOL_AuthorizationService::getInstance()->getActionStatus($forumSection->entity, 'add_topic'); throw new AuthorizationException($status['msg']); } } } } else { $isModerator = OW::getUser()->isAuthorized('forum'); $canEdit = OW::getUser()->isAuthorized('forum', 'edit') && $userId == $topicDto->userId; if (!$canEdit && !$isModerator) { throw new AuthorizationException(); } } // first topic's post $postDto = $forumService->findTopicFirstPost($topicId); $this->assign('post', $postDto); $uid = uniqid(); $editTopicForm = $this->generateEditTopicForm($topicDto, $postDto, $uid); $this->addForm($editTopicForm); $lang = OW::getLanguage(); $router = OW::getRouter(); $topicInfo = $forumService->getTopicInfo($topicId); $groupUrl = $router->urlForRoute('group-default', array('groupId' => $topicDto->groupId)); $topicUrl = $router->urlForRoute('topic-default', array('topicId' => $topicDto->id)); $lang->addKeyForJs('forum', 'confirm_delete_attachment'); $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments'); $this->assign('enableAttachments', $enableAttachments); if ($enableAttachments) { $attachments = $attachmentService->findAttachmentsByPostIdList(array($postDto->id)); $this->assign('attachments', $attachments); $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid); $this->addComponent('attachmentsCmp', $attachmentCmp); } if (OW::getRequest()->isPost() && $editTopicForm->isValid($_POST)) { $values = $editTopicForm->getValues(); $topicId = (int) $values['topic-id']; $postId = (int) $values['post-id']; $title = trim($values['title']); $text = trim($values['text']); $topicDto = $forumService->findTopicById($topicId); $postDto = $forumService->findPostById($postId); if ($topicDto === null || $postDto === null || $topicDto->userId != $userId && !$isModerator) { exit; } //save topic $topicDto->title = strip_tags($title); $forumService->saveOrUpdateTopic($topicDto); //save post $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($text, array('form', 'input', 'button'), null, true)); $forumService->saveOrUpdatePost($postDto); //save post edit info $editPostDto = $forumService->findEditPost($postId); if ($editPostDto === null) { $editPostDto = new FORUM_BOL_EditPost(); } $editPostDto->postId = $postId; $editPostDto->userId = $userId; $editPostDto->editStamp = time(); $forumService->saveOrUpdateEditPost($editPostDto); if ($enableAttachments) { $filesArray = BOL_AttachmentService::getInstance()->getFilesByBundleName('forum', $values['attachmentUid']); if ($filesArray) { $attachmentService = FORUM_BOL_PostAttachmentService::getInstance(); $skipped = 0; foreach ($filesArray as $file) { $attachmentDto = new FORUM_BOL_PostAttachment(); $attachmentDto->postId = $postDto->id; $attachmentDto->fileName = $file['dto']->origFileName; $attachmentDto->fileNameClean = $file['dto']->fileName; $attachmentDto->fileSize = $file['dto']->size * 1024; $attachmentDto->hash = uniqid(); $added = $attachmentService->addAttachment($attachmentDto, $file['path']); if (!$added) { $skipped++; } } BOL_AttachmentService::getInstance()->deleteAttachmentByBundle('forum', $values['attachmentUid']); if ($skipped) { OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added')); } } } OW::getEventManager()->trigger(new OW_Event('feed.action', array('pluginKey' => 'forum', 'entityType' => 'forum-topic', 'entityId' => $topicDto->id, 'userId' => $topicDto->userId, 'time' => $postDto->createStamp))); OW::getEventManager()->trigger(new OW_Event(FORUM_BOL_ForumService::EVENT_AFTER_TOPIC_EDIT, array('topicId' => $topicDto->id))); $this->redirect($topicUrl); } OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'edit_topic_title')); OW::getDocument()->setHeadingIconClass('ow_ic_edit'); $this->assign('isHidden', $isHidden); if ($isHidden) { $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId)); OW::getEventManager()->trigger($event); $eventData = $event->getData(); /** @var OW_Component $componentForumCaption */ $componentForumCaption = $eventData['component']; if (!empty($componentForumCaption)) { $this->assign('componentForumCaption', $componentForumCaption->render()); } else { $componentForumCaption = false; $this->assign('componentForumCaption', $componentForumCaption); } $bcItems = array(array('href' => OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)), 'label' => OW::getLanguage()->text('forum', 'back_to_topic'))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']); } else { $bcItems = array(array('href' => $router->urlForRoute('forum-default'), 'label' => $lang->text('forum', 'forum_index')), array('href' => $router->urlForRoute('forum-default') . '#section-' . $topicInfo['sectionId'], 'label' => $topicInfo['sectionName']), array('href' => $groupUrl, 'label' => $topicInfo['groupName']), array('href' => $topicUrl, 'label' => htmlspecialchars($topicDto->title))); $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems, $lang->text('forum', 'topic_location')); $this->addComponent('breadcrumb', $breadCrumbCmp); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum'); } }