Example #1
0
/**
 *
 * @package CRM
 * @copyright CiviCRM LLC (c) 2004-2015
 * $Id$
 * @param $filesDirectory
 */
function civicrm_setup($filesDirectory)
{
    global $crmPath, $sqlPath, $pkgPath, $tplPath;
    global $compileDir;
    // Setup classloader
    // This is needed to allow CiviCRM to be installed by drush.
    // TODO: move to civicrm.drush.inc drush_civicrm_install()
    global $crmPath;
    require_once $crmPath . '/CRM/Core/ClassLoader.php';
    CRM_Core_ClassLoader::singleton()->register();
    $sqlPath = $crmPath . DIRECTORY_SEPARATOR . 'sql';
    $tplPath = $crmPath . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR;
    if (!is_dir($filesDirectory)) {
        mkdir($filesDirectory, 0777);
        chmod($filesDirectory, 0777);
    }
    $scratchDir = $filesDirectory . DIRECTORY_SEPARATOR . 'civicrm';
    if (!is_dir($scratchDir)) {
        mkdir($scratchDir, 0777);
    }
    $compileDir = $scratchDir . DIRECTORY_SEPARATOR . 'templates_c' . DIRECTORY_SEPARATOR;
    if (!is_dir($compileDir)) {
        mkdir($compileDir, 0777);
    }
    $compileDir = addslashes($compileDir);
}
function civicrm_init()
{
    require_once 'CRM/Core/ClassLoader.php';
    CRM_Core_ClassLoader::singleton()->register();
    require_once 'PEAR.php';
    $config = CRM_Core_Config::singleton();
}
Example #3
0
 /**
  * @param bool $force
  *
  * @return object
  */
 public static function &singleton($force = FALSE)
 {
     if ($force || self::$_singleton === NULL) {
         self::$_singleton = new CRM_Core_ClassLoader();
     }
     return self::$_singleton;
 }
function civicrm_init()
{
    require_once 'CRM/Core/ClassLoader.php';
    CRM_Core_ClassLoader::singleton()->register();
    require_once 'PEAR.php';
    $config = CRM_Core_Config::singleton();
    // this is the front end, so let others know
    $config->userFrameworkFrontend = 1;
}
 /**
  * Simple name based constructor
  */
 function __construct($theClass = '', $name = '')
 {
     if (empty($name)) {
         $name = str_replace('_', ' ', get_class($this));
         // also split AllTests to All Tests
         $name = str_replace('AllTests', 'All Tests', $name);
     }
     parent::__construct($name);
     // also load the class loader
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
 }
