public function actionPostIndex() { if (!$this->_getConversationModel()->canStartConversations($errorPhraseKey)) { throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey); } $input = $this->_input->filter(array('recipients' => XenForo_Input::STRING, 'conversation_title' => XenForo_Input::STRING)); /* @var $editorHelper XenForo_ControllerHelper_Editor */ $editorHelper = $this->getHelper('Editor'); $input['message_body'] = $editorHelper->getMessageText('message_body', $this->_input); $input['message_body'] = XenForo_Helper_String::autoLinkBbCode($input['message_body']); $visitor = XenForo_Visitor::getInstance(); /* @var $conversationDw XenForo_DataWriter_ConversationMaster */ $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster'); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $visitor->toArray()); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $input['message_body']); $conversationDw->set('user_id', $visitor['user_id']); $conversationDw->set('username', $visitor['username']); $conversationDw->set('title', $input['conversation_title']); $conversationDw->addRecipientUserNames(explode(',', $input['recipients'])); // checks permissions $messageDw = $conversationDw->getFirstMessageDw(); $messageDw->set('message', $input['message_body']); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_getAttachmentHelper()->getAttachmentTempHash()); $conversationDw->preSave(); if (!$conversationDw->hasErrors()) { $this->assertNotFlooding('conversation'); } $conversationDw->save(); $conversation = $conversationDw->getMergedData(); $this->_getConversationModel()->markConversationAsRead($conversation['conversation_id'], XenForo_Visitor::getUserId(), XenForo_Application::$time); $this->_request->setParam('conversation_id', $conversation['conversation_id']); return $this->responseReroute(__CLASS__, 'single'); }
public function actionSave() { if ($this->_input->inRequest('preview')) { return $this->responseReroute(__CLASS__, 'preview'); } $this->_assertPostOnly(); $feedId = $this->_input->filterSingle('feed_id', XenForo_Input::UINT); $data = $this->_getFeedFormData(); $data['message_template'] = $this->getHelper('Editor')->getMessageText('message_template', $this->_input); $data['message_template'] = XenForo_Helper_String::autoLinkBbCode($data['message_template']); if ($data['user_id'] == -1) { $username = $this->_input->filterSingle('username', XenForo_Input::STRING); if ($user = $this->getModelFromCache('XenForo_Model_User')->getUserByName($username)) { $data['user_id'] = $user['user_id']; } } $data['user_id'] = intval(max($data['user_id'], 0)); $writer = XenForo_DataWriter::create('XenForo_DataWriter_Feed'); if ($feedId) { $writer->setExistingData($feedId); } $writer->bulkSet($data); $writer->save(); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('feeds')); }
public function updateCategory($input) { $dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Categories'); if (!empty($input['category_id']) && ($category = $this->getCategoryByID($input['category_id']))) { $dw->setExistingData($category); } $dw->bulkSet(array('category_name' => $input['category_name'], 'category_description' => XenForo_Helper_String::autoLinkBbCode($input['category_description']), 'category_parent' => $input['category_parent'], 'category_disabled' => $input['category_disabled'])); $dw->save(); $input['category_id'] = $dw->get('category_id'); return $input; }
public function renderJson() { $options = XenForo_Application::get('options'); $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $this)); switch ($options->dark_taigachat_bbcode) { case 'Full': $formatter->displayableTags = true; break; case 'Basic': default: $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color'); break; case 'None': $formatter->displayableTags = array('url', 'email'); break; } $formatter->getTagsAgain(); $parser = new XenForo_BbCode_Parser($formatter); if ($options->dark_taigachat_imagemode == 'Link') { foreach ($this->_params['taigachat']['messages'] as &$message) { $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']); } } $maxid = $this->_params['taigachat']['lastrefresh']; foreach ($this->_params['taigachat']['messages'] as &$message) { if ($options->dark_taigachat_bbcode == 'Full') { $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']); } else { // We don't want to parse youtube etc. urls if [media] is disabled $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false)); $message['message'] = $autoLinkParser->render($message['message']); } if ($message['id'] > $maxid) { $maxid = $message['id']; } } XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['taigachat']['messages'], $parser); if ($options->dark_taigachat_direction) { $this->_params['taigachat']['messages'] = array_reverse($this->_params['taigachat']['messages']); } $template = $this->createTemplateObject($this->_templateName, $this->_params); $template->setParams($this->_params); $rendered = $template->render(); $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered); $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered); //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered); $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput(array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid)); $extraHeaders = XenForo_Application::gzipContentIfSupported($derp); foreach ($extraHeaders as $extraHeader) { header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]); } return $derp; }
public function actionAddReply() { $this->_assertPostOnly(); $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT); $message = $this->getHelper('Editor')->getMessageText('message', $this->_input); $message = XenForo_Helper_String::autoLinkBbCode($message); //Get visitor id and check for duplicate post $visitorId = XenForo_Visitor::getUserId(); $xenOptions = XenForo_Application::getOptions(); $timeDiff = $xenOptions->sonnbPreventDoublePost_duration; $this->_assertIsDoublePost($message, $visitorId, $threadId, $timeDiff); return parent::actionAddReply(); }
public function save() { $userId = $this->_options['conversation_send_by_user_id']['option_value'] != '' ? $this->_options['conversation_send_by_user_id']['option_value'] : XenForo_Visitor::getUserId(); $recipientUserId = $this->_options['conversation_recipient_user_id']['option_value']; $recipientUserId = explode(',', $recipientUserId); // guests can't participate in conversations if (!$userId) { return false; } // users can't send themselves messages if ($userId == $recipientUserId) { return false; } $userModel = XenForo_Model::create('XenForo_Model_User'); $user = $userModel->getUserById($userId); if ($this->_options['conversation_message_template']['option_value'] == '') { $message = ''; foreach ($this->_templateFields as $field) { if ($this->_options['conversation_hide_empty_fields']['option_value'] == array() || $this->_options['conversation_hide_empty_fields']['option_value'] !== array() && $field['value'] != '') { $message .= $field['title'] . ':' . PHP_EOL; if ($field['field_type'] == 'wysiwyg') { $message .= '[INDENT="1"]' . $field['value'] . '[/INDENT]' . PHP_EOL; } else { $message .= '[INDENT="1"][B]' . $field['value'] . '[/B][/INDENT]' . PHP_EOL; } } } } else { $message = $this->_options['conversation_message_template']['option_value']; } $message = XenForo_Helper_String::autoLinkBbCode($message); $locked = $this->_options['conversation_locked']['option_value'] !== array() ? true : false; $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster'); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $user); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $message); $conversationDw->set('user_id', $user['user_id']); $conversationDw->set('username', $user['username']); $conversationDw->set('title', $this->_options['conversation_title_template']['option_value']); $conversationDw->set('conversation_open', $locked ? 0 : 1); $conversationDw->addRecipientUserIds($recipientUserId); $messageDw = $conversationDw->getFirstMessageDw(); $messageDw->set('message', $message); if ($this->_attachmentHash) { $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_attachmentHash); } $conversationDw->preSave(); $conversationDw->save(); $conversation = $conversationDw->getMergedData(); $this->_getConversationModel()->markConversationAsRead($conversation['conversation_id'], $user['user_id'], XenForo_Application::$time); }
/** * Approves the specified moderation queue entry. * * @see XenForo_ModerationQueueHandler_Abstract::approveModerationQueueEntry() */ public function approveModerationQueueEntry($contentId, $message, $title) { $message = XenForo_Helper_String::autoLinkBbCode($message); $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT); $dw->setExistingData($contentId); $dw->set('message_state', 'visible'); $dw->set('message', $message); if ($dw->save()) { XenForo_Model_Log::logModeratorAction('post', $dw->getMergedData(), 'approve'); return true; } else { return false; } }
public static function processMessagesForView(&$params, &$view) { $options = XenForo_Application::get('options'); $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $view)); switch ($options->dark_taigachat_bbcode) { case 'Full': $formatter->displayableTags = true; break; case 'Basic': default: $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color'); break; case 'None': $formatter->displayableTags = array('url', 'email'); break; } $formatter->getTagsAgain(); $parser = new XenForo_BbCode_Parser($formatter); if ($options->dark_taigachat_imagemode == 'Link') { foreach ($params['taigachat']['messages'] as &$message) { $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']); } } $maxUpdate = $params['taigachat']['lastrefresh']; foreach ($params['taigachat']['messages'] as &$message) { if ($options->dark_taigachat_bbcode == 'Full') { $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']); } else { // We don't want to parse youtube etc. urls if [media] is disabled $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false)); $message['message'] = $autoLinkParser->render($message['message']); } if ($message['last_update'] > $maxUpdate) { $maxUpdate = $message['last_update']; } if (substr($message['message'], 0, 3) == '/me') { $message['message'] = substr($message['message'], 4); $message['me'] = true; } } if ($options->dark_taigachat_smilies) { XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser); } else { XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['taigachat']['messages'], $parser, array("states" => array("stopSmilies" => true))); } if ($options->dark_taigachat_direction) { $params['taigachat']['messages'] = array_reverse($params['taigachat']['messages']); } return max($maxUpdate, XenForo_Application::getSimpleCacheData('taigachat_lastUpdate')); }
/** * Approves the specified moderation queue entry. * * @see XenForo_ModerationQueueHandler_Abstract::approveModerationQueueEntry() */ public function approveModerationQueueEntry($contentId, $message, $title) { $message = XenForo_Helper_String::autoLinkBbCode($message); $dw = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum', XenForo_DataWriter::ERROR_SILENT); $dw->setExistingData($contentId); $dw->set('group_state', 'visible'); $dw->set('title', $title); $dw->set('description', $message); if ($dw->save()) { XenForo_Model_Log::logModeratorAction('socialForum', $dw->getMergedData(), 'approve'); return true; } else { return false; } }
/** * Shows thumbs of images in the thread being created. * * @return XenForo_ControllerResponse_Abstract */ public function actionCreateArticleThumbnails() { $this->_assertPostOnly(); $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); $message = $this->getHelper('Editor')->getMessageText('message', $this->_input); $message = XenForo_Helper_String::autoLinkBbCode($message); $thumbnailsModel = $this->_getThumbnailsModel(); $thumbs = $thumbnailsModel->getImagesFromMessage($message); $viewParams = array('forum' => $forum, 'thumbs' => $thumbs); return $this->responseView('Waindigo_Thumbnails_ViewPublic_Thread_Thumbnails', 'waindigo_thread_create_thumbs_thumbnails', $viewParams); }
public static function runDailyCleanUp() { $options = XenForo_Application::get('options'); $model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat'); if ($options->dark_taigachat_archivethread > 0) { // swap timezone to default temporarily $oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName(); XenForo_Locale::setDefaultTimeZone($options->guestTimeZone); $messages = array_reverse($model->getMessagesToday()); if (count($messages) > 0) { $userModel = XenForo_Model::create('XenForo_Model_User'); $post = ""; foreach ($messages as $message) { $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']); $date = XenForo_Locale::dateTime($message['date'], 'absolute'); if ($message['user_id'] > 0) { $url = XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("members/" . $message['user_id']), true); $user = "******"; } else { $user = "******"; } $me = substr($message['message'], 0, 3) == '/me'; if ($me) { $message['message'] = substr($message['message'], 3); $post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n"; } else { $post .= "{$date} - {$user}: {$message['message']}\r\n"; } } $username = "******"; if ($options->dark_taigachat_archiveuser > 0) { $user = $userModel->getUserById($options->dark_taigachat_archiveuser); $username = $user['username']; } $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true); $writer->set('user_id', $options->dark_taigachat_archiveuser); $writer->set('username', $username); $writer->set('message', $post); $writer->set('thread_id', $options->dark_taigachat_archivethread); $writer->save(); } // put timezone back to how it was XenForo_Locale::setDefaultTimeZone($oldTimeZone); } $model->deleteOldMessages(); }
public function actionAddReply() { $this->_assertPostOnly(); $input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input); $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']); $str = strtoupper($input['message']); $numberLink = substr_count($str, '[/URL]'); $visitor = XenForo_Visitor::getInstance(); $daysRegistered = XenForo_Permission::hasPermission($visitor['permissions'], 'forum', 'daysRegistered'); if ($daysRegistered && $daysRegistered > 0) { $canPostLink = $visitor['register_date'] + $daysRegistered * 60 * 60 * 24; if ($canPostLink > XenForo_Application::$time && $numberLink) { return $this->responseError(new XenForo_Phrase('XP_you_must_wait_x_days_to_post_link', array('days' => $daysRegistered))); } } return parent::actionAddReply(); }
public function save() { $threadId = $this->_options['post_thread_id']['option_value']; $threadModel = $this->_getThreadModel(); $thread = $threadModel->getThreadById($threadId); $forum = $this->_getForumModel()->getForumById($thread['node_id']); $userId = $this->_options['post_post_by_user_id']['option_value'] != '' ? $this->_options['post_post_by_user_id']['option_value'] : XenForo_Visitor::getUserId(); if (!$userId) { $user = array('username' => 'Guest', 'user_id' => null); } else { $userModel = XenForo_Model::create('XenForo_Model_User'); $user = $userModel->getUserById($userId); } if ($this->_options['post_message_template']['option_value'] == '') { $message = ''; foreach ($this->_templateFields as $field) { if ($this->_options['post_hide_empty_fields']['option_value'] == array() || $this->_options['post_hide_empty_fields']['option_value'] !== array() && $field['value'] != '') { $message .= $field['title'] . ':' . PHP_EOL; if ($field['field_type'] == 'wysiwyg') { $message .= '[INDENT="1"]' . $field['value'] . '[/INDENT]' . PHP_EOL; } else { $message .= '[INDENT="1"][B]' . $field['value'] . '[/B][/INDENT]' . PHP_EOL; } } } } else { $message = $this->_options['post_message_template']['option_value']; } $message = XenForo_Helper_String::autoLinkBbCode($message); $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $writer->set('user_id', $user['user_id']); $writer->set('username', $user['username']); $writer->set('message', $message); $writer->set('message_state', $this->_getPostModel()->getPostInsertMessageState($thread, $forum)); $writer->set('thread_id', $threadId); $writer->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum); if ($this->_attachmentHash) { $writer->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, $this->_attachmentHash); } $writer->preSave(); $writer->save(); $post = $writer->getMergedData(); // set the post $this->_post = $post; }
public function actionPostEdit() { $vals = $this->_input->filter(array('postid' => XenForo_Input::UINT, 'poststarttime' => XenForo_Input::STRING, 'message' => XenForo_Input::STRING)); $helper = $this->getHelper('ForumThreadPost'); try { list($post_info, $thread_info, $forum_info) = $helper->assertPostValidAndViewable($vals['postid']); $this->_assertCanEditPost($post_info, $thread_info, $forum_info); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render(), RV_POST_ERROR); } $vals['message'] = XenForo_Helper_String::autoLinkBbCode($vals['message']); $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $dw->setExistingData($vals['postid']); $dw->set('message', $vals['message']); $dw->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, $vals['poststarttime']); $dw->save(); return array('success' => true); }
/** * Inserts a new user or updates an existing one. * * @return XenForo_ControllerResponse_Abstract */ public function actionSave() { $xenOptions = XenForo_Application::get('options'); if ($xenOptions->th_noForo_noMessageCount) { $this->_assertPostOnly(); $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT); if ($userId) { $user = $this->_getUserOrError($userId); $this->getHelper('Admin')->checkSuperAdminEdit($user); if ($this->_getUserModel()->isUserSuperAdmin($user)) { $visitorPassword = $this->_input->filterSingle('visitor_password', XenForo_Input::STRING); $this->getHelper('Admin')->assertVisitorPasswordCorrect($visitorPassword); } } $userInput = $this->_input->filter(array('username' => XenForo_Input::STRING, 'email' => XenForo_Input::STRING, 'user_group_id' => XenForo_Input::UINT, 'user_state' => XenForo_Input::STRING, 'is_discouraged' => XenForo_Input::UINT, 'gender' => XenForo_Input::STRING, 'dob_day' => XenForo_Input::UINT, 'dob_month' => XenForo_Input::UINT, 'dob_year' => XenForo_Input::UINT, 'location' => XenForo_Input::STRING, 'occupation' => XenForo_Input::STRING, 'custom_title' => XenForo_Input::STRING, 'homepage' => XenForo_Input::STRING, 'about' => XenForo_Input::STRING, 'signature' => XenForo_Input::STRING, 'like_count' => XenForo_Input::UINT, 'trophy_points' => XenForo_Input::UINT, 'style_id' => XenForo_Input::UINT, 'language_id' => XenForo_Input::UINT, 'timezone' => XenForo_Input::STRING, 'content_show_signature' => XenForo_Input::UINT, 'enable_rte' => XenForo_Input::UINT, 'visible' => XenForo_Input::UINT, 'receive_admin_email' => XenForo_Input::UINT, 'show_dob_date' => XenForo_Input::UINT, 'show_dob_year' => XenForo_Input::UINT, 'allow_view_profile' => XenForo_Input::STRING, 'allow_post_profile' => XenForo_Input::STRING, 'allow_send_personal_conversation' => XenForo_Input::STRING, 'allow_view_identities' => XenForo_Input::STRING, 'allow_receive_news_feed' => XenForo_Input::STRING)); $secondaryGroupIds = $this->_input->filterSingle('secondary_group_ids', XenForo_Input::UINT, array('array' => true)); $userInput['about'] = XenForo_Helper_String::autoLinkBbCode($userInput['about']); if ($this->_input->filterSingle('clear_status', XenForo_Input::UINT)) { //TODO: clear status } /* @var $writer XenForo_DataWriter_User */ $writer = XenForo_DataWriter::create('XenForo_DataWriter_User'); if ($userId) { $writer->setExistingData($userId); } $writer->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true); $writer->bulkSet($userInput); $writer->setSecondaryGroups($secondaryGroupIds); $password = $this->_input->filterSingle('password', XenForo_Input::STRING); if ($password !== '') { $writer->setPassword($password); } $customFields = $this->_input->filterSingle('custom_fields', XenForo_Input::ARRAY_SIMPLE); $customFieldsShown = $this->_input->filterSingle('custom_fields_shown', XenForo_Input::STRING, array('array' => true)); $writer->setCustomFields($customFields, $customFieldsShown); $writer->save(); $userId = $writer->get('user_id'); // TODO: redirect to previous search if possible? return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('users/search', null, array('last_user_id' => $userId)) . $this->getLastHash($userId)); } return parent::actionSave(); }
public function actionEdit() { list($comment, $content, $album) = $this->_getCommentOrError(); if (!$comment['canEdit']) { throw $this->_throwFriendlyNoPermission('sonnb_xengallery_you_do_not_have_permission_to_edit_this_comment'); } if ($this->_request->isPost()) { $message = $this->_input->filterSingle('message', XenForo_Input::STRING); $message = XenForo_Helper_String::autoLinkBbCode($message); $commentDw = XenForo_DataWriter::create('sonnb_XenGallery_DataWriter_Comment'); $commentDw->setExistingData($comment); $commentDw->set('message', $message); $commentDw->save(); if ($this->_noRedirect()) { return $this->responseView('sonnb_XenGallery_ViewPublic_Comment_EditInline', '', array('comment' => $commentDw->getMergedData(), 'content' => $content, 'album' => $album)); } else { return $this->_redirectToContainer($comment, $content, $album, new XenForo_Phrase('changes_saved'), XenForo_ControllerResponse_Redirect::RESOURCE_UPDATED); } } else { return $this->responseView('sonnb_XenGallery_ViewPublic_Comment_Edit', 'sonnb_xengallery_comment_edit', array('comment' => $comment, 'content' => $content, 'album' => $album, 'breadCrumbs' => $this->_getCommentModel()->getCommentBreadCrumbs($comment, $content, $album), 'includeTaggerJs' => $this->_getGalleryModel()->includeJsTagger())); } }
public function postToThread($comment, $media) { if (!($thread = $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($media['thread_id']))) { $dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Media'); $dw->setExistingData($media); $dw->set('thread_id', '0'); $dw->save(); return false; } $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $writer->set('user_id', $comment['user_id']); $writer->set('username', $comment['username']); $writer->set('message', XenForo_Helper_String::autoLinkBbCode($comment['comment_message'])); $writer->set('ip_id', $comment['comment_ip']); $writer->set('thread_id', $thread['thread_id']); $writer->save(); $post = $writer->getMergedData(); $dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Comments'); $dw->setExistingData($comment); $dw->set('post_id', $post['post_id']); $dw->save(); return true; }
public function actionPreview() { $this->_assertPostOnly(); $feed = $this->_getFeedFormData(); $feedModel = $this->_getFeedModel(); $feedData = $feedModel->getFeedData($feed['url'], $exception); if (!$feedData || empty($feedData['entries'])) { return $this->responseError(new XenForo_Phrase('there_was_problem_requesting_feed', array('message' => $exception instanceof Exception ? $exception->getMessage() : new XenForo_Phrase('n_a')))); } if (empty($feed['title'])) { $feed['title'] = $feedData['title']; } $feed['message_template'] = XenForo_Helper_String::autoLinkBbCode($feed['message_template']); $feed['baseUrl'] = $feedModel->getFeedBaseUrl($feed['url']); // get a random entry from the feed $entry = $feedData['entries'][mt_rand(0, count($feedData['entries']) - 1)]; $entry = $feedModel->prepareFeedEntry($entry, $feedData, $feed); if ($feed['user_id'] == -1) { $entry['author'] = $this->_input->filterSingle('username', XenForo_Input::STRING); } $viewParams = array('feed' => $feed, 'feedData' => $feedData, 'entry' => $entry, 'prefixes' => XenForo_Model::create('XenForo_Model_DataRegistry')->get('threadPrefixes')); return $this->responseView('XenForo_ViewAdmin_Feed_Preview', 'feed_preview', $viewParams); }
public function execute(array $deferred, array $data, $targetRunTime, &$status) { $data = array_merge(array('start' => 0, 'count' => 0, 'criteria' => null, 'userIds' => null, 'conversation' => array()), $data); $s = microtime(true); /* @var $userModel XenForo_Model_User */ /* @var $conversationModel XenForo_Model_Conversation */ $userModel = XenForo_Model::create('XenForo_Model_User'); $conversationModel = XenForo_Model::create('XenForo_Model_Conversation'); if (is_array($data['criteria'])) { $userIds = $userModel->getUserIds($data['criteria'], $data['start'], 1000); } else { if (is_array($data['userIds'])) { $userIds = $data['userIds']; } else { $userIds = array(); } } if (!$userIds) { return false; } $conversation = $data['conversation']; $limitTime = $targetRunTime > 0; foreach ($userIds as $key => $userId) { $data['count']++; $data['start'] = $userId; unset($userIds[$key]); $conversationUser = $userModel->getUserById($conversation['user_id']); if ($userId == $conversationUser['user_id']) { continue; } $user = $userModel->getUserById($userId); $title = $conversation['message_title']; $body = $conversation['message_body']; $phraseTitles = XenForo_Helper_String::findPhraseNamesFromStringSimple($title . $body); /** @var XenForo_Model_Phrase $phraseModel */ $phraseModel = XenForo_Model::create('XenForo_Model_Phrase'); $phrases = $phraseModel->getPhraseTextFromPhraseTitles($phraseTitles, $user['language_id']); foreach ($phraseTitles as $search => $phraseTitle) { if (isset($phrases[$phraseTitle])) { $title = str_replace($search, $phrases[$phraseTitle], $title); $body = str_replace($search, $phrases[$phraseTitle], $body); } } $replacements = array('{name}' => $user['username'], '{id}' => $user['user_id']); $body = strtr($body, $replacements); $body = XenForo_Helper_String::autoLinkBbCode($body); /** @var XenForo_DataWriter_ConversationMaster $conversationDw */ $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster'); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $conversationUser); $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $body); $conversationDw->set('user_id', $conversationUser['user_id']); $conversationDw->set('username', $conversationUser['username']); $conversationDw->set('title', utf8_substr($title, 0, 100)); $conversationDw->set('open_invite', $conversation['open_invite']); $conversationDw->set('conversation_open', $conversation['conversation_locked'] ? 0 : 1); $conversationDw->addRecipientUserIds(array($user['user_id'])); // bypasses permissions $messageDw = $conversationDw->getFirstMessageDw(); $messageDw->set('message', $body); $conversationDw->save(); $conversationModel->markConversationAsRead($conversationDw->get('conversation_id'), $conversationUser['user_id'], XenForo_Application::$time); if ($conversation['delete_type']) { $conversationModel->deleteConversationForUser($conversationDw->get('conversation_id'), $conversationUser['user_id'], $conversation['delete_type']); } if ($limitTime && microtime(true) - $s > $targetRunTime) { break; } } if (is_array($data['userIds'])) { $data['userIds'] = $userIds; } $actionPhrase = new XenForo_Phrase('messaging'); $typePhrase = new XenForo_Phrase('users'); $status = sprintf('%s... %s (%d)', $actionPhrase, $typePhrase, $data['count']); return $data; }
public function editPost($post, $user, $edit_data = array()) { unset($post['absolute_url']); unset($post['message_html']); if (!$user) { return array('error' => 3, 'errors' => 'The user array key was not set.'); } if (!$user->isRegistered()) { return array('error' => 4, 'errors' => 'User is not registered.'); } $fetchOptions = array('permissionCombinationId' => $user->data['permission_combination_id']); $thread = $this->getThread($post['thread_id']); $forum = $this->getForum($thread['node_id'], array('permissionCombinationId' => $user->data['permission_combination_id'])); $permissions = XenForo_Permission::unserializePermissions($forum['node_permission_cache']); if (!$this->canViewThread($user, $thread, $permissions) || !$this->canReplyToThread($user, $thread, $forum, $permissions)) { // User does not have permission to post in this thread. return array('error' => 14, 'errors' => 'The user does not have permissions to post in this thread.'); } if (array_key_exists('message', $edit_data)) { $edit_data['message'] = XenForo_Helper_String::autoLinkBbCode($edit_data['message']); } // Init the diff array. $diff_array = array(); // Create the data writer object for registrations, and set the defaults. $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); // Set the existing data of the user before we submit the data. $writer->setExistingData($post['post_id']); // Bulkset the edited data. $writer->bulkSet($edit_data); // Pre save the data. $writer->preSave(); if ($writer->hasErrors()) { // The edit failed, return errors. return array('error' => TRUE, 'errors' => $writer->getErrors()); } // Save the user to the database. $writer->save(); // Get the user data. $post_data = $writer->getMergedData(); // Check the difference between the before and after data. $diff_array = array_merge(array_diff_assoc($post, $post_data), $diff_array); foreach ($diff_array as $diff_key => $diff_value) { if (array_key_exists($diff_key, $post_data)) { $diff_array[$diff_key] = $post_data[$diff_key]; } } if (count($diff_array) == 0) { // Nothing was changed, throw error. return array('error' => 9, 'errors' => 'No values were changed.'); } return $diff_array; }
/** * Shows a preview of the thread creation. * * @return XenForo_ControllerResponse_Abstract */ public function actionCreateThreadPreview() { $this->_assertPostOnly(); $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); $message = $this->getHelper('Editor')->getMessageText('message', $this->_input); $message = XenForo_Helper_String::autoLinkBbCode($message); /** @var $taggingModel XenForo_Model_UserTagging */ $taggingModel = $this->getModelFromCache('XenForo_Model_UserTagging'); $taggingModel->getTaggedUsersInMessage($message, $message); $viewParams = array('forum' => $forum, 'message' => $message); return $this->responseView('XenForo_ViewPublic_Thread_CreatePreview', 'thread_create_preview', $viewParams); }
/** * Inserts a reply into a conversation. * * @return XenForo_ControllerResponse_Abstract */ public function actionInsertReply() { $this->_assertPostOnly(); if ($this->_input->inRequest('more_options')) { return $this->responseReroute(__CLASS__, 'reply'); } $input = array(); $input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input); $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']); $conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT); $conversation = $this->_getConversationOrError($conversationId); $this->_assertCanReplyToConversation($conversation); $visitor = XenForo_Visitor::getInstance(); $attachmentHash = $this->_input->filterSingle('attachment_hash', XenForo_Input::STRING); $messageDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMessage'); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_MESSAGE_SENDER, $visitor->toArray()); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $attachmentHash); $messageDw->set('conversation_id', $conversation['conversation_id']); $messageDw->set('user_id', $visitor['user_id']); $messageDw->set('username', $visitor['username']); $messageDw->set('message', $input['message']); $messageDw->preSave(); $spamModel = $this->_getSpamPreventionModel(); if (!$messageDw->hasErrors() && $spamModel->visitorRequiresSpamCheck()) { $spamResult = $spamModel->checkMessageSpam($input['message'], array(), $this->_request); switch ($spamResult) { case XenForo_Model_SpamPrevention::RESULT_MODERATED: case XenForo_Model_SpamPrevention::RESULT_DENIED: $spamModel->logSpamTrigger('conversation_message', null); $messageDw->error(new XenForo_Phrase('your_content_cannot_be_submitted_try_later')); break; } } if (!$messageDw->hasErrors()) { $this->assertNotFlooding('conversation'); } $messageDw->save(); $message = $messageDw->getMergedData(); $this->_getDraftModel()->deleteDraft('conversation-' . $conversation['conversation_id']); $conversationModel = $this->_getConversationModel(); if (!$this->_noRedirect() || !$this->_input->inRequest('last_date')) { $conversationModel->markConversationAsRead($conversation['conversation_id'], XenForo_Visitor::getUserId(), XenForo_Application::$time, 0, false); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('conversations/message', $conversation, array('message_id' => $message['message_id'])), new XenForo_Phrase('your_message_has_been_posted')); } else { $lastDate = $this->_input->filterSingle('last_date', XenForo_Input::UINT); $limit = 3; $messageFetchOptions = array('limit' => $limit + 1, 'join' => 0); if (XenForo_Application::getOptions()->showMessageOnlineStatus) { $messageFetchOptions['join'] |= XenForo_Model_Conversation::FETCH_MESSAGE_SESSION_ACTIVITY; } $messages = $conversationModel->getNewestConversationMessagesAfterDate($conversationId, $lastDate, $messageFetchOptions); // We fetched one more message than needed. If more than $limit message were returned, // we can show the 'there are more messages' notice if (count($messages) > $limit) { $firstUnshown = $conversationModel->getNextMessageInConversation($conversationId, $lastDate); // remove the extra post array_pop($messages); } else { $firstUnshown = false; } if (!$firstUnshown || $firstUnshown['message_date'] < $conversation['last_read_date']) { $conversationModel->markConversationAsRead($conversation['conversation_id'], XenForo_Visitor::getUserId(), XenForo_Application::$time, 0, false); } $messages = array_reverse($messages, true); $messages = $conversationModel->prepareMessages($messages, $conversation); $messages = $conversationModel->getAndMergeAttachmentsIntoConversationMessages($messages); $viewParams = array('conversation' => $conversation, 'canReplyConversation' => $conversationModel->canReplyToConversation($conversation), 'canViewAttachments' => $conversationModel->canViewAttachmentOnConversation($conversation), 'firstUnshown' => $firstUnshown, 'messages' => $messages, 'lastMessage' => end($messages)); return $this->responseView('XenForo_ViewPublic_Conversation_ViewNewMessages', 'conversation_view_new_messages', $viewParams); } }
public function actionPutIndex() { $messageId = $this->_input->filterSingle('message_id', XenForo_Input::UINT); $message = $this->_getMessageOrError($messageId); $conversation = $this->_getConversationOrError($message['conversation_id']); if (!$this->_getConversationModel()->canEditMessage($message, $conversation, $errorPhraseKey)) { throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey); } // TODO $input = $this->_input->filter(array()); /* @var $editorHelper XenForo_ControllerHelper_Editor */ $editorHelper = $this->getHelper('Editor'); $input['message_body'] = $editorHelper->getMessageText('message_body', $this->_input); $input['message_body'] = XenForo_Helper_String::autoLinkBbCode($input['message_body']); $messageDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMessage'); $messageDw->setExistingData($message, true); $messageDw->set('message', $input['message_body']); $messageDw->setExtraData(XenForo_DataWriter_ConversationMessage::DATA_ATTACHMENT_HASH, $this->_getAttachmentHelper()->getAttachmentTempHash($message)); $messageDw->save(); return $this->responseReroute(__CLASS__, 'single'); }
public function actionSaveInline() { $this->_assertPostOnly(); if ($this->_input->inRequest('more_options')) { return $this->responseReroute(__CLASS__, 'edit'); } $postId = $this->_input->filterSingle('post_id', XenForo_Input::UINT); $ftpHelper = $this->getHelper('ForumThreadPost'); list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($postId); $this->_assertCanEditPost($post, $thread, $forum); $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $dw->setExistingData($postId); $dw->set('message', XenForo_Helper_String::autoLinkBbCode($this->getHelper('Editor')->getMessageText('message', $this->_input))); $dw->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum); $this->_setSilentEditOptions($post, $thread, $forum, $dw); $dw->save(); XenForo_Model_Log::logModeratorAction('post', $post, 'edit', array(), $thread); if ($this->_noRedirect()) { $this->_request->setParam('thread_id', $thread['thread_id']); return $this->responseReroute('XenForo_ControllerPublic_Thread', 'show-posts'); } else { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('posts', $post)); } }
/** * Displays a conversation message preview viewable from the Admin CP * * @return XenForo_ControllerResponse_View */ public function actionUserMessagePreview() { $this->_assertPostOnly(); $visitor = XenForo_Visitor::getInstance(); if (!$visitor->is_admin) { return $this->getNoPermissionResponseException(); } $conversation = $this->_input->filter(array('from_user' => XenForo_Input::STRING, 'message_title' => XenForo_Input::STRING, 'message_body' => XenForo_Input::STRING, 'open_invite' => XenForo_Input::BOOLEAN, 'conversation_locked' => XenForo_Input::BOOLEAN, 'conversation_leave' => XenForo_Input::BOOLEAN)); $replacements = array('{name}' => $visitor['username'], '{id}' => $visitor['user_id']); $conversation['message_body'] = strtr($conversation['message_body'], $replacements); $conversation['message_body'] = XenForo_Helper_String::autoLinkBbCode($conversation['message_body']); $viewParams = array('conversation' => $conversation); return $this->responseView('XenForo_ViewPublic_Misc_MessagePreview', 'user_message_preview', $viewParams); }
public function save() { $forumId = $this->_options['thread_forum_node_id']['option_value']; $forum = $this->_getForumModel()->getForumById($forumId); $userId = $this->_options['thread_post_by_user_id']['option_value'] != '' ? $this->_options['thread_post_by_user_id']['option_value'] : XenForo_Visitor::getUserId(); if (!$userId) { $user = array('username' => 'Guest', 'user_id' => null); } else { $userModel = XenForo_Model::create('XenForo_Model_User'); $user = $userModel->getUserById($userId); } $input['title'] = htmlspecialchars_decode($this->_options['thread_title_template']['option_value']); if ($this->_options['thread_message_template']['option_value'] == '') { $message = ''; foreach ($this->_templateFields as $field) { if ($this->_options['thread_hide_empty_fields']['option_value'] == array() || $this->_options['thread_hide_empty_fields']['option_value'] !== array() && $field['value'] != '') { $message .= $field['title'] . ':' . PHP_EOL; if ($field['field_type'] == 'wysiwyg') { $message .= '[INDENT="1"]' . $field['value'] . '[/INDENT]' . PHP_EOL; } else { $message .= '[INDENT="1"][B]' . $field['value'] . '[/B][/INDENT]' . PHP_EOL; } } } } else { $this->_replaceAttachmentIds($this->_options['thread_message_template']['option_value']); $message = $this->_options['thread_message_template']['option_value']; } $message = XenForo_Helper_String::autoLinkBbCode($message); $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread'); $writer->set('user_id', $user['user_id']); $writer->set('username', $user['username']); $writer->set('title', $input['title']); $writer->set('node_id', $forumId); $prefixId = 0; if (!empty($forum['default_prefix_id'])) { $prefixId = $forum['default_prefix_id']; } // set the thread id from the options if (!empty($this->_options['thread_prefix']['option_value'])) { $prefixId = $this->_options['thread_prefix']['option_value']; } // verify the thread is usable if (!array_key_exists('thread_prefix', $this->_options) || !$this->_getPrefixModel()->verifyPrefixIsUsable($this->_options['thread_prefix']['option_value'], $forum['node_id'])) { $prefixId = 0; // not usable, just blank it out } $writer->set('prefix_id', $prefixId); if ($this->_options['thread_sticky']['option_value'] && $this->_getForumModel()->canStickUnstickThreadInForum($forum, $errorPhraseKey, null, $user)) { $writer->set('sticky', $this->_options['thread_sticky']['option_value']); } if ($this->_options['thread_lock']['option_value']) { $writer->set('discussion_open', 0); } $postModel = XenForo_Model::create('XenForo_Model_Post'); $writer->set('discussion_state', $postModel->getPostInsertMessageState(array(), $forum)); $postWriter = $writer->getFirstMessageDw(); $postWriter->set('message', $message); if ($this->_attachmentHash) { $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_ATTACHMENT_HASH, $this->_attachmentHash); } $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum); $writer->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum); $writer->preSave(); if ($this->_options['thread_poll']['option_value']['question'] != '') { $pollInput = array(); $pollInput['question'] = $this->_options['thread_poll']['option_value']['question']; $pollInput['public_votes'] = array_key_exists('public_votes', $this->_options['thread_poll']['option_value']) ? $this->_options['thread_poll']['option_value']['public_votes'] : false; // 1.4 options if (XenForo_Application::$versionId >= 1040000) { $pollInput['change_vote'] = array_key_exists('change_vote', $this->_options['thread_poll']['option_value']) ? $this->_options['thread_poll']['option_value']['change_vote'] : false; $pollInput['view_results_unvoted'] = array_key_exists('view_results_unvoted', $this->_options['thread_poll']['option_value']) ? $this->_options['thread_poll']['option_value']['view_results_unvoted'] : false; switch ($this->_options['thread_poll']['option_value']['max_votes_type']) { case 'single': $pollInput['max_votes'] = 1; break; case 'unlimited': $pollInput['max_votes'] = 0; break; default: $pollInput['max_votes'] = $this->_options['thread_poll']['option_value']['max_votes_value']; } } else { if (XenForo_Application::$versionId >= 1030000) { $pollInput['multiple'] = array_key_exists('multiple', $this->_options['thread_poll']['option_value']) ? $this->_options['thread_poll']['option_value']['multiple'] : false; } } $pollWriter = XenForo_DataWriter::create('XenForo_DataWriter_Poll'); // close date if (isset($this->_options['thread_poll']['option_value']['close'])) { if (!$this->_options['thread_poll']['option_value']['close_length']) { $pollWriter->error(new XenForo_Phrase('please_enter_valid_length_of_time')); } else { $pollInput['close_date'] = strtotime('+' . $this->_options['thread_poll']['option_value']['close_length'] . ' ' . $this->_options['thread_poll']['option_value']['close_units']); } } $pollWriter->bulkSet($pollInput); $pollWriter->set('content_type', 'thread'); $pollWriter->set('content_id', 0); // changed before saving $pollWriter->addResponses($this->_options['thread_poll']['option_value']['responses']); $pollWriter->preSave(); $writer->mergeErrors($pollWriter->getErrors()); $writer->set('discussion_type', 'poll', '', array('setAfterPreSave' => true)); } $writer->save(); $thread = $writer->getMergedData(); if (isset($pollWriter)) { $pollWriter->set('content_id', $thread['thread_id'], '', array('setAfterPreSave' => true)); $pollWriter->save(); } // set the thread $this->_thread = $thread; $threadModel = XenForo_Model::create('XenForo_Model_Thread'); $threadModel->markThreadRead($thread, $forum, XenForo_Application::$time); // check to see if we need to watch the thread, and if we can watch the thread if ($this->_options['thread_automatically_watch']['option_value'] != '' && $threadModel->canWatchThread($thread, $forum)) { $threadWatchModel = XenForo_Model::create('XenForo_Model_ThreadWatch'); $threadWatchModel->setThreadWatchState(XenForo_Visitor::getUserId(), $thread['thread_id'], $this->_options['thread_automatically_watch']['option_value']); } }
public static function runDailyCleanUp() { $options = XenForo_Application::get('options'); $model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat'); if ($options->dark_taigachat_archivethread > 0) { // swap timezone to default temporarily $timeZone = XenForo_Locale::getDefaultTimeZone(); if (!empty($timeZone)) { $oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName(); } XenForo_Locale::setDefaultTimeZone($options->guestTimeZone); $messages = array_reverse($model->getMessagesToday()); if (count($messages) > 0) { for ($i = 0; $i < count($messages); $i += $options->dark_taigachat_archive_split) { $userModel = XenForo_Model::create('XenForo_Model_User'); $post = ""; for ($j = $i; $j < min(count($messages), $i + $options->dark_taigachat_archive_split); $j++) { //foreach($messages as $message){ $message = $messages[$j]; $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']); $date = XenForo_Locale::dateTime($message['date'], 'absolute'); if ($message['user_id'] > 0) { $user = "******"; } else { $user = "******"; } $me = substr($message['message'], 0, 3) == '/me'; if ($me) { $message['message'] = substr($message['message'], 3); $post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n"; } else { $post .= "{$date} - {$user}: {$message['message']}\r\n"; } } if (empty($post)) { continue; } $username = "******"; if ($options->dark_taigachat_archiveuser > 0) { $user = $userModel->getUserById($options->dark_taigachat_archiveuser); $username = $user['username']; } $writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true); if (defined('XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM')) { $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM, false); } $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MESSAGE_LENGTH, 0); $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_IMAGES, 0); $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MEDIA, 0); $writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_VERIFY_GUEST_USERNAME, false); $writer->set('user_id', $options->dark_taigachat_archiveuser); $writer->set('username', $username); $writer->set('message', $post); $writer->set('thread_id', $options->dark_taigachat_archivethread); $writer->save(); } } // put timezone back to how it was if (!empty($oldTimeZone)) { XenForo_Locale::setDefaultTimeZone($oldTimeZone); } } $model->deleteOldMessages(); }
public function actionSaveInline() { $this->_assertPostOnly(); if ($this->_input->inRequest('more_options')) { return $this->responseReroute(__CLASS__, 'edit'); } $postId = $this->_input->filterSingle('post_id', XenForo_Input::UINT); $ftpHelper = $this->getHelper('ForumThreadPost'); list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($postId); $this->_assertCanEditPost($post, $thread, $forum); $message = XenForo_Helper_String::autoLinkBbCode($this->getHelper('Editor')->getMessageText('message', $this->_input)); $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post'); $dw->setExistingData($postId); $dw->set('message', $message); $dw->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum); $this->_setSilentEditOptions($post, $thread, $forum, $dw); $spamModel = $this->_getSpamPreventionModel(); if (!$dw->hasErrors() && $dw->get('message_state') == 'visible' && $spamModel->visitorRequiresSpamCheck()) { $spamExtraParams = array('permalink' => XenForo_Link::buildPublicLink('canonical:threads', $thread)); switch ($spamModel->checkMessageSpam($message, $spamExtraParams, $this->_request)) { case XenForo_Model_SpamPrevention::RESULT_MODERATED: case XenForo_Model_SpamPrevention::RESULT_DENIED: $spamModel->logSpamTrigger('post', $post['post_id']); $dw->error(new XenForo_Phrase('your_content_cannot_be_submitted_try_later')); break; } } $dw->save(); $options = array('authorAlert' => $this->_input->filterSingle('send_author_alert', XenForo_Input::BOOLEAN), 'authorAlertReason' => $this->_input->filterSingle('author_alert_reason', XenForo_Input::STRING)); if ($options['authorAlert']) { $this->_getPostModel()->sendModeratorActionAlert('edit', $dw->getMergedData(), $thread, $options['authorAlertReason']); } XenForo_Model_Log::logModeratorAction('post', $post, 'edit', array(), $thread); if ($this->_noRedirect()) { $this->_request->setParam('thread_id', $thread['thread_id']); return $this->responseReroute('XenForo_ControllerPublic_Thread', 'show-posts'); } else { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('posts', $post)); } }
public function actionSave() { $this->_assertPostOnly(); $this->_assertRegistrationRequired(); $commentModel = $this->_getCommentModel(); $commentId = $this->_input->filterSingle('comment_id', XenForo_Input::UINT); $fetchOptions = array('join' => XenGallery_Model_Comment::FETCH_MEDIA | XenGallery_Model_Comment::FETCH_ALBUM_CONTENT | XenGallery_Model_Comment::FETCH_USER); list($comment, $content) = $this->_getMediaHelper()->assertCommentAndContentValidAndViewable($commentId, $fetchOptions); $input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input); $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']); $writer = XenForo_DataWriter::create('XenGallery_DataWriter_Comment'); $writer->setExistingData($commentId); $writer->set('message', $input['message']); $writer->save(); $this->_sendAuthorAlert($comment, 'xengallery_comment', 'edit', array('content' => $content, 'comment' => $comment)); $this->_logChanges($writer, $comment, 'edit', array(), 'xengallery_comment'); if ($this->_noRedirect()) { if ($commentId) { $comment = $commentModel->prepareComments($comment); $comment['message'] = $input['message']; if ($comment['rating_id']) { $rating = $this->_getRatingModel()->getRatingById($comment['rating_id']); if ($rating) { $comment['rating'] = $rating['rating']; } else { $comment['rating'] = 0; } } } $visitor = XenForo_Visitor::getInstance(); $viewParams = array('comment' => $comment, 'canViewRatings' => $this->_getMediaModel()->canViewRatings(), 'canViewIps' => XenForo_Permission::hasPermission($visitor->permissions, 'general', 'viewIps'), 'canViewWarnings' => $this->getModelFromCache('XenForo_Model_User')->canViewWarnings(), 'canReport' => $visitor['user_id'] ? true : false); return $this->responseView('XenGallery_ViewPublic_Media_Save_CommentListItem', '', $viewParams); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('xengallery/comments', $comment), new XenForo_Phrase('xengallery_comment_updated_successfully')); }
public function actionEdit() { $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT); $userFetchOptions = array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS); $user = $this->getHelper('UserProfile')->getUserOrError($userId, $userFetchOptions); $visitor = XenForo_Visitor::getInstance(); $userModel = $this->_getUserModel(); if (!$userModel->canEditUser($user)) { return $this->responseNoPermission(); } if ($visitor->hasAdminPermission('user')) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildAdminLink('users/edit', $user)); } $user['permissions'] = XenForo_Permission::unserializePermissions($user['global_permission_cache']); $userCanSetCustomTitle = XenForo_Permission::hasPermission($user['permissions'], 'general', 'editCustomTitle'); $userCanEditProfile = XenForo_Permission::hasPermission($user['permissions'], 'general', 'editProfile'); $userCanEditSignature = XenForo_Permission::hasPermission($user['permissions'], 'general', 'editSignature') && XenForo_Permission::hasPermission($user['permissions'], 'signature', 'maxLines') != 0; $customFields = $this->_getFieldModel()->getUserFields(array('moderator_editable' => true), array('valueUserId' => $user['user_id'])); if (!$userCanEditProfile) { // the user can't edit their profile, so don't let moderator change empty values foreach ($customFields as $fieldId => $customField) { if (!$customField['field_value']) { unset($customFields[$fieldId]); } } } if ($this->isConfirmedPost()) { $dwInput = $this->_input->filter(array('custom_title' => XenForo_Input::STRING, 'location' => XenForo_Input::STRING, 'occupation' => XenForo_Input::STRING, 'homepage' => XenForo_Input::STRING)); $dwInput['about'] = $this->getHelper('Editor')->getMessageText('about', $this->_input); $dwInput['about'] = XenForo_Helper_String::autoLinkBbCode($dwInput['about']); $dwInput['signature'] = $this->getHelper('Editor')->getMessageText('signature', $this->_input); $dwInput['signature'] = XenForo_Helper_String::autoLinkBbCode($dwInput['signature']); // moderators can only edit things that users can change or have set themselves, // so check to see if the user can edit OR if there's an existing value if (!$userCanSetCustomTitle && !$user['custom_title']) { unset($dwInput['custom_title']); } if (!$userCanEditProfile) { if (!$user['location']) { unset($dwInput['location']); } if (!$user['occupation']) { unset($dwInput['occupation']); } if (!$user['homepage']) { unset($dwInput['homepage']); } if (!$user['about']) { unset($dwInput['about']); } } if (!$userCanEditSignature && !$user['signature']) { unset($dwInput['signature']); } $customFieldsValues = $this->_input->filterSingle('custom_fields', XenForo_Input::ARRAY_SIMPLE); $customFieldsShown = $this->_input->filterSingle('custom_fields_shown', XenForo_Input::STRING, array('array' => true)); // only edit the ones that can be edited and are shown $customFieldsEditable = array_intersect($customFieldsShown, array_keys($customFields)); $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($user); $dw->bulkSet($dwInput); $dw->setCustomFields($customFieldsValues, $customFieldsEditable); $dw->save(); if ($this->_input->filterSingle('remove_avatar', XenForo_Input::BOOLEAN)) { /** @var XenForo_Model_Avatar $avatarModel */ $avatarModel = $this->getModelFromCache('XenForo_Model_Avatar'); $avatarModel->deleteAvatar($user['user_id']); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('members', $user)); } else { $viewParams = array('user' => $user, 'customFields' => $this->_getFieldModel()->prepareUserFields($customFields, true), 'userCanSetCustomTitle' => $userCanSetCustomTitle, 'userCanEditProfile' => $userCanEditProfile, 'userCanEditSignature' => $userCanEditSignature); return $this->responseView('XenForo_ViewPublic_Member_Edit', 'member_edit', $viewParams); } }