Beispiel #1
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('tagId' => null, 'position' => 0, 'deleteFirst' => false), $data);
     if (!$data['tagId']) {
         return false;
     }
     $db = XenForo_Application::getDb();
     $matches = $db->fetchAll("\r\n\t\t\tSELECT tag_content_id, content_type, content_id\r\n\t\t\tFROM xf_tag_content\r\n\t\t\tWHERE tag_id = ?\r\n\t\t\t\tAND tag_content_id > ?\r\n\t\t\tORDER BY tag_content_id\r\n\t\t\tLIMIT 1000\r\n\t\t", array($data['tagId'], $data['position']));
     if (!$matches) {
         return false;
     }
     /** @var XenForo_Model_Tag $tagModel */
     $tagModel = XenForo_Model::create('XenForo_Model_Tag');
     XenForo_Db::beginTransaction($db);
     $limitTime = $targetRunTime > 0;
     $s = microtime(true);
     foreach ($matches as $match) {
         $data['position'] = $match['tag_content_id'];
         if ($data['deleteFirst']) {
             $db->delete('xf_tag_content', 'tag_content_id = ' . $match['tag_content_id']);
         }
         $tagModel->rebuildTagCache($match['content_type'], $match['content_id']);
         if ($limitTime && microtime(true) - $s >= $targetRunTime) {
             break;
         }
     }
     XenForo_Db::commit($db);
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('tags');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Beispiel #2
0
 public function actionErrorServer()
 {
     $upgradePending = false;
     try {
         $db = XenForo_Application::getDb();
         if ($db->isConnected()) {
             $dbVersionId = $db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
             if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
                 $upgradePending = true;
             }
         }
     } catch (Exception $e) {
     }
     if (XenForo_Application::debugMode()) {
         $showDetails = true;
     } else {
         if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
             $showDetails = true;
         } else {
             $showDetails = false;
         }
     }
     if ($upgradePending && !$showDetails) {
         return $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
     } else {
         if ($showDetails) {
             $view = $this->responseView('XenForo_ViewPublic_Error_ServerError', 'error_server_error', array('exception' => $this->_request->getParam('_exception')));
             $view->responseCode = 500;
             return $view;
         } else {
             return $this->responseError(new XenForo_Phrase('server_error_occurred'), 500);
         }
     }
 }
