Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10571 limit email template access by user groups #10581

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

taslangraham
Copy link
Contributor

@taslangraham taslangraham commented Nov 5, 2024

For #10571

@taslangraham taslangraham force-pushed the i10571_limit_template_access_by_sender_and_receiver_role branch 5 times, most recently from 0352bec to ba47e2b Compare November 14, 2024 19:12
@taslangraham taslangraham force-pushed the i10571_limit_template_access_by_sender_and_receiver_role branch 7 times, most recently from 3cb222d to cf0580b Compare November 20, 2024 15:29
@taslangraham taslangraham changed the title pkp/pkp-lib#10571 pkp/pkp-lib#10571 limit email template access by user groups Nov 20, 2024
@taslangraham taslangraham force-pushed the i10571_limit_template_access_by_sender_and_receiver_role branch 2 times, most recently from 8b6f076 to 75b9ed1 Compare November 20, 2024 17:01
@taslangraham taslangraham marked this pull request as ready for review November 20, 2024 18:32
@taslangraham taslangraham force-pushed the i10571_limit_template_access_by_sender_and_receiver_role branch from 75b9ed1 to 405e376 Compare November 20, 2024 18:37
@taslangraham
Copy link
Contributor Author

@ewhanson Just an update - I've made a new commit since I last requested your review.

This handles cases where a template was restored to default settings, and also cleans up template access when a template is deleted

->getMany()
->getMany();

$templates = Repo::emailTemplate()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This $templates variable is directly replacing the one above. Is that what you meant to do? If so, the above one should be removed.

$emailTemplates->add($emailTemplate);
}
Repo::emailTemplate()
->getCollector($context->getId())
->alternateTo([$this->mailable::getEmailTemplateKey()])
->getMany()
->each(fn (EmailTemplate $e) => $emailTemplates->add($e));
->each(function (EmailTemplate $e) use ($context, $request, $emailTemplates) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, but since this isn't an arrow function anymore, I would be more verbose about the variable name, just to make it easier to read at a glance.

},
"assignableTemplateUserGroups": {
"type": "array",
"description": "List of User Groups that can be assigned to the template",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Period at the end.

},
"isUnrestricted": {
"type": "boolean",
"description": "Boolean indicating if an email template is available to all user groups within the roles associated with the template's mailable.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between indicating and if.

"type": "integer",
"apiSummary": true
},
"name": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the individual items support descriptions off the top of my head, but the name being an integer is a little confusing. Assuming this is correct, a description would be helpful to understand what the number is supposed to represent in terms of the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an error on my part. It should be a string.

@@ -46,6 +48,14 @@ public function __construct(string $action, array $locales)
'isMultilingual' => true,
'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist',
'plugins' => 'paste,link,lists',
]))->addField(new FieldEmailTemplateUnrestricted('isUnrestricted', [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a lot more of the setup logic for the Vue components can be done in PHP so that these can both be done with existing FieldOptions components. I mentioned this in the ui-library PR as well and we can chat about it more in our next one-on-one (probably easier to share screen and code together than writing it all out here).

*
*/
public function installEmailTemplates(
string $templatesFile,
array $locales = [],
?string $emailKey = null,
bool $skipExisting = false
bool $skipExisting = false,
$recordTemplateGroupAccess = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mention this directly below, but I don't think this optional parameter will be necessary. I think the assumption of "unrestricted if no additional data provided" below is enough.

@@ -0,0 +1,34 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs file docblock.

@@ -0,0 +1,74 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs file docblock.

/**
* @file classes/migration/upgrade/v3_5_0/PreflightCheckMigration.php
*
* Copyright (c) 2014-2021 Simon Fraser University
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 2024 here and below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants