Пример #1
2
 /**
  * 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;
 }
Пример #2
0
 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));
 }
Пример #3
0
 /**
  * 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."));
     }
 }
Пример #4
0
 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'))));
 }
Пример #5
0
 /**
  *
  * @see XenForo_Route_Prefix_Forums::buildLink()
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if (isset($data['social_forum_id'])) {
         if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) {
             $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray();
         } else {
             $socialForum = $data;
         }
         $class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix');
         $router = new $class();
         $link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams);
         if (XenForo_Application::isRegistered('routeFiltersOut')) {
             $routeFilters = XenForo_Application::get('routeFiltersOut');
             if (isset($routeFilters['social-forums'])) {
                 foreach ($routeFilters['social-forums'] as $filter) {
                     if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) {
                         list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']);
                         $newLink = preg_replace($from, $to, $link);
                     } else {
                         $newLink = $link;
                     }
                     if ($newLink != $link) {
                         $link = $newLink;
                         break;
                     }
                 }
             }
         }
         return $link;
     }
     return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
 }
Пример #6
0
 public function actionTogglePrivate()
 {
     $this->_assertPostOnly();
     $idExists = $this->_input->filterSingle('exists', array(XenForo_Input::UINT, 'array' => true));
     $ids = $this->_input->filterSingle('id', array(XenForo_Input::UINT, 'array' => true));
     $nodeModel = $this->_getNodeModel();
     $nodes = $nodeModel->getAllNodes();
     $permissionEntries = $this->_getPermissionModel()->getAllContentPermissionEntriesByTypeGrouped('node');
     $privateNodes = array();
     foreach ($permissionEntries['system'] as $nodeId => $nodePermissions) {
         if (!empty($nodePermissions['general']['viewNode']) && $nodePermissions['general']['viewNode'] == 'reset') {
             $privateNodes[$nodeId] = true;
         }
     }
     foreach ($nodes as $nodeId => $node) {
         if (isset($idExists[$nodeId])) {
             $itemActive = !empty($ids[$nodeId]) ? 1 : 0;
             if (!empty($privateNodes[$nodeId]) != $itemActive) {
                 // TODO: better approach that doesn't rely on every
                 // permission having "revoke" value
                 $this->_setPermissionRevokeStatus($node['node_id'], 0, 0, $itemActive);
             }
         }
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('nodes/private', $node));
 }
Пример #7
0
 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');
 }
Пример #8
0
 /**
  * @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');
 }
Пример #9
0
 /**
  * Method to build a link to the specified page/action with the provided
  * data and params.
  *
  * @see XenForo_Route_BuilderInterface
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if (!empty($data['ip_id'])) {
         $extraParams['ip_id'] = $data['ip_id'];
     }
     return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'user_id', 'username');
 }
Пример #10
0
 /**
  * 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'));
 }
Пример #11
0
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if ($action == 'categories' && isset($data['categorytitle'])) {
         $data['title'] = $data['categorytitle'];
     }
     return XenForo_Link::buildSubComponentLink($this->_getSubcomponents(), $outputPrefix, $action, $extension, $data);
 }
Пример #12
0
 /**
  * Attempts to match the routing path. See {@link XenForo_Route_Interface} for further details.
  *
  * @param string $routePath Routing path
  * @param Zend_Controller_Request_Http $request Request object
  * @param XenForo_Router $router Routing object
  *
  * @return XenForo_RouteMatch|bool
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     if (!XenForo_Application::isRegistered('routeFiltersIn')) {
         return false;
     }
     $filters = XenForo_Application::get('routeFiltersIn');
     if (!$filters) {
         return false;
     }
     foreach ($filters as $filter) {
         if (isset($filter['match_regex'])) {
             $from = $filter['match_regex'];
             $to = $filter['match_replace'];
         } else {
             list($from, $to) = XenForo_Link::translateRouteFilterToRegex(urldecode($filter['replace_route']), urldecode($filter['find_route']));
         }
         $newRoutePath = preg_replace($from, $to, $routePath);
         if ($newRoutePath != $routePath) {
             $match = $router->getRouteMatch();
             $match->setModifiedRoutePath($newRoutePath);
             return $match;
         }
     }
     return false;
 }
 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);
     }
 }
Пример #14
0
 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;
 }
Пример #15
0
 /**
  * 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 buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     $actions = explode('/', $action);
     switch ($actions[0]) {
         case 'top-owned-games':
             $intParams = 'owned_id';
             $strParams = '';
             break;
         case 'top-played-games':
             $intParams = 'played_id';
             $strParams = '';
             break;
         case 'top-recently-played-games':
             $intParams = 'recent_id';
             $strParams = '';
             break;
         default:
             $intParams = '';
             $strParams = '';
             break;
     }
     $action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
     if ($intParams) {
         return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, $intParams, $strParams);
     } else {
         return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, $strParams);
     }
 }
Пример #17
0
 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');
     }
 }
 /**
  * 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']));
 }
Пример #19
0
 public function run()
 {
     /* @var $classModel ThemeHouse_Objects_Model_Class */
     $classModel = XenForo_Model::create('ThemeHouse_Objects_Model_Class');
     $classes = $classModel->getAllClasses();
     if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
         $routes = self::$_data['routesPublic'];
     } elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
         $routes = self::$_data['routesAdmin'];
     }
     foreach ($classes as $class) {
         $routePrefix = '';
         if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
             $routePrefix = isset($class['route_prefix']) ? $class['route_prefix'] : '';
         } elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
             $routePrefix = isset($class['route_prefix_admin']) ? $class['route_prefix_admin'] : '';
         }
         if ($routePrefix && !isset($routes[$routePrefix])) {
             $routes[$routePrefix]['build_link'] = 'all';
             if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
                 $routes[$routePrefix]['route_class'] = 'ThemeHouse_Objects_Route_Prefix_Objects';
             } elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
                 $routes[$routePrefix]['route_class'] = 'ThemeHouse_Objects_Route_PrefixAdmin_Objects';
             }
         }
     }
     if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
         XenForo_Link::setHandlerInfoForGroup('public', $routes);
     } elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
         XenForo_Link::setHandlerInfoForGroup('admin', $routes);
     }
     parent::run();
 }
Пример #20
0
 public function prepareParams()
 {
     if (!empty($this->_params['_user']['user_id'])) {
         call_user_func_array(array('bdApi_ViewApi_Helper_Subscription', 'prepareDiscoveryParams'), array(&$this->_params, $this->_response, bdApi_Model_Subscription::TYPE_USER, $this->_params['_user']['user_id'], XenForo_Link::buildApiLink('users', $this->_params['_user'], array('oauth_token' => '')), isset($this->_params['_user']['bdapi_user']) ? $this->_params['_user']['bdapi_user'] : ''));
     }
     parent::prepareParams();
 }
Пример #21
0
 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));
     }
 }
Пример #22
0
 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();
 }
 protected function _getExtraDataLink(array $widget)
 {
     if (XenForo_Application::$versionId > 1040000) {
         return XenForo_Link::buildPublicLink('find-new/profile-posts');
     }
     return parent::_getExtraDataLink($widget);
 }
Пример #24
0
 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);
 }
Пример #25
0
 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');
 }
Пример #26
0
 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();
 }
Пример #27
0
 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')));
     }
 }
Пример #28
0
 /**
  * Method to build a link to the specified page/action with the provided
  * data and params.
  *
  * @see XenForo_Route_BuilderInterface
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if ($data) {
         XenForo_Link::prepareExtensionAndAction($extension, $action);
         $actionParts = explode('/', $action, 2);
         $url = $outputPrefix . '/' . $actionParts[0];
         switch (strtolower($actionParts[0])) {
             case 'permission':
                 if (!empty($data['permission_group_id']) && !empty($data['permission_id'])) {
                     $url .= '/' . $data['permission_group_id'] . '/' . $data['permission_id'];
                 }
                 break;
             case 'permission-group':
                 if (!empty($data['permission_group_id'])) {
                     $url .= '/' . $data['permission_group_id'];
                 }
                 break;
             case 'interface-group':
                 if (!empty($data['interface_group_id'])) {
                     $url .= '/' . $data['interface_group_id'];
                 }
                 break;
         }
         if (isset($actionParts[1])) {
             $url .= '/' . $actionParts[1];
         }
         return $url . $extension;
     }
     return false;
 }
Пример #29
0
 /**
  * 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;
 }
Пример #30
0
 public function actionDelete()
 {
     $filterParams = $this->_getFilterParams();
     $attachmentIds = $this->_input->filterSingle('attachment_ids', array(XenForo_Input::UINT, 'array' => true));
     if ($attachmentId = $this->_input->filterSingle('attachment_id', XenForo_Input::UINT)) {
         $attachmentIds[] = $attachmentId;
     }
     if ($this->isConfirmedPost()) {
         // delete specified attachments
         foreach ($attachmentIds as $attachmentId) {
             $dw = XenForo_DataWriter::create('XenForo_DataWriter_Attachment');
             $dw->setExistingData($attachmentId);
             $dw->delete();
         }
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('attachments', null, $filterParams));
     } else {
         // show confirmation dialogue
         $viewParams = array('attachmentIds' => $attachmentIds, 'filterParams' => $filterParams);
         if (count($attachmentIds) == 1) {
             list($attachmentId) = $attachmentIds;
             $viewParams['attachment'] = $this->_getAttachmentModel()->getAttachmentById($attachmentId);
         }
         return $this->responseView('XenForo_ViewAdmin_Attachment_Delete', 'attachment_delete', $viewParams);
     }
 }