/** * Check on user and group permissions and on duplicate FAQs * * @param array $resultset Array with search results * * @return void */ public function reviewResultset(array $resultset) { $this->setResultset($resultset); $duplicateResults = []; $currentUserId = $this->user->getUserId(); if ('medium' === $this->_config->get('security.permLevel')) { $currentGroupIds = $this->user->perm->getUserGroups($currentUserId); } else { $currentGroupIds = array(-1); } foreach ($this->rawResultset as $result) { $permission = false; // check permissions for groups if ('medium' === $this->_config->get('security.permLevel')) { $groupPermission = $this->faq->getPermission('group', $result->id); if (count($groupPermission) && in_array($groupPermission[0], $currentGroupIds)) { $permission = true; } } // check permission for user if ($permission || 'basic' === $this->_config->get('security.permLevel')) { $userPermission = $this->faq->getPermission('user', $result->id); if (in_array(-1, $userPermission) || in_array($this->user->getUserId(), $userPermission)) { $permission = true; } else { $permission = false; } } // check on duplicates if (!isset($duplicateResults[$result->id])) { $duplicateResults[$result->id] = 1; } else { ++$duplicateResults[$result->id]; continue; } if ($permission) { $this->reviewedResultset[] = $result; } } $this->setNumberOfResults($this->reviewedResultset); }