From 70d331a669e32d765061e1835466f3d2dfc7c06d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 6 Mar 2013 21:19:47 -0500 Subject: [PATCH] CRM-12039 - Display warning to prevent downloads if the default container doesn't have a URL --- CRM/Admin/Page/Extensions.php | 3 ++ CRM/Extension/Container/Default.php | 44 +++++++++++++++++++++++++++++ CRM/Extension/System.php | 4 +-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 CRM/Extension/Container/Default.php diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index c4999a82e1..9b52e7bbb5 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -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 index 0000000000..447197c95d --- /dev/null +++ b/CRM/Extension/Container/Default.php @@ -0,0 +1,44 @@ +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 path setting page and correct it.
', + 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 URL setting page and correct it.
', + array( + 1 => $url, + ) + ) + ); + } + + return $errors; + } +} \ No newline at end of file diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index c0384a83a9..8da0688d51 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -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; } -- 2.25.1