/** * Inserts tag links into an HTML-formatted text. * * @param string $html * @param array $tags * @param array $options * @return string */ public static function autoTag($html, array $tags, array &$options = array()) { if (empty($tags)) { return $html; } $html = strval($html); $htmlNullified = utf8_strtolower($html); $htmlNullified = preg_replace_callback('#<a[^>]+>.+?</a>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified); $htmlNullified = preg_replace_callback('#<[^>]+>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified); // prepare the options $onceOnly = empty($options['onceOnly']) ? false : true; $options['autoTagged'] = array(); // reset this // sort tags with the longest one first // since 1.0.3 usort($tags, array(__CLASS__, '_autoTag_sortTagsByLength')); foreach ($tags as $tag) { $offset = 0; $tagText = utf8_strtolower($tag['tag']); $tagLength = utf8_strlen($tagText); while (true) { $pos = utf8_strpos($htmlNullified, $tagText, $offset); if ($pos !== false) { // the tag has been found if (self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) { // and it has good surrounding characters // start replacing $displayText = utf8_substr($html, $pos, $tagLength); $template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag'); $template->setParam('tag', $tag); $template->setParam('displayText', $displayText); $replacement = $template->render(); if (strlen($replacement) === 0) { // in case template system hasn't been initialized $replacement = sprintf('<a href="%s">%s</a>', XenForo_Link::buildPublicLink('tags', $tag), $displayText); } $html = utf8_substr_replace($html, $replacement, $pos, $tagLength); $htmlNullified = utf8_substr_replace($htmlNullified, str_repeat('_', utf8_strlen($replacement)), $pos, $tagLength); // sondh@2012-09-20 // keep track of the auto tagged tags $options['autoTagged'][$tagText][$pos] = $replacement; $offset = $pos + utf8_strlen($replacement); if ($onceOnly) { // auto link only once per tag // break the loop now break; // while (true) } } else { $offset = $pos + $tagLength; } } else { // no match has been found, stop working with this tag break; // while (true) } } } return $html; }
public function prepareApiDataForProfilePost(array $profilePost, array $user) { $profilePost = $this->prepareProfilePost($profilePost, $user); $publicKeys = array('profile_post_id' => 'profile_post_id', 'profile_user_id' => 'timeline_user_id', 'user_id' => 'poster_user_id', 'username' => 'poster_username', 'post_date' => 'post_create_date', 'message' => 'post_body', 'likes' => 'post_like_count', 'comment_count' => 'post_comment_count'); $data = bdApi_Data_Helper_Core::filter($profilePost, $publicKeys); if (isset($profilePost['message_state'])) { switch ($profilePost['message_state']) { case 'visible': $data['post_is_published'] = true; $data['post_is_deleted'] = false; break; case 'moderated': $data['post_is_published'] = false; $data['post_is_deleted'] = false; break; case 'deleted': $data['post_is_published'] = false; $data['post_is_deleted'] = true; break; } } if (isset($profilePost['like_date'])) { $data['post_is_liked'] = !empty($profilePost['like_date']); } $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts', $profilePost), 'timeline' => bdApi_Data_Helper_Core::safeBuildApiLink('users/timeline', $user), 'timeline_user' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $user), 'poster' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $profilePost), 'likes' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/likes', $profilePost), 'comments' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/comments', $profilePost), 'report' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/report', $profilePost), 'poster_avatar' => XenForo_Template_Helper_Core::callHelper('avatar', array($profilePost, 'm', false, true))); $data['permissions'] = array('view' => $this->canViewProfilePost($profilePost, $user), 'edit' => $this->canEditProfilePost($profilePost, $user), 'delete' => $this->canDeleteProfilePost($profilePost, $user), 'like' => $this->canLikeProfilePost($profilePost, $user), 'comment' => $this->canCommentOnProfilePost($profilePost, $user), 'report' => $this->canReportProfilePost($profilePost, $user)); return $data; }
/** * Check and apply the association request. * * @return XenForo_ControllerResponse_Redirect|XenForo_ControllerResponse_View */ public function actionIndex() { $mcAssoc = $this->getMcAssoc(); $inputData = $this->_input->filterSingle('data', XenForo_Input::STRING); $visitor = XenForo_Visitor::getInstance(); $isAdmin = $visitor['is_admin']; $visitorName = $visitor['username']; try { $data = $mcAssoc->unwrapData($inputData); $username = $mcAssoc->unwrapKey($data->key); if ($username != $visitorName) { throw new Exception("Username does not match."); } $this->handleData($visitor, $data); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink("mc-association/view")); } catch (Exception $e) { if ($inputData == null) { $message = "No data provided."; } else { $message = $e->getMessage(); } $opts = XenForo_Application::get('options'); $message .= "<br /><pre>Credentials in use" . json_encode(["site_id" => $opts->mcAssocSiteId, "instance_secret" => $opts->mcAssocInstanceSecret, "shared_secret" => $opts->mcAssocSharedSecret]) . "</pre>"; return $this->responseView('AssociationMc_ViewPublic_Error', 'association_error', array("exceptionMessage" => $isAdmin ? $message : "Please contact an administrator for more information.")); } }
public function generateHtmlRecurrence($days, $amount, $currency, $comment, array $data, XenForo_View $view) { $data[] = utf8_strtolower($currency); $data[] = $amount; $processorModel = $this->_getProcessorModel(); $itemId = $processorModel->generateItemId('bdshop', XenForo_Visitor::getInstance(), $data); $processorNames = $processorModel->getProcessorNames(); $processors = array(); foreach ($processorNames as $processorId => $processorClass) { $processors[$processorId] = bdPaygate_Processor_Abstract::create($processorClass); } $recurringInterval = false; $recurringUnit = false; if ($days > 0) { if ($days % 360 == 0) { $recurringInterval = $days / 365; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_YEAR; } elseif ($days % 30 == 0) { $recurringInterval = $days / 30; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_MONTH; } else { $recurringInterval = $days; $recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_DAY; } } return implode('', bdPaygate_Processor_Abstract::prepareForms($processors, $amount, $currency, $comment, $itemId, $recurringInterval, $recurringUnit, array(bdPaygate_Processor_Abstract::EXTRA_RETURN_URL => XenForo_Link::buildPublicLink('full:shop/thanks')))); }
protected function _getExtraDataLink(array $widget) { if (XenForo_Application::$versionId > 1040000) { return XenForo_Link::buildPublicLink('find-new/profile-posts'); } return parent::_getExtraDataLink($widget); }
protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog'); $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => 'resource_category', 'content_id' => $content['resource_category_id'], 'content_user_id' => $logUser['user_id'], 'content_username' => $logUser['username'], 'content_title' => $content['category_title'], 'content_url' => XenForo_Link::buildPublicLink('resources/categories', $content), 'discussion_content_type' => 'resource_category', 'discussion_content_id' => $content['resource_category_id'], 'action' => $action, 'action_params' => $actionParams)); $dw->save(); return $dw->get('moderator_log_id'); }
public static function navigationTabs(&$extraTabs, $selectedTabId) { $options = XenForo_Application::get('options'); if (XenForo_Visitor::getInstance()->hasPermission('players', 'view') && $options->displayPlayersTab && $options->displayPlayers) { $extraTabs['players'] = array('title' => new XenForo_Phrase('players'), 'href' => XenForo_Link::buildPublicLink('full:players'), 'position' => 'home', 'linksTemplate' => 'player_tab_links'); } }
protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject) { $renderTemplateObject->setParams($params); if (!isset($params['url'])) { // try to detect the correct url for different templates $autoDetectedUrl = false; switch ($positionCode) { case 'forum_list': $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums'); break; case 'forum_view': $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums', $params['forum']); break; case 'member_view': // this widget on member_view, seriously? $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:members', $params['user']); break; case 'resource_author_view': $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources/authors', $params['user']); break; case 'resource_view': $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources', $params['resource']); break; case 'thread_view': $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:threads', $params['thread']); break; } if ($autoDetectedUrl !== false) { $renderTemplateObject->setParam('url', $autoDetectedUrl); } } return $renderTemplateObject->render(); }
/** * Confirms a lost password reset request and resets the password. * * @return XenForo_ControllerResponse_Abstract */ public function actionConfirm() { $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT); if (!$userId) { return $this->responseError(new XenForo_Phrase('no_account_specified')); } $confirmationModel = $this->_getUserConfirmationModel(); $confirmation = $confirmationModel->getUserConfirmationRecord($userId, 'password'); if (!$confirmation) { if (XenForo_Visitor::getUserId()) { // probably already been reset return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildPublicLink('index')); } else { return $this->responseError(new XenForo_Phrase('your_password_could_not_be_reset')); } } $confirmationKey = $this->_input->filterSingle('c', XenForo_Input::STRING); if ($confirmationKey) { $accountConfirmed = $confirmationModel->validateUserConfirmationRecord($confirmationKey, $confirmation); } else { $accountConfirmed = false; } if ($accountConfirmed) { $confirmationModel->resetPassword($userId); $confirmationModel->deleteUserConfirmationRecord($userId, 'password'); XenForo_Visitor::setup(0); return $this->responseMessage(new XenForo_Phrase('your_password_has_been_reset')); } else { return $this->responseError(new XenForo_Phrase('your_password_could_not_be_reset')); } }
public function actionDiscordLink() { $this->_assertPostOnly(); $visitor = XenForo_Visitor::getInstance(); if (!$visitor->hasPermission('general', 'linkDiscord')) { return $this->responseNoPermission(); } $tokenModel = $this->_getTokenmodel(); $generate = $this->_input->filterSingle('create', XenForo_Input::STRING, array('default' => '')); if (strlen($generate)) { $dw = XenForo_DataWriter::create('DiscordAuth_DataWriter_Token'); $existing = $tokenModel->getTokenByUserId($visitor['user_id']); if ($existing === false || !$existing['valid']) { if ($existing !== false) { $dw->setExistingData($existing, true); } try { $dw->set('user_id', $visitor['user_id']); $dw->set('token', self::generateToken()); $dw->save(); // self::generateToken may throw Exception } catch (Exception $e) { XenForo_Error::logException($e, false); } } } $unlink = $this->_input->filterSingle('unlink', XenForo_Input::STRING, array('default' => '')); if (strlen($unlink)) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('da_discord_id', null); $dw->save(); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('account/discord'))); }
public function actionSigPicUpload() { $this->_assertPostOnly(); if (!XenForo_Visitor::getInstance()->hasPermission('signature', 'sigpic')) { return $this->responseNoPermission(); } $sigpic = XenForo_Upload::getUploadedFile('sigpic'); $sigpicModel = $this->getModelFromCache('TPUSigPic_Model_SigPic'); $visitor = XenForo_Visitor::getInstance(); $inputData = $this->_input->filter(array('delete' => XenForo_Input::UINT)); if ($sigpic) { $sigpicData = $sigpicModel->uploadSigPic($sigpic, $visitor['user_id'], $visitor->getPermissions()); } else { if ($inputData['delete']) { $sigpicData = $sigpicModel->deleteSigPic(XenForo_Visitor::getUserId()); } } if (isset($sigpicData) && is_array($sigpicData)) { foreach ($sigpicData as $key => $val) { $visitor[$key] = $val; } } $message = new XenForo_Phrase('upload_completed_successfully'); if ($this->_noRedirect()) { // TODO } else { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('account/signature'), $message); } }
public function actionDelete() { $tag = $this->_getTagOrError(); $tagDw = XenForo_DataWriter::create('sonnb_XenGallery_DataWriter_Tag'); $tagDw->setExistingData($tag, true); $tagDw->delete(); switch ($tag['content_type']) { case sonnb_XenGallery_Model_Album::$contentType: $redirectTarget = XenForo_Link::buildPublicLink('gallery/albums', array('album_id' => $tag['content_id'])); break; default: $content = $this->_getContentModel()->getContentById($tag['content_id']); $redirectTarget = $this->_buildLink('gallery/' . $content['content_type'] . 's', $content); break; } if ($this->_request->isXmlHttpRequest() && $tag['content_type'] !== sonnb_XenGallery_Model_Album::$contentType) { $this->_routeMatch->setResponseType('json'); $content = $this->_getContentModel()->getContentById($tag['content_id']); if (!empty($photo['tagUsers'])) { $content['tagUsers'] = $this->_getTagModel()->getTagsByContentId($content['content_type'], $content['content_id'], array('tag_state' => 'accepted')); } return $this->responseView('sonnb_XenGallery_ViewPublic_Tag_Delete', '', array('content' => $content)); } else { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirectTarget); } }
/** * * Adds the "Chat" tab with permission-based links. * * @param array $extraTabs * @param unknown_type $selectedTabId */ public static function navTabsListener(array &$extraTabs, $selectedTabId) { if (XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_view')) { $perms = array("canModerateChat" => XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_mod_access'), "canAccessChat" => XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_user_access') || XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_guest_access')); $extraTabs['chat'] = array('title' => new XenForo_Phrase('modm_ajaxchat_tabname'), 'href' => $perms['canAccessChat'] ? XenForo_Link::buildPublicLink('chat/login') : XenForo_Link::buildPublicLink('chat/online'), 'position' => 'middle', 'linksTemplate' => 'modm_ajaxchat_nav_links', 'perms' => $perms); } }
public static function getSessionActivityDetailsForList(array $activities) { $categoryIds = array(); foreach ($activities as $activity) { if (!empty($activity['params']['category_id'])) { $categoryIds[$activity['params']['category_id']] = intval($activity['params']['category_id']); } } $categoryData = array(); if ($categoryIds) { /* @var $categoryModel SimplePortal_Model_Category */ $categoryModel = XenForo_Model::create('SimplePortal_Model_Category'); $categories = $categoryModel->getCategories(array('category_id' => $categoryIds)); foreach ($categories as $category) { $categoryData[$category['category_id']] = array('title' => $category['title'], 'url' => XenForo_Link::buildPublicLink('portal/categories', $category)); } } $output = array(); foreach ($activities as $key => $activity) { $category = false; if (!empty($activity['params']['category_id'])) { $categoryId = $activity['params']['category_id']; if (isset($categoryData[$categoryId])) { $category = $categoryData[$categoryId]; } } if ($category) { $output[$key] = array(new XenForo_Phrase('el_portal_viewing_portal'), $category['title'], $category['url'], false); } else { $output[$key] = new XenForo_Phrase('el_portal_viewing_portal'); } } return $output; }
/** * Gets visible moderation queue entries for specified user. * * @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser() */ public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser) { /** @var XenForo_Model_ProfilePost $profilePostModel */ $profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost'); $comments = $profilePostModel->getProfilePostCommentsByIds($contentIds); $profilePostIds = XenForo_Application::arrayColumn($comments, 'profile_post_id'); $profilePosts = $profilePostModel->getProfilePostsByIds($profilePostIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY | XenForo_Model_ProfilePost::FETCH_USER_POSTER, 'visitingUser' => $viewingUser)); $output = array(); foreach ($comments as $key => &$comment) { if (isset($profilePosts[$comment['profile_post_id']])) { $comment['profilePost'] = $profilePosts[$comment['profile_post_id']]; $comment['profileUser'] = $profilePostModel->getProfileUserFromProfilePost($comment['profilePost'], $viewingUser); if (!$comment['profilePost'] || !$comment['profileUser']) { continue; } $canManage = true; if (!$profilePostModel->canViewProfilePostAndContainer($comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) { $canManage = false; } else { if (!$profilePostModel->canViewProfilePostComment($comment, $comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) { $canManage = false; } else { if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) { $canManage = false; } } } if ($canManage) { $output[$comment['profile_post_comment_id']] = array('message' => $comment['message'], 'user' => array('user_id' => $comment['user_id'], 'username' => $comment['username']), 'title' => new XenForo_Phrase('profile_post_comment_by_x', array('username' => $comment['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts/comments', $comment), 'contentTypeTitle' => new XenForo_Phrase('profile_post_comment'), 'titleEdit' => false); } } } return $output; }
public static function runDailyCleanUp() { $options = XenForo_Application::get('options'); $model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat'); if ($options->dark_taigachat_archivethread > 0) { $messages = array_reverse($model->getMessagesToday()); if (count($messages) > 0) { $userModel = XenForo_Model::create('XenForo_Model_User'); $post = ""; foreach ($messages as $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 = "******"; } $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(); } } $model->deleteOldMessages(); }
public function actionProfileresultsdisplay() { $maxRes = 100; $visitor = XenForo_Visitor::getInstance(); if (!$visitor['user_id']) { throw $this->getNoPermissionResponseException(); } $uid = $visitor['user_id']; unset($visitor); $query = mb_strtolower($this->_input->filterSingle('q', XenForo_Input::STRING), 'UTF-8'); $q = substr($query, 0, 255); ProfileNdx_search_engine::cleanOldsFromLimit(); ProfileNdx_search_engine::cleanOldsFromCache(); $permission = ProfileNdx_search_engine::userCanSearch($uid, $q); if (!$permission['status']) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('search/profileresultswait/', '', array('redirect' => XenForo_Link::buildPublicLink('search/profileresultsdisplay/', '', array('q' => $query)), 'wait' => $permission['wait'])), ''); } $viewpar = ProfileNdx_search_engine::getFromCache($q); if ($viewpar == null) { $results = (new ProfileNdx_search_engine())->search($q); $viewpar = array('search' => array('search_query' => $query), 'results' => array_slice($results, 0, $maxRes), 'totalResults' => count($results), 'resultStartOffset' => 0, 'resultEndOffset' => min(count($results), $maxRes)); $results = (new ProfileNdx_search_engine())->toHtml($viewpar['results']); $viewpar['results'] = $results; ProfileNdx_search_engine::saveToCache($q, $viewpar); } return $this->responseView('XenForo_ViewPublic_Base', 'kiror_search_results', $viewpar); }
public function actionPopup() { $options = XenForo_Application::get('options'); $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink($options->dark_taigachat_route . '/popup')); $viewParams = array('request' => $this->_request); return $this->responseView('Dark_TaigaChat_ViewPublic_TaigaChat_Popup', 'dark_taigachat_popup', $viewParams); }
/** * Gets visible moderation queue entries for specified user. * * @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser() */ public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser) { /* @var $profilePostModel XenForo_Model_ProfilePost */ $profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost'); $profilePosts = $profilePostModel->getProfilePostsByIds($contentIds); $profileUserIds = array(); foreach ($profilePosts as $profilePost) { $profileUserIds[] = $profilePost['profile_user_id']; } $users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds($profileUserIds, array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id'])); $output = array(); foreach ($profilePosts as $profilePost) { if (!isset($users[$profilePost['profile_user_id']])) { continue; } $user = $users[$profilePost['profile_user_id']]; $canManage = true; if (!$profilePostModel->canViewProfilePostAndContainer($profilePost, $user, $null, $viewingUser)) { $canManage = false; } else { if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) { $canManage = false; } } if ($canManage) { $output[$profilePost['profile_post_id']] = array('message' => $profilePost['message'], 'user' => array('user_id' => $profilePost['user_id'], 'username' => $profilePost['username']), 'title' => new XenForo_Phrase('profile_post_for_x', array('username' => $user['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'contentTypeTitle' => new XenForo_Phrase('profile_post'), 'titleEdit' => false); } } return $output; }
public function actionPromote() { if (!$this->perms['promote']) { return $this->responseNoPermission(); } $input = $this->_input->filter(array('thread_id' => XenForo_Input::UINT, 'promote_date' => XenForo_Input::UINT, 'promote_icon' => XenForo_Input::STRING, 'attach_data' => XenForo_Input::UINT, 'image_data' => XenForo_Input::STRING, 'medio_data' => XenForo_Input::UINT, 'date' => XenForo_Input::STRING, 'hour' => XenForo_Input::UINT, 'mins' => XenForo_Input::UINT, 'ampm' => XenForo_Input::STRING, 'zone' => XenForo_Input::STRING, 'delete' => XenForo_Input::STRING)); $ftpHelper = $this->getHelper('ForumThreadPost'); list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($input['thread_id']); if ($this->_request->isPost()) { $this->getModelFromCache('EWRporta_Model_Promotes')->updatePromotion($input); $this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentFeatures')); $this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentNews')); } else { $threadPromote = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteByThreadId($thread['thread_id']); $visitor = XenForo_Visitor::getInstance(); $datetime = $threadPromote ? $threadPromote['promote_date'] : $thread['post_date']; $datetime = new DateTime(date('r', $datetime)); $datetime->setTimezone(new DateTimeZone($visitor['timezone'])); $datetime = explode('.', $datetime->format('Y-m-d.h.i.A.T')); $datetime = array('date' => $datetime[0], 'hour' => $datetime[1], 'mins' => $datetime[2], 'meri' => $datetime[3], 'zone' => $datetime[4]); $icons = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteIcons($thread); $viewParams = array('thread' => $thread, 'icons' => $icons, 'threadPromote' => $threadPromote, 'datetime' => $datetime, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum)); return $this->responseView('EWRporta_ViewPublic_Promote', 'EWRporta_Promote', $viewParams); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('threads', $thread)); }
/** * @param array $logUser * @param array $content * @param $action * @param array $actionParams * @param null $parentContent * @return mixed */ protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog'); $dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'content_id' => $content['content_id'], 'content_user_id' => $content['user_id'], 'content_username' => $content['username'], 'content_title' => XenForo_Helper_String::wordWrapString($content['title'], 140), 'content_url' => XenForo_Link::buildPublicLink('gallery/photos', $content), 'discussion_content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'discussion_content_id' => $content['content_id'], 'action' => $action, 'action_params' => $actionParams)); $dw->save(); return $dw->get('moderator_log_id'); }
public function getBreadcrumbsForContent(array $content) { $breadCrumbs = $this->_getCategoryModel()->getCategoryBreadcrumb($content); $breadCrumbs = array_values($breadCrumbs); $breadCrumbs[] = array('href' => XenForo_Link::buildPublicLink('full:resources', $content), 'value' => $content['title']); return $breadCrumbs; }
public function actionTrash() { if (!XenForo_Visitor::getInstance()->hasPermission('forum', 'trashThreads')) { throw $this->getErrorOrNoPermissionResponseException(false); } if (!($targetNode = XenForo_Application::getOptions()->nixfifty_trash_can)) { return $this->responseError(new XenForo_Phrase('trash_can_node_not_set')); } $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT); list($thread, $forum) = $this->getHelper('ForumThreadPost')->assertThreadValidAndViewable($threadId); if ($this->isConfirmedPost()) { $softDelete = $this->_input->filterSingle('trash_type', XenForo_Input::UINT); $trashType = $softDelete ? 'move' : 'soft'; $options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING)); $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread'); $dw->setExistingData($threadId); $dw->set('node_id', $targetNode); $dw->save(); if ($trashType == 'soft' && XenForo_Visitor::getInstance()->hasPermission('forum', 'softDeleteTrashedThreads')) { $this->_getThreadModel()->deleteThread($threadId, $trashType, $options); XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $trashType, array('reason' => $options['reason'])); } XenForo_Model_Log::logModeratorAction('thread', $thread, 'move', array('from' => $forum['title'])); $this->_updateModeratorLogThreadEdit($thread, $dw, array('node_id')); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum)); } else { return $this->responseView('', 'trash_thread', array('thread' => $thread)); } }
protected function _pageContainer() { $threadLinkString = 'threadLinkString'; $threadLink = XenForo_Link::buildPublicLink($threadLinkString); $prefix = rtrim(str_replace($threadLinkString, '', $threadLink), '/'); //TODO Global Variable if (!isset($GLOBALS['ThreadInOverlay_overlayLinks'])) { return; } foreach ($GLOBALS['ThreadInOverlay_overlayLinks'] as $link => $action) { $linkPrefixed = $prefix . $link; $regEx = '/<a href="' . preg_quote($linkPrefixed, '/') . '"[^>]*>/i'; $offset = 0; $matches = array(); do { $matched = preg_match($regEx, $this->_contents, $matches, PREG_OFFSET_CAPTURE, $offset + 1); if ($matched) { $offset = $matches[0][1]; $found = $matches[0][0]; if (strpos($found, 'class="') !== false) { // there is a class attribute already if (strpos($found, 'OverlayTrigger') === false) { $replacement = str_replace('class="', 'class="OverlayTrigger ', $found); } } else { // no class yet $replacement = str_replace('<a', '<a class="OverlayTrigger"', $found); } // all seems find, update content now $this->_contents = substr_replace($this->_contents, $replacement, $offset, strlen($found)); } } while ($matched); } }
public function renderRss() { $forum = $this->_params['forum']; $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24'; $feed = new Zend_Feed_Writer_Feed(); $feed->setEncoding('utf-8'); $feed->setTitle($forum['title']); $feed->setDescription($forum['description'] ? $forum['description'] : $forum['title']); $feed->setLink(XenForo_Link::buildPublicLink('canonical:forums', $forum)); if (!$buggyXmlNamespace) { $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:forums.rss', $forum), 'rss'); } $feed->setDateModified(XenForo_Application::$time); $feed->setLastBuildDate(XenForo_Application::$time); if (XenForo_Application::get('options')->boardTitle) { $feed->setGenerator(XenForo_Application::get('options')->boardTitle); } foreach ($this->_params['threads'] as $thread) { // TODO: add contents of first post in future // TODO: wrap in exception handling down the line $entry = $feed->createEntry(); $entry->setTitle($thread['title']); $entry->setLink(XenForo_Link::buildPublicLink('canonical:threads', $thread)); $entry->setDateCreated(new Zend_Date($thread['post_date'], Zend_Date::TIMESTAMP)); $entry->setDateModified(new Zend_Date($thread['last_post_date'], Zend_Date::TIMESTAMP)); if (!$buggyXmlNamespace) { $entry->addAuthor(array('name' => $thread['username'], 'uri' => XenForo_Link::buildPublicLink('canonical:members', $thread))); if ($thread['reply_count']) { $entry->setCommentCount($thread['reply_count']); } } $feed->addEntry($entry); } return $feed->export('rss'); }
/** * Saves changes to the messages/discussions in the mdoeration queue. * * @return XenForo_ControllerResponse_Abstract */ public function actionSave() { $this->_assertPostOnly(); $queue = $this->_input->filterSingle('queue', XenForo_Input::ARRAY_SIMPLE); $this->_getModerationQueueModel()->saveModerationQueueChanges($queue); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('moderation-queue')); }
protected function _preDispatch($action) { parent::_preDispatch($action); if (XenForo_Application::getOptions()->sonnb_XG_disableCamera) { throw $this->responseException($this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildPublicLink('gallery'))); } }
/** * Gets the link to the specified content. * * @see XenForo_ReportHandler_Abstract::getContentLink() */ public function getContentLink(array $report, array $contentInfo) { // we can't have non-participants view a conversation at this point, so don't provide a link // maybe check if the visitor has permission to view the conversation and build the link then? return ''; return XenForo_Link::buildPublicLink('conversations/message', array('conversation_id' => $contentInfo['conversation']['conversation_id'], 'title' => $contentInfo['conversation']['title']), array('message_id' => $report['content_id'])); }
/** * Gets visible moderation queue entries for specified user. * * @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser() */ public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser) { /* @var $resourceModel XenResource_Model_Resource */ $resourceModel = XenForo_Model::create('XenResource_Model_Resource'); $resources = $resourceModel->getResourcesByIds($contentIds, array('join' => XenResource_Model_Resource::FETCH_DESCRIPTION)); $categories = XenForo_Model::create('XenResource_Model_Category')->getAllCategories(array('permissionCombinationId' => $viewingUser['permission_combination_id'])); $output = array(); foreach ($resources as $resource) { if (!isset($categories[$resource['resource_category_id']])) { continue; } $category = $categories[$resource['resource_category_id']]; $categoryPermissions = XenForo_Permission::unserializePermissions($category['category_permission_cache']); $canManage = true; if (!$resourceModel->canViewResourceAndContainer($resource, $category, $null, $viewingUser, $categoryPermissions)) { $canManage = false; } else { if (!XenForo_Permission::hasContentPermission($categoryPermissions, 'editAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'deleteAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'approveUnapprove')) { $canManage = false; } } if ($canManage) { $output[$resource['resource_id']] = array('message' => $resource['description'], 'user' => array('user_id' => $resource['user_id'], 'username' => $resource['username']), 'title' => $resource['title'], 'link' => XenForo_Link::buildPublicLink('resources', $resource), 'contentTypeTitle' => new XenForo_Phrase('resource'), 'titleEdit' => true); } } return $output; }
public function renderHtml() { if (!empty($this->_params['captcha'])) { $this->_params['captcha'] = $this->_params['captcha']->render($this); } $this->_params['editorTemplate'] = XenForo_ViewPublic_Helper_Editor::getEditorTemplate($this, 'message', !empty($this->_params['draft']) ? $this->_params['draft']['message'] : '', array('autoSaveUrl' => XenForo_Link::buildPublicLink('forums/save-draft', $this->_params['forum']))); }