Merge pull request #9575 from jitendrapurohit/CRM-19761
[civicrm-core.git] / api / v3 / System.php
index 80aac09c866c4b8dbf4107c210eadcca6419a65e..6187cce4cc81e4a8b001a3292c7034238da68a13 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2016                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -236,6 +236,7 @@ function civicrm_api3_system_get($params) {
         'version' => phpversion(),
         'time' => time(),
         'tz' => date_default_timezone_get(),
+        'sapi' => php_sapi_name(),
         'extensions' => get_loaded_extensions(),
         'ini' => _civicrm_api3_system_get_redacted_ini(),
       ),
@@ -258,8 +259,21 @@ function civicrm_api3_system_get($params) {
           CRM_Extension_System::singleton()->getManager()->getStatuses(),
           PREG_GREP_INVERT
         ),
+        'multidomain' => CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_domain') > 1,
+        'settings' => _civicrm_api3_system_get_redacted_settings(),
         'exampleUrl' => CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE),
       ),
+      'http' => array(
+        'software' => CRM_Utils_Array::value('SERVER_SOFTWARE', $_SERVER),
+        'forwarded' => !empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['X_FORWARDED_PROTO']),
+        'port' => (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443) ? 'Standard' : 'Nonstandard',
+      ),
+      'os' => array(
+        'type' => php_uname('s'),
+        'release' => php_uname('r'),
+        'version' => php_uname('v'),
+        'machine' => php_uname('m'),
+      ),
     ),
   );
 
@@ -334,6 +348,31 @@ function _civicrm_api3_system_get_redacted_mysql() {
   return $result;
 }
 
+/**
+ * Get redacted settings.
+ *
+ * @return array
+ * @throws CiviCRM_API3_Exception
+ */
+function _civicrm_api3_system_get_redacted_settings() {
+  static $whitelist = NULL;
+  if ($whitelist === NULL) {
+    $whitelist = _civicrm_api3_system_get_whitelist(__DIR__ . '/System/setting-whitelist.txt');
+  }
+
+  $apiResult = civicrm_api3('Setting', 'get', array());
+  $result = array();
+  foreach ($apiResult['values'] as $settings) {
+    foreach ($settings as $key => $value) {
+      if (in_array($key, $whitelist)) {
+        $result[$key] = $value;
+      }
+    }
+  }
+
+  return $result;
+}
+
 /**
  * Read a whitelist.
  *
@@ -350,3 +389,14 @@ function _civicrm_api3_system_get_whitelist($whitelistFile) {
   );
   return $whitelist;
 }
+
+/**
+ * Update log table structures.
+ *
+ * This updates the engine type if defined in the hook and changes the field type
+ * for log_conn_id to reflect CRM-18193.
+ */
+function civicrm_api3_system_updatelogtables() {
+  $schema = new CRM_Logging_Schema();
+  $schema->updateLogTableSchema();
+}