Skip to content
Snippets Groups Projects
Commit c725c98c authored by jaapjansma's avatar jaapjansma
Browse files

Fix for permission to view contact filter.

parent beb42d01
No related branches found
No related tags found
No related merge requests found
......@@ -26,15 +26,6 @@ class PermissionToViewContactFilter extends AbstractFieldFilterHandler {
$this->initializeField($this->configuration['datasource'], $this->configuration['field']);
}
/**
* Sets the default filter.
*
* @throws \Exception
*/
public function setDefaultFilterValues() {
$this->setFilter([]);
}
/**
* @param array $filter
* The filter settings
......@@ -43,7 +34,7 @@ class PermissionToViewContactFilter extends AbstractFieldFilterHandler {
public function setFilter($filter) {
$this->resetFilter();
$dataFlow = $this->dataSource->ensureField($this->inputFieldSpecification);
$where = $this->getAclWhereClause();
$where = $this->getAclWhereClause($filter['value']);
$contactTableAlias = 'civicrm_contact_'.$this->inputFieldSpecification->alias;
$where = str_replace(["`contact_a`.", "contact_a."], "`{$contactTableAlias}`.", $where);
if ($where) {
......@@ -65,10 +56,10 @@ class PermissionToViewContactFilter extends AbstractFieldFilterHandler {
}
}
protected function getAclWhereClause() {
protected function getAclWhereClause($contactId = null) {
$tables = array();
$whereTables = array();
$where = \CRM_ACL_API::whereClause(\CRM_ACL_API::VIEW, $tables, $whereTables, NULL, FALSE, TRUE, FALSE);
$where = \CRM_ACL_API::whereClause(\CRM_ACL_API::VIEW, $tables, $whereTables, $contactId, FALSE, TRUE, FALSE);
return $where;
}
......@@ -131,17 +122,16 @@ class PermissionToViewContactFilter extends AbstractFieldFilterHandler {
}
/**
* Add the elements to the filter form.
* Get a list of possible operator options.
*
* @param \Civi\DataProcessor\DataSpecification\FieldSpecification $fieldSpec
*
* @param \CRM_Core_Form $form
* @param array $defaultFilterValue
* @param string $size
* Possible values: full or compact
* @return array
* Return variables belonging to this filter.
*/
public function addToFilterForm(\CRM_Core_Form $form, $defaultFilterValue, $size='full') {
return null; // This filter has no additional options to select.
protected function getOperatorOptions(\Civi\DataProcessor\DataSpecification\FieldSpecification $fieldSpec) {
return [
'=' => E::ts('Is equal'),
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment