Exemplo n.º 1
0
 /**
  * Browse all options.
  *
  *
  * @return void
  */
 public function browse()
 {
     $mapper = CRM_Extension_System::singleton()->getMapper();
     $manager = CRM_Extension_System::singleton()->getManager();
     // build announcements at the top of the page
     $this->assign('extAddNewEnabled', CRM_Extension_System::singleton()->getBrowser()->isEnabled());
     $reqs = CRM_Extension_System::singleton()->getDownloader()->checkRequirements();
     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());
     $this->assign('extDbUpgradeUrl', CRM_Utils_System::url('civicrm/admin/extensions/upgrade', 'reset=1'));
     // TODO: Debate whether to immediately detect changes in underlying source tree
     // $manager->refresh();
     // build list of local extensions
     $localExtensionRows = array();
     // array($pseudo_id => extended_CRM_Extension_Info)
     $keys = array_keys($manager->getStatuses());
     sort($keys);
     foreach ($keys as $key) {
         try {
             $obj = $mapper->keyToInfo($key);
         } catch (CRM_Extension_Exception $ex) {
             CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)));
             continue;
         }
         $row = self::createExtendedInfo($obj);
         $row['id'] = $obj->key;
         // assign actions
         $action = 0;
         switch ($row['status']) {
             case CRM_Extension_Manager::STATUS_UNINSTALLED:
                 $action += CRM_Core_Action::ADD;
                 break;
             case CRM_Extension_Manager::STATUS_DISABLED:
                 $action += CRM_Core_Action::ENABLE;
                 $action += CRM_Core_Action::DELETE;
                 break;
             case CRM_Extension_Manager::STATUS_DISABLED_MISSING:
                 $action += CRM_Core_Action::DELETE;
                 break;
             case CRM_Extension_Manager::STATUS_INSTALLED:
             case CRM_Extension_Manager::STATUS_INSTALLED_MISSING:
                 $action += CRM_Core_Action::DISABLE;
                 break;
             default:
         }
         // TODO if extbrowser is enabled and extbrowser has newer version than extcontainer,
         // then $action += CRM_Core_Action::UPDATE
         $row['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $row['id'], 'key' => $obj->key), ts('more'), FALSE, 'extension.local.action', 'Extension', $row['id']);
         // Key would be better to send, but it's not an integer.  Moreover, sending the
         // values to hook_civicrm_links means that you can still get at the key
         $localExtensionRows[$row['id']] = $row;
     }
     $this->assign('localExtensionRows', $localExtensionRows);
     // build list of available downloads
     $remoteExtensionRows = array();
     foreach (CRM_Extension_System::singleton()->getBrowser()->getExtensions() as $info) {
         $row = (array) $info;
         $row['id'] = $info->key;
         $action = CRM_Core_Action::UPDATE;
         $row['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $row['id'], 'key' => $row['key']), ts('more'), FALSE, 'extension.remote.action', 'Extension', $row['id']);
         if (isset($localExtensionRows[$info->key])) {
             if (version_compare($localExtensionRows[$info->key]['version'], $info->version, '<')) {
                 $row['is_upgradeable'] = TRUE;
             }
         }
         $remoteExtensionRows[$row['id']] = $row;
     }
     $this->assign('remoteExtensionRows', $remoteExtensionRows);
 }
Exemplo n.º 2
0
 /**
  * Checks if extensions are set up properly
  * @return array
  */
 public function checkExtensionUpgrades()
 {
     $messages = array();
     if (CRM_Extension_Upgrades::hasPending()) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Extension upgrades are pending.  Please visit <a href="%1">the upgrade page</a> to run them.', array(1 => CRM_Utils_System::url('civicrm/admin/extensions/upgrade', 'reset=1'))), ts('Run Extension Upgrades'), \Psr\Log\LogLevel::ERROR, 'fa-plug');
     }
     return $messages;
 }