Exemplo n.º 1
0
function civicrm_main()
{
    global $civicrmUpgrade, $adminPath;
    civicrm_setup();
    // setup vars
    $configFile = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    // generate backend config file
    $string = "\n<?php\nrequire_once '{$configFile}';\n";
    $string = trim($string);
    civicrm_write_file($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.config.php', $string);
    // generate backend settings file
    $string = civicrm_config(false);
    civicrm_write_file($configFile, $string);
    // generate frontend settings file
    $string = civicrm_config(true);
    civicrm_write_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php', $string);
    include_once $configFile;
    // for install case only
    if (!$civicrmUpgrade) {
        $sqlPath = $adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'sql';
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_sample_report.mysql', true);
        require_once 'CRM/Core/Config.php';
        $config =& CRM_Core_Config::singleton();
        // now also build the menu
        require_once 'CRM/Core/Menu.php';
        CRM_Core_Menu::store();
    }
}
Exemplo n.º 2
0
 /**
  * Display an introductory screen with any pre-upgrade messages
  */
 public function runIntro()
 {
     $upgrade = new CRM_Upgrade_Form();
     $template = CRM_Core_Smarty::singleton();
     list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
     if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
         CRM_Core_Error::fatal($error);
     }
     $config = CRM_Core_Config::singleton();
     // All cached content needs to be cleared because the civi codebase was just replaced
     CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
     CRM_Core_Menu::store();
     // cleanup only the templates_c directory
     $config->cleanup(1, FALSE);
     $preUpgradeMessage = NULL;
     $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
     $template->assign('currentVersion', $currentVer);
     $template->assign('newVersion', $latestVer);
     $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2', array(1 => $currentVer, 2 => $latestVer)));
     $template->assign('upgraded', FALSE);
     // Render page header
     if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
         CRM_Utils_System::addHTMLHead($region->render(''));
     }
     $template->assign('preUpgradeMessage', $preUpgradeMessage);
     $content = $template->fetch('CRM/common/success.tpl');
     echo CRM_Utils_System::theme($content, $this->_print, TRUE);
 }
Exemplo n.º 3
0
 static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup module permissions
     $config->cleanupPermissions();
     // also rebuild word replacement cache
     CRM_Core_BAO_WordReplacement::rebuild();
     CRM_Core_BAO_Setting::updateSettingsFromMetaData();
     CRM_Core_Resources::singleton()->resetCacheCode();
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
 }
Exemplo n.º 4
0
 public function rebuildMenu()
 {
     // ensure config is set with new values
     $config =& CRM_Core_Config::singleton(true, true);
     // rebuild menu items
     require_once 'CRM/Core/Menu.php';
     CRM_Core_Menu::store();
     // also delete the IDS file so we can write a new correct one on next load
     $configFile = $config->uploadDir . 'Config.IDS.ini';
     @unlink($configFile);
 }
Exemplo n.º 5
0
 public function rebuildMenu()
 {
     // ensure config is set with new values
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
     // rebuild menu items
     CRM_Core_Menu::store();
     // also delete the IDS file so we can write a new correct one on next load
     $configFile = $config->uploadDir . 'Config.IDS.ini';
     @unlink($configFile);
 }
Exemplo n.º 6
0
 /**
  * @param bool $triggerRebuild
  * @param bool $sessionReset
  *
  * @throws Exception
  */
 public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup module permissions
     $config->cleanupPermissions();
     // rebuild word replacement cache - pass false to prevent operations redundant with this fn
     CRM_Core_BAO_WordReplacement::rebuild(FALSE);
     Civi::service('settings_manager')->flush();
     // Clear js caches
     CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
     CRM_Case_XMLRepository::singleton(TRUE);
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
     //CRM-16257 update Config.IDS.ini might be an old copy
     CRM_Core_IDS::createConfigFile(TRUE);
 }
function civicrm_main()
{
    global $civicrmUpgrade, $adminPath;
    civicrm_setup();
    // setup vars
    $configFile = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    // generate backend config file
    $string = "\n<?php\ndefine('CIVICRM_SETTINGS_PATH', '{$configFile}');\n\$error = @include_once( '{$configFile}' );\nif ( \$error == false ) {\n    echo \"Could not load the settings file at: {$configFile}\n\";\n    exit( );\n}\n\n// Load class loader\nrequire_once \$civicrm_root . '/CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
    $string = trim($string);
    civicrm_write_file($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.config.php', $string);
    $liveSite = substr_replace(JURI::root(), '', -1, 1);
    $siteKey = md5(uniqid('', true) . $liveSite);
    // generate backend settings file
    $string = civicrm_config(FALSE, $siteKey);
    civicrm_write_file($configFile, $string);
    // generate frontend settings file
    $string = civicrm_config(TRUE, $siteKey);
    civicrm_write_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php', $string);
    define('CIVICRM_SETTINGS_PATH', $configFile);
    include_once CIVICRM_SETTINGS_PATH;
    // for install case only
    if (!$civicrmUpgrade) {
        $sqlPath = $adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'sql';
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
        require_once 'CRM/Core/ClassLoader.php';
        CRM_Core_ClassLoader::singleton()->register();
        require_once 'CRM/Core/Config.php';
        $config = CRM_Core_Config::singleton();
        // now also build the menu
        require_once 'CRM/Core/Menu.php';
        CRM_Core_Menu::store();
    }
}
Exemplo n.º 8
0
 /**
  * This is the main function that is called on every click action and based on the argument
  * respective functions are called
  *
  * @param $args array this array contains the arguments of the url 
  * 
  * @static
  * @access public
  */
 static function invoke($args)
 {
     require_once 'CRM/Core/I18n.php';
     require_once 'CRM/Utils/Wrapper.php';
     require_once 'CRM/Core/Action.php';
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/Menu.php';
     require_once 'CRM/Core/Component.php';
     require_once 'CRM/Core/Permission.php';
     if ($args[0] !== 'civicrm') {
         return;
     }
     if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') {
         CRM_Core_Menu::store();
         CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
         // also reset navigation
         require_once 'CRM/Core/BAO/Navigation.php';
         CRM_Core_BAO_Navigation::resetNavigation();
         return CRM_Utils_System::redirect();
     }
     // first fire up IDS and check for bad stuff
     require_once 'CRM/Core/IDS.php';
     $ids = new CRM_Core_IDS();
     $ids->check($args);
     $config =& CRM_Core_Config::singleton();
     // also initialize the i18n framework
     $i18n =& CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Standalone') {
         require_once 'CRM/Core/Session.php';
         $session =& CRM_Core_Session::singleton();
         if ($session->get('new_install') !== true) {
             require_once 'CRM/Core/Standalone.php';
             CRM_Core_Standalone::sidebarLeft();
         } else {
             if ($args[1] == 'standalone' && $args[2] == 'register') {
                 CRM_Core_Menu::store();
             }
         }
     }
     // get the menu items
     $path = implode('/', $args);
     $item =& CRM_Core_Menu::get($path);
     // we should try to compute menus, if item is empty and stay on the same page,
     // rather than compute and redirect to dashboard.
     if (!$item) {
         CRM_Core_Menu::store(false);
         $item =& CRM_Core_Menu::get($path);
     }
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         require_once 'CRM/Core/Joomla.php';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = null;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template =& CRM_Core_Smarty::singleton();
         if (isset($item['is_public']) && $item['is_public']) {
             $template->assign('urlIsPublic', true);
         } else {
             $template->assign('urlIsPublic', false);
         }
         if (isset($item['return_url'])) {
             $session =& CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             return call_user_func($item['page_callback'], $newArgs);
         } else {
             if (strstr($item['page_callback'], '_Form')) {
                 $wrapper =& new CRM_Utils_Wrapper();
                 return $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : null);
             } else {
                 $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
                 $mode = 'null';
                 if (isset($pageArgs['mode'])) {
                     $mode = $pageArgs['mode'];
                     unset($pageArgs['mode']);
                 }
                 $title = CRM_Utils_Array::value('title', $item);
                 if (strstr($item['page_callback'], '_Page')) {
                     eval('$object =& ' . "new {$item['page_callback']}( \$title, \$mode );");
                 } else {
                     if (strstr($item['page_callback'], '_Controller')) {
                         $addSequence = 'false';
                         if (isset($pageArgs['addSequence'])) {
                             $addSequence = $pageArgs['addSequence'];
                             $addSequence = $addSequence ? 'true' : 'false';
                             unset($pageArgs['addSequence']);
                         }
                         eval('$object =& ' . "new {$item['page_callback']} ( \$title, true, \$mode, null, \$addSequence );");
                     } else {
                         CRM_Core_Error::fatal();
                     }
                 }
                 return $object->run($newArgs, $pageArgs);
             }
         }
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
     return CRM_Utils_System::redirect();
 }
Exemplo n.º 9
0
 static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
 }
Exemplo n.º 10
0
 /**
  * Example: Run an external SQL script
  *
  * @return TRUE on success
  * @throws Exception
  */
 public function upgrade_4204()
 {
     $this->ctx->log->info('Applying update 4204');
     // this path is relative to the extension base dir
     $this->executeSqlFile('sql/upgrade_4204.sql');
     // rebuild menu items
     CRM_Core_Menu::store();
     $params = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
     if ($params['outBound_option'] == 0 && CRM_Utils_Array::value('smtpServer', $params) == 'smtp.mandrillapp.com') {
         unset($params['qfKey'], $params['entryURL'], $params['sendmail_path'], $params['sendmail_args'], $params['outBound_option']);
         $params['is_active'] = 1;
         CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mandrill_smtp_settings');
     }
     return TRUE;
 }