Exemplo n.º 1
0
 public function setupSettingTable($timezone, $locale, $securityToken)
 {
     // create setting data table.
     $fields = array("setting" => "VARCHAR(255) NOT NULL", "context" => "VARCHAR(255) NOT NULL", "value" => "LONGTEXT");
     if (!$this->dbConnector->createTable(CRM_SETTINGS_TABLE_NAME, $fields, ["setting", "context"])) {
         return false;
     }
     // fill the settings table.
     // base dir. We suppose here we have been called from updater.php or other root file.
     $currentURL = \creamy\CRMUtils::getCurrentURLPath();
     // i.e: http://localhost:8080/creamy/updater.php
     $baseurl = \creamy\CRMUtils::getBasedirFromURL($currentURL);
     // => http://localhost:8080/creamy
     $data = array("setting" => CRM_SETTING_CRM_BASE_URL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $baseurl);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // admin account
     $adminEmail = array("setting" => CRM_SETTING_ADMIN_USER, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => 1);
     $adminEmailFound = $this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $adminEmail);
     // crm version
     $data = array("setting" => CRM_SETTING_CRM_VERSION, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_INSTALL_VERSION);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // installation date. We try to get it from the Config.php file first
     if ($timestamp = filemtime(dirname(__FILE__) . '/Config.php')) {
         $dbDate = date("Y-m-d H:i:s", $timestamp);
     } else {
         $dbDate = $this->dbConnector->now();
     }
     $data = array("setting" => CRM_SETTING_INSTALLATION_DATE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $dbDate);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // plugin system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_MODULE_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // statistics system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_STATISTICS_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // email notifications of events.
     $data = array("setting" => CRM_SETTING_EVENTS_EMAIL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // job scheduling frequency
     $data = array("setting" => CRM_SETTING_JOB_SCHEDULING_MIN_FREQ, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_JOB_SCHEDULING_HOURLY);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // active plugins (empty by default)
     $data = array("setting" => CRM_SETTING_ACTIVE_MODULES, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => "");
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // customer list fields
     $data = array("setting" => CRM_SETTING_CUSTOMER_LIST_FIELDS, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SETTING_DEFAULT_CUSTOMER_LIST_FIELDS);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // timezone
     $data = array("setting" => CRM_SETTING_TIMEZONE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $timezone);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // locale
     $data = array("setting" => CRM_SETTING_LOCALE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $locale);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // security token
     $data = array("setting" => CRM_SETTING_SECURITY_TOKEN, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $securityToken);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     error_log("Creamy install: Settings database set.");
     return true;
 }
Exemplo n.º 2
0
 /** Sets general settings parameters of the CRM */
 private function setGeneralParametersInSettings()
 {
     // crm version
     $data = array("setting" => CRM_SETTING_CRM_VERSION, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_INSTALL_VERSION);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // base dir. We suppose here we have been called from updater.php or other root file.
     $currentURL = \creamy\CRMUtils::getCurrentURLPath();
     // i.e: http://localhost:8080/creamy/updater.php
     $baseurl = \creamy\CRMUtils::getBasedirFromURL($currentURL);
     // => http://localhost:8080/creamy
     $data = array("setting" => CRM_SETTING_CRM_BASE_URL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $baseurl);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // installation date. We try to get it from the Config.php file first
     if ($timestamp = filemtime(dirname(__FILE__) . '/Config.php')) {
         $dbDate = date("Y-m-d H:i:s", $timestamp);
     } else {
         $dbDate = $this->dbConnector->now();
     }
     $data = array("setting" => CRM_SETTING_INSTALLATION_DATE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => $dbDate);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // module system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_MODULE_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // statistics system enabled (1 by default)
     $data = array("setting" => CRM_SETTING_STATISTICS_SYSTEM_ENABLED, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // email notifications of events.
     $data = array("setting" => CRM_SETTING_EVENTS_EMAIL, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => true);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // job scheduling frequency
     $data = array("setting" => CRM_SETTING_JOB_SCHEDULING_MIN_FREQ, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_JOB_SCHEDULING_HOURLY);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // active modules (empty by default)
     $data = array("setting" => CRM_SETTING_ACTIVE_MODULES, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => "");
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // customer list fields
     $data = array("setting" => CRM_SETTING_CUSTOMER_LIST_FIELDS, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SETTING_DEFAULT_CUSTOMER_LIST_FIELDS);
     if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
         return false;
     }
     // timezone
     if (defined('CRM_TIMEZONE')) {
         $data = array("setting" => CRM_SETTING_TIMEZONE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_TIMEZONE);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     // locale
     if (defined('CRM_LOCALE')) {
         $data = array("setting" => CRM_SETTING_LOCALE, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_LOCALE);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     // security token
     if (defined('CRM_SECURITY_TOKEN')) {
         $data = array("setting" => CRM_SETTING_SECURITY_TOKEN, "context" => CRM_SETTING_CONTEXT_CREAMY, "value" => CRM_SECURITY_TOKEN);
         if (!$this->dbConnector->insert(CRM_SETTINGS_TABLE_NAME, $data)) {
             return false;
         }
     }
     return true;
 }