// The api will throw an exception if afform is not found (because of the index 0 param)
$afform = civicrm_api4('Afform', 'get', [
- 'checkPermissions' => FALSE,
'where' => [['name', '=', $pageArgs['afform']]],
- 'select' => ['title', 'module_name', 'directive_name'],
+ 'select' => ['title', 'module_name', 'directive_name', 'type'],
], 0);
$this->assign('directive', $afform['directive_name']);
->setModules([$afform['module_name'], 'afformStandalone'])
->load();
- if (!empty($afform['title'])) {
- $title = strip_tags($afform['title']);
- CRM_Utils_System::setTitle($title);
- }
-
// 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'])]]);
+ if (CRM_Core_Permission::check('administer CiviCRM')) {
+ if (($pagePath[1] ?? NULL) === 'admin') {
+ CRM_Utils_System::appendBreadCrumb([['title' => E::ts('Admin'), 'url' => CRM_Utils_System::url('civicrm/admin')]]);
+ }
+ if ($afform['type'] !== 'system' &&
+ \CRM_Extension_System::singleton()->getMapper()->isActiveModule('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'])]]);
+ }
}
}
+ 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)) . '#']]);
+ }
+
parent::run();
}