/** * Add an organization filter if it wasn't specified in the filter. * * Checks the filter on sematic correctness and replaces the text seacrh filter * with the real filter. * * @param mixed $filter True for the filter stored in this model or a filter array * @return array The filter to use */ protected function _checkFilterUsed($filter) { $filter = parent::_checkFilterUsed($filter); if (isset($filter['gr2o_id_organization'])) { // Check for option to check for any organisation if (true === $filter['gr2o_id_organization']) { unset($filter['gr2o_id_organization']); } } else { // Add the correct filter if ($this->isMultiOrganization() && !isset($filter['gr2o_patient_nr'])) { $allowed = $this->user->getAllowedOrganizations(); // If we are not looking for a specific patient, we can look at all patients $filter['gr2o_id_organization'] = array_keys($allowed); } else { // Otherwise, we can only see in our current organization $filter['gr2o_id_organization'] = $this->getCurrentOrganization(); } } if (self::SSN_HASH === $this->hashSsn) { // Make sure a search for a SSN is hashed when needed. array_walk_recursive($filter, array($this, 'applyHash')); } return $filter; }