Exemple #1
0
 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $attDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $attachments = $attachmentService->findAllAttachments();
     if (!$attachments) {
         return;
     }
     foreach ($attachments as $file) {
         OW::getDbo()->query("SELECT 1 ");
         $ext = UTIL_File::getExtension($file->fileName);
         $path = $attachmentService->getAttachmentFilePath($file->id, $file->hash, $ext);
         $fileName = str_replace($attDir, '', $path);
         $content = file_get_contents($configs['url'] . '/' . $fileName);
         if (mb_strlen($content)) {
             OW::getStorage()->fileSetContent($path, $content);
         }
     }
 }
 /**
  * Returns class instance
  *
  * @return FORUM_BOL_PostAttachmentService
  */
 public static function getInstance()
 {
     if (!isset(self::$classInstance)) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #3
0
 public function export($params)
 {
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $dir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $url = OW::getStorage()->getFileUrl($dir);
     /* @var $za ZipArchives */
     $za = $params['zipArchive'];
     $archiveDir = $params['archiveDir'];
     $string = json_encode(array('url' => $url));
     $za->addFromString($archiveDir . '/' . 'configs.txt', $string);
 }
 /**
  * @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())))));
     }
 }
Exemple #5
0
 /**
  * This action adds a post and after execution redirects to default action
  *
  * @param array $params
  * @throws Redirect404Exception
  * @throws AuthenticateException
  */
 public function addPost(array $params)
 {
     if (!isset($params['topicId']) || !($topicId = (int) $params['topicId'])) {
         throw new Redirect404Exception();
     }
     $topicDto = $this->forumService->findTopicById($topicId);
     if (!$topicDto) {
         throw new Redirect404Exception();
     }
     $uid = $params['uid'];
     $addPostForm = $this->generateAddPostForm($topicId, $uid);
     if (OW::getRequest()->isPost() && $addPostForm->isValid($_POST)) {
         $data = $addPostForm->getValues();
         if ($data['topic'] && $data['topic'] == $topicDto->id && !$topicDto->locked) {
             if (!OW::getUser()->getId()) {
                 throw new AuthenticateException();
             }
             $postDto = new FORUM_BOL_Post();
             $postDto->topicId = $data['topic'];
             $postDto->userId = OW::getUser()->getId();
             $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($data['text'], array('form', 'input', 'button'), null, true));
             $postDto->createStamp = time();
             $this->forumService->saveOrUpdatePost($postDto);
             $topicDto->lastPostId = $postDto->getId();
             $this->forumService->saveOrUpdateTopic($topicDto);
             $this->forumService->deleteByTopicId($topicId);
             $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
             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'));
                     }
                 }
             }
             $postUrl = $this->forumService->getPostUrl($topicId, $postDto->id);
             $event = new OW_Event('forum.add_post', array('postId' => $postDto->id, 'topicId' => $topicId, 'userId' => $postDto->userId));
             OW::getEventManager()->trigger($event);
             $forumGroup = $this->forumService->findGroupById($topicDto->groupId);
             if ($forumGroup) {
                 $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
                 if ($forumSection) {
                     $pluginKey = $forumSection->isHidden ? $forumSection->entity : 'forum';
                     $action = $forumSection->isHidden ? 'add_topic' : 'edit';
                     BOL_AuthorizationService::getInstance()->trackAction($pluginKey, $action);
                 }
             }
             $this->redirect($postUrl);
         }
     } else {
         $this->redirect(OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)));
     }
 }
