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

Ensure users with the perm "CiviEvent: access CiviEvent " can edit events they have created. #12424

Merged
merged 3 commits into from
Aug 16, 2018

Conversation

alifrumin
Copy link
Contributor

Overview

Users with the permission "CiviEvent: access CiviEvent " should be able to edit events they create (regardless of whether they have the permission "CiviEvent: edit all events").

Before

Users with the permission "CiviEvent: access CiviEvent" could create but not edit their events.

After

Users with the permission "CiviEvent: access CiviEvent" can create AND edit their events.

Technical Details

It looks like this commit 5836c35#diff-57f730edc03717d188e539c92cd1a3d9L2047 changed the way that the $createdEvents array was formatted so that the key was the event id and the value was the title of the event while this line https://github.com/civicrm/civicrm-core/blob/5.2.1/CRM/Event/BAO/Event.php#L2126 expects the value to be the event id.

@civibot
Copy link

civibot bot commented Jul 5, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@alifrumin Are you able to add a test?

@alifrumin
Copy link
Contributor Author

alifrumin commented Jul 6, 2018

absolutely

@alifrumin alifrumin changed the title Ensure users with the perm "CiviEvent: access CiviEvent " can edit events they have created. WIP Ensure users with the perm "CiviEvent: access CiviEvent " can edit events they have created. Jul 9, 2018
@colemanw
Copy link
Member

@alifrumin I've checked the code over and your logic looks sound. I see that the function \CRM_ACL_BAO_ACL::group() requires an array of ids not an array keyed by id, so that looks to be the right fix. Once the test is working ping me and I'm happy to merge it.

@eileenmcnaughton
Copy link
Contributor

this may relate #11716

@eileenmcnaughton
Copy link
Contributor

@alifrumin failing test is related

@alifrumin
Copy link
Contributor Author

Yeah I know, I got distracted by some other work but I hope to work on this test this week

@alifrumin
Copy link
Contributor Author

When I ran just this test locally, it passed but when I ran all the tests in the tests/phpunit/CRM/Event/BAO folder this test failed because the static $permissions in the CRM_Event_BAO_Event:CheckPermissions function was throwing things off. We changed the static $permissions to use the Civi::$statics[CLASS]['permissions'] as documented by Tim here and unset it in the test here and now the test is passing.

@colemanw could you take a look at this again? It is ready to be merged from our perspective.

@alifrumin alifrumin changed the title WIP Ensure users with the perm "CiviEvent: access CiviEvent " can edit events they have created. Ensure users with the perm "CiviEvent: access CiviEvent " can edit events they have created. Aug 6, 2018
@alifrumin
Copy link
Contributor Author

@eileenmcnaughton thank you for your diligence.

@mattwire
Copy link
Contributor

Hi @alifrumin I've just had a look at this - agree that it is an improvement. However with the introduction of this there are a couple of other issues that come up:

  1. Navigation menu links "New Event" and "Manage Events" are only visible if you have "Edit All Events" permission - I think that needs to be changed as part of this PR so they are visible.
  2. On the manage events page Event Links->Register Participant requires "CiviEvent: edit event participants" but is not disabled if the user does not have that permission. Can it be disabled please?

mattwire added a commit to mattwire/civicrm-core that referenced this pull request Aug 16, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Aug 16, 2018
@mattwire
Copy link
Contributor

On second thoughts, I think we should merge this now. I'm working on an extension that enhances events functionality and this checkPermission function is a real pain as the caching does not work properly - basically it should be two separate functions as currently if you call it first without an eventId it populates all events, but if you call it first with an eventId it only populates one event and will not cache all events if called a second time as it assumes that the cache has been built - see https://github.com/mattwire/civicrm-core/tree/civievent_permissions for a possible improvement which builds on this PR.

  1. and 2. could be done as follow-up PRs.

@eileenmcnaughton @colemanw Are one of you happy to merge this?

@eileenmcnaughton eileenmcnaughton merged commit c69852b into civicrm:master Aug 16, 2018
@eileenmcnaughton
Copy link
Contributor

Ok merged - any tickets to update?

@alifrumin alifrumin deleted the editOwnEvents branch August 17, 2018 14:26
@alifrumin
Copy link
Contributor Author

Thank you @mattwire and @eileenmcnaughton! No tickets to update that I know of.

@mattwire 1 and 2 are very good points. If you start pr's for them let me know and I am happy to test them/ If I come into some extra time I will give it a go.

mattwire added a commit to mattwire/civicrm-core that referenced this pull request Sep 5, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Sep 11, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Oct 19, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Oct 20, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Oct 20, 2018
mattwire added a commit to mattwire/civicrm-core that referenced this pull request Oct 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants