-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
Make Send SMS permission independent of Edit Contact permission #12067
Make Send SMS permission independent of Edit Contact permission #12067
Conversation
@mattwire @JKingsnorth are either of you able to review this one? |
CRM/Contact/Task.php
Outdated
!empty(self::$_tasks[self::TASK_SMS]['title']) | ||
) { | ||
$tasks[self::TASK_SMS] = self::$_tasks[self::TASK_SMS]['title']; | ||
} |
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.
Here's a scope for code improvement:
// lets declare a array of tasks we should be looking, to be included in final list of permitted $tasks
foreach ([
self::MAP_CONTACTS,
...
self::CREATE_MAILING,
self::TASK_SMS,
] as $taskID) {
if (isset(self::$_tasks[$taskID]) && !empty(self::$_tasks[$taskID]['title']) {
$tasks[$taskID] = self::$_tasks[$taskID]['title'];
}
}
@michaelmcandrew what do you think?
So we have a number of functions in play here:
As a step forwards I think it would be better to:
|
Thanks for the feedback @monishdeb and @mattwire - I'll take a look ASAP. |
@mattwire - I've thought about this for a while, and although I get the motivation, I can't see a sensible way to do what you said. When I try, the code ends up more complex. If I add it unconditionally in tasks() then when it comes to permissionedTaskTitles() I have to do two things
So it seems simpler to keep it as it is. I can make the change if you prefer but wanted to check first. Or if I am missing something, feel free to let me know / have a go yourself. @Monish - if we end up keeping it this way, I will add your refactoring |
@michaelmcandrew Ok let's keep it simple for now and just change it as @monishdeb suggested. Is there a unit test we could add at the same time? |
97085f9
to
474f2a8
Compare
@mattwire - ok sounds good. give me a shout if you ever want to discuss further clean up on this area of the code base. re: tests, I did add a permissions test in #11590 which this PR also passes. Might that be good enough? Else, are there any unit tests specifically for CRM/Contact/Task.php that I could copy? @monishdeb - I've implemented the code cleanup that you suggested. |
Merging - I think the change has been adequately reviewed (and I also checked the code myself). We don't have tests on this function yet (the permissioned tiles) and it would be good to add but I also think this change could slip through without one as it is pretty trivial |
Overview
A (presumably fairly trivial) follow on from #11590.
Most of the tasks listed in
CRM_Contact_Task::tasks()
also require the edit contact permission but a few do not. The ones that do not are mentioned in the final else of::permissionedTaskTitles()
.We want people to be able to Send SMS without having the edit contacts permission. Therefore, we need to mention it in this final else clause.
Before
You needed an Edit contact permission AND the send SMS permission to send SMS
After
You only need the send SMS permission to send SMS.