Afform - Add link to edit form in breadcrumbs
authorColeman Watts <coleman@civicrm.org>
Sun, 28 Feb 2021 05:10:39 +0000 (00:10 -0500)
committerColeman Watts <coleman@civicrm.org>
Sun, 28 Feb 2021 05:10:39 +0000 (00:10 -0500)
ext/afform/core/CRM/Afform/Page/AfformBase.php

index a2981b63aaa87a2217bf5c0f8eeda0582fd8e123..079d58a320c3bee478aab29eaa17abc3c74208dc 100644 (file)
@@ -30,7 +30,19 @@ class CRM_Afform_Page_AfformBase extends CRM_Core_Page {
     if (!empty($afform['title'])) {
       $title = strip_tags($afform['title']);
       CRM_Utils_System::setTitle($title);
-      CRM_Utils_System::appendBreadCrumb([['title' => $title, 'url' => CRM_Utils_System::url(implode('/', $pagePath), NULL, FALSE, '!/')]]);
+    }
+
+    // If the user has "access civicrm" append home breadcrumb
+    if (CRM_Core_Permission::check('access CiviCRM')) {
+      CRM_Utils_System::appendBreadCrumb([['title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm')]]);
+      // If the user has "admin civicrm" & the admin extension is enabled
+      if (CRM_Core_Permission::check('administer CiviCRM') && CRM_Utils_Array::findAll(
+          \CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(),
+          ['fullName' => 'org.civicrm.afform_admin']
+        )) {
+        CRM_Utils_System::appendBreadCrumb([['title' => E::ts('Form Builder'), 'url' => CRM_Utils_System::url('civicrm/admin/afform')]]);
+        CRM_Utils_System::appendBreadCrumb([['title' => E::ts('Edit Form'), 'url' => CRM_Utils_System::url('civicrm/admin/afform', NULL, FALSE, '/edit/' . $pageArgs['afform'])]]);
+      }
     }
 
     parent::run();