-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#61 Split Edit Message Templates Permission #11974
dev/core#61 Split Edit Message Templates Permission #11974
Conversation
Can one of the admins verify this patch? |
Jenkins ok to test |
@mattwire perhaps you can trade with Compucorp to review one of yours? I know you want review on your membership tidy up one. I think the idea of splitting up the permissions makes sense in principle. I'm a bit alarmed to see those php calls from the tpl file but I'm sure there are ample other places where we check permissions to compare to. If we really don't have an existing smarty permission check maybe we should add one in CRM_Core_Smarty_Plugins? |
@@ -262,15 +262,15 @@ | |||
<page_callback>CRM_Admin_Page_MessageTemplates</page_callback> | |||
<adminGroup>Communications</adminGroup> | |||
<icon>admin/small/template.png</icon> | |||
<access_arguments>edit message templates</access_arguments> | |||
<access_arguments>edit message templates;edit user-driven message templates;edit system workflow message templates</access_arguments> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the xml sometimes uses commas & sometimes semi-colons - do they have the same meaning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s the diff between or and I think ; == or , == and
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Seamus is right
2665aa1
to
4766edc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks pretty good overall, some minor comments
<li id='tab_user'> <a href='#user' title='{ts}User-driven Messages{/ts}'> {ts}User-driven Messages{/ts} </a></li> | ||
<li id='tab_workflow'><a href='#workflow' title='{ts}System Workflow Messages{/ts}'>{ts}System Workflow Messages{/ts}</a></li> | ||
{if $canEditUserDrivenMessageTemplates or $canEditMessageTemplates} | ||
<li id='tab_user'> <a href='#user' title='{ts}User-driven Messages{/ts}'> {ts}User-driven Messages{/ts} </a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it wasn't something you introduced, but can you remove the extra spaces here like in the second link below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright i will.
* @param int $workflowId | ||
*/ | ||
private function checkUserPermission($workflowId) { | ||
if (isset($workflowId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really familiar with message templates so just a question here, is it impossible for user driven message templates to have a workflow ID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User driven message templates do not have workflow ID. A template becomes system workflow message template the moment it has workflow ID.
4766edc
to
3b23dae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me, it'll require someone (non compucorp) to review too though
|
test this please |
I just looked into this because it's a very sensible suggestion, but the problem is that smarty functions can't be called from within |
Hi @ajesamson thanks for this contribution. I'm just looking at it for the first time and my initial question is about whether the original permission indeed ought to be kept around. That seems needlessly confusing, as it will have significant overlap with the new permissions. |
@colemanw ah yeah - you'd need to add in a capture I suppose which starts to get a bit complex |
Hi @colemanw the reason why it was left behind is more or less for backward compatibility. It was meant to allow existing users with permission continue working without impacting their process on upgrade. Your suggestions are highly welcomed on how best to handle this. |
@ajesamson I would have thought we could remove the old permission, making sure we add an upgrader message (there was one when batch permissions were added) telling the user that they will need to reconfigure permissions for message templates. The only other place it may cause a problem is if that permission is used in extensions, @totten normally says "grep universe" to find out. |
I agree. As part of the upgrade, I think all users with the old permission should be granted the 2 new ones. And the upgrade message can give admins a heads up that they now have finer control if they want it. |
Do we actually have an effective methodology for adding permissions during upgrade? |
@colemanw Please can you provide a guide on how best to migrate the old permission for existing users to 2 new ones. I have spent some time looking through the code base but could not get a method that provides easy access to CMS permission table for such upgrade. The suggested sample code by @mattwire used |
@ajesamson @colemanw I think adding perms on upgrade across the CMS is too hard looking at it. I think historically we have set a message on upgrade & that will have to do
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-approving after revision changes
// if ($rev == '5.12.34') { | ||
// $preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>'; | ||
// } | ||
if ($rev == '5.3.0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton can you move this code into FiveThree.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah dang - didn't spot that!
This appears to have caused a regression - see #12896 |
Overview
The
edit message templates
permission currently grants access to user-driven messages and system workflow message. The implication of this is that, there is no way of restricting a particular user to just user-driven messages or system workflow messages.This PR adds 2 new granular permissions called
edit user-driven message templates
andedit system workflow message templates
. This helps to further limit which of the templates a user can view and edit, while retaining exitingedit message templates
permission for backward compability.Before
After
Technical Details
New permissions were added to existing ones
and applied to message template urls.
Permission checks were applied on the view page, restricting tab access. Checks were also carried out while building the form to ensure users with one permission, does not edit forms belonging to other permission group.
For existing users to be aware of these changes, a pre-upgrade message notification was provided. This affords them the opportunity of deciding whether to upgrade existing user permissions or not.