Example #6
0
 /**
  * @return \EnvTests
  */
 public static function suite()
 {
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     $suite = new EnvTests();
     $tests = getenv('PHPUNIT_TESTS');
     foreach (explode(' ', $tests) as $test) {
         if (strpos($test, '::') !== FALSE) {
             list($class, $method) = explode('::', $test);
             $clazz = new \ReflectionClass($class);
             $suite->addTestMethod($clazz, $clazz->getMethod($method));
         } else {
             $suite->addTestSuite($test);
         }
     }
     return $suite;
 }
 protected function getInput()
 {
     $value = $this->value;
     $name = $this->name;
     // Initiate CiviCRM
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     $ufGroups = CRM_Core_PseudoConstant::ufGroup();
     $options[] = JHTML::_('select.option', '', JText::_('- Select Profile -'));
     foreach ($ufGroups as $key => $values) {
         $options[] = JHTML::_('select.option', $key, $values);
     }
     return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value);
 }
 protected function getInput()
 {
     $value = $this->value;
     $name = $this->name;
     // Initiate CiviCRM
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     $query = "\nSELECT value, description\nFROM civicrm_option_value\nWHERE option_group_id =24\n";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $options[] = JHTML::_('select.option', $dao->value, $dao->description);
     }
     return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $dao->value);
 }
 /**
  *  Constructor.
  *
  *  Because we are overriding the parent class constructor, we
  *  need to show the same arguments as exist in the constructor of
  *  PHPUnit_Framework_TestCase, since
  *  PHPUnit_Framework_TestSuite::createTest() creates a
  *  ReflectionClass of the Test class and checks the constructor
  *  of that class to decide how to set up the test.
  *
  * @param string $name
  * @param array $data
  * @param string $dataName
  * @param array $browser
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array())
 {
     parent::__construct($name, $data, $dataName, $browser);
     $this->loggedInAs = NULL;
     $this->settings = new CiviSeleniumSettings();
     if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
         global $CiviSeleniumTestCase_polled;
         if (!$CiviSeleniumTestCase_polled) {
             $CiviSeleniumTestCase_polled = TRUE;
             CRM_Utils_Network::waitForServiceStartup($this->drivers[0]->getHost(), $this->drivers[0]->getPort(), $this->settings->serverStartupTimeOut);
         }
     }
     // autoload
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     // also initialize a connection to the db
     // FIXME: not necessary for most tests, consider moving into functions that need this
     $config = CRM_Core_Config::singleton();
 }
 protected function getInput()
 {
     $value = $this->value;
     $name = $this->name;
     // Initiate CiviCRM
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     // Get list of all ContribPagesPCP  and assign to options array
     $options = array();
     $query = "SELECT cp.id, cp.title \n\t\t          FROM civicrm_contribution_page cp, civicrm_pcp_block pcp \n\t\t          WHERE cp.is_active = 1 \n\t\t\t\t    AND pcp.is_active = 1 \n\t\t\t\t\tAND pcp.entity_id = cp.id \n\t\t\t\t    AND pcp.entity_table = 'civicrm_contribution_page'\n\t\t\t\t  ORDER BY cp.title;";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $options[] = JHTML::_('select.option', $dao->id, $dao->title);
     }
     return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value, $name);
 }
 protected function getInput()
 {
     $value = $this->value;
     $name = $this->name;
     // Initiate CiviCRM
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     $options = array();
     $options[] = JHTML::_('select.option', '0', JText::_('- Select Contribution Page -'));
     $query = 'SELECT id,title  FROM civicrm_contribution_page WHERE is_active = 1 ORDER BY title';
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $options[] = JHTML::_('select.option', $dao->id, $dao->title);
     }
     return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value, $name);
 }
 protected function getInput()
 {
     $value = $this->value;
     $name = $this->name;
     // Initiate CiviCRM
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     $params = array('version' => '3', 'is_online_registration' => 1, 'is_active' => 1, 'isCurrent' => 1, 'return.title' => 1, 'return.id' => 1, 'return.end_date' => 1, 'return.start_date' => 1);
     $events = civicrm_api('event', 'get', $params);
     $currentdate = date("Y-m-d H:i:s");
     $options = array();
     $options[] = JHTML::_('select.option', '', JText::_('- Select Event -'));
     foreach ($events['values'] as $event) {
         if (strtotime($event['start_date']) >= strtotime($currentdate) || strtotime($event['end_date']) >= strtotime($currentdate)) {
             $options[] = JHTML::_('select.option', $event['id'], $event['event_title']);
         }
     }
     return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value);
 }
Example #13
0
 /**
  * @description: initialize CiviCRM
  * @return bool $success
  */
 public function initialize()
 {
     static $initialized = FALSE;
     static $failure = FALSE;
     if ($failure) {
         return FALSE;
     }
     if (!$initialized) {
         // Check for php version and ensure its greater than minPhpVersion
         $minPhpVersion = '5.3.3';
         if (version_compare(PHP_VERSION, $minPhpVersion) < 0) {
             echo '<p>' . sprintf(__('CiviCRM requires PHP Version %s or greater. You are running PHP Version %s', 'civicrm-wordpress'), $minPhpVersion, PHP_VERSION) . '<p>';
             exit;
         }
         // check for settings
         if (!file_exists(CIVICRM_SETTINGS_PATH)) {
             $error = FALSE;
         } else {
             $error = (include_once CIVICRM_SETTINGS_PATH);
         }
         // autoload
         require_once 'CRM/Core/ClassLoader.php';
         CRM_Core_ClassLoader::singleton()->register();
         // get ready for problems
         $installLink = admin_url() . "options-general.php?page=civicrm-install";
         $docLinkInstall = "http://wiki.civicrm.org/confluence/display/CRMDOC/WordPress+Installation+Guide";
         $docLinkTrouble = "http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Configuration+Trouble-shooting";
         $forumLink = "http://forum.civicrm.org/index.php/board,6.0.html";
         // construct message
         $errorMsgAdd = sprintf(__('Please review the <a href="%s">WordPress Installation Guide</a> and the <a href="%s">Trouble-shooting page</a> for assistance. If you still need help installing, you can often find solutions to your issue by searching for the error message in the <a href="%s">installation support section of the community forum</a>.', 'civicrm-wordpress'), $docLinkInstall, $docLinkTrouble, $forumLink);
         // does install message get used?
         $installMessage = sprintf(__('Click <a href="%s">here</a> for fresh install.', 'civicrm-wordpress'), $installLink);
         if ($error == FALSE) {
             header('Location: ' . admin_url() . 'options-general.php?page=civicrm-install');
             return FALSE;
         }
         // access global defined in civicrm.settings.php
         global $civicrm_root;
         // this does pretty much all of the civicrm initialization
         if (!file_exists($civicrm_root . 'CRM/Core/Config.php')) {
             $error = FALSE;
         } else {
             $error = (include_once 'CRM/Core/Config.php');
         }
         // have we got it?
         if ($error == FALSE) {
             // set static flag
             $failure = TRUE;
             // FIX ME - why?
             wp_die("<strong><p class='error'>" . sprintf(__('Oops! - The path for including CiviCRM code files is not set properly. Most likely there is an error in the <em>civicrm_root</em> setting in your CiviCRM settings file (%s).', 'civicrm-wordpress'), CIVICRM_SETTINGS_PATH) . "</p><p class='error'> &raquo; " . sprintf(__('civicrm_root is currently set to: <em>%s</em>.', 'civicrm-wordpress'), $civicrm_root) . "</p><p class='error'>" . $errorMsgAdd . "</p></strong>");
             // won't reach here!
             return FALSE;
         }
         // set static flag
         $initialized = TRUE;
         // initialize the system by creating a config object
         $config = CRM_Core_Config::singleton();
         // sync the logged in user with WP
         global $current_user;
         if ($current_user) {
             // sync procedure sets session values for logged in users
             require_once 'CRM/Core/BAO/UFMatch.php';
             CRM_Core_BAO_UFMatch::synchronize($current_user, FALSE, 'WordPress', $this->get_civicrm_contact_type('Individual'));
         }
     }
     // notify plugins
     do_action('civicrm_initialized');
     // success!
     return 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();
    }
}
 private function _bootstrap()
 {
     // so the configuration works with php-cli
     $_SERVER['PHP_SELF'] = "/index.php";
     $_SERVER['HTTP_HOST'] = $this->_site;
     $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
     // SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
     $_SERVER['SCRIPT_FILENAME'] = __FILE__;
     // CRM-8917 - check if script name starts with /, if not - prepend it.
     if (ord($_SERVER['SCRIPT_NAME']) != 47) {
         $_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
     }
     $civicrm_root = dirname(__DIR__);
     chdir($civicrm_root);
     require_once 'civicrm.config.php';
     // autoload
     require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $this->_config = CRM_Core_Config::singleton();
     require_once 'CRM/Utils/System.php';
     $class = 'CRM_Utils_System_' . $this->_config->userFramework;
     $cms = new $class();
     if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
         $this->_log(ts("Failed to bootstrap CMS"));
         return FALSE;
     }
     if (strtolower($this->_entity) == 'job') {
         if (!$this->_user) {
             $this->_log(ts("Jobs called from cli.php require valid user as parameter"));
             return FALSE;
         }
     }
     if (!empty($this->_user)) {
         if (!$cms->loadUser($this->_user)) {
             $this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
             return FALSE;
         }
     }
     return TRUE;
 }
