From: Tim Otten Date: Tue, 10 Dec 2019 05:01:32 +0000 (-0800) Subject: afform_gui - Add nav item under "Administer => Customize Data and Screens" X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ce8b69575a3f6b0915e2a97a9d058dc8e1be9fde;p=civicrm-core.git afform_gui - Add nav item under "Administer => Customize Data and Screens" --- diff --git a/ext/afform/gui/CRM/AfformGui/Upgrader.php b/ext/afform/gui/CRM/AfformGui/Upgrader.php index 068d9e76dd..ce85f6b6cf 100644 --- a/ext/afform/gui/CRM/AfformGui/Upgrader.php +++ b/ext/afform/gui/CRM/AfformGui/Upgrader.php @@ -10,10 +10,30 @@ class CRM_AfformGui_Upgrader extends CRM_AfformGui_Upgrader_Base { // upgrade tasks. They are executed in order (like Drupal's hook_update_N). /** - * Example: Run an external SQL script when the module is installed. - * + * Setup navigation item on new installs + */ public function install() { - $this->executeSqlFile('sql/myinstall.sql'); + // $this->executeSqlFile('sql/myinstall.sql'); + try { + $existing = civicrm_api3('Navigation', 'getcount', [ + 'name' => 'afform_gui', + 'domain_id' => CRM_Core_Config::domainID(), + ]); + if (!$existing) { + civicrm_api3('Navigation', 'create', [ + 'parent_id' => 'Customize Data and Screens', + 'label' => ts('Afforms'), + 'weight' => 1, + 'name' => 'afform_gui', + 'permission' => 'administer CiviCRM', + 'url' => 'civicrm/admin/afform', + 'is_active' => 1, + ]); + } + } + catch (Exception $e) { + // Couldn't create menu item. + } } /** @@ -35,10 +55,15 @@ class CRM_AfformGui_Upgrader extends CRM_AfformGui_Upgrader_Base { } /** - * Example: Run an external SQL script when the module is uninstalled. - * + * Cleanup navigtaion upon removal + */ public function uninstall() { - $this->executeSqlFile('sql/myuninstall.sql'); + // $this->executeSqlFile('sql/myuninstall.sql'); + civicrm_api3('Navigation', 'get', [ + 'name' => 'afform_gui', + 'return' => ['id'], + 'api.Navigation.delete' => [], + ]); } /**