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

CRM-19494 Refactoring of permission code #9246

Merged
merged 22 commits into from
Oct 24, 2016

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 13, 2016

@systopia Do you want to look at this as a proposed replacement for your PR #9242 - Your PR is good except for a couple of things

  1. it doesn't actually work
  2. after fixing the reason it doesn't actually work it doesn't work for another reason

:-)

Basically you are assuming an id-indexed list of contact ids is passed in & that is not the case (issue 1). After making them id-indexed it turns out the links function goes & bashes the carefully constructed link list out of the water.

Re performance - I'm feeling OK-ish about this but there is a problem that it actually gets called twice rather than once when creating a form. I think session caching is probably the only way to avoid this. I've added comments about that.


@eileenmcnaughton
Copy link
Contributor Author

test this please

@bjendres
Copy link
Contributor

Your PR is good except for a couple of things: it doesn't actually work

Oh nooo, sorry. Seems I got sloppy on the last 5% :-/

I'm pretty much out for the weekend, but I'll fix this on Monday.

Thanks @eileenmcnaughton, enjoy the rest of the sprint!

@bjendres
Copy link
Contributor

BTW, the old PR is #9229, not 9242

@eileenmcnaughton
Copy link
Contributor Author

@systopia I feel fairly good about this now. I did some further clean up on top & seeing the lack of regression from that made me feel better about it all. I did fix a few things. Back to you to re-review but I think this can probably be merged

@nganivet
Copy link
Contributor

@systopia: how does this play with https://issues.civicrm.org/jira/browse/CRM-19256 ?

@eileenmcnaughton
Copy link
Contributor Author

@nganivet I think I mis-referred to that ticket at some point - there should be no connection between the 2

@eileenmcnaughton
Copy link
Contributor Author

@systopia This PR is just waiting on you to reconfirm the changes I made to your PR....

…iew my contact

Conflicts:
	CRM/Contact/BAO/Contact/Permission.php
@@ -140,8 +140,8 @@ public static function allow($id, $type = CRM_Core_Permission::VIEW) {
$contactID = CRM_Core_Session::getLoggedInContactID();

// first: check if contact is trying to view own contact
if ($type == CRM_Core_Permission::VIEW && CRM_Core_Permission::check('view my contact')
|| $type == CRM_Core_Permission::EDIT && CRM_Core_Permission::check('edit my contact')
if ($contactID == $id && ($type == CRM_Core_Permission::VIEW && CRM_Core_Permission::check('view my contact')
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, thanks for spotting this.

@bjendres
Copy link
Contributor

@eileenmcnaughton, Sorry for the delay.

The changes all look sensible to me, but I couldn't test everything in detail. I ran the CRM_ACL_ListTest again, and I made sure that the integration into the contact search works properly. If you're reasonably sure you didn't break anything with your changes in CRM_Contact_Selector, I say we can go ahead and merge.

@eileenmcnaughton
Copy link
Contributor Author

OK let's merge it - I did test it quite a bit locally & we can test more once merged.

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

Successfully merging this pull request may close these issues.

4 participants