Example #16
0
 /**
  * @return bool
  */
 private function _bootstrap()
 {
     // so the configuration works with php-cli
     $_SERVER['PHP_SELF'] = "/index.php";
     $_SERVER['HTTP_HOST'] = $this->_site;
     $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
     $_SERVER['SERVER_SOFTWARE'] = NULL;
     $_SERVER['REQUEST_METHOD'] = 'GET';
     // SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
     $_SERVER['SCRIPT_FILENAME'] = __FILE__;
     // CRM-8917 - check if script name starts with /, if not - prepend it.
     if (ord($_SERVER['SCRIPT_NAME']) != 47) {
         $_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
     }
     $civicrm_root = dirname(__DIR__);
     chdir($civicrm_root);
     require_once 'civicrm.config.php';
     // autoload
     if (!class_exists('CRM_Core_ClassLoader')) {
         require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
     }
     CRM_Core_ClassLoader::singleton()->register();
     $this->_config = CRM_Core_Config::singleton();
     // HTTP_HOST will be 'localhost' unless overwritten with the -s argument.
     // Now we have a Config object, we can set it from the Base URL.
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         $_SERVER['HTTP_HOST'] = preg_replace('!^https?://([^/]+)/$!i', '$1', $this->_config->userFrameworkBaseURL);
     }
     $class = 'CRM_Utils_System_' . $this->_config->userFramework;
     $cms = new $class();
     if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
         $this->_log(ts("Failed to bootstrap CMS"));
         return FALSE;
     }
     if (strtolower($this->_entity) == 'job') {
         if (!$this->_user) {
             $this->_log(ts("Jobs called from cli.php require valid user as parameter"));
             return FALSE;
         }
     }
     if (!empty($this->_user)) {
         if (!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
             $this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
             return FALSE;
         }
         if (!$cms->loadUser($this->_user)) {
             $this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
             return FALSE;
         }
     }
     return TRUE;
 }
