CRM-12039 - Display warning to prevent downloads if the default container doesn't...
authorTim Otten <totten@civicrm.org>
Thu, 7 Mar 2013 02:19:47 +0000 (21:19 -0500)
committerTim Otten <totten@civicrm.org>
Thu, 7 Mar 2013 02:19:47 +0000 (21:19 -0500)
CRM/Admin/Page/Extensions.php
CRM/Extension/Container/Default.php [new file with mode: 0644]
CRM/Extension/System.php

index c4999a82e169e2946c0d3ee3c76509af914e96b5..9b52e7bbb5ab5de48649eedd3bc67b9384311d89 100644 (file)
@@ -145,6 +145,9 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
     if (empty($reqs)) {
       $reqs = CRM_Extension_System::singleton()->getBrowser()->checkRequirements();
     }
+    if (empty($reqs)) {
+      $reqs = CRM_Extension_System::singleton()->getDefaultContainer()->checkRequirements();
+    }
     $this->assign('extAddNewReqs', $reqs);
 
     $this->assign('extDbUpgrades', CRM_Extension_Upgrades::hasPending());
diff --git a/CRM/Extension/Container/Default.php b/CRM/Extension/Container/Default.php
new file mode 100644 (file)
index 0000000..447197c
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * The default container is just a basic container which can be configured via the
+ * web UI.
+ */
+class CRM_Extension_Container_Default extends CRM_Extension_Container_Basic {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function checkRequirements() {
+    $errors = array();
+
+    // In current configuration, we don't construct the default container unless baseDir is set,
+    // so this error condition is more theoretical.
+    if (empty($this->baseDir) || !is_dir($this->baseDir)) {
+      $civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
+      $url = CRM_Utils_System::url('civicrm/admin/setting/path', "reset=1&civicrmDestination=${civicrmDestination}");
+      $errors[] = array(
+        'title' => ts('Invalid Base Directory'),
+        'message' => ts('The extensions directory is not properly set. Please go to the <a href="%1">path setting page</a> and correct it.<br/>',
+          array(
+            1 => $url,
+          )
+        )
+      );
+    }
+    if (empty($this->baseUrl)) {
+      $civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
+      $url = CRM_Utils_System::url('civicrm/admin/setting/url', "reset=1&civicrmDestination=${civicrmDestination}");
+      $errors[] = array(
+        'title' => ts('Invalid Base URL'),
+        'message' => ts('The extensions URL is not properly set. Please go to the <a href="%1">URL setting page</a> and correct it.<br/>',
+          array(
+            1 => $url,
+          )
+        )
+      );
+    }
+
+    return $errors;
+  }
+}
\ No newline at end of file
index c0384a83a960d4c721de16f02e897e3205b32e91..8da0688d51d53edc601ed7cbfb2fc2b828e03000 100644 (file)
@@ -113,12 +113,12 @@ class CRM_Extension_System {
    *
    * This container should be a particular, writeable directory.
    *
-   * @return CRM_Extension_Container_Basic|FALSE (false if not configured)
+   * @return CRM_Extension_Container_Default|FALSE (false if not configured)
    */
   public function getDefaultContainer() {
     if ($this->defaultContainer === NULL) {
       if ($this->parameters['extensionsDir']) {
-        $this->defaultContainer = new CRM_Extension_Container_Basic($this->parameters['extensionsDir'], $this->parameters['extensionsURL'], $this->getCache(), 'default');
+        $this->defaultContainer = new CRM_Extension_Container_Default($this->parameters['extensionsDir'], $this->parameters['extensionsURL'], $this->getCache(), 'default');
       } else {
         $this->defaultContainer = FALSE;
       }