コード例 #1
0
 /**
  * Protected constructor to prevent creating a new instance of the
  * *Singleton* via the `new` operator from outside of this class.
  */
 protected function __construct($locale = null, $databaseConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     // initialize language and user locale
     if (isset($locale)) {
         $this->locale = $locale;
     } else {
         if (\creamy\DatabaseConnectorFactory::instantiationAvailableForConnectorOfType($databaseConnectorType)) {
             // else if we have access to database, check the CRM locale setting.
             $dbConnector = \creamy\DatabaseConnectorFactory::getInstance()->getDatabaseConnectorOfType($databaseConnectorType);
             $dbConnector->where("setting", CRM_SETTING_LOCALE);
             if ($settingRow = $dbConnector->getOne(CRM_SETTINGS_TABLE_NAME)) {
                 $this->locale = $settingRow["value"];
             }
         }
     }
     // if locale could not be stablished, fallback to default.
     if (!isset($this->locale)) {
         $this->locale = CRM_LANGUAGE_DEFAULT_LOCALE;
     }
     // initialize map of language texts.
     $filepath = dirname(dirname(__FILE__)) . CRM_LANGUAGE_BASE_DIR . $this->locale;
     $translations = $this->getTranslationsFromFile($filepath);
     if (!isset($translations)) {
         // fallback to en_US installation (everybody knows english, don't they?)
         $filepath = dirname(dirname(__FILE__)) . CRM_LANGUAGE_BASE_DIR . "en_US";
         $this->locale = "en_US";
         $translations = $this->getTranslationsFromFile($filepath);
     }
     $this->texts = $translations;
 }
コード例 #2
0
ファイル: DbHandler.php プロジェクト: kisorbiswal/Creamy
 /** Creation and class lifetime management */
 function __construct($dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     // Database connector
     $this->dbConnector = \creamy\DatabaseConnectorFactory::getInstance()->getDatabaseConnectorOfType($dbConnectorType);
     // language handler
     $locale = $this->getLocaleSetting();
     $this->lh = \creamy\LanguageHandler::getInstance($locale, $dbConnectorType);
 }
コード例 #3
0
ファイル: Updater.php プロジェクト: kisorbiswal/Creamy
 /**
  * Constructor.
  */
 function __construct($dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     // database
     require_once 'DatabaseConnectorFactory.php';
     $this->dbConnector = \creamy\DatabaseConnectorFactory::getInstance()->getDatabaseConnectorOfType($dbConnectorType);
     // system versions
     $this->currendDatabaseVersion = $this->checkCurrentDatabaseVersion();
     $this->currentFilesystemVersion = $this->checkCurrentFilesystemVersion();
 }
コード例 #4
0
ファイル: DbInstaller.php プロジェクト: kisorbiswal/Creamy
 public function __construct($dbhost, $dbname, $dbuser, $dbpass, $dbport = CRM_DEFAULT_DB_PORT, $dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     $this->lh = \creamy\LanguageHandler::getInstance();
     try {
         $dbConnectorFactory = \creamy\DatabaseConnectorFactory::getInstance();
         $this->dbConnector = $dbConnectorFactory->getDatabaseConnectorOfType($dbConnectorType, $dbhost, $dbname, $dbuser, $dbpass, $dbport);
         $this->state = CRM_INSTALL_STATE_SUCCESS;
     } catch (\Exception $e) {
         $this->state = CRM_INSTALL_STATE_ERROR;
         $this->error = CRM_INSTALL_STATE_DATABASE_ERROR . ". Unable to instantiate database connector of type {$dbConnectorType}. Incorrect credentials or access denied.";
     }
 }
コード例 #5
0
ファイル: Module.php プロジェクト: kisorbiswal/Creamy
 /**
  * Convenience method that returns the Database Connector to be used by module's subclasses.
  * @return the module instance of DbConnector.
  */
 public function db($dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     if (!isset($this->dbConnector)) {
         $this->dbConnector = \creamy\DatabaseConnectorFactory::getInstance()->getDatabaseConnectorOfType($dbConnectorType);
     }
     return $this->dbConnector;
 }
コード例 #6
0
ファイル: ModuleHandler.php プロジェクト: kisorbiswal/Creamy
 /** 
  * Returns true if the module system is enabled. 
  * @return true if the module system is enabled. False otherwise.
  */
 public static function moduleSystemEnabled($dbConnectorType = CRM_DB_CONNECTOR_TYPE_MYSQL)
 {
     require_once 'DatabaseConnectorFactory.php';
     if ($dbConnector = \creamy\DatabaseConnectorFactory::getInstance()->getDatabaseConnectorOfType($dbConnectorType)) {
         $dbConnector->where("setting", CRM_SETTING_MODULE_SYSTEM_ENABLED);
         $result = $dbConnector->getOne(CRM_SETTINGS_TABLE_NAME);
         if (isset($result) && array_key_exists("value", $result)) {
             return $result["value"];
         }
     }
     return false;
 }