Attempt to fix paging on contact summary
[civicrm-core.git] / CRM / Extension / Downloader.php
index d8ff17ab1cca4367bd7e173a8880aceed80a7a3a..2e5a19060ac4d8f51cbf71be5f1c1c81c846117c 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
  * This class handles downloads of remotely-provided extensions
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 class CRM_Extension_Downloader {
   /**
@@ -57,10 +57,12 @@ class CRM_Extension_Downloader {
   /**
    * Determine whether downloading is supported.
    *
+   * @param \CRM_EXtension_Info $extensionInfo Optional info for (updated) extension
+   *
    * @return array
    *   list of error messages; empty if OK
    */
-  public function checkRequirements() {
+  public function checkRequirements($extensionInfo = NULL) {
     $errors = array();
 
     if (!$this->containerDir || !is_dir($this->containerDir) || !is_writable($this->containerDir)) {
@@ -88,6 +90,18 @@ class CRM_Extension_Downloader {
       CRM_Core_Error::debug_log_message('WARNING: The downloader may be unable to download files which require HTTP redirection. This may be a configuration issue with PHP\'s open_basedir or safe_mode.');
     }
 
+    if ($extensionInfo) {
+      $requiredExtensions = CRM_Extension_System::singleton()->getManager()->findInstallRequirements([$extensionInfo->key], $extensionInfo);
+      foreach ($requiredExtensions as $extension) {
+        if (CRM_Extension_System::singleton()->getManager()->getStatus($extension) !== CRM_Extension_Manager::STATUS_INSTALLED && $extension !== $extensionInfo->key) {
+          $errors[] = [
+            'title' => ts('Missing Requirement: %1', [1 => $extension]),
+            'message' => ts('You will not be able to install/upgrade %1 until you have installed the %2 extension.', [1 => $extensionInfo->key, 2 => $extension]),
+          ];
+        }
+      }
+    }
+
     return $errors;
   }