Compare commits

...

7 commits

6 changed files with 26 additions and 22 deletions

View file

@ -95,7 +95,7 @@ abstract class BaseMailingList
*/ */
static protected function getCustomFields(): array static protected function getCustomFields(): array
{ {
return CustomField::get() return CustomField::get(FALSE)
->addSelect('*') ->addSelect('*')
->addWhere('custom_group_id:name', '=', static::CUSTOM_GROUP_NAME) ->addWhere('custom_group_id:name', '=', static::CUSTOM_GROUP_NAME)
->execute() ->execute()

View file

@ -53,7 +53,7 @@ class EventMailingList extends BaseMailingList {
->addJoin('Participant AS participant', 'INNER', ->addJoin('Participant AS participant', 'INNER',
['id', '=', 'participant.contact_id'], ['id', '=', 'participant.contact_id'],
['participant.event_id', '=', $this->event['id']], ['participant.event_id', '=', $this->event['id']],
['participant.status', 'IN', self::getEnabledParticipantStatus()], ['participant.status_id', 'IN', self::getEnabledParticipantStatus()],
) )
->addGroupBy('id') ->addGroupBy('id')
->execute() ->execute()
@ -93,6 +93,6 @@ class EventMailingList extends BaseMailingList {
* @return ?array * @return ?array
*/ */
public static function getEnabledParticipantStatus(): ?array { public static function getEnabledParticipantStatus(): ?array {
return MailingListSettings::get(E::SHORT_NAME . '_participant_status'); return MailingListSettings::get('participant_status');
} }
} }

View file

@ -29,21 +29,21 @@ class QueueHelper {
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$this->eventQueue = \Civi::queue( $this->eventQueue = \Civi::queue(
'propeace-mailinglist-event-queue', [ 'propeace-mailinglist-event-queue', [
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$this->emailQueue = \Civi::queue( $this->emailQueue = \Civi::queue(
'propeace-mailinglist-email-queue', [ 'propeace-mailinglist-email-queue', [
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$this->groups = []; $this->groups = [];
@ -106,12 +106,14 @@ class QueueHelper {
* Stores an email address in the queue helper singleton. * Stores an email address in the queue helper singleton.
* *
* @param \CRM_Queue_TaskContext $context * @param \CRM_Queue_TaskContext $context
* @param string $email * @param string|null $email
* *
* @return bool * @return bool
*/ */
public static function storeEmail(\CRM_Queue_TaskContext $context, string $email): bool { public static function storeEmail(\CRM_Queue_TaskContext $context, ?string $email): bool {
if (!empty($email)) {
self::getInstance()->addToEmails($email); self::getInstance()->addToEmails($email);
}
return TRUE; return TRUE;
} }

View file

@ -1,5 +1,5 @@
Package: de.propeace.mailinglistsync Package: de.propeace.mailinglistsync
Copyright (C) 2025, FIXME <FIXME> Copyright (C) 2025, Pro Peace <info@propeace.de>
Licensed under the GNU Affero Public License 3.0 (below). Licensed under the GNU Affero Public License 3.0 (below).
------------------------------------------------------------------------------- -------------------------------------------------------------------------------

View file

@ -7,12 +7,12 @@
<authors> <authors>
<author> <author>
<name>Marc Koch</name> <name>Marc Koch</name>
<email>koch@forumZFD.de</email> <email>marc.koch@propeace.de</email>
<role>Maintainer</role> <role>Maintainer</role>
</author> </author>
</authors> </authors>
<urls> <urls>
<!-- <url desc="Main Extension Page">https://FIXME</url>--> <url desc="Main Extension Page">https://git.propeace.de/ProPeace/de.propeace.mailinglistsync</url>-->
<!-- <url desc="Documentation">https://FIXME</url>--> <!-- <url desc="Documentation">https://FIXME</url>-->
<!-- <url desc="Support">https://FIXME</url>--> <!-- <url desc="Support">https://FIXME</url>-->
<url desc="Licensing">https://www.gnu.org/licenses/agpl-3.0.html</url> <url desc="Licensing">https://www.gnu.org/licenses/agpl-3.0.html</url>

View file

@ -129,7 +129,7 @@ function mailinglistsync_civicrm_validateForm($formName, &$fields, &$files, &$fo
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -145,7 +145,7 @@ function mailinglistsync_civicrm_validateForm($formName, &$fields, &$files, &$fo
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -225,8 +225,10 @@ function mailinglistsync_civicrm_post(string $op, string $objectName, int $objec
->first()['event_id']; ->first()['event_id'];
$mailingList = new EventMailingList($eventId); $mailingList = new EventMailingList($eventId);
// Check permission to alter event mailing list // Check permission to alter event mailing list if it is not a deletion
if ($mailingList->isEnabled() && !CRM_Core_Permission::check('manage_event_mailinglists')) { if ($op !== 'delete'
&& $mailingList->isEnabled()
&& !CRM_Core_Permission::check('manage_event_mailinglists')) {
CRM_Core_Session::setStatus( CRM_Core_Session::setStatus(
E::ts('You do not have permission to manage event mailing lists.'), E::ts('You do not have permission to manage event mailing lists.'),
E::ts('Permission Denied'), E::ts('Permission Denied'),
@ -324,7 +326,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -345,7 +347,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -372,7 +374,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -393,7 +395,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -414,7 +416,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback
@ -449,7 +451,7 @@ function mailinglistsync_civicrm_postCommit(string $op, string $objectName, int
'type' => 'SqlParallel', 'type' => 'SqlParallel',
'is_autorun' => FALSE, 'is_autorun' => FALSE,
'reset' => FALSE, 'reset' => FALSE,
'error' => 'drop', 'error' => 'abort',
]); ]);
$queue->createItem(new CRM_Queue_Task( $queue->createItem(new CRM_Queue_Task(
// callback // callback