Beispiel #3
0
 public static function install($previous)
 {
     if (XenForo_Application::$versionId < 1020070) {
         // note: this can't be phrased
         throw new XenForo_Exception('This add-on requires XenForo 1.2.0 or higher.', TRUE);
     }
     $db = XenForo_Application::getDb();
     $tables = self::getTables();
     $install = self::DataInstall();
     $upgrade = self::DataUpgrade();
     if (!$previous) {
         foreach ($tables as $tableSql) {
             try {
                 $db->query($tableSql);
             } catch (Zend_Db_Exception $e) {
             }
         }
         foreach ($install as $dataSql) {
             try {
                 $db->query($dataSql);
             } catch (Zend_Db_Exception $e) {
             }
         }
     } else {
         // Upgrade Ads [Advanced]
         foreach ($upgrade as $key => $dataSql) {
             if ($previous['version_id'] < $key) {
                 try {
                     $db->query($dataSql);
                 } catch (Zend_Db_Exception $e) {
                 }
             }
         }
     }
 }
    public function execute(array $deferred, array $data, $targetRunTime, &$status)
    {
        $data = array_merge(array('position' => 0, 'batch' => 10), $data);
        $data['batch'] = max(1, $data['batch']);
        /* @var $albumModel XenGallery_Model_Album */
        $albumModel = XenForo_Model::create('XenGallery_Model_Album');
        $albumIds = $albumModel->getSharedAlbumIdsInRange($data['position'], $data['batch']);
        if (sizeof($albumIds) == 0) {
            return true;
        }
        $db = XenForo_Application::getDb();
        XenForo_Db::beginTransaction($db);
        foreach ($albumIds as $albumId) {
            $data['position'] = $albumId;
            $album = $albumModel->getAlbumByIdSimple($albumId);
            $bind = array($album['album_id'], $album['album_user_id']);
            $ownerShared = $db->fetchOne('SELECT shared_user_id FROM xengallery_shared_map WHERE album_id = ? AND shared_user_id = ?', $bind);
            if (!$ownerShared) {
                $db->query('
					INSERT IGNORE INTO xengallery_shared_map
						(album_id, shared_user_id)
					VALUES
						(?, ?)
				', $bind);
            }
        }
        XenForo_Db::commit($db);
        $actionPhrase = new XenForo_Phrase('rebuilding');
        $typePhrase = new XenForo_Phrase('xengallery_album_permissions');
        $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
        return $data;
    }
Beispiel #5
0
 /**
  * @param int $position
  * @param array $options
  * @param string $detailedMessage
  * @return bool|int|string|true
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
     if (count($locations) < 1) {
         return true;
     }
     XenForo_Db::beginTransaction();
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $position = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
Beispiel #6
0
 private static function installCustomized($existingAddOn, $addOnData)
 {
     if (XenForo_Application::$versionId < 1030000) {
         throw new XenForo_Exception('[bd] Tag Me v3 requires XenForo 1.3.0+.');
     }
     $db = XenForo_Application::getDb();
     $effectiveVersionId = 0;
     if (!empty($existingAddOn)) {
         $effectiveVersionId = $existingAddOn['version_id'];
     }
     if ($effectiveVersionId == 0) {
         $db->query("\n\t\t\t\tINSERT IGNORE INTO xf_permission_entry\n\t\t\t\t\t(user_group_id, user_id, permission_group_id, permission_id, permission_value, permission_value_int)\n\t\t\t\tSELECT user_group_id, user_id, 'general', 'bdtagme_groupTag', permission_value, 0\n\t\t\t\tFROM xf_permission_entry\n\t\t\t\tWHERE permission_group_id = 'general' AND permission_id = 'cleanSpam'\n\t\t\t");
     }
     if ($effectiveVersionId > 0 and $effectiveVersionId < 3062) {
         $db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag' WHERE content_type = 'post' AND action = 'tagged'");
         $db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag' WHERE content_type = 'profile_post' AND action = 'tagged'");
         $db->query("UPDATE IGNORE `xf_user_alert` SET action = 'tag_comment' WHERE content_type = 'profile_post' AND action = 'comment_tagged'");
         $db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'post_tag' WHERE alert = 'post_tagged'");
         $db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'profile_post_tag' WHERE alert = 'profile_post_tagged'");
         $db->query("UPDATE IGNORE `xf_user_alert_optout` SET alert = 'profile_post_tag_comment' WHERE alert = 'profile_post_comment_tagged'");
         $db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'post_tagged'");
         $db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'profile_post_tagged'");
         $db->query("DELETE FROM `xf_user_alert_optout` WHERE alert = 'profile_post_comment_tagged'");
     }
 }
Beispiel #7
0
 public static function helperRichUserName(array $user, $usernameHtml = '')
 {
     if (!is_array($user) || !isset($user['username']) && $usernameHtml === '') {
         return '';
     }
     if ($usernameHtml === '') {
         $usernameHtml = htmlspecialchars($user['username']);
     }
     $stylingOrder = array_map('intval', XenForo_Application::getOptions()->get("3ps_cmfu_markupStylingOrder"));
     // sanity checks
     if ($stylingOrder["preset"] == 0 && $stylingOrder["user"] == 0) {
         return $usernameHtml;
     }
     if (empty($user['user_id'])) {
         $user['display_style_group_id'] = XenForo_Model_User::$defaultGuestGroupId;
     } elseif ($user['display_style_group_id'] == null) {
         $user['display_style_group_id'] = XenForo_Application::getDb()->fetchOne("SELECT `display_style_group_id` FROM `xf_user` WHERE `user_id` = ?", $user["user_id"]);
     }
     if (!isset($user["3ps_cmfu_options"])) {
         $user["3ps_cmfu_options"] = XenForo_Application::getDb()->fetchOne("SELECT `3ps_cmfu_options` FROM `xf_user` WHERE `user_id`=?", $user["user_id"]);
     }
     $options = unserialize($user["3ps_cmfu_options"]);
     if (!$options) {
         $options = ThreePointStudio_CustomMarkupForUser_Constants::$defaultOptionsArray;
         XenForo_Model::create("XenForo_Model_User")->insertDefaultCustomMarkup($user["user_id"]);
     }
     $extraClasses = self::getUserExtraClasses($user);
     if (empty($user["user_id"])) {
         $html = "{inner}";
     } else {
         $html = ThreePointStudio_CustomMarkupForUser_Helpers::getCustomMarkupHtml($options, "username", $user, $extraClasses);
     }
     return str_replace("{inner}", $usernameHtml, $html);
 }
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     return true;
     $data = array_merge(array('position' => 0, 'batch' => 10), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $feedbackModel NixFifty_XenTrader_Model_Feedback */
     $feedbackModel = XenForo_Model::create('NixFifty_XenTrader_Model_Feedback');
     $feedbackItems = $feedbackModel->getUserIdsInFeedbackRange($data['position'], $data['batch']);
     if (sizeof($feedbackItems) == 0) {
         return true;
     }
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     foreach ($feedbackItems as $feedbackItem) {
         $data['position'] = $item['media_id'];
         $feedbackCount = $db->fetchOne('
             SELECT COUNT(*)
             FROM xf_nixfifty_xentrader_feedback
             WHERE to_user_id = ?
         ', $feedbackItem);
         $db->update('xf_nixfifty_xentrader_user', array('total' => $feedbackCount), 'user_id = ' . $db->quote($feedbackItem));
     }
     XenForo_Db::commit($db);
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = 'fam i think im broken';
     //new XenForo_Phrase('xengallery_rebuild_thumbnails');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
 public static function processInvoices()
 {
     if (XenForo_Application::$versionId > 1020000) {
         $addOns = XenForo_Application::get('addOns');
         $isInInstalled = !empty($addOns['ThemeHouse_Invoices']);
     } else {
         $isInInstalled = $this->getAddOnById('ThemeHouse_Invoices') ? true : false;
     }
     if (!$isInInstalled) {
         return;
     }
     /* @var $invoiceModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_Invoice */
     $invoiceModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_Invoice');
     $invoices = $invoiceModel->getPaidInvoices();
     $db = XenForo_Application::getDb();
     $db->update('invoice_th', array('paid_date' => XenForo_Application::$time), 'paid_state = \'paid\' AND paid_date = \'\'');
     $db->update('invoice_th', array('paid_date' => '', 'paid_state' => 'uncleared'), 'paid_date < ' . (XenForo_Application::$time - 60 * 60) . ' AND paid_state = \'paid\' AND payment_method = \'\'');
     $unprocessedInvoiceIds = $invoiceModel->getUnprocessedInvoicesFromInvoiceIds(array_keys($invoices));
     foreach ($unprocessedInvoiceIds as $invoiceId) {
         $invoice = $invoices[$invoiceId];
         if (!$db->update('invoice_th', array('paid_state' => 'paid'), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId))) {
             continue;
         }
         $db->update('invoice_th', array('paid_date' => XenForo_Application::$time), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId));
         $db->beginTransaction();
         $invoiceModel->processInvoice($invoice);
         $db->update('invoice_th', array('payment_method' => 'infusionsoft'), 'infusionsoft_invoice_id_th = ' . $db->quote($invoiceId));
         $db->commit();
     }
 }
 protected static function _getDb()
 {
     if (self::$_db === null) {
         self::$_db = XenForo_Application::getDb();
     }
     return self::$_db;
 }
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'queryKeys' => array('xengallery_media_drop', 'xengallery_media_add', 'xengallery_album', 'xengallery_comment', 'xengallery_user_tag', 'xf_user')), $data);
     if (!$data['queryKeys']) {
         return true;
     }
     $s = microtime(true);
     $db = XenForo_Application::getDb();
     $status = sprintf('%s... %s %s', 'Adding', 'XFMG Table Indexes', str_repeat(' . ', $data['position']));
     foreach ($data['queryKeys'] as $key => $name) {
         $data['position']++;
         $query = $this->_getQueryToExecute($name);
         if (!$query) {
             continue;
         }
         try {
             $db->query($query);
             unset($data['queryKeys'][$key]);
         } catch (Zend_Db_Exception $e) {
             if ($name != 'xengallery_media_drop') {
                 XenForo_Error::logException($e, false, "XenForo Media Gallery: Error adding index(es) ({$name}): ");
             }
             unset($data['queryKeys'][$key]);
             continue;
         }
         if ($targetRunTime && microtime(true) - $s > $targetRunTime) {
             break;
         }
     }
     return $data;
 }
Beispiel #12
0
 /**
  * Helper method to get the database object.
  *
  * @return Zend_Db_Adapter_Abstract
  */
 protected function _getDb()
 {
     if ($this->_db === null) {
         $this->_db = XenForo_Application::getDb();
     }
     return $this->_db;
 }
Beispiel #13
0
 public function __construct()
 {
     $this->_db = XenForo_Application::getDb();
     $this->_importModel = XenForo_Model::create('XenForo_Model_Import');
     $this->_db->setProfiler(false);
     // this causes lots of memory usage in debug mode, so stop that
 }
Beispiel #14
0
    protected function _getTemplatesFromDataSource(array $templateList)
    {
        $db = XenForo_Application::getDb();
        $listByLanguageId = array();
        foreach ($templateList as $template) {
            if (preg_match('#^__(.+)_(\\d+)$#', $template, $matches)) {
                $templateName = $matches[1];
                $languageId = $matches[2];
                if (!isset($listByLanguageId[$languageId])) {
                    $listByLanguageId[$languageId] = array();
                }
                $listByLanguageId[$languageId][] = $templateName;
            }
        }
        $results = array();
        foreach ($listByLanguageId as $languageId => $templateNames) {
            $templates = $db->fetchPairs('
				SELECT title, template_compiled
				FROM xf_template_compiled
				WHERE title IN (' . $db->quote($templateNames) . ')
					AND style_id = ?
					AND language_id = ?
			', array(XenForo_Application::getOptions()->get('defaultStyleId'), $languageId));
            foreach ($templates as $title => $compiled) {
                $results[sprintf('__%s_%d', $title, $languageId)] = $compiled;
            }
        }
        return $results;
    }
Beispiel #15
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('batch' => 10, 'position' => 0, 'positionRebuild' => false), $data);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($data['position'], $data['batch']);
     if (count($locations) < 1) {
         return false;
     }
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $data['position'] = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('sonnb_xengallery_location');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
Beispiel #16
0
 public static function uninstall()
 {
     //Get the db
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     //Drop the custom tables from the db
     try {
         $db->query("\n\t\t\t    DROP TABLE IF EXISTS `xf_thread_rating`\n\t\t   ");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_count` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_count`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_sum` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_sum`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_avg` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_avg`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     XenForo_Db::commit($db);
 }
Beispiel #17
0
 /**
  * Constructor.
  *
  * @param string$keyName
  */
 public function __construct($keyName)
 {
     $this->_keyName = $keyName;
     @set_time_limit(0);
     ignore_user_abort(true);
     XenForo_Application::getDb()->setProfiler(false);
     // this can use a lot of memory
 }
    public function touchDb($id = null)
    {
        XenForo_Application::getDb()->query('
			UPDATE xf_phrase
			SET last_file_update = ?
			WHERE phrase_id = ?
		', array(XenForo_Application::$time, $id ? $id : $this->_data['id']));
    }
    public function templateTouchDb($styleId)
    {
        XenForo_Application::getDb()->query('
			UPDATE xf_' . ($styleId == -1 ? 'admin_' : '') . 'template
			SET last_file_update = ?
			WHERE template_id = ?
		', array(XenForo_Application::$time, $this->_data['id']));
    }
Beispiel #20
0
 protected function _genKey($userId)
 {
     $randomKey = XenForo_Application::generateRandomString(10);
     $db = XenForo_Application::getDb();
     $db->query('UPDATE xf_user
         SET gen_key = ' . $db->quote($randomKey) . '
         WHERE user_id = ' . $userId . '');
 }
Beispiel #21
0
 protected function save($prefs)
 {
     if ($this->userId > 0) {
         $_db = $_db = XenForo_Application::getDb();
         $_db->query("INSERT INTO geek_listings_prefs ( pref_user_id, pref_type_id, pref_cat, pref_subcat, pref_location, pref_lat, pref_lng, pref_alert_on_new, pref_email_on_new, pref_last_check, pref_last_alert, pref_last_email, pref_city, pref_country)\n                                VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0, ?, ?  ) ON DUPLICATE KEY UPDATE\n                                pref_type_id=VALUES(pref_type_id),pref_cat=VALUES(pref_cat), pref_subcat=VALUES(pref_subcat), pref_location=VALUES(pref_location), pref_lat=VALUES(pref_lat), pref_lng=VALUES(pref_lng), pref_alert_on_new=VALUES(pref_alert_on_new), pref_email_on_new=VALUES(pref_email_on_new), pref_city=VALUES(pref_city), pref_country=VALUES(pref_country) ", [$this->userId, $this->typeId, $this->cat, $this->subcat, $this->location, $this->lat, $this->lng, $this->alert_on_new, $this->email_on_new, $this->city, $this->country]);
     }
     XenForo_Helper_Cookie::setCookie('GeekListing_prefs_' . $this->typeId, serialize($prefs));
 }
 protected function _postInstall()
 {
     $addOn = $this->getModelFromCache('XenForo_Model_AddOn')->getAddOnById('Waindigo_SocialPerms');
     if ($addOn) {
         $db = XenForo_Application::getDb();
         $db->query("\r\n\t\t\t\tINSERT INTO xf_social_permission_set_th (social_permission_set_id, creator_permissions, awaiting_permissions, invited_permissions, guest_permissions, member_permissions, moderator_permissions)\r\n\t\t\t\t\tSELECT social_permission_set_id, creator_permissions, awaiting_permissions, invited_permissions, guest_permissions, member_permissions, moderator_permissions\r\n\t\t\t\t\tFROM xf_social_permission_set_waindigo");
     }
 }
Beispiel #23
0
 public function __construct()
 {
     @set_time_limit(0);
     ignore_user_abort(true);
     $this->_db = XenForo_Application::getDb();
     $this->_importModel = XenForo_Model::create('sonnb_XenGallery_Model_Import');
     $this->_db->setProfiler(false);
 }
 public static function removeHandlerClass($contentType, $cacheRebuild = true)
 {
     $db = XenForo_Application::getDb();
     $where = 'content_type = ' . $db->quote($contentType) . ' AND field_name = ' . $db->quote('simpleportal_handler_class');
     $db->delete('xf_content_type_field', $where);
     if ($cacheRebuild) {
         XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache();
     }
 }
Beispiel #25
0
 public function insertMailQueue(Zend_Mail $mailObj)
 {
     if (!self::$_deferredQueued) {
         XenForo_Application::defer('MailQueue', array(), 'MailQueue');
         self::$_deferredQueued = true;
     }
     XenForo_Application::getDb()->insert('xf_mail_queue', array('mail_data' => serialize($mailObj), 'queue_date' => XenForo_Application::$time));
     return true;
 }
Beispiel #26
0
 private static function uninstallCustomized()
 {
     $db = XenForo_Application::getDb();
     $db->query("DELETE FROM `xf_content_type` WHERE addon_id = ?", array('bdApiConsumer'));
     $db->query("DELETE FROM `xf_content_type_field` WHERE content_type = ?", array('bdapi_consumer'));
     $db->query("DELETE FROM `xf_user_alert` WHERE content_type = ?", array('bdapi_consumer'));
     $db->query("DELETE FROM `xf_user_alert_optout` WHERE alert LIKE 'bdapiconsumer_%s'");
     XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache();
 }
Beispiel #27
0
 protected function _installVersion4()
 {
     try {
         XenForo_Application::getDb()->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tADD block_adsense TINYINT UNSIGNED NOT NULL DEFAULT '0'\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     // we can't insert a random string into an option because the options are installed after this install process
     XenForo_Application::defer('DigitalPointAdPositioning_Deferred_RandomGenerator', array(), 'dp_adpos_random', false, time() + 30);
 }
Beispiel #28
0
 protected function _getUserPostCountInThread($threadId)
 {
     $db = XenForo_Application::getDb();
     return $db->fetchAll('SELECT user.*, tup.post_count
         FROM xf_thread_user_post as tup
         LEFT JOIN xf_user AS user ON (user.user_id = tup.user_id)
         WHERE tup.thread_id = ?
         ORDER BY tup.post_count DESC', $threadId);
 }
 public function run($addonId, $path)
 {
     $addonModel = XenForo_Model::create('XenForo_Model_AddOn');
     $this->printMessage('Importing ' . $addonId . ' from ' . realPath($path) . '...');
     $print = 'importing addon.xml...';
     $print .= str_repeat(' ', $this->_column - strlen($print));
     $t = microtime(true);
     $m = memory_get_usage(true);
     $this->printMessage($print, false);
     $xml = new SimpleXMLElement($path . '/addon.xml', 0, true);
     $addOnData = array('addon_id' => (string) $xml['addon_id'], 'title' => (string) $xml['title'], 'version_string' => (string) $xml['version_string'], 'version_id' => (string) $xml['version_id'], 'install_callback_class' => (string) $xml['install_callback_class'], 'install_callback_method' => (string) $xml['install_callback_method'], 'uninstall_callback_class' => (string) $xml['uninstall_callback_class'], 'uninstall_callback_method' => (string) $xml['uninstall_callback_method'], 'url' => (string) $xml['url']);
     $version = file_get_contents($path . '/version.txt');
     if ($version) {
         foreach ($addOnData as &$data) {
             $data = str_replace('{@revision}', $version, $data);
         }
     }
     $addOnData['version_id'] = (int) $addOnData['version_id'];
     $existingAddOn = $addonModel->verifyAddOnIsInstallable($addOnData, $addonModel->getAddonById($addonId) ? $addonId : false);
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     if ($addOnData['install_callback_class'] && $addOnData['install_callback_method']) {
         call_user_func(array($addOnData['install_callback_class'], $addOnData['install_callback_method']), $existingAddOn, $addOnData);
     }
     $addOnDw = XenForo_DataWriter::create('XenForo_DataWriter_AddOn');
     if ($existingAddOn) {
         $addOnDw->setExistingData($existingAddOn, true);
     }
     $addOnDw->bulkSet($addOnData);
     $addOnDw->save();
     $t = abs(microtime(true) - $t);
     $m = abs(memory_get_usage(true) - $m);
     $m = $m / 1024 / 1024;
     $this->printMessage('done (' . number_format($t, 2) . 'sec, ' . number_format($m, 2) . 'mb)');
     $this->_importXml($addonId, $path . '/admin_navigation.xml', 'AdminNavigation');
     $this->_importXml($addonId, $path . '/admin_permissions.xml', 'Admin', 'importAdminPermissionsAddOnXml');
     $this->_importXml($addonId, $path . '/code_events.xml', 'CodeEvent', 'importEventsAddOnXml');
     $this->_importXml($addonId, $path . '/code_event_listeners.xml', 'CodeEvent', 'importEventListenersAddOnXml');
     $this->_importXml($addonId, $path . '/cron.xml', 'Cron', 'importCronEntriesAddOnXml');
     $this->_importXml($addonId, $path . '/email_templates.xml', 'EmailTemplate');
     $this->_importXml($addonId, $path . '/options.xml', 'Option');
     $this->_importXml($addonId, $path . '/permissions.xml', 'Permission');
     $this->_importXml($addonId, $path . '/route_prefixes.xml', 'RoutePrefix', 'importPrefixesAddOnXml');
     $this->_importXml($addonId, $path . '/style_properties.xml', 'StyleProperty', 'importStylePropertyXml', array(0, $addonId));
     $this->_importXml($addonId, $path . '/admin_style_properties.xml', 'StyleProperty', 'importStylePropertyXml', array(-1, $addonId));
     foreach (array('templates/admin', 'templates/master', 'phrases') as $dir) {
         $this->_removeDirectory(XenForo_Application::getInstance()->getRootDir() . '/' . $dir . '/' . $addonId);
     }
     $this->_importXml($addonId, $path . '/templates.xml', 'Template');
     $this->_importXml($addonId, $path . '/admin_templates.xml', 'AdminTemplate');
     $this->_importXml($addonId, $path . '/phrases.xml', 'Phrase');
     // TODO: bbcode
     XenForo_Db::commit($db);
     $this->printEmptyLine();
     $this->manualRun('rebuild', false, false, array('caches' => 'addon'));
 }
Beispiel #30
0
    /**
     * Goes to the data source to load the list of templates.
     *
     * @param array Template list
     *
     * @return array Key-value pairs of template titles/compiled templates
     */
    protected function _getTemplatesFromDataSource(array $templateList)
    {
        $db = XenForo_Application::getDb();
        return $db->fetchPairs('
			SELECT title, template_compiled
			FROM xf_admin_template_compiled
			WHERE title IN (' . $db->quote($templateList) . ')
				AND language_id = ?
		', self::$_languageId);
    }