Beispiel #1
0
 public function createContent($tabId, $tabName, array $createCriteria, array $params)
 {
     if (empty($params['existing_content_id'])) {
         return $tabId;
     }
     /* @var $mediaDw XenGallery_DataWriter_Media */
     $mediaDw = XenForo_DataWriter::create('XenGallery_DataWriter_Media', XenForo_DataWriter::ERROR_SILENT);
     if (!$mediaDw->setExistingData($params['existing_content_id'])) {
         return $tabId;
     }
     if ($tabId && $mediaDw->get('tab_id')) {
         $this->_getTabModel()->mergeTabIds($tabId, $mediaDw->get('tab_id'));
         return $tabId;
     }
     if (!$tabId) {
         if ($mediaDw->get('tab_id')) {
             $tabId = $mediaDw->get('tab_id');
         } else {
             $newTabId = $this->getTabId();
             $mediaDw->set('tab_id', $newTabId);
             if (!$mediaDw->save()) {
                 return $tabId;
             }
             $tabId = $newTabId;
             $this->insertTab($tabId, 'xengallery_media', $mediaDw->get('media_id'), $tabName);
         }
     }
     return $tabId;
 }
Beispiel #2
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');
 }
Beispiel #3
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));
     }
 }
Beispiel #4
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('batch' => 100, 'position' => 0, 'positionRebuild' => false), $data);
     /* @var $threadModel XenForo_Model_Thread */
     $threadModel = XenForo_Model::create('XenForo_Model_Thread');
     $threadIds = $threadModel->getThreadIdsInRange($data['position'], $data['batch']);
     if (sizeof($threadIds) == 0) {
         return false;
     }
     $forums = XenForo_Model::create('XenForo_Model_Forum')->getForumsByThreadIds($threadIds);
     foreach ($threadIds as $threadId) {
         $data['position'] = $threadId;
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
         if ($dw->setExistingData($threadId)) {
             $dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
             if (isset($forums[$dw->get('node_id')])) {
                 $dw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forums[$dw->get('node_id')]);
             }
             if ($data['positionRebuild']) {
                 $dw->rebuildDiscussion();
             } else {
                 $dw->rebuildDiscussionCounters();
             }
             $dw->save();
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('threads');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Beispiel #5
0
 public function actionExpire()
 {
     $warningId = $this->_input->filterSingle('warning_id', XenForo_Input::UINT);
     $warning = $this->_getWarningOrError($warningId);
     if (!$this->_getUserModel()->canViewWarnings() || !$this->_getWarningModel()->canUpdateWarningExpiration($warning)) {
         return $this->responseNoPermission();
     }
     if ($this->isConfirmedPost()) {
         $expire = $this->_input->filterSingle('expire', XenForo_Input::STRING);
         if ($expire == 'now') {
             $expiryDate = XenForo_Application::$time;
         } else {
             if ($expire == 'future') {
                 $expiryLength = $this->_input->filterSingle('expiry_length', XenForo_Input::UINT);
                 $expiryUnit = $this->_input->filterSingle('expiry_unit', XenForo_Input::STRING);
                 $expiryDate = strtotime("+{$expiryLength} {$expiryUnit}");
                 $expiryDate = min(pow(2, 32) - 1, $expiryDate);
                 if (!$expiryDate || $expiryDate < XenForo_Application::$time) {
                     $expiryDate = XenForo_Application::$time;
                 }
             } else {
                 return $this->responseReroute(__CLASS__, 'index');
             }
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Warning');
         $dw->setExistingData($warning, true);
         $dw->set('expiry_date', $expiryDate);
         $dw->save();
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
     } else {
         return $this->responseReroute(__CLASS__, 'index');
     }
 }
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'batch' => 5), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $albumModel XenGallery_Model_Album */
     $albumModel = XenForo_Model::create('XenGallery_Model_Album');
     /* @var $mediaModel XenGallery_Model_Media */
     $mediaModel = XenForo_Model::create('XenGallery_Model_Media');
     $albumIds = $albumModel->getAlbumIdsInRange($data['position'], $data['batch']);
     if (sizeof($albumIds) == 0) {
         return true;
     }
     foreach ($albumIds as $albumId) {
         $count = $mediaModel->countMedia(array('album_id' => $albumId));
         $albumWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Album');
         $albumWriter->setExistingData($albumId);
         $albumWriter->set('album_media_count', $count);
         $albumWriter->save();
         $data['position'] = $albumId;
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('xengallery_rebuilding_album_media_counts');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Beispiel #7
0
 /**
  * Saves a custom resource field.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionSave()
 {
     $fieldId = $this->_input->filterSingle('field_id', XenForo_Input::STRING);
     $newFieldId = $this->_input->filterSingle('new_field_id', XenForo_Input::STRING);
     $dwInput = $this->_input->filter(array('display_group' => XenForo_Input::STRING, 'display_order' => XenForo_Input::UINT, 'field_type' => XenForo_Input::STRING, 'match_type' => XenForo_Input::STRING, 'match_regex' => XenForo_Input::STRING, 'match_callback_class' => XenForo_Input::STRING, 'match_callback_method' => XenForo_Input::STRING, 'max_length' => XenForo_Input::UINT, 'required' => XenForo_Input::UINT, 'display_template' => XenForo_Input::STRING));
     $categoryIds = $this->_input->filterSingle('resource_category_ids', XenForo_Input::UINT, array('array' => true));
     $dw = XenForo_DataWriter::create('XenResource_DataWriter_ResourceField');
     if ($fieldId) {
         $dw->setExistingData($fieldId);
     } else {
         $dw->set('field_id', $newFieldId);
     }
     $dw->bulkSet($dwInput);
     $dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_CATEGORY_IDS, $categoryIds);
     $dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_TITLE, $this->_input->filterSingle('title', XenForo_Input::STRING));
     $dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_DESCRIPTION, $this->_input->filterSingle('description', XenForo_Input::STRING));
     $fieldChoices = $this->_input->filterSingle('field_choice', XenForo_Input::STRING, array('array' => true));
     $fieldChoicesText = $this->_input->filterSingle('field_choice_text', XenForo_Input::STRING, array('array' => true));
     $fieldChoicesCombined = array();
     foreach ($fieldChoices as $key => $choice) {
         if (isset($fieldChoicesText[$key])) {
             $fieldChoicesCombined[$choice] = $fieldChoicesText[$key];
         }
     }
     $dw->setFieldChoices($fieldChoicesCombined);
     $dw->save();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('resource-fields') . $this->getLastHash($dw->get('field_id')));
 }
 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')));
 }
Beispiel #9
0
 public function deleteTemplate($input)
 {
     $dw = XenForo_DataWriter::create('EWRcarta_DataWriter_Templates');
     $dw->setExistingData($input);
     $dw->delete();
     return true;
 }
Beispiel #10
0
 public function createContent($tabId, $tabName, array $createCriteria, array $params)
 {
     if (!$createCriteria['resource_category_id']) {
         return $tabId;
     }
     /* @var $dw XenResource_DataWriter_Resource */
     $dw = XenForo_DataWriter::create('XenResource_DataWriter_Resource', XenForo_DataWriter::ERROR_SILENT);
     $dw->bulkSet(array('resource_category_id' => $createCriteria['resource_category_id'], 'title' => $params['title'], 'tag_line' => isset($params['tag_line']) ? $params['tag_line'] : new XenForo_Phrase('waindigo_resource_tag_line_create_tabs', $params, false), 'user_id' => $params['user_id'], 'username' => $params['username'], 'tab_id' => $tabId));
     $dw->setOption(Waindigo_Tabs_Extend_XenResource_DataWriter_Resource::OPTION_CHECK_TAB_RULES, false);
     $descriptionDw = $dw->getDescriptionDw();
     $descriptionDw->set('message', $params['message']);
     $versionDw = $dw->getVersionDw();
     $dw->set('is_fileless', 1);
     $versionDw->setOption(XenResource_DataWriter_Version::OPTION_IS_FILELESS, true);
     $versionDw->set('version_string', XenForo_Locale::date(XenForo_Application::$time, 'Y-m-d'));
     if ($dw->hasErrors()) {
         return $tabId;
     }
     if (!$tabId) {
         $tabId = $this->getTabId();
         $dw->set('tab_id', $tabId);
     }
     if (!$dw->save()) {
         return $tabId;
     }
     $this->insertTab($tabId, 'resource', $dw->get('resource_id'), $tabName);
     return $tabId;
 }
Beispiel #11
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'batch' => 70), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $postModel XenForo_Model_Post */
     $postModel = XenForo_Model::create('XenForo_Model_Post');
     $postIds = $postModel->getPostIdsInRange($data['position'], $data['batch']);
     if (sizeof($postIds) == 0) {
         return true;
     }
     foreach ($postIds as $postId) {
         $data['position'] = $postId;
         /* @var $postDw XenForo_DataWriter_DiscussionMessage_Post */
         $postDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
         if ($postDw->setExistingData($postId)) {
             XenForo_Db::beginTransaction();
             $postDw->rebuildPostVerseCache();
             XenForo_Db::commit();
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('posts');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Beispiel #12
0
 public function insert()
 {
     $dw = XenForo_DataWriter::create($this->dataWriter);
     $dw->bulkSet($this->getValidatedInputFields());
     $dw->save();
     return $dw->getMergedData();
 }
 protected function _postInstall()
 {
     /* @var $captchaQuestionModel XenForo_Model_CaptchaQuestion */
     $captchaQuestionModel = XenForo_Model::create('XenForo_Model_CaptchaQuestion');
     $captchaQuestions = $captchaQuestionModel->getAllCaptchaQuestions();
     /* @var $phraseModel XenForo_Model_Phrase */
     $phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
     $phrases = $phraseModel->getEffectivePhraseListForLanguage(0, array('title' => 'captcha_question_'));
     $phraseTitles = array();
     foreach ($phrases as $phrase) {
         $phraseTitles[substr($phrase['title'], strlen('captcha_question'))] = $phrase['phrase_id'];
     }
     foreach ($captchaQuestions as $captchaQuestion) {
         $data = array('title' => 'captcha_question_' . $captchaQuestion['captcha_question_id'], 'phrase_text' => $captchaQuestion['question'], 'language_id' => 0, 'global_cache' => 0);
         /* @var $writer XenForo_DataWriter_Phrase */
         $writer = XenForo_DataWriter::create('XenForo_DataWriter_Phrase');
         $phraseId = array_search('captcha_question' . $captchaQuestion['captcha_question_id'], $phraseTitles);
         if ($phraseId) {
             $writer->setExistingData($phraseId);
         }
         $writer->bulkSet($data);
         if ($writer->isChanged('title') || $writer->isChanged('phrase_text')) {
             $writer->updateVersionId();
         }
         $writer->save();
     }
 }
Beispiel #14
0
 /**
  *
  * @see Waindigo_Library_DataWriter_Library::_postSave()
  */
 protected function _postSave()
 {
     if (isset($GLOBALS['Waindigo_Library_ControllerAdmin_Library'])) {
         /* @var $controller Waindigo_Library_ControllerAdmin_Library */
         $controller = $GLOBALS['Waindigo_Library_ControllerAdmin_Library'];
         $fieldIds = $controller->getInput()->filterSingle('available_fields', XenForo_Input::STRING, array('array' => true));
         $this->_getThreadFieldModel()->updateThreadFieldForumAssociationByForum($this->get('node_id'), $fieldIds);
         $templates = $controller->getInput()->filter(array('thread_header' => XenForo_Input::STRING, 'thread_footer' => XenForo_Input::STRING));
         $headerName = '_header_node.' . $this->get('node_id');
         $footerName = '_footer_node.' . $this->get('node_id');
         $oldTemplates = $this->_getTemplateModel()->getTemplatesInStyleByTitles(array($headerName, $footerName));
         /* @var $templateWriter XenForo_DataWriter_Template */
         $templateWriter = XenForo_DataWriter::create('XenForo_DataWriter_Template');
         if (isset($oldTemplates[$headerName])) {
             $templateWriter->setExistingData($oldTemplates[$headerName]);
         }
         $templateWriter->set('title', $headerName);
         $templateWriter->set('style_id', 0);
         $templateWriter->set('template', $templates['thread_header']);
         $templateWriter->save();
         /* @var $templateWriter XenForo_DataWriter_Template */
         $templateWriter = XenForo_DataWriter::create('XenForo_DataWriter_Template');
         if (isset($oldTemplates[$footerName])) {
             $templateWriter->setExistingData($oldTemplates[$footerName]);
         }
         $templateWriter->set('title', $footerName);
         $templateWriter->set('style_id', 0);
         $templateWriter->set('template', $templates['thread_footer']);
         $templateWriter->save();
         $this->_updateCustomFields = unserialize($this->get('custom_fields'));
     }
     $this->updateCustomFields();
     parent::_postSave();
 }
Beispiel #15
0
 public function setPageWatchState($userID, $pageID, $state, $overWrite = true)
 {
     $pageWatch = $this->getUserPageWatchByPageId($userID, $pageID);
     if ($pageWatch && !$overWrite) {
         return true;
     }
     switch ($state) {
         case 'watch_email':
         case 'watch_no_email':
             $dw = XenForo_DataWriter::create('EWRcarta_DataWriter_PageWatch');
             if ($pageWatch) {
                 $dw->setExistingData($pageWatch, true);
             } else {
                 $dw->set('user_id', $userID);
                 $dw->set('page_id', $pageID);
             }
             $dw->set('email_subscribe', $state == 'watch_email' ? 1 : 0);
             $dw->save();
             return true;
         case '':
             if ($pageWatch) {
                 $dw = XenForo_DataWriter::create('EWRcarta_DataWriter_PageWatch');
                 $dw->setExistingData($pageWatch, true);
                 $dw->delete();
             }
             return true;
         default:
             return false;
     }
 }
Beispiel #16
0
 /**
  * Deletes the specified moderation queue entry.
  *
  * @see XenForo_ModerationQueueHandler_Abstract::deleteModerationQueueEntry()
  */
 public function deleteModerationQueueEntry($contentId)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
     $dw->setExistingData($contentId);
     $dw->set('discussion_state', 'deleted');
     return $dw->save();
 }
Beispiel #17
0
 public function logRequest($requestMethod, $requestUri, array $requestData, $responseCode, array $responseOutput, array $bulkSet = array())
 {
     $days = bdApi_Option::get('logRetentionDays');
     if ($days == 0) {
         return false;
     }
     $dw = XenForo_DataWriter::create('bdApi_DataWriter_Log');
     $dw->bulkSet($bulkSet);
     if (!isset($bulkSet['client_id'])) {
         /* @var $session bdApi_Session */
         $session = XenForo_Application::getSession();
         $dw->set('client_id', $session->getOAuthClientId());
     }
     if (!isset($bulkSet['user_id'])) {
         $visitor = XenForo_Visitor::getInstance();
         $dw->set('user_id', $visitor->get('user_id'));
     }
     if (!isset($bulkSet['ip_address'])) {
         $dw->set('ip_address', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
     }
     $dw->set('request_date', XenForo_Application::$time);
     $dw->set('request_method', $requestMethod);
     $dw->set('request_uri', $requestUri);
     $dw->set('request_data', $this->_filterData($requestData));
     $dw->set('response_code', $responseCode);
     $dw->set('response_output', $this->_filterData($responseOutput));
     return $dw->save();
 }
 public static function setIndexNodeId($nodeId)
 {
     $optionDw = XenForo_DataWriter::create('XenForo_DataWriter_Option');
     $optionDw->setExistingData('wf_indexNodeId');
     $optionDw->set('option_value', $nodeId);
     $optionDw->save();
 }
Beispiel #19
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();
 }
Beispiel #20
0
 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = isset($options['batch']) ? $options['batch'] : 75;
     $options['batch'] = max(1, $options['batch']);
     /* @var $userModel XenForo_Model_User */
     $userModel = XenForo_Model::create('XenForo_Model_User');
     /* @var $conversationModel XenForo_Model_Conversation */
     $conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
     $userIds = $userModel->getUserIdsInRange($position, $options['batch']);
     if (sizeof($userIds) == 0) {
         return true;
     }
     XenForo_Db::beginTransaction();
     foreach ($userIds as $userId) {
         $position = $userId;
         /* @var $userDw XenForo_DataWriter_User */
         $userDw = XenForo_DataWriter::create('XenForo_DataWriter_User', XenForo_DataWriter::ERROR_SILENT);
         if ($userDw->setExistingData($userId)) {
             $userDw->set('alerts_unread', $userModel->getUnreadAlertsCount($userId));
             $userDw->set('conversations_unread', $conversationModel->countUnreadConversationsForUser($userId));
             $userDw->save();
             $userDw->rebuildUserGroupRelations();
             $userDw->rebuildPermissionCombinationId();
             $userDw->rebuildDisplayStyleGroupId();
             $userDw->rebuildIdentities();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
 public static function install($existingAddOn, $addOnData)
 {
     $version = isset($existingAddOn['version_id']) ? $existingAddOn['version_id'] : 0;
     if ($version && $version < 1000300) {
         // migrate to remove the 'use' from the bad tag list
         $tags = XenForo_Application::getOptions()->SV_AttachImpro_badTags;
         $tags = explode(',', $tags);
         if (($key = array_search('use', $tags)) !== false) {
             unset($tags[$key]);
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Option', XenForo_DataWriter::ERROR_SILENT);
         $dw->setExistingData('SV_AttachImpro_badTags');
         $dw->setOption(XenForo_DataWriter_Option::OPTION_REBUILD_CACHE, false);
         $dw->set('option_value', implode(',', $tags));
         $dw->save();
         XenForo_Application::defer(self::AddonNameSpace . 'Deferred_SVGAttachmentThumb', array());
     } else {
         if ($version == 0) {
             $addon = XenForo_Model::create('XenForo_Model_AddOn')->getAddOnById('SV_SVGAttachment');
             if (!empty($addon)) {
                 XenForo_Application::defer(self::AddonNameSpace . 'Deferred_SVGAttachmentThumb', array());
             }
         }
     }
     $addonsToUninstall = array('SV_SVGAttachment' => array(), 'SV_XARAttachment' => array());
     SV_Utils_Install::removeOldAddons($addonsToUninstall);
     return true;
 }
Beispiel #22
0
 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     if ($position == 0) {
         XenForo_Model::create('XenForo_Model_Node')->updateNestedSetInfo();
     }
     /* @var $forumModel XenForo_Model_Forum */
     $forumModel = XenForo_Model::create('XenForo_Model_Forum');
     $forums = $forumModel->getForums(array(), array('limit' => $options['batch'], 'offset' => $position));
     XenForo_Db::beginTransaction();
     foreach ($forums as $forum) {
         $position++;
         $forumDw = XenForo_DataWriter::create('XenForo_DataWriter_Forum', XenForo_DataWriter::ERROR_SILENT);
         if ($forumDw->setExistingData($forum, true)) {
             $forumDw->rebuildCounters();
             $forumDw->save();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     if (!$forums) {
         return true;
     } else {
         return $position;
     }
 }
Beispiel #23
0
 /**
  * Displays a form to change the visitor's language, or changes it if a language_id is present.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionLanguage()
 {
     $visitor = XenForo_Visitor::getInstance();
     if ($this->_input->inRequest('language_id')) {
         $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING));
         $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT);
         if ($languageId) {
             $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
             if (!isset($languages[$languageId])) {
                 $languageId = 0;
             }
         }
         if ($visitor['user_id']) {
             $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
             $dw->setExistingData($visitor['user_id']);
             $dw->set('language_id', $languageId);
             $dw->save();
             XenForo_Helper_Cookie::deleteCookie('language_id');
         } else {
             XenForo_Helper_Cookie::setCookie('language_id', $languageId, 86400 * 365);
         }
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false));
     } else {
         $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
         $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->getDynamicRedirect(false, false));
         return $this->responseView('XenForo_ViewPublic_Misc_Language', 'language_chooser', $viewParams);
     }
 }
Beispiel #24
0
 public function updateContentTagCache(array $content, array $cache)
 {
     $dw = XenForo_DataWriter::create('XenGallery_DataWriter_Media');
     $dw->setExistingData($content['media_id']);
     $dw->set('tags', $cache);
     $dw->save();
 }
Beispiel #25
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');
 }
Beispiel #26
0
 public function updateContentTagCache(array $content, array $cache)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
     $dw->setExistingData($content['thread_id']);
     $dw->set('tags', $cache);
     $dw->save();
 }
Beispiel #27
0
 /**
  *
  * @see XenResource_DataWriter_Resource::_insertDiscussionThread()
  */
 protected function _insertDiscussionThread($nodeId, $prefixId = 0)
 {
     /* @var $nodeModel XenForo_Model_Node */
     $nodeModel = $this->getModelFromCache('XenForo_Model_Node');
     $node = $nodeModel->getNodeById($nodeId);
     if (!$node) {
         return false;
     }
     if ($node['node_type_id'] == 'SocialCategory') {
         $socialForumId = 0;
         if (isset($GLOBALS['XenResource_ControllerPublic_Resource'])) {
             /* @var $controller XenResource_ControllerPublic_Resource */
             $controller = $GLOBALS['XenResource_ControllerPublic_Resource'];
             $socialForumId = $controller->getInput()->filterSingle('social_forum_id', XenForo_Input::UINT);
         }
         if ($socialForumId) {
             $socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
             $socialForum = $socialForumModel->getSocialForumById($socialForumId);
         }
         if (!empty($socialForum) && $socialForum['node_id'] == $node['node_id']) {
             ThemeHouse_SocialGroups_SocialForum::setup($socialForum);
             // TODO check permissions
         } else {
             $writer = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum');
             $writer->bulkSet(array('node_id' => $nodeId, 'user_id' => XenForo_Visitor::getUserId(), 'title' => $this->_getThreadTitle(), 'description' => $this->get('tag_line'), 'social_forum_type' => 'resource'));
             $writer->save();
             ThemeHouse_SocialGroups_SocialForum::setup($writer->getMergedData());
             $this->set('social_forum_id', $writer->get('social_forum_id'), '', array('setAfterPreSave' => true));
         }
     }
     return parent::_insertDiscussionThread($nodeId, $prefixId);
 }
Beispiel #28
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);
     }
 }
 public function actionSave()
 {
     $dwInput = $this->_input->filter(array('event_id' => XenForo_Input::STRING, 'description' => XenForo_Input::STRING, 'callback_class' => XenForo_Input::STRING, 'callback_method' => XenForo_Input::STRING, 'hint' => XenForo_Input::STRING, 'addon_id' => XenForo_Input::STRING));
     if (!empty($dwInput['event_id']) && empty($dwInput['description']) && empty($dwInput['callback_class']) && empty($dwInput['callback_class']) && !empty($dwInput['hint']) && !empty($dwInput['addon_id'])) {
         /** @var XenForo_Model_AddOn $addOnModel */
         $addOnModel = $this->getModelFromCache('XenForo_Model_AddOn');
         $addOn = $addOnModel->getAddOnById($dwInput['addon_id']);
         /** @var DevHelper_Model_Config $configModel */
         $configModel = $this->getModelFromCache('DevHelper_Model_Config');
         $config = $configModel->loadAddOnConfig($addOn);
         if (strpos($dwInput['event_id'], 'load_class') === 0) {
             $classPath = DevHelper_Generator_File::getClassPath($dwInput['hint']);
             if (is_file($classPath)) {
                 $method = DevHelper_Generator_Code_Listener::generateLoadClass($dwInput['hint'], $addOn, $config);
                 if ($method) {
                     $clazz = DevHelper_Generator_Code_Listener::getClassName($addOn, $config);
                     $this->_request->setParam('description', $dwInput['hint']);
                     $this->_request->setParam('callback_class', $clazz);
                     $this->_request->setParam('callback_method', $method);
                     XenForo_DataWriter::create('XenForo_DataWriter_CodeEventListener');
                 }
             }
         }
     }
     return parent::actionSave();
 }
Beispiel #30
0
 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);
     }
 }