Exemple #6
0
    /**
     * 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'));
            }
        }
    }
Exemple #7
0
 public function __construct(array $params)
 {
     parent::__construct();
     $this->forumService = FORUM_BOL_ForumService::getInstance();
     if (!isset($params['groupId']) || !($groupId = (int) $params['groupId'])) {
         $this->setVisible(false);
         return;
     }
     $groupInfo = $this->forumService->getGroupInfo($groupId);
     if (!$groupInfo) {
         $this->setVisible(false);
         return;
     }
     $forumSection = $this->forumService->findSectionById($groupInfo->sectionId);
     if (!$forumSection) {
         $this->setVisible(false);
         return;
     }
     $isHidden = $forumSection->isHidden;
     $userId = OW::getUser()->getId();
     if ($isHidden) {
         $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         $event = new OW_Event('forum.can_view', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId), true);
         OW::getEventManager()->trigger($event);
         $canView = $event->getData();
         $eventParams = array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId, 'action' => 'add_topic');
         $event = new OW_Event('forum.check_permissions', $eventParams);
         OW::getEventManager()->trigger($event);
         $canEdit = $event->getData();
     } else {
         $isModerator = OW::getUser()->isAuthorized('forum');
         $canView = OW::getUser()->isAuthorized('forum', 'view');
         $canEdit = OW::getUser()->isAuthorized('forum', 'edit');
         $canEdit = $canEdit || $isModerator ? true : false;
     }
     if ($groupInfo->isPrivate) {
         if (!$userId) {
             $this->assign('authFailed', true);
             return;
         } else {
             if (!$isModerator) {
                 if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($groupInfo->roles))) {
                     $this->assign('authFailed', true);
                     return;
                 }
             }
         }
     }
     if (!$canView) {
         $this->assign('authFailed', true);
         return;
     }
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     if (!$groupInfo) {
         $forumUrl = OW::getRouter()->urlForRoute('forum-default');
         OW::getApplication()->redirect($forumUrl);
     }
     $topicList = $this->forumService->getGroupTopicList($groupId, $page);
     $topicCount = $this->forumService->getGroupTopicCount($groupId);
     $userIds = array();
     $topicIds = array();
     foreach ($topicList as $topic) {
         array_push($topicIds, $topic['id']);
         if (isset($topic['lastPost']) && !in_array($topic['lastPost']['userId'], $userIds)) {
             array_push($userIds, $topic['lastPost']['userId']);
         }
     }
     $attachments = FORUM_BOL_PostAttachmentService::getInstance()->getAttachmentsCountByTopicIdList($topicIds);
     $this->assign('attachments', $attachments);
     $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
     $this->assign('usernames', $usernames);
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
     $this->assign('displayNames', $displayNames);
     $perPage = $this->forumService->getTopicPerPageConfig();
     $pageCount = $topicCount ? ceil($topicCount / $perPage) : 1;
     $paging = new BASE_CMP_Paging($page, $pageCount, $perPage);
     $this->assign('paging', $paging->render());
     $addTopicUrl = OW::getRouter()->urlForRoute('add-topic', array('groupId' => $groupId));
     $this->assign('addTopicUrl', $addTopicUrl);
     $this->assign('canEdit', $canEdit);
     $this->assign('groupId', $groupId);
     $this->assign('topicList', $topicList);
     $this->assign('isHidden', $isHidden);
     $showCaption = !empty($params['caption']) ? $params['caption'] : false;
     if ($showCaption) {
         $groupName = htmlspecialchars($groupInfo->name);
         OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'forum_page_heading', array('forum' => $groupName)));
         OW::getDocument()->setHeadingIconClass('ow_ic_forum');
         OW::getDocument()->setTitle($groupName);
         OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'group_meta_description', array('group' => $groupName)));
         if ($isHidden) {
             $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $groupInfo->entityId));
             OW::getEventManager()->trigger($event);
             $eventData = $event->getData();
             $componentForumCaption = $eventData['component'];
             if (!empty($componentForumCaption)) {
                 $this->assign('componentForumCaption', $componentForumCaption->render());
             } else {
                 $componentForumCaption = false;
                 $this->assign('componentForumCaption', $componentForumCaption);
             }
             OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
             OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
         } else {
             $bcItems = array(array('href' => OW::getRouter()->urlForRoute('forum-default'), 'label' => OW::getLanguage()->text('forum', 'forum_index')), array('href' => OW::getRouter()->urlForRoute('section-default', array('sectionId' => $groupInfo->sectionId)), 'label' => $forumSection->name), array('label' => $groupInfo->name));
             $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
             $this->addComponent('breadcrumb', $breadCrumbCmp);
         }
     }
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'group', 'groupId' => $groupId)));
     $this->assign('showCaption', $showCaption);
 }
 /**
  * Deletes post
  * 
  * @param int $postId
  */
 public function deletePost($postId)
 {
     $editPostDao = FORUM_BOL_EditPostDao::getInstance();
     //delete post edit info
     $editPostDao->deleteByPostId($postId);
     //delete post
     $this->postDao->deleteById($postId);
     //delete attachments
     FORUM_BOL_PostAttachmentService::getInstance()->deletePostAttachments($postId);
     //delete flags
     BOL_FlagService::getInstance()->deleteByTypeAndEntityId(FORUM_CLASS_ContentProvider::POST_ENTITY_TYPE, $postId);
     $event = new OW_Event(self::EVENT_AFTER_POST_DELETE, array('postId' => $postId));
     OW::getEventManager()->trigger($event);
 }
 /**
  * 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');
     }
 }
Exemple #10
0
 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');
     }
 }
Exemple #11
0
 /**
  * This action adds a post and after execution redirects to default action
  *
  * @param array $params
  */
 public function addPost(array $params)
 {
     if (!isset($params['topicId']) || !($topicId = (int) $params['topicId'])) {
         throw new Redirect404Exception();
     }
     $topicDto = $this->forumService->findTopicById($topicId);
     if (!$topicDto) {
         throw new Redirect404Exception();
     }
     $addPostForm = $this->generateAddPostForm($topicId);
     if (OW::getRequest()->isPost() && $addPostForm->isValid($_POST)) {
         $data = $addPostForm->getValues();
         if ($data['topic'] && $data['topic'] == $topicDto->id && !$topicDto->locked) {
             if (!OW::getUser()->getId()) {
                 throw new AuthenticateException();
             }
             $postDto = new FORUM_BOL_Post();
             $postDto->topicId = $data['topic'];
             $postDto->userId = OW::getUser()->getId();
             $postDto->text = trim($data['text']);
             $postDto->createStamp = time();
             $this->forumService->saveOrUpdatePost($postDto);
             $topicDto->lastPostId = $postDto->getId();
             $this->forumService->saveOrUpdateTopic($topicDto);
             $this->forumService->deleteByTopicId($topicId);
             if (isset($data['attachments']) && count($data['attachments'])) {
                 $filesArray = $data['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(OW::getLanguage()->text('forum', 'not_all_attachments_added'));
                 }
             }
             $postUrl = $this->forumService->getPostUrl($topicId, $postDto->id);
             $event = new OW_Event('forum.add_post', array('postId' => $postDto->id, 'topicId' => $topicId, 'userId' => $postDto->userId));
             OW::getEventManager()->trigger($event);
             $forumGroup = $this->forumService->findGroupById($topicDto->groupId);
             if ($forumGroup) {
                 $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
                 if ($forumSection) {
                     $pluginKey = $forumSection->isHidden ? $forumSection->entity : 'forum';
                     $eventParams = array('pluginKey' => $pluginKey, 'action' => 'add_post');
                     if ($credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
                         OW::getEventManager()->call('usercredits.track_action', $eventParams);
                     }
                 }
             }
             $this->redirect($postUrl);
         }
     } else {
         $this->redirect(OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)));
     }
 }
    /**
     * 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'));
            }
        }
    }