Skip to content

Commit

Permalink
pkp#10571 WIP: Allow admins and managers to assign user groups to ema…
Browse files Browse the repository at this point in the history
…il templates within a mailable
  • Loading branch information
taslangraham committed Jan 14, 2025
1 parent 6c4d9d4 commit fa69721
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion classes/emailTemplate/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,25 @@ public function add(EmailTemplate $emailTemplate): string
}

/** @copydoc DAO::update() */
public function edit(EmailTemplate $emailTemplate, array $params)
public function edit(EmailTemplate $emailTemplate, array $params, $contextId)
{
$newEmailTemplate = clone $emailTemplate;
$newEmailTemplate->setAllData(array_merge($newEmailTemplate->_data, $params));

$userGroupIds = $params['userGroupIds'];
unset($params['userGroupIds']);

Hook::call('EmailTemplate::edit', [$newEmailTemplate, $emailTemplate, $params]);

if ($newEmailTemplate->getId()) {
$this->dao->update($newEmailTemplate);
} else {
$this->dao->insert($newEmailTemplate);
}

if($userGroupIds) {
$this->dao->updateTemplateAccessGroups($emailTemplate, $userGroupIds, $contextId);
}
}

/** @copydoc DAO::delete() */
Expand Down

0 comments on commit fa69721

Please sign in to comment.