Example #17
0
 /**
  *  Constructor.
  *
  *  Because we are overriding the parent class constructor, we
  *  need to show the same arguments as exist in the constructor of
  *  PHPUnit_Framework_TestCase, since
  *  PHPUnit_Framework_TestSuite::createTest() creates a
  *  ReflectionClass of the Test class and checks the constructor
  *  of that class to decide how to set up the test.
  *
  * @param string $name
  * @param array $data
  * @param string $dataName
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     // we need full error reporting
     error_reporting(E_ALL & ~E_NOTICE);
     self::$_dbName = self::getDBName();
     // also load the class loader
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     if (function_exists('_civix_phpunit_setUp')) {
         // FIXME: loosen coupling
         _civix_phpunit_setUp();
     }
 }
Example #18
0
/**
 * Initialize CiviCRM - should be run at the start of each API function.
 */
function _civicrm_api3_initialize()
{
    require_once 'CRM/Core/ClassLoader.php';
    CRM_Core_ClassLoader::singleton()->register();
    CRM_Core_Config::singleton();
}
 /**
  *  Constructor.
  *
  *  Because we are overriding the parent class constructor, we
  *  need to show the same arguments as exist in the constructor of
  *  PHPUnit_Framework_TestCase, since
  *  PHPUnit_Framework_TestSuite::createTest() creates a
  *  ReflectionClass of the Test class and checks the constructor
  *  of that class to decide how to set up the test.
  *
  * @param string $name
  * @param array $data
  * @param string $dataName
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     // we need full error reporting
     error_reporting(E_ALL & ~E_NOTICE);
     if (!empty($GLOBALS['mysql_db'])) {
         self::$_dbName = $GLOBALS['mysql_db'];
     } else {
         self::$_dbName = 'civicrm_tests_dev';
     }
     //  create test database
     self::$utils = new Utils($GLOBALS['mysql_host'], $GLOBALS['mysql_port'], $GLOBALS['mysql_user'], $GLOBALS['mysql_pass']);
     // also load the class loader
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     if (function_exists('_civix_phpunit_setUp')) {
         // FIXME: loosen coupling
         _civix_phpunit_setUp();
     }
 }
 /**
  * Make sure that CiviCRM is loaded
  */
 protected function bootstrap()
 {
     if (defined('CIVICRM_UF')) {
         // already loaded settings
         return;
     }
     $app = JFactory::getApplication();
     // copied from example -- but why?
     define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
     require_once CIVICRM_SETTINGS_PATH;
     require_once 'CRM/Core/ClassLoader.php';
     CRM_Core_ClassLoader::singleton()->register();
     require_once 'CRM/Core/Config.php';
     $civiConfig = CRM_Core_Config::singleton();
 }
