Skip to content

Commit

Permalink
CRM-20910: Check permission param while retrieving participants from api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jitendra Purohit committed Jul 19, 2017
1 parent 6005042 commit baa3dc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -6121,7 +6121,8 @@ public static function buildQillForFieldValue(
$pseudoOptions = CRM_Core_PseudoConstant::worldRegion();
}
elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
$pseudoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
$checkPermission = CRM_Utils_Array::value('check_permission', $pseudoExtraParam, TRUE);
$pseudoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, $checkPermission, TRUE);
}
elseif ($fieldName == 'contribution_product_id') {
$pseudoOptions = CRM_Contribute_PseudoConstant::products();
Expand Down
10 changes: 7 additions & 3 deletions CRM/Event/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ public static function where(&$query) {
* @param $query
*/
public static function whereClauseSingle(&$values, &$query) {
$checkPermission = TRUE;
if (!empty($query->_skipPermission)) {
$checkPermission = FALSE;
}
list($name, $op, $value, $grouping, $wildcard) = $values;
$fields = array_merge(CRM_Event_BAO_Event::fields(), CRM_Event_BAO_Participant::exportableFields());

Expand Down Expand Up @@ -400,7 +404,7 @@ public static function whereClauseSingle(&$values, &$query) {
}
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);

list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op, array('check_permission' => $checkPermission));
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
return;
Expand All @@ -425,7 +429,7 @@ public static function whereClauseSingle(&$values, &$query) {
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType);
}

list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op);
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op, array('check_permission' => $checkPermission));
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
$query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
return;
Expand Down Expand Up @@ -461,7 +465,7 @@ public static function whereClauseSingle(&$values, &$query) {
if (!array_key_exists($qillName, $fields)) {
break;
}
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op);
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op, array('check_permission' => $checkPermission));
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
return;
}
Expand Down

0 comments on commit baa3dc8

Please sign in to comment.