public function actionRespond() { $form = $this->_getFormOrError($this->_input->filterSingle('form_id', XenForo_Input::UINT)); $fieldModel = $this->_getFieldModel(); $destinationOptionModel = $this->_getDestinationOptionModel(); $attachmentParams = array(); // check to see if attachments are enabled $attachmentsEnabled = $destinationOptionModel->getAttachmentsEnabled($form['form_id']); if ($attachmentsEnabled) { $attachmentParams = array('hash' => md5(uniqid('', true)), 'content_type' => 'form', 'content_data' => array('form_id' => $form['form_id'])); } $params = array(); if (XenForo_Visitor::getUserId()) { $params['visitor'] = XenForo_Visitor::getInstance(); } else { $params['visitor'] = array('username' => 'Guest'); } // process GET supplied default values $fields = $fieldModel->prepareFields($fieldModel->getFields(array('form_id' => $form['form_id'])), true); foreach ($fields as $fieldId => &$field) { $field['default_value'] = $this->_renderTemplate($field['default_value'], $params); $getDefaultValue = $this->_input->filterSingle($field['field_name'], XenForo_Input::STRING); if ($getDefaultValue) { $field['default_value'] = $getDefaultValue; } } $viewParams = array('form' => $form, 'fields' => $fields, 'attachmentManager' => $attachmentsEnabled, 'attachmentParams' => $attachmentParams, 'attachmentConstraints' => $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints(), 'captcha' => XenForo_Captcha_Abstract::createDefault()); return $this->responseView('LiquidPro_SimpleForms_ViewPublic_Form_Respond', 'form_respond', $viewParams); }
public function actionEdit() { $mediaID = $this->_input->filterSingle('media_id', XenForo_Input::UINT); if (!($media = $this->getModelFromCache('EWRmedio_Model_Media')->getMediaByID($mediaID))) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, XenForo_Link::buildPublicLink('media')); } if (!$this->perms['mod'] && $media['user_id'] !== XenForo_Visitor::getUserId()) { return $this->responseNoPermission(); } if ($this->perms['admin'] || $media['user_id'] == XenForo_Visitor::getUserId()) { $this->perms['alter'] = true; } if ($this->_request->isPost()) { $input = $this->_input->filter(array('category_id' => XenForo_Input::UINT, 'media_title' => XenForo_Input::STRING, 'media_hours' => XenForo_Input::UINT, 'media_minutes' => XenForo_Input::UINT, 'media_seconds' => XenForo_Input::UINT, 'media_keywords' => XenForo_Input::STRING, 'media_keyarray' => XenForo_Input::ARRAY_SIMPLE, 'media_keylinks' => XenForo_Input::ARRAY_SIMPLE, 'media_oldlinks' => XenForo_Input::ARRAY_SIMPLE, 'media_custom1' => XenForo_Input::ARRAY_SIMPLE, 'media_custom2' => XenForo_Input::ARRAY_SIMPLE, 'media_custom3' => XenForo_Input::ARRAY_SIMPLE, 'media_custom4' => XenForo_Input::ARRAY_SIMPLE, 'media_custom5' => XenForo_Input::ARRAY_SIMPLE, 'submit' => XenForo_Input::STRING)); $input['media_id'] = $media['media_id']; $input['media_description'] = $this->getHelper('Editor')->getMessageText('media_description', $this->_input); $input['bypass'] = $this->perms['bypass']; if (!empty($input['media_keyarray'])) { $input['media_keywords'] = implode(',', $input['media_keyarray']); } if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) { return $this->responseCaptchaFailed(); } $media = $this->getModelFromCache('EWRmedio_Model_Media')->updateMedia($input); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('media', $media)); } $category = $this->getModelFromCache('EWRmedio_Model_Categories')->getCategoryByID($media['category_id']); $viewParams = array('perms' => $this->perms, 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'media' => $media, 'customs' => $this->getModelFromCache('EWRmedio_Model_Custom')->getCustomOptions($media), 'keylinks' => $this->getModelFromCache('EWRmedio_Model_Media')->getKeywordLinks($media), 'fullList' => $this->getModelFromCache('EWRmedio_Model_Lists')->getCategoryList(), 'services' => $this->getModelFromCache('EWRmedio_Model_Services')->getServices(), 'breadCrumbs' => array_reverse($this->getModelFromCache('EWRmedio_Model_Lists')->getCrumbs($category))); if (!XenForo_Application::get('options')->EWRmedio_newkeywords) { $viewParams['keywords'] = $this->getModelFromCache('EWRmedio_Model_Media')->getKeywordNolinks($media); } return $this->responseView('EWRmedio_ViewPublic_MediaEdit', 'EWRmedio_MediaEdit', $viewParams); }
public function actionCreatePage() { if (!$this->perms['create']) { return $this->responseNoPermission(); } $input = array('page_name' => '', 'page_content' => '', 'page_type' => $this->_input->filterSingle('page_type', XenForo_Input::STRING), 'page_index' => 0, 'page_protect' => 0, 'page_sidebar' => 1, 'page_sublist' => 1, 'page_groups' => '', 'page_users' => '', 'page_admins' => ''); $attachmentParams = array('hash' => md5(uniqid('', true)), 'content_type' => 'wiki', 'content_data' => array('page_id' => '')); $attachmentConstraints = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints(); $attachments = array(); if ($this->_request->isPost()) { $input = $this->_input->filter(array('attachment_hash' => XenForo_Input::STRING, 'page_name' => XenForo_Input::STRING, 'page_slug' => XenForo_Input::STRING, 'page_type' => XenForo_Input::STRING, 'page_parent' => XenForo_Input::UINT, 'submit' => XenForo_Input::STRING)) + $input; $input['page_content'] = $this->getHelper('Editor')->getMessageText('page_content', $this->_input); if ($this->perms['admin']) { $input = $this->_input->filter(array('page_index' => XenForo_Input::UINT, 'page_protect' => XenForo_Input::UINT, 'page_sidebar' => XenForo_Input::UINT, 'page_sublist' => XenForo_Input::UINT, 'page_groups' => array(XenForo_Input::UINT, array('array' => true)), 'usernames' => XenForo_Input::STRING, 'administrators' => XenForo_Input::STRING)) + $input; $input['page_groups'] = implode(',', $input['page_groups']); } if ($input['page_content'] && $input['submit']) { if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) { return $this->responseCaptchaFailed(); } $page = $this->getModelFromCache('EWRcarta_Model_Pages')->updatePage($input); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('wiki', $page)); } if ($input['attachment_hash']) { $attachmentParams['hash'] = $input['attachment_hash']; $attachments = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentsByTempHash($attachmentParams['hash']); } } if ($input['page_type'] == 'phpfile' && !$this->perms['admin']) { $input['page_type'] = 'bbcode'; } $viewParams = array('attachmentParams' => $attachmentParams, 'attachments' => $this->getModelFromCache('XenForo_Model_Attachment')->prepareAttachments($attachments), 'attachmentConstraints' => $attachmentConstraints, 'perms' => $this->perms, 'input' => $input, 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'groups' => $this->getModelFromCache('XenForo_Model_UserGroup')->getUserGroupOptions($input['page_groups']), 'fullList' => $this->getModelFromCache('EWRcarta_Model_Lists')->getPageList()); return $this->responseView('EWRcarta_ViewPublic_PageCreate', 'EWRcarta_PageCreate', $viewParams); }
public function actionCreateThread() { $response = parent::actionCreateThread(); if (!empty($response->params['forum']['node_id']) && $this->_getCaptchaModel()->checkRequiredCaptcha('create_thread_captcha', $response->params['forum']['node_id'])) { $response->params['captcha'] = XenForo_Captcha_Abstract::createDefault(true); } return $response; }
protected function _loginErrorResponse($error, $defaultLogin, $needCaptcha, $redirect = false) { if ($needCaptcha) { $captcha = XenForo_Captcha_Abstract::createDefault(true); } else { $captcha = false; } return $this->responseView('XenForo_ViewPublic_Login', 'error_with_login', array('text' => $error, 'defaultLogin' => $defaultLogin, 'captcha' => $captcha, 'redirect' => $redirect)); }
protected function _loginErrorResponse($error, $defaultLogin, $needCaptcha, $redirect = false, array $postData = null) { if ($needCaptcha && XenForo_Application::getOptions()->loginLimit == 'captcha') { $captcha = XenForo_Captcha_Abstract::createDefault(true); } else { $captcha = false; } return $this->responseView('XenForo_ViewPublic_Login', 'error_with_login', array('text' => $error, 'defaultLogin' => $defaultLogin, 'captcha' => $captcha, 'redirect' => $redirect, 'postData' => $postData)); }
protected function _getDefaultViewParams(array $forum, array $thread, array $posts, $page = 1, array $viewParams = array()) { $viewParams = parent::_getDefaultViewParams($forum, $thread, $posts, $page, $viewParams); //prd($thread); if (!empty($thread['node_id']) && $this->_getCaptchaModel()->checkRequiredCaptcha('thread_reply_captcha', $thread['node_id'])) { $viewParams['captcha'] = XenForo_Captcha_Abstract::createDefault(true); } return $viewParams; }
protected function _getRegisterFormResponse(array $fields, array $errors = array()) { $options = XenForo_Application::get('options'); if (empty($fields['timezone'])) { $fields['timezone'] = $options->guestTimeZone; $fields['timezoneAuto'] = true; } $viewParams = array('fields' => $fields, 'errors' => $errors, 'timeZones' => XenForo_Helper_TimeZone::getTimeZones(), 'dobRequired' => $options->get('registrationSetup', 'requireDob'), 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'tosUrl' => XenForo_Dependencies_Public::getTosUrl()); return $this->responseView('XenForo_ViewPublic_Register_Form', 'register_form', $viewParams, $this->_getRegistrationContainerParams()); }
/** * Displays a form to retrieve a lost password. * * @return XenForo_ControllerResponse_Abstract */ public function actionIndex() { if (XenForo_Visitor::getUserId()) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildPublicLink('index')); } $viewParams = array(); if (XenForo_Application::get('options')->lostPasswordCaptcha) { $viewParams['captcha'] = XenForo_Captcha_Abstract::createDefault(); } return $this->responseView('XenForo_ViewPublic_LostPassword_Form', 'lost_password', $viewParams); }
protected function _getRegisterFormResponse(array $fields, array $errors = array()) { $options = XenForo_Application::get('options'); if (empty($fields['timezone'])) { $fields['timezone'] = $options->guestTimeZone; $fields['timezoneAuto'] = true; } if (!empty($fields['custom_fields']) && is_array($fields['custom_fields'])) { $customFieldValues = $fields['custom_fields']; } else { $customFieldValues = array(); } XenForo_Application::getSession()->set('registrationTime', time()); $regKey = md5(uniqid('xf', true)); XenForo_Application::getSession()->set('registrationKey', $regKey); $customFields = $this->_getFieldModel()->prepareUserFields($this->_getFieldModel()->getUserFields(array('registration' => true)), true, $customFieldValues, false); $viewParams = array('fields' => $fields, 'errors' => $errors, 'timeZones' => XenForo_Helper_TimeZone::getTimeZones(), 'dobRequired' => $options->get('registrationSetup', 'requireDob'), 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'tosUrl' => XenForo_Dependencies_Public::getTosUrl(), 'regKey' => $regKey, 'fieldMap' => $this->_getFieldHashMap(), 'customFields' => $customFields, 'customFieldHoneyPot' => $this->_getCustomFieldHoneyPot($customFields)); return $this->responseView('XenForo_ViewPublic_Register_Form', 'register_form', $viewParams, $this->_getRegistrationContainerParams()); }
public function actionRespond() { $form = $this->_getFormOrError($this->_input->filterSingle('form_id', XenForo_Input::UINT)); $fieldModel = $this->_getFieldModel(); $destinationOptionModel = $this->_getDestinationOptionModel(); $attachmentModel = $this->getModelFromCache('XenForo_Model_Attachment'); $attachmentParams = array(); $constraints = $attachmentModel->getAttachmentConstraints(); // check to see if attachments are enabled $attachmentTypes = $destinationOptionModel->getAttachmentsDestinationHandlers($form['form_id']); if ($attachmentTypes) { $attachmentParams = array('hash' => md5(uniqid('', true)), 'content_type' => 'form', 'content_data' => array('form_id' => $form['form_id'])); $attachmentHandler = $attachmentModel->getAttachmentHandler($attachmentParams['content_type']); if (!$attachmentHandler || !$attachmentHandler->canUploadAndManageAttachments($attachmentParams['content_data'])) { XenForo_Error::debug('form_destination_id ' . $form_destination_id . ' does not accept attachments for the user ' . XenForo_Visitor::getUserId()); throw new XenForo_Exception(new XenForo_Phrase('attachment_cannot_be_shown_at_this_time'), true); } $constraints = $attachmentHandler->getAttachmentConstraints(); } $params = array(); if (XenForo_Visitor::getUserId()) { $params['visitor'] = XenForo_Visitor::getInstance(); } else { $params['visitor'] = array('username' => 'Guest'); } // process GET supplied default values $fields = $fieldModel->prepareFields($fieldModel->getFields(array('form_id' => $form['form_id'])), true); foreach ($fields as $fieldId => &$field) { $field['default_value'] = $this->_renderTemplate($field['default_value'], $params); $getDefaultValue = $this->_input->filterSingle($field['field_name'], XenForo_Input::STRING); if ($getDefaultValue) { $field['default_value'] = $getDefaultValue; } } $viewParams = array('form' => $form, 'fields' => $fields, 'attachmentManager' => !empty($attachmentTypes), 'attachmentParams' => $attachmentParams, 'attachmentConstraints' => $constraints, 'captcha' => XenForo_Captcha_Abstract::createDefault()); return $this->responseView('LiquidPro_SimpleForms_ViewPublic_Form_Respond', 'form_respond', $viewParams); }
/** * Displays a form to create a new thread in this forum. * * @return XenForo_ControllerResponse_Abstract */ public function actionCreateThread() { $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT); $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING); $ftpHelper = $this->getHelper('ForumThreadPost'); $forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName); $forumId = $forum['node_id']; $this->_assertCanPostThreadInForum($forum); $maxResponses = XenForo_Application::get('options')->pollMaximumResponses; if ($maxResponses == 0) { $maxResponses = 10; // number to create for non-JS users } if ($maxResponses > 2) { $pollExtraArray = array_fill(0, $maxResponses - 2, true); } else { $pollExtraArray = array(); } $title = $this->_input->filterSingle('title', XenForo_Input::STRING); $prefixId = $this->_input->filterSingle('prefix_id', XenForo_Input::STRING); $tags = ''; $draft = $this->_getDraftModel()->getDraftByUserKey("forum-{$forumId}", XenForo_Visitor::getUserId()); $attachmentHash = null; if (!$prefixId) { $prefixId = $forum['default_prefix_id']; } $poll = array(); if ($draft) { $extra = @unserialize($draft['extra_data']); if (!empty($extra['prefix_id']) && !$prefixId) { $prefixId = $extra['prefix_id']; } if (!empty($extra['title']) && !$title) { $title = $extra['title']; } if (!empty($extra['attachment_hash'])) { $attachmentHash = $extra['attachment_hash']; } if (!empty($extra['tags'])) { $tags = $extra['tags']; } if (!empty($extra['poll'])) { $poll = $extra['poll']; if (!empty($poll['responses'])) { $poll['extraResponses'] = array(); $poll['responses'] = array_filter($poll['responses']); if (sizeof($poll['responses']) < 2) { $poll['extraResponses'] = array_fill(0, 2 - count($poll['responses']), true); } } } } $attachmentParams = $this->_getForumModel()->getAttachmentParams($forum, array('node_id' => $forum['node_id']), null, null, $attachmentHash); /** @var XenForo_Model_Tag $tagModel */ $tagModel = $this->getModelFromCache('XenForo_Model_Tag'); $tagger = $tagModel->getTagger('thread'); $tagger->setPermissionsFromContext($forum); $viewParams = array('thread' => array('discussion_open' => 1, 'prefix_id' => $forum['default_prefix_id']), 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'title' => $title, 'prefixId' => $prefixId, 'tags' => $tags, 'draft' => $draft, 'prefixes' => $this->_getPrefixModel()->getUsablePrefixesInForums($forumId), 'attachmentParams' => $attachmentParams, 'watchState' => $this->_getThreadWatchModel()->getThreadWatchStateForVisitor(false), 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'canEditTags' => $this->_getThreadModel()->canEditTags(null, $forum), 'tagPermissions' => $tagger->getPermissions(), 'poll' => $poll, 'canPostPoll' => $this->_getForumModel()->canPostPollInForum($forum), 'pollExtraArray' => $pollExtraArray, 'canLockUnlockThread' => $this->_getForumModel()->canLockUnlockThreadInForum($forum), 'canStickUnstickThread' => $this->_getForumModel()->canStickUnstickThreadInForum($forum), 'attachmentConstraints' => $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints()); return $this->responseView('XenForo_ViewPublic_Thread_Create', 'thread_create', $viewParams); }
/** * Returns a new CAPTCHA * * @return XenForo_ControllerResponse_View */ public function actionCaptcha() { $viewParams = array('captcha' => XenForo_Captcha_Abstract::createDefault()); return $this->responseView('XenForo_ViewPublic_Misc_Captcha', 'captcha', $viewParams); }
/** * Displays a form to add a reply to a thread. * * @return XenForo_ControllerResponse_Abstract */ public function actionReply() { $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT); $ftpHelper = $this->getHelper('ForumThreadPost'); list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId); $this->_assertCanReplyToThread($thread, $forum); $quickReplyAttachmentHash = $this->_input->filterSingle('attachment_hash', XenForo_Input::STRING); $attachmentParams = $this->_getForumModel()->getAttachmentParams($forum, array('thread_id' => $thread['thread_id']), null, null, $quickReplyAttachmentHash); $attachments = !empty($attachmentParams['attachments']) ? $attachmentParams['attachments'] : array(); $defaultMessage = ''; $quotePost = null; if ($quoteId = $this->_input->filterSingle('quote', XenForo_Input::UINT)) { $postModel = $this->_getPostModel(); $quotePost = $postModel->getPostById($quoteId, array('join' => XenForo_Model_Post::FETCH_USER)); if ($quotePost && $quotePost['thread_id'] == $threadId && $postModel->canViewPost($quotePost, $thread, $forum)) { $defaultMessage = $postModel->getQuoteTextForPost($quotePost); } } else { if ($this->_input->inRequest('more_options')) { $defaultMessage = $this->getHelper('Editor')->getMessageText('message', $this->_input); } } $viewParams = array('post' => $quotePost, 'thread' => $thread, 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'attachmentParams' => $attachmentParams, 'attachments' => $attachments, 'attachmentConstraints' => $this->_getAttachmentModel()->getAttachmentConstraints(), 'defaultMessage' => $defaultMessage, 'watchState' => $this->_getThreadWatchModel()->getThreadWatchStateForVisitor($threadId), 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'canLockUnlockThread' => $this->_getThreadModel()->canLockUnlockThread($thread, $forum), 'canStickUnstickThread' => $this->_getThreadModel()->canStickUnstickThread($thread, $forum)); return $this->responseView('XenForo_ViewPublic_Thread_Reply', 'thread_reply', $viewParams); }
public function actionSubmit() { if (!$this->perms['submit']) { return $this->responseNoPermission(); } if ($this->_request->isPost()) { $input = $this->_input->filter(array('category_id' => XenForo_Input::UINT, 'service_id' => XenForo_Input::UINT, 'service_value' => XenForo_Input::STRING, 'service_value2' => XenForo_Input::STRING, 'media_thumb' => XenForo_Input::STRING, 'media_title' => XenForo_Input::STRING, 'media_hours' => XenForo_Input::UINT, 'media_minutes' => XenForo_Input::UINT, 'media_seconds' => XenForo_Input::UINT, 'media_keywords' => XenForo_Input::STRING, 'media_keyarray' => XenForo_Input::ARRAY_SIMPLE, 'media_custom1' => XenForo_Input::ARRAY_SIMPLE, 'media_custom2' => XenForo_Input::ARRAY_SIMPLE, 'media_custom3' => XenForo_Input::ARRAY_SIMPLE, 'media_custom4' => XenForo_Input::ARRAY_SIMPLE, 'media_custom5' => XenForo_Input::ARRAY_SIMPLE, 'media_node' => XenForo_Input::UINT, 'create_thread' => XenForo_Input::UINT, 'submit' => XenForo_Input::STRING)); $input['bypass'] = $this->perms['bypass']; $input['media_description'] = $this->getHelper('Editor')->getMessageText('media_description', $this->_input); if (!($source = $this->_input->filterSingle('source', XenForo_Input::STRING))) { if (!empty($input['media_keyarray'])) { $input['media_keywords'] = implode(',', $input['media_keyarray']); } if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) { return $this->responseCaptchaFailed(); } $media = $this->getModelFromCache('EWRmedio_Model_Media')->updateMedia($input); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('media', $media)); } } if ($source = $this->_input->filterSingle('source', XenForo_Input::STRING)) { $media = $this->getModelFromCache('EWRmedio_Model_Submit')->fetchFeedInfo($source); } $options = XenForo_Application::get('options'); $forums = array(); foreach ($options->EWRmedio_autoforum as $forum) { $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($forum); if ($forum && $this->getModelFromCache('XenForo_Model_Forum')->canPostThreadInForum($forum)) { $forums[] = $forum; } } $viewParams = array('captcha' => XenForo_Captcha_Abstract::createDefault(), 'media' => !empty($media) ? $media : false, 'customs' => $this->getModelFromCache('EWRmedio_Model_Custom')->getCustomOptions(), 'forums' => $forums, 'checked' => $options->EWRmedio_autocheck ? 'checked' : '', 'fullList' => $this->getModelFromCache('EWRmedio_Model_Lists')->getCategoryList()); if (!$options->EWRmedio_newkeywords) { $viewParams['keywords'] = $this->getModelFromCache('EWRmedio_Model_Keywords')->getAllKeywords(); } return $this->responseView('EWRmedio_ViewPublic_Submit', 'EWRmedio_Submit', $viewParams); }
public function actionEdit() { $pageSlug = $this->_input->filterSingle('page_slug', XenForo_Input::STRING); if (!($page = $this->getModelFromCache('EWRcarta_Model_Pages')->getPageBySlug($pageSlug))) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('wiki')); } if (!empty($page['page_groups']) || !empty($page['page_users']) || !empty($page['page_admins'])) { $visitor = XenForo_Visitor::getInstance(); if (!empty($page['page_groups'])) { $groups = explode(',', $page['page_groups']); $member = false; foreach ($groups as $group) { if ($visitor->isMemberOf($group)) { $this->perms['edit'] = true; $override = true; break; } } } if (!empty($page['page_users'])) { $userIDs = explode(',', $page['page_users']); if (in_array($visitor['user_id'], $userIDs)) { $this->perms['edit'] = true; $override = true; } $users = $this->getModelFromCache('XenForo_Model_User')->getUsersByIds($userIDs); $usernames = array(); foreach ($users as $user) { $usernames[] = $user['username']; } $page['page_users'] = implode(', ', $usernames); } if (!empty($page['page_admins'])) { $userIDs = explode(',', $page['page_admins']); if (in_array($visitor['user_id'], $userIDs)) { $this->perms['edit'] = true; $this->perms['masks'] = true; $override = true; } $users = $this->getModelFromCache('XenForo_Model_User')->getUsersByIds($userIDs); $usernames = array(); foreach ($users as $user) { $usernames[] = $user['username']; } $page['page_admins'] = implode(', ', $usernames); } } if (!$this->perms['edit']) { return $this->responseNoPermission(); } if (!$this->perms['admin'] && $page['page_protect'] && empty($override)) { return $this->responseNoPermission(); } $page['timestamp'] = XenForo_Application::$time; $attachmentParams = array('hash' => md5(uniqid('', true)), 'content_type' => 'wiki', 'content_data' => array('page_id' => $page['page_id'])); $attachmentConstraints = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints(); $attachments = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentsByContentId('wiki', $page['page_id']); if ($this->_request->isPost()) { $input = $this->_input->filter(array('attachment_hash' => XenForo_Input::STRING, 'page_name' => XenForo_Input::STRING, 'page_slugNew' => XenForo_Input::STRING, 'page_type' => XenForo_Input::STRING, 'page_parent' => XenForo_Input::UINT, 'timestamp' => XenForo_Input::UINT, 'submit' => XenForo_Input::STRING)); $input['page_id'] = $page['page_id']; $input['page_content'] = $this->getHelper('Editor')->getMessageText('page_content', $this->_input); $input['page_slug'] = $input['page_slugNew']; if ($this->perms['admin']) { $input = $this->_input->filter(array('page_index' => XenForo_Input::UINT, 'page_protect' => XenForo_Input::UINT, 'page_sidebar' => XenForo_Input::UINT, 'page_sublist' => XenForo_Input::UINT)) + $input; $page['page_index'] = $input['page_index']; $page['page_protect'] = $input['page_protect']; $page['page_sidebar'] = $input['page_sidebar']; $page['page_sublist'] = $input['page_sublist']; } if ($this->perms['admin'] || $this->perms['masks']) { $input = $this->_input->filter(array('page_groups' => array(XenForo_Input::UINT, array('array' => true)), 'usernames' => XenForo_Input::STRING, 'administrators' => XenForo_Input::STRING)) + $input; $input['page_groups'] = implode(',', $input['page_groups']); $page['page_groups'] = $input['page_groups']; $page['page_users'] = $input['usernames']; $page['page_admins'] = $input['administrators']; } if ($input['page_content'] && $input['submit']) { if ($page['page_date'] > $input['timestamp']) { throw new XenForo_Exception(new XenForo_Phrase('page_has_been_edited'), true); } if (!XenForo_Captcha_Abstract::validateDefault($this->_input)) { return $this->responseCaptchaFailed(); } $page = $this->getModelFromCache('EWRcarta_Model_Pages')->updatePage($input); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('wiki', $page)); } $attachmentParams['hash'] = $input['attachment_hash']; $page['page_name'] = $input['page_name']; $page['page_type'] = $input['page_type']; $page['page_parent'] = $input['page_parent']; $page['page_content'] = $input['page_content']; $page['timestamp'] = $input['timestamp']; $attachments += $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentsByTempHash($attachmentParams['hash']); } $children = array($page['page_id'] => $page); $children = $this->getModelFromCache('EWRcarta_Model_Lists')->getPageList($page['page_id'], $children); $fullList = $this->getModelFromCache('EWRcarta_Model_Lists')->getPageList(); foreach ($fullList as &$list) { $list['disabled'] = array_key_exists($list['page_id'], $children) ? true : false; } $forums = array(); foreach (XenForo_Application::get('options')->EWRcarta_wikiforum as $forum) { if ($forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($forum)) { $forums[] = $forum; } } $viewParams = array('attachmentParams' => $attachmentParams, 'attachments' => $this->getModelFromCache('XenForo_Model_Attachment')->prepareAttachments($attachments), 'attachmentConstraints' => $attachmentConstraints, 'perms' => $this->perms, 'page' => $page, 'input' => !empty($input) ? $input : false, 'forums' => !empty($forums) ? $forums : false, 'thread' => !empty($page['thread_id']) ? $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($page['thread_id']) : false, 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'fullList' => $fullList, 'groups' => $this->getModelFromCache('XenForo_Model_UserGroup')->getUserGroupOptions($page['page_groups']), 'breadCrumbs' => array_reverse($this->getModelFromCache('EWRcarta_Model_Lists')->getCrumbs($page))); return $this->responseView('EWRcarta_ViewPublic_PageEdit', 'EWRcarta_PageEdit', $viewParams); }
/** * Displays a form to create a new thread in this forum. * * @return XenForo_ControllerResponse_Abstract */ public function actionCreateThread() { $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT); $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING); $ftpHelper = $this->getHelper('ForumThreadPost'); $forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName); $forumId = $forum['node_id']; $this->_assertCanPostThreadInForum($forum); $attachmentParams = $this->getModelFromCache('XenForo_Model_Forum')->getAttachmentParams($forum, array('node_id' => $forum['node_id'])); $viewParams = array('thread' => array('discussion_open' => 1), 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'attachmentParams' => $attachmentParams, 'watchState' => $this->_getThreadWatchModel()->getThreadWatchStateForVisitor(false), 'captcha' => XenForo_Captcha_Abstract::createDefault(), 'canLockUnlockThread' => $this->_getForumModel()->canLockUnlockThreadInForum($forum), 'canStickUnstickThread' => $this->_getForumModel()->canStickUnstickThreadInForum($forum), 'attachmentConstraints' => $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints()); return $this->responseView('XenForo_ViewPublic_Thread_Create', 'thread_create', $viewParams); }