Example #21
0
 /**
  * @param array API configuration.
  */
 function __construct($config = NULL)
 {
     $this->local = TRUE;
     $this->input = array();
     $this->lastResult = array();
     if (isset($config) && isset($config['server'])) {
         // we are calling a remote server via REST
         $this->local = FALSE;
         $this->uri = $config['server'];
         if (isset($config['path'])) {
             $this->uri .= "/" . $config['path'];
         } else {
             $this->uri .= '/sites/all/modules/civicrm/extern/rest.php';
         }
         $this->uri .= '?json=1';
         if (isset($config['key'])) {
             $this->key = $config['key'];
         } else {
             die("\nFATAL:param['key] missing\n");
         }
         if (isset($config['api_key'])) {
             $this->api_key = $config['api_key'];
         } else {
             die("\nFATAL:param['api_key] missing\n");
         }
         return;
     }
     if (isset($config) && isset($config['conf_path'])) {
         define('CIVICRM_SETTINGS_PATH', $config['conf_path'] . '/civicrm.settings.php');
         require_once CIVICRM_SETTINGS_PATH;
         require_once 'CRM/Core/ClassLoader.php';
         require_once 'api/api.php';
         require_once "api/v3/utils.php";
         \CRM_Core_ClassLoader::singleton()->register();
         $this->cfg = \CRM_Core_Config::singleton();
         $this->init();
     } else {
         $this->cfg = \CRM_Core_Config::singleton();
     }
 }
Example #22
0
<?php

ini_set('include_path', '.' . PATH_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . '..');
// make sure the memory_limit is at least 512 MB
$memLimitString = trim(ini_get('memory_limit'));
$memLimitUnit = strtolower(substr($memLimitString, -1));
$memLimit = (int) $memLimitString;
switch ($memLimitUnit) {
    case 'g':
        $memLimit *= 1024;
    case 'm':
        $memLimit *= 1024;
    case 'k':
        $memLimit *= 1024;
}
if ($memLimit >= 0 and $memLimit < 536870912) {
    // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
    ini_set('memory_limit', -1);
}
date_default_timezone_set('UTC');
// avoid php warnings if timezone is not set - CRM-10844
define('CIVICRM_UF', 'Drupal');
define('CIVICRM_UF_BASEURL', '/');
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
# TODO: pull these settings from configuration
$genCode = new CRM_Core_CodeGen_Main('../CRM/Core/DAO/', '../sql/', '../', '../templates/', NULL, @$argv[3], empty($argv[2]) ? NULL : $argv[2], empty($argv[1]) ? 'schema/Schema.xml' : $argv[1], getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL);
$genCode->main();
Example #23
0
 /**
  * Bootstrap the CiviCRM runtime.
  *
  * @param array $options
  *   See options in class doc.
  * @throws \Exception
  */
 public function boot($options = array())
 {
     if (!defined('CIVICRM_SETTINGS_PATH')) {
         $this->options = $options = array_merge($this->options, $options);
         $settings = $this->getCivicrmSettingsPhp($options);
         if (empty($settings) || !file_exists($settings)) {
             throw new \Exception("Failed to locate civicrm.settings.php." . " By default, this tool searches the parent directories for a standard CMS (Drupal, WordPress, etal) and standard civicrm.settings.php." . " Symlinks and multisite configurations may interfere." . " To customize, set variable CIVICRM_SETTINGS to point to the preferred civicrm.settings.php.");
         }
         $reader = new SiteConfigReader($settings);
         $GLOBALS['_CV'] = $reader->compile(array('buildkit', 'home'));
         define('CIVICRM_SETTINGS_PATH', $settings);
         $error = @(include_once $settings);
         if ($error == FALSE) {
             throw new \Exception("Could not load the CiviCRM settings file: {$settings}");
         }
         list($cmsType, $cmsBasePath) = $this->findCmsRoot($this->getSearchDir());
         if (PHP_SAPI === "cli") {
             $_SERVER['SCRIPT_FILENAME'] = $cmsBasePath . '/index.php';
             $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
             $_SERVER['SERVER_SOFTWARE'] = NULL;
             $_SERVER['REQUEST_METHOD'] = 'GET';
             if (ord($_SERVER['SCRIPT_NAME']) != 47) {
                 $_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
             }
         }
     }
     // Backward compatibility - New civicrm.settings.php files include
     // the classloader, but old ones don't.
     global $civicrm_root;
     require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
     \CRM_Core_ClassLoader::singleton()->register();
     if (!empty($options['prefetch'])) {
         // I'm not sure why this is called explicitly during bootstrap
         // rather than lazily. However, it seems to be done by all
         // the existing bootstrap code. Perhaps initializing Config
         // has a side-effect of initializing other things?
         \CRM_Core_Config::singleton();
     }
 }