Skip to content

Commit

Permalink
Fix CiviCRM 5.70+ and smarty3+ compatibility (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlutfy authored Oct 24, 2024
1 parent b66ac16 commit 2a6876b
Show file tree
Hide file tree
Showing 9 changed files with 841 additions and 33 deletions.
4 changes: 1 addition & 3 deletions CRM/Volunteer/Form/IncludeProfile.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

require_once 'CRM/Core/Form.php';

/**
* Form controller class
*
Expand Down Expand Up @@ -53,4 +51,4 @@ static function getProfileSelectorTypes() {

return $configs;
}
}
}
9 changes: 3 additions & 6 deletions CRM/Volunteer/Form/Settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

require_once 'CRM/Core/Form.php';

/**
* Form controller class
*
Expand Down Expand Up @@ -364,10 +362,9 @@ function getRenderableElementNames() {

foreach ($this->_elements as $element) {
$groupName = $this->getGroupName($element);

$label = $element->getLabel();
if (!empty($label)) {

if (!empty($label)) {
if (!array_key_exists($groupName, $elementGroups)) {
$elementGroups[$groupName] = array();
}
Expand Down Expand Up @@ -403,8 +400,8 @@ private function getGroupName(HTML_QuickForm_element $element) {

// otherwise fallback to settings metadata
if (empty($groupName)) {
$setting = CRM_Utils_Array::value($element->getName(), $this->_settingsMetadata);
$groupName = $setting['group_name'];
$elName = $element->getName();
$groupName = $this->_settingsMetadata[$elName]['group_name'] ?? NULL;
}

return $groupName;
Expand Down
2 changes: 0 additions & 2 deletions CRM/Volunteer/Form/VolunteerSignUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
+--------------------------------------------------------------------+
*/

require_once 'CRM/Core/Form.php';

/**
* Form controller class
*
Expand Down
31 changes: 12 additions & 19 deletions CRM/Volunteer/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CRM_Volunteer_Upgrader extends CRM_Extension_Upgrader_Base {
const customContactTypeName = 'Volunteer';
const skillLevelOptionGroupName = 'skill_level';

public function install() {
public function postInstall() {
$volActivityTypeId = $this->createActivityType(CRM_Volunteer_BAO_Assignment::CUSTOM_ACTIVITY_TYPE);
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('volunteer_custom_activity_type_name', CRM_Volunteer_BAO_Assignment::CUSTOM_ACTIVITY_TYPE);
Expand All @@ -62,6 +62,17 @@ public function install() {

// uncomment the next line to insert sample data
// $this->executeSqlFile('sql/volunteer_sample.mysql');

// See VOL-237. Avoid order of operation problems by assigning a value to the
// slider_widget_fields setting after the install, which is responsible for
// creating both the setting and the custom field whose ID is used in the
// initial value.
$customFieldId = civicrm_api3('customField', 'getvalue', array(
'custom_group_id' => 'Volunteer_Information',
'name' => 'camera_skill_level',
'return' => 'id',
));
_volunteer_update_slider_fields(array(CRM_Core_Action::ADD => $customFieldId));
}

/**
Expand Down Expand Up @@ -507,23 +518,6 @@ public function uninstall() {
}
}

/**
* Perform post-install tasks.
*
* See VOL-237. Avoid order of operation problems by assigning a value to the
* slider_widget_fields setting after the install, which is responsible for
* creating both the setting and the custom field whose ID is used in the
* initial value.
*/
public function postInstall() {
$customFieldId = civicrm_api3('customField', 'getvalue', array(
'custom_group_id' => 'Volunteer_Information',
'name' => 'camera_skill_level',
'return' => 'id',
));
_volunteer_update_slider_fields(array(CRM_Core_Action::ADD => $customFieldId));
}

/**
* Example: Run a simple query when a module is enabled
*
Expand Down Expand Up @@ -893,7 +887,6 @@ public function executeCustomDataTemplateFile($relativePath) {
$xmlCode = $smarty->fetch($relativePath);
$xml = simplexml_load_string($xmlCode);

require_once 'CRM/Utils/Migrate/Import.php';
$import = new CRM_Utils_Migrate_Import();
$import->runXmlElement($xml);
return TRUE;
Expand Down
6 changes: 3 additions & 3 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<releaseDate>2024-02-10</releaseDate>
<version>2.4.5</version>
<compatibility>
<ver>5.60</ver>
<ver>5.71</ver>
</compatibility>
<comments>
Developed by Ginkgo Street Labs and CiviCRM, LLC with contributions from the community. Special thanks to Friends of Georgia State Parks &amp; Historic Sites for funding the initial release, and to The Manhattan Neighborhood Network for funding the 1.4 release.
</comments>
<civix>
<namespace>CRM/Volunteer</namespace>
<format>23.02.1</format>
<format>24.09.1</format>
</civix>
<urls>
<url desc="Documentation">https://docs.civicrm.org/volunteer/en/latest/</url>
Expand All @@ -31,8 +31,8 @@
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
</mixins>
<classloader>
<psr0 prefix="CRM_" path="."/>
Expand Down
Binary file added mixin/lib/[email protected]
Binary file not shown.
Loading

0 comments on commit 2a6876b

Please sign in to comment.