Cleanup deprecated CRM_Core_BAO_Settings calls CRM-17507
[civicrm-core.git] / CRM / Utils / HttpClient.php
index a5c0078b5b64299426ac0f45123dad10ccea3a47..ee4cb5171fac1d8253821ac496e8158458512e61 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
@@ -35,8 +35,6 @@
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
  */
 class CRM_Utils_HttpClient {
 
@@ -50,7 +48,8 @@ class CRM_Utils_HttpClient {
   protected static $singleton;
 
   /**
-   * @var int|NULL seconds; or NULL to use system default
+   * @var int|NULL
+   *   seconds; or NULL to use system default
    */
   protected $connectionTimeout;
 
@@ -93,6 +92,7 @@ class CRM_Utils_HttpClient {
 
     $fp = @fopen($localFile, "w");
     if (!$fp) {
+      // Fixme: throw error instead of setting message
       CRM_Core_Session::setStatus(ts('Unable to write to %1.<br />Is the location writable?', array(1 => $localFile)), ts('Write Error'), 'error');
       return self::STATUS_WRITE_ERROR;
     }
@@ -100,8 +100,9 @@ class CRM_Utils_HttpClient {
 
     curl_exec($ch);
     if (curl_errno($ch)) {
+      // Fixme: throw error instead of setting message
       CRM_Core_Session::setStatus(ts('Unable to download extension from %1. Error Message: %2',
-        array(1 => $remoteFile, 2 => curl_error($ch))), ts('Download Error'), 'error');
+        array(1 => $remoteFile, 2 => curl_error($ch))), ts('Extension download error'), 'error');
       return self::STATUS_DL_ERROR;
     }
     else {
@@ -135,7 +136,7 @@ class CRM_Utils_HttpClient {
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
-      //CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
+      // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
       return array(self::STATUS_DL_ERROR, NULL);
     }
 
@@ -171,7 +172,7 @@ class CRM_Utils_HttpClient {
     list($ch, $caConfig) = $this->createCurl($remoteFile);
 
     if (preg_match('/^https:/', $remoteFile) && !$caConfig->isEnableSSL()) {
-      //CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
+      // CRM_Core_Error::fatal('Cannot install this extension - does not support SSL');
       return array(self::STATUS_DL_ERROR, NULL);
     }
 
@@ -197,7 +198,7 @@ class CRM_Utils_HttpClient {
    */
   protected function createCurl($remoteFile) {
     $caConfig = CA_Config_Curl::probe(array(
-      'verify_peer' => (bool) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, TRUE),
+      'verify_peer' => (bool) Civi::settings()->get('verifySSL'),
     ));
 
     $ch = curl_init();