dev/core#4127 move standalone profile modification to userSystem
authorHerb v/d Dool <herb@3speedhub.com>
Wed, 15 Feb 2023 22:18:42 +0000 (17:18 -0500)
committerHerb v/d Dool <herb@3speedhub.com>
Fri, 3 Mar 2023 01:34:02 +0000 (20:34 -0500)
CRM/UF/Page/Group.php
CRM/Utils/System/Base.php
CRM/Utils/System/DrupalBase.php
CRM/Utils/System/Joomla.php
CRM/Utils/System/WordPress.php

index 2cf6c83c5095e778294d446325e382a7295ef554..de929317efe033e532846a4796d78536d3ac9084 100644 (file)
@@ -216,31 +216,7 @@ class CRM_UF_Page_Group extends CRM_Core_Page {
     $template->assign('tplFile', 'CRM/Profile/Form/Edit.tpl');
     $profile = trim($template->fetch('CRM/Form/default.tpl'));
 
-    // not sure how to circumvent our own navigation system to generate the right form url
-    $urlReplaceWith = 'civicrm/profile/create&amp;gid=' . $gid . '&amp;reset=1';
-    if ($config->userSystem->is_drupal && $config->cleanURL) {
-      $urlReplaceWith = 'civicrm/profile/create?gid=' . $gid . '&amp;reset=1';
-    }
-    $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
-
-    // FIXME: (CRM-3587) hack to make standalone profile work
-    // in wordpress and joomla without administrator login
-    if ($config->userFramework == 'Joomla') {
-      $profile = str_replace('/administrator/', '/index.php', $profile);
-    }
-    elseif ($config->userFramework == 'WordPress') {
-      //@todo remove this part when it is OK to deprecate CIVICRM_UF_WP_BASEPAGE-CRM-15933
-      if (defined('CIVICRM_UF_WP_BASEPAGE')) {
-        $wpbase = CIVICRM_UF_WP_BASEPAGE;
-      }
-      elseif (!empty($config->wpBasePage)) {
-        $wpbase = $config->wpBasePage;
-      }
-      else {
-        $wpbase = 'index.php';
-      }
-      $profile = str_replace('/wp-admin/admin.php', '/' . $wpbase . '/', $profile);
-    }
+    $profile = $config->userSystem->modifyStandaloneProfile($profile, ['gid' => $gid]);
 
     // add header files
     CRM_Core_Resources::singleton()->addCoreResources('html-header');
index 0fe6c55f247c8571cd89e9f8e94a6a61b429129e..72ea4f1331f7dcdcbdb9dfc6c40bcaa3715dde7f 100644 (file)
@@ -1132,4 +1132,21 @@ abstract class CRM_Utils_System_Base {
     return $contactParameters;
   }
 
+  /**
+   * Modify standalone profile
+   *
+   * @param string $profile
+   * @param array $params
+   *
+   * @return string
+   */
+  public function modifyStandaloneProfile($profile, $params):string {
+    // Not sure how to circumvent our own navigation system to generate the
+    // right form url.
+    $urlReplaceWith = 'civicrm/profile/create&amp;gid=' . $params['gid'] . '&amp;reset=1';
+    $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+    return $profile;
+  }
+
 }
index a59bf97f6e88facec745c65fc4deee137ed8e01b..3574213f7d76ded2823ae0da2484febdb7a4be6d 100644 (file)
@@ -824,4 +824,18 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
     return $contactParameters;
   }
 
+  /**
+   * @inheritdoc
+   */
+  public function modifyStandaloneProfile($profile, $params):string {
+    $config = CRM_Core_Config::singleton();
+    $urlReplaceWith = 'civicrm/profile/create&amp;gid=' . $params['gid'] . '&amp;reset=1';
+    if ($config->cleanURL) {
+      $urlReplaceWith = 'civicrm/profile/create?gid=' . $params['gid'] . '&amp;reset=1';
+    }
+    $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+    return $profile;
+  }
+
 }
index d91cc5f7f7bb2f4d4c2364de3ab7000dd8be5673..0117a19bfd068648658db865ea48931be9f30501 100644 (file)
@@ -1031,4 +1031,17 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
     return $contactParameters;
   }
 
+  /**
+   * @inheritdoc
+   */
+  public function modifyStandaloneProfile($profile, $params):string {
+    $urlReplaceWith = 'civicrm/profile/create&amp;gid=' . $params['gid'] . '&amp;reset=1';
+    $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+    // FIXME: (CRM-3587) hack to make standalone profile work
+    // in Joomla without administrator login.
+    $profile = str_replace('/administrator/', '/index.php', $profile);
+    return $profile;
+  }
+
 }
index 4d20f8949525e2cbd9afdc32c229e9aa9eaa26eb..a384dfa6eab63b26d8c5bf87f9105d99f3ae6865 100644 (file)
@@ -1672,4 +1672,26 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     return $contactParameters;
   }
 
+  /**
+   * @inheritdoc
+   */
+  public function modifyStandaloneProfile($profile, $params):string {
+    $urlReplaceWith = 'civicrm/profile/create&amp;gid=' . $params['gid'] . '&amp;reset=1';
+    $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+    //@todo remove this part when it is OK to deprecate CIVICRM_UF_WP_BASEPAGE-CRM-15933
+    $config = CRM_Core_Config::singleton();
+    if (defined('CIVICRM_UF_WP_BASEPAGE')) {
+      $wpbase = CIVICRM_UF_WP_BASEPAGE;
+    }
+    elseif (!empty($config->wpBasePage)) {
+      $wpbase = $config->wpBasePage;
+    }
+    else {
+      $wpbase = 'index.php';
+    }
+    $profile = str_replace('/wp-admin/admin.php', '/' . $wpbase . '/', $profile);
+    return $profile;
+  }
+
 }