Skip to content
Snippets Groups Projects
Commit b49f0996 authored by herbdool's avatar herbdool
Browse files

#4127 move standalone profile modification to userSystem

parent 054806bb
Branches
Tags
No related merge requests found
......@@ -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&gid=' . $gid . '&reset=1';
if ($config->userSystem->is_drupal && $config->cleanURL) {
$urlReplaceWith = 'civicrm/profile/create?gid=' . $gid . '&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');
......
......@@ -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&gid=' . $params['gid'] . '&reset=1';
$profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
return $profile;
}
}
......@@ -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&gid=' . $params['gid'] . '&reset=1';
if ($config->cleanURL) {
$urlReplaceWith = 'civicrm/profile/create?gid=' . $params['gid'] . '&reset=1';
}
$profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
return $profile;
}
}
......@@ -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&gid=' . $params['gid'] . '&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;
}
}
......@@ -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&gid=' . $params['gid'] . '&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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment