From f5b516e8f177b94885d00b316043e14557de1087 Mon Sep 17 00:00:00 2001 From: Seamus Lee <seamuslee001@gmail.com> Date: Mon, 8 Jul 2024 13:14:08 +1000 Subject: [PATCH 1/3] Fix saving of category id field on group form --- mailingcategorisation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mailingcategorisation.php b/mailingcategorisation.php index 8e34d71..4d6c3e7 100644 --- a/mailingcategorisation.php +++ b/mailingcategorisation.php @@ -48,7 +48,7 @@ function mailingcategorisation_civicrm_buildForm($formName, &$form): void { $action = $form->getAction(); if ($formName === 'CRM_Group_Form_Edit' && !($action & (CRM_Core_Action::DELETE))) { /** @var \CRM_Group_Form_Edit $form */ - if (!$form->elementExists('category_id') && !$form->isSubmitted() && CRM_Core_Permission::check('manage mailing categories')) { + if (!$form->elementExists('category_id') && CRM_Core_Permission::check('manage mailing categories')) { $form->addField('category_id', [ 'entity' => 'GroupCategory', 'action' => 'create', @@ -87,7 +87,7 @@ function mailingcategorisation_civicrm_validateForm($formName, &$fields, &$files if (!empty($fields['category_id'])) { $id = $form->getEntityId(); $result = GroupCategory::get(FALSE)->addWhere('category_id', '=', $fields['category_id'])->execute(); - if (!empty($result['group_id']) && ((!empty($id) && $id != $result['group_id']) || empty($id))) { + if (!empty($result[0]['group_id']) && ((!empty($id) && $id != $result[0]['group_id']) || empty($id))) { $errors['category_id'] = E::ts('Another group is already the unsubscribe group for category %1', [ 1 => CRM_Core_PseudoConstant::getLabel('CRM_Mailingcategorisation_DAO_MailingCategory', 'category_id', $fields['category_id']), ]); @@ -101,10 +101,10 @@ function mailingcategorisation_civicrm_postProcess($formName, &$form): void { if ($formName === 'CRM_Group_Form_Edit' && !($action & (CRM_Core_Action::DELETE)) && CRM_Core_Permission::check('manage mailing categories')) { $id = $form->getEntityId(); $check = GroupCategory::get(FALSE)->addWhere('group_id', '=', $id)->execute(); - if (count($check) == 0) { + if (count($check) == 0 && !empty($form->getSubmittedValue('category_id'))) { GroupCategory::create(FALSE)->addValue('group_id', $id)->addValue('category_id', $form->getSubmittedValue('category_id'))->execute(); } - else { + elseif (count($check) > 0) { if (empty($form->getSubmittedValue('category_id'))) { GroupCategory::delete(FALSE)->addWhere('id', '=', $check[0]['id'])->execute(); } -- GitLab From 0f83afac5dc4f3327b2841bde01a8ba907013cca Mon Sep 17 00:00:00 2001 From: John Twyman <john.twyman@greens.org.au> Date: Mon, 8 Jul 2024 13:48:26 +1000 Subject: [PATCH 2/3] Bump version for bug fix release --- info.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.xml b/info.xml index a8335b2..c5b8017 100644 --- a/info.xml +++ b/info.xml @@ -14,8 +14,8 @@ <url desc="Support">https://lab.jmaconsulting.biz/extensions/mailingcategorisation</url> <url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url> </urls> - <releaseDate>2024-03-01</releaseDate> - <version>1.1</version> + <releaseDate>2024-07-08</releaseDate> + <version>1.1.1</version> <develStage>alpha</develStage> <compatibility> <ver>5.70</ver> -- GitLab From dbc4ea993640a319ee9a48a71b57e96d59ffe5a1 Mon Sep 17 00:00:00 2001 From: John Twyman <john.twyman@greens.org.au> Date: Mon, 8 Jul 2024 13:49:53 +1000 Subject: [PATCH 3/3] Tidy up info.xml --- info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.xml b/info.xml index c5b8017..ccd4b64 100644 --- a/info.xml +++ b/info.xml @@ -16,7 +16,7 @@ </urls> <releaseDate>2024-07-08</releaseDate> <version>1.1.1</version> - <develStage>alpha</develStage> + <develStage>stable</develStage> <compatibility> <ver>5.70</ver> </compatibility> -- GitLab