-
-
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
CRM-19773 - Call hook_civicrm_selectWhereClause when checking event permissions #9544
Conversation
colemanw
commented
Dec 15, 2016
•
edited by civicrm-builder
Loading
edited by civicrm-builder
- CRM-19773: Call hook_civicrm_selectWhereClause from the BAOs
* @return array | ||
*/ | ||
public static function getLocationEvents() { | ||
$events = array(); | ||
$ret = array( |
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.
So cool ...
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.
Yep, that's 3 levels of joins to get the state_province name :)
if ($userID = $session->get('userID')) { | ||
$createdEvents = array_keys(CRM_Event_PseudoConstant::event(NULL, TRUE, "created_id={$userID}")); | ||
} | ||
$result = civicrm_api3('Event', 'get', array( |
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.
Wouldn't keeping $allEvents = CRM_Event_PseudoConstant::event(NULL, TRUE); be more efficient than an API call?
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.
The api call invokes hook_civicrm_selectWhereClause and the pseudoconstant lookup does not (I did add it there, but because of the $all
flag being set to true
it skips the hook). The pseudoconstant function is deprecated anyway.
@@ -482,7 +482,7 @@ public function whereClause(&$params, $sortBy = TRUE, $force) { | |||
} | |||
else { | |||
$curDate = date('YmdHis'); | |||
$clauses[5] = "(end_date >= {$curDate} OR end_date IS NULL)"; | |||
$clauses[] = "(end_date >= {$curDate} OR end_date IS NULL)"; | |||
} | |||
} | |||
else { |
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.
So if I understand correctly we do not need to filter in the Manage Events page since the filtering takes place in CRM_Event_BAO_Event::checkPermissions() ?
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.
Right.
@civicrm-builder retest this please |
test this please |
It would be good to get a test on this |
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.
Tested, works fine. Also added a test #10125. Not sure why the build isn't passing here.
@civicrm-builder test this please |
$result = civicrm_api3('Event', 'get', array( | ||
'check_permissions' => 1, | ||
'return' => 'title', | ||
'created_id' => 'user_contact_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.
Build shows a break at this point - maybe all failing test needs $this->createLoggedInUser();
in them to validate 'created_id' => 'user_contact_id'
param?
I don't know why the test is failing but once you get it to pass it's good to merge based on @jitendrapurohit's review & my reading of the code - adding merge-on-pass |
@colemanw this has been reviewed AND @jitendrapurohit added a unit test! - but can't merge as tests are failing I think the trick is to allow 'user_contact_id' to be converted to NULL & rely on whether it is mandatory or not to enforce the id - in the case of the failing tests it is not
|
from function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $entity) { |
@colemanw needs rebasing but will hopefully pass now |
@colemanw this appears to have caused a regression due to default limit of 25 on the api calls |
Yes, it's fixed if I add |
I've opened a PR - #10327 |