3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Config handles all the run time configuration changes that the system needs to deal with.
30 * Typically we'll have different values for a user's sandbox, a qa sandbox and a production area.
31 * The default values in general, should reflect production values (minimizes chances of screwing up)
34 * @copyright CiviCRM LLC (c) 2004-2013
39 require_once 'Log.php';
40 require_once 'Mail.php';
42 require_once 'api/api.php';
43 class CRM_Core_Config
extends CRM_Core_Config_Variables
{
45 /// BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
49 * the dsn of the database connection
55 * the name of user framework
58 public $userFramework = 'Drupal';
61 * the name of user framework url variable name
64 public $userFrameworkURLVar = 'q';
67 * the dsn of the database connection for user framework
70 public $userFrameworkDSN = NULL;
73 * The connector module for the CMS/UF
75 * @var CRM_Util_System_{$uf}
77 public $userSystem = NULL;
80 * The root directory where Smarty should store
84 public $templateCompileDir = './templates_c/en_US/';
86 public $configAndLogDir = NULL;
88 // END: BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
91 /// BEGIN HELPER CLASS PROPERTIES
95 * are we initialized and in a proper state
98 public $initialized = 0;
101 * the factory class used to instantiate our DB objects
104 private $DAOFactoryClass = 'CRM_Contact_DAO_Factory';
107 * The handle to the log that we are using
110 private static $_log = NULL;
113 * the handle on the mail handler that we are using
116 public static $_mail = NULL;
119 * We only need one instance of this object. So we use the singleton
120 * pattern and cache the instance in this variable
124 private static $_singleton = NULL;
127 * component registry object (of CRM_Core_Component type)
129 public $componentRegistry = NULL;
132 /// END HELPER CLASS PROPERTIES
136 /// RUNTIME SET CLASS PROPERTIES
140 * to determine wether the call is from cms or civicrm
142 public $inCiviCRM = FALSE;
145 /// END: RUNTIME SET CLASS PROPERTIES
149 * Define recaptcha key
152 public $recaptchaPublicKey;
155 * The constructor. Sets domain id if defined, otherwise assumes
156 * single instance installation.
161 private function __construct() {
165 * Singleton function used to manage this object.
167 * @param $loadFromDB boolean whether to load from the database
168 * @param $force boolean whether to force a reconstruction
173 static function &singleton($loadFromDB = TRUE, $force = FALSE) {
174 if (self
::$_singleton === NULL ||
$force) {
175 // goto a simple error handler
176 $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK
;
177 $GLOBALS['_PEAR_default_error_options'] = array('CRM_Core_Error', 'simpleHandler');
179 // lets ensure we set E_DEPRECATED to minimize errors
181 if (defined('E_DEPRECATED')) {
182 error_reporting(error_reporting() & ~E_DEPRECATED
);
185 // first, attempt to get configuration object from cache
186 $cache = CRM_Utils_Cache
::singleton();
187 self
::$_singleton = $cache->get('CRM_Core_Config' . CRM_Core_Config
::domainID());
188 // if not in cache, fire off config construction
189 if (!self
::$_singleton) {
190 self
::$_singleton = new CRM_Core_Config
;
191 self
::$_singleton->_initialize($loadFromDB);
193 //initialize variables. for gencode we cannot load from the
194 //db since the db might not be initialized
196 // initialize stuff from the settings file
197 self
::$_singleton->setCoreVariables();
199 self
::$_singleton->_initVariables();
201 // I dont think we need to do this twice
202 // however just keeping this commented for now in 4.4
203 // in case we hit any issues - CRM-13064
204 // We can safely delete this once we release 4.4.4
205 // self::$_singleton->setCoreVariables();
207 $cache->set('CRM_Core_Config' . CRM_Core_Config
::domainID(), self
::$_singleton);
210 // we retrieve the object from memcache, so we now initialize the objects
211 self
::$_singleton->_initialize($loadFromDB);
213 // CRM-9803, NYSS-4822
214 // this causes various settings to be reset and hence we should
215 // only use the config object that we retrived from memcache
218 self
::$_singleton->initialized
= 1;
220 if (isset(self
::$_singleton->customPHPPathDir
) &&
221 self
::$_singleton->customPHPPathDir
223 $include_path = self
::$_singleton->customPHPPathDir
. PATH_SEPARATOR
. get_include_path();
224 set_include_path($include_path);
227 // set the callback at the very very end, to avoid an infinite loop
228 // set the error callback
229 CRM_Core_Error
::setCallback();
231 // call the hook so other modules can add to the config
232 // again doing this at the very very end
233 CRM_Utils_Hook
::config(self
::$_singleton);
235 // make sure session is always initialised
236 $session = CRM_Core_Session
::singleton();
238 // for logging purposes, pass the userID to the db
239 $userID = $session->get('userID');
241 CRM_Core_DAO
::executeQuery('SET @civicrm_user_id = %1',
242 array(1 => array($userID, 'Integer'))
246 // initialize authentication source
247 self
::$_singleton->initAuthSrc();
249 return self
::$_singleton;
253 private function _setUserFrameworkConfig($userFramework) {
255 $this->userFrameworkClass
= 'CRM_Utils_System_' . $userFramework;
256 $this->userHookClass
= 'CRM_Utils_Hook_' . $userFramework;
257 $userPermissionClass = 'CRM_Core_Permission_' . $userFramework;
258 $this->userPermissionClass
= new $userPermissionClass();
260 $class = $this->userFrameworkClass
;
261 // redundant with _initVariables
262 $userSystem = $this->userSystem
= new $class();
264 if ($userFramework == 'Joomla') {
265 $this->userFrameworkURLVar
= 'task';
268 if (defined('CIVICRM_UF_BASEURL')) {
269 $this->userFrameworkBaseURL
= CRM_Utils_File
::addTrailingSlash(CIVICRM_UF_BASEURL
, '/');
271 //format url for language negotiation, CRM-7803
272 $this->userFrameworkBaseURL
= CRM_Utils_System
::languageNegotiationURL($this->userFrameworkBaseURL
);
274 if (CRM_Utils_System
::isSSL()) {
275 $this->userFrameworkBaseURL
= str_replace('http://', 'https://',
276 $this->userFrameworkBaseURL
281 if (defined('CIVICRM_UF_DSN')) {
282 $this->userFrameworkDSN
= CIVICRM_UF_DSN
;
285 // this is dynamically figured out in the civicrm.settings.php file
286 if (defined('CIVICRM_CLEANURL')) {
287 $this->cleanURL
= CIVICRM_CLEANURL
;
293 $this->userFrameworkVersion
= $userSystem->getVersion();
295 if ($userFramework == 'Joomla') {
297 $dbprefix = $mainframe ?
$mainframe->getCfg('dbprefix') : 'jos_';
298 $this->userFrameworkUsersTableName
= $dbprefix . 'users';
300 elseif ($userFramework == 'WordPress') {
302 $dbprefix = $wpdb ?
$wpdb->prefix
: '';
303 $this->userFrameworkUsersTableName
= $dbprefix . 'users';
308 * Initializes the entire application.
309 * Reads constants defined in civicrm.settings.php and
310 * stores them in config properties.
315 private function _initialize($loadFromDB = TRUE) {
317 // following variables should be set in CiviCRM settings and
318 // as crucial ones, are defined upon initialisation
319 // instead of in CRM_Core_Config_Defaults
320 if (defined('CIVICRM_DSN')) {
321 $this->dsn
= CIVICRM_DSN
;
323 elseif ($loadFromDB) {
324 // bypass when calling from gencode
325 echo 'You need to define CIVICRM_DSN in civicrm.settings.php';
329 if (defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
330 $this->templateCompileDir
= CRM_Utils_File
::addTrailingSlash(CIVICRM_TEMPLATE_COMPILEDIR
);
332 // also make sure we create the config directory within this directory
333 // the below statement will create both the templates directory and the config and log directory
334 $this->configAndLogDir
=
335 CRM_Utils_File
::baseFilePath($this->templateCompileDir
) .
336 'ConfigAndLog' . DIRECTORY_SEPARATOR
;
337 CRM_Utils_File
::createDir($this->configAndLogDir
);
339 // we're automatically prefixing compiled templates directories with country/language code
341 if (!empty($tsLocale)) {
342 $this->templateCompileDir
.= CRM_Utils_File
::addTrailingSlash($tsLocale);
344 elseif (!empty($this->lcMessages
)) {
345 $this->templateCompileDir
.= CRM_Utils_File
::addTrailingSlash($this->lcMessages
);
348 CRM_Utils_File
::createDir($this->templateCompileDir
);
350 elseif ($loadFromDB) {
351 echo 'You need to define CIVICRM_TEMPLATE_COMPILEDIR in civicrm.settings.php';
357 if (defined('CIVICRM_UF')) {
358 $this->userFramework
= CIVICRM_UF
;
359 $this->_setUserFrameworkConfig($this->userFramework
);
362 echo 'You need to define CIVICRM_UF in civicrm.settings.php';
366 // also initialize the logger
367 self
::$_log = Log
::singleton('display');
369 // initialize component registry early to avoid "race"
370 // between CRM_Core_Config and CRM_Core_Component (they
372 $this->componentRegistry
= new CRM_Core_Component();
376 * initialize the DataObject framework
381 private function _initDAO() {
382 CRM_Core_DAO
::init($this->dsn
);
384 $factoryClass = $this->DAOFactoryClass
;
385 require_once str_replace('_', DIRECTORY_SEPARATOR
, $factoryClass) . '.php';
386 CRM_Core_DAO
::setFactory(new $factoryClass());
387 if (CRM_Utils_Constant
::value('CIVICRM_MYSQL_STRICT', CRM_Utils_System
::isDevelopment())) {
388 CRM_Core_DAO
::executeQuery('SET SESSION sql_mode = STRICT_TRANS_TABLES');
393 * returns the singleton logger for the application
400 static public function &getLog() {
401 if (!isset(self
::$_log)) {
402 self
::$_log = Log
::singleton('display');
409 * initialize the config variables
414 private function _initVariables() {
415 // retrieve serialised settings
416 $variables = array();
417 CRM_Core_BAO_ConfigSetting
::retrieve($variables);
419 // if settings are not available, go down the full path
420 if (empty($variables)) {
421 // Step 1. get system variables with their hardcoded defaults
422 $variables = get_object_vars($this);
424 // Step 2. get default values (with settings file overrides if
425 // available - handled in CRM_Core_Config_Defaults)
426 CRM_Core_Config_Defaults
::setValues($variables);
428 // retrieve directory and url preferences also
429 CRM_Core_BAO_Setting
::retrieveDirectoryAndURLPreferences($variables);
431 // add component specific settings
432 $this->componentRegistry
->addConfig($this);
434 // serialise settings
435 $settings = $variables;
436 CRM_Core_BAO_ConfigSetting
::add($settings);
439 $urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
440 $dirArray = array('uploadDir', 'customFileUploadDir');
442 foreach ($variables as $key => $value) {
443 if (in_array($key, $urlArray)) {
444 $value = CRM_Utils_File
::addTrailingSlash($value, '/');
446 elseif (in_array($key, $dirArray)) {
448 $value = CRM_Utils_File
::addTrailingSlash($value);
450 if (empty($value) ||
(CRM_Utils_File
::createDir($value, FALSE) === FALSE)) {
451 // seems like we could not create the directories
452 // settings might have changed, lets suppress a message for now
453 // so we can make some more progress and let the user fix their settings
454 // for now we assign it to a know value
456 $value = $this->templateCompileDir
;
457 $url = CRM_Utils_System
::url('civicrm/admin/setting/path', 'reset=1');
458 CRM_Core_Session
::setStatus(ts('%1 has an incorrect directory path. Please go to the <a href="%2">path setting page</a> and correct it.', array(
461 )), ts('Check Settings'), 'alert');
464 elseif ($key == 'lcMessages') {
465 // reset the templateCompileDir to locale-specific and make sure it exists
466 if (substr($this->templateCompileDir
, -1 * strlen($value) - 1, -1) != $value) {
467 $this->templateCompileDir
.= CRM_Utils_File
::addTrailingSlash($value);
468 CRM_Utils_File
::createDir($this->templateCompileDir
);
472 $this->$key = $value;
475 if ($this->userFrameworkResourceURL
) {
476 // we need to do this here so all blocks also load from an ssl server
477 if (CRM_Utils_System
::isSSL()) {
478 CRM_Utils_System
::mapConfigToSSL();
480 $rrb = parse_url($this->userFrameworkResourceURL
);
481 // dont use absolute path if resources are stored on a different server
483 $this->resourceBase
= $this->userFrameworkResourceURL
;
484 if (isset($_SERVER['HTTP_HOST']) &&
487 $this->resourceBase
= ($rrb['host'] == $_SERVER['HTTP_HOST']) ?
$rrb['path'] : $this->userFrameworkResourceURL
;
491 if (!$this->customFileUploadDir
) {
492 $this->customFileUploadDir
= $this->uploadDir
;
495 if ($this->geoProvider
) {
496 $this->geocodeMethod
= 'CRM_Utils_Geocode_' . $this->geoProvider
;
498 elseif ($this->mapProvider
) {
499 $this->geocodeMethod
= 'CRM_Utils_Geocode_' . $this->mapProvider
;
502 require_once (str_replace('_', DIRECTORY_SEPARATOR
, $this->userFrameworkClass
) . '.php');
503 $class = $this->userFrameworkClass
;
504 // redundant with _setUserFrameworkConfig
505 $this->userSystem
= new $class();
509 * Retrieve a mailer to send any mail from the application
511 * @param boolean $persist open a persistent smtp connection, should speed up mailings
515 static function &getMailer($persist = FALSE) {
516 if (!isset(self
::$_mail)) {
517 $mailingInfo = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
521 if ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_REDIRECT_TO_DB ||
522 (defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL
)
524 self
::$_mail = self
::_createMailer('CRM_Mailing_BAO_Spool', array());
526 elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_SMTP
) {
527 if ($mailingInfo['smtpServer'] == '' ||
!$mailingInfo['smtpServer']) {
528 CRM_Core_Error
::debug_log_message(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
529 CRM_Core_Error
::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
532 $params['host'] = $mailingInfo['smtpServer'] ?
$mailingInfo['smtpServer'] : 'localhost';
533 $params['port'] = $mailingInfo['smtpPort'] ?
$mailingInfo['smtpPort'] : 25;
535 if ($mailingInfo['smtpAuth']) {
536 $params['username'] = $mailingInfo['smtpUsername'];
537 $params['password'] = CRM_Utils_Crypt
::decrypt($mailingInfo['smtpPassword']);
538 $params['auth'] = TRUE;
541 $params['auth'] = FALSE;
544 // set the localhost value, CRM-3153
545 $params['localhost'] = CRM_Utils_Array
::value('SERVER_NAME', $_SERVER, 'localhost');
547 // also set the timeout value, lets set it to 30 seconds
549 $params['timeout'] = 30;
552 $params['persist'] = $persist;
554 self
::$_mail = self
::_createMailer('smtp', $params);
556 elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_SENDMAIL
) {
557 if ($mailingInfo['sendmail_path'] == '' ||
558 !$mailingInfo['sendmail_path']
560 CRM_Core_Error
::debug_log_message(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
561 CRM_Core_Error
::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
563 $params['sendmail_path'] = $mailingInfo['sendmail_path'];
564 $params['sendmail_args'] = $mailingInfo['sendmail_args'];
566 self
::$_mail = self
::_createMailer('sendmail', $params);
568 elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_MAIL
) {
569 self
::$_mail = self
::_createMailer('mail', array());
571 elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_MOCK
) {
572 self
::$_mail = self
::_createMailer('mock', array());
574 elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_DISABLED
) {
575 CRM_Core_Error
::debug_log_message(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
576 CRM_Core_Session
::setStatus(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
579 CRM_Core_Error
::debug_log_message(ts('There is no valid SMTP server Setting Or SendMail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
580 CRM_Core_Session
::setStatus(ts('There is no valid SMTP server Setting Or sendMail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))));
581 CRM_Core_Error
::debug_var('mailing_info', $mailingInfo);
588 * Create a new instance of a PEAR Mail driver
590 * @param string $driver 'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory()
591 * @param array $params
592 * @return Mail (More specifically, a class which implements the "send()" function)
594 public static function _createMailer($driver, $params) {
595 if ($driver == 'CRM_Mailing_BAO_Spool') {
596 $mailer = new CRM_Mailing_BAO_Spool($params);
599 $mailer = Mail
::factory($driver, $params);
601 CRM_Utils_Hook
::alterMail($mailer, $driver, $params);
606 * delete the web server writable directories
608 * @param int $value 1 - clean templates_c, 2 - clean upload, 3 - clean both
614 public function cleanup($value, $rmdir = TRUE) {
615 $value = (int ) $value;
619 CRM_Utils_File
::cleanDir($this->templateCompileDir
, $rmdir);
620 CRM_Utils_File
::createDir($this->templateCompileDir
);
624 CRM_Utils_File
::cleanDir($this->uploadDir
);
625 CRM_Utils_File
::createDir($this->uploadDir
);
626 CRM_Utils_File
::restrictAccess($this->uploadDir
);
631 * verify that the needed parameters are not null in the config
633 * @param CRM_Core_Config (reference ) the system config object
634 * @param array (reference ) the parameters that need a value
640 static function check(&$config, &$required) {
641 foreach ($required as $name) {
642 if (CRM_Utils_System
::isNull($config->$name)) {
650 * reset the serialized array and recompute
654 $query = "UPDATE civicrm_domain SET config_backend = null";
655 CRM_Core_DAO
::executeQuery($query);
658 // This method should initialize auth sources
659 function initAuthSrc() {
660 $session = CRM_Core_Session
::singleton();
661 if ($session->get('userID') && !$session->get('authSrc')) {
662 $session->set('authSrc', CRM_Core_Permission
::AUTH_SRC_LOGIN
);
666 CRM_Contact_BAO_Contact_Permission
::initChecksumAuthSrc();
670 * one function to get domain ID
672 static function domainID($domainID = NULL, $reset = FALSE) {
677 if ($reset ||
empty($domain)) {
678 $domain = defined('CIVICRM_DOMAIN_ID') ? CIVICRM_DOMAIN_ID
: 1;
685 * do general cleanup of caches, temp directories and temp tables
688 function cleanupCaches($sessionReset = TRUE) {
689 // cleanup templates_c directory
690 $this->cleanup(1, FALSE);
693 self
::clearDBCache();
696 $session = CRM_Core_Session
::singleton();
702 * Do general cleanup of module permissions.
704 function cleanupPermissions() {
705 $module_files = CRM_Extension_System
::singleton()->getMapper()->getActiveModuleFiles();
706 if ($this->userPermissionClass
->isModulePermissionSupported()) {
707 // Can store permissions -- so do it!
708 $this->userPermissionClass
->upgradePermissions(
709 CRM_Core_Permission
::basicPermissions()
712 // Cannot store permissions -- warn if any modules require them
713 $modules_with_perms = array();
714 foreach ($module_files as $module_file) {
715 $perms = $this->userPermissionClass
->getModulePermissions($module_file['prefix']);
716 if (!empty($perms)) {
717 $modules_with_perms[] = $module_file['prefix'];
720 if (!empty($modules_with_perms)) {
721 CRM_Core_Session
::setStatus(
722 ts('Some modules define permissions, but the CMS cannot store them: %1', array(1 => implode(', ', $modules_with_perms))),
723 ts('Permission Error'),
731 * Flush information about loaded modules
733 function clearModuleList() {
734 CRM_Extension_System
::singleton()->getCache()->flush();
735 CRM_Utils_Hook
::singleton(TRUE);
736 CRM_Core_PseudoConstant
::getModuleExtensions(TRUE);
737 CRM_Core_Module
::getAll(TRUE);
743 public static function clearDBCache() {
745 'TRUNCATE TABLE civicrm_acl_cache',
746 'TRUNCATE TABLE civicrm_acl_contact_cache',
747 'TRUNCATE TABLE civicrm_cache',
748 'TRUNCATE TABLE civicrm_prevnext_cache',
749 'UPDATE civicrm_group SET cache_date = NULL',
750 'TRUNCATE TABLE civicrm_group_contact_cache',
751 'TRUNCATE TABLE civicrm_menu',
752 'UPDATE civicrm_setting SET value = NULL WHERE name="navigation" AND contact_id IS NOT NULL',
753 'DELETE FROM civicrm_setting WHERE name="modulePaths"', // CRM-10543
756 foreach ($queries as $query) {
757 CRM_Core_DAO
::executeQuery($query);
760 // also delete all the import and export temp tables
761 self
::clearTempTables();
765 * clear leftover temporary tables
767 public static function clearTempTables() {
769 $dao = CRM_Core_DAO
::executeQuery("SELECT DATABASE();");
771 SELECT TABLE_NAME as tableName
772 FROM INFORMATION_SCHEMA.TABLES
773 WHERE TABLE_SCHEMA = %1
775 ( TABLE_NAME LIKE 'civicrm_import_job_%'
776 OR TABLE_NAME LIKE 'civicrm_export_temp%'
777 OR TABLE_NAME LIKE 'civicrm_task_action_temp%'
778 OR TABLE_NAME LIKE 'civicrm_report_temp%'
782 $params = array(1 => array($dao->database(), 'String'));
783 $tableDAO = CRM_Core_DAO
::executeQuery($query, $params);
785 while ($tableDAO->fetch()) {
786 $tables[] = $tableDAO->tableName
;
788 if (!empty($tables)) {
789 $table = implode(',', $tables);
790 // drop leftover temporary tables
791 CRM_Core_DAO
::executeQuery("DROP TABLE $table");
796 * function to check if running in upgrade mode
798 static function isUpgradeMode($path = NULL) {
799 if (defined('CIVICRM_UPGRADE_ACTIVE')) {
804 // note: do not re-initialize config here, since this function is part of
805 // config initialization itself
807 if (defined('CIVICRM_UF') && CIVICRM_UF
== 'Joomla') {
811 $path = CRM_Utils_Array
::value($urlVar, $_GET);
814 if ($path && preg_match('/^civicrm\/upgrade(\/.*)?$/', $path)) {
822 * Wrapper function to allow unit tests to switch user framework on the fly
824 public function setUserFramework($userFramework = NULL) {
825 $this->userFramework
= $userFramework;
826 $this->_setUserFrameworkConfig($userFramework);
829 // end CRM_Core_Config