ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLuceneSearchResultFilter Class Reference

Validate Lucene search results Do access checks, create ref_ids from obj_ids... More...

+ Collaboration diagram for ilLuceneSearchResultFilter:

Public Member Functions

 addFilter (ilLuceneResultFilter $filter)
 add filter
 setCandidates ($a_ids)
 Set result ids.
 getCandidates ()
 get result ids
 getUserId ()
 Get user id.
 getRequiredPermission ()
 Get required permission.
 isLimitReached ()
 Check if search max hits is reached.
 getResultIds ()
 get filtered ids
 getResultObjIds ()
 get filtered ids
 getResults ()
 get results
 getMaxHits ()
 get max hits
 loadFromDb ()
 Load results from db.
 filter ()
 Filter search results.

Static Public Member Functions

static getInstance ($a_user_id)

Protected Member Functions

 __construct ($a_user_id)
 Singleton constructor.
 checkFilter ($a_ref_id)
 check appended filter
 append ($a_ref_id, $a_obj_id)
 Append to filtered results.
 isOffsetReached ($a_current_nr)
 Check if offset is reached.

Protected Attributes

 $user_id = null
 $result = array()
 $checked = array()
 $settings
 $cache
 $required_permission = 'visible'
 $limit_reached = false
 $offset = 0
 $filters = array()

Static Protected Attributes

static $instance = null

Detailed Description

Validate Lucene search results Do access checks, create ref_ids from obj_ids...

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilLuceneSearchResultFilter.php.

Constructor & Destructor Documentation

ilLuceneSearchResultFilter::__construct (   $a_user_id)
protected

Singleton constructor.

Parameters
int$a_usr_iduser id
Returns

Definition at line 55 of file class.ilLuceneSearchResultFilter.php.

References ilUserSearchCache\_getInstance(), getInstance(), and getUserId().

{
$this->user_id = $a_user_id;
$this->settings = ilSearchSettings::getInstance();
include_once('Services/Search/classes/class.ilUserSearchCache.php');
$this->cache = ilUserSearchCache::_getInstance($this->getUserId());
$this->offset = $this->settings->getMaxHits() * ($this->cache->getResultPageNumber() - 1);
}

+ Here is the call graph for this function:

Member Function Documentation

ilLuceneSearchResultFilter::addFilter ( ilLuceneResultFilter  $filter)

add filter

Parameters
@return

Definition at line 86 of file class.ilLuceneSearchResultFilter.php.

{
$this->filters[] = $filter;
}
ilLuceneSearchResultFilter::append (   $a_ref_id,
  $a_obj_id 
)
protected

Append to filtered results.

Parameters
intref_id
intobj_id

Definition at line 284 of file class.ilLuceneSearchResultFilter.php.

Referenced by filter().

{
$this->checked[$a_ref_id] = $a_obj_id;
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::checkFilter (   $a_ref_id)
protected

check appended filter

Parameters
int$a_ref_idreference id
Returns
bool

Definition at line 267 of file class.ilLuceneSearchResultFilter.php.

Referenced by filter().

{
foreach($this->filters as $filter)
{
if(!$filter->filter($a_ref_id))
{
return false;
}
}
return true;
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::filter ( )

Filter search results.

Do RBAC checks.

public

Parameters
introot node id
boolcheck and boolean search
Returns
bool success status

Definition at line 197 of file class.ilLuceneSearchResultFilter.php.

References $ilLog, $ref_id, ilObject\_getAllReferences(), append(), checkFilter(), getCandidates(), getRequiredPermission(), getResultIds(), and isOffsetReached().

{
global $ilAccess,$ilLog,$tree;
// get ref_ids and check access
$counter = 0;
$offset_counter = 0;
foreach($this->getCandidates() as $obj_id)
{
// Check referenced objects
foreach(ilObject::_getAllReferences($obj_id) as $ref_id)
{
// Check filter
if(!$this->checkFilter($ref_id))
{
$this->cache->appendToFailed($ref_id);
continue;
}
// Access failed by prior check
if($this->cache->isFailed($ref_id))
{
continue;
}
// Offset check
if($this->cache->isChecked($ref_id) and !$this->isOffsetReached($offset_counter))
{
$ilLog->write(__METHOD__.': Result was checked.');
$offset_counter++;
break;
}
// RBAC check
if($ilAccess->checkAccessOfUser($this->getUserId(),
'',
'',
$obj_id))
{
++$counter;
$offset_counter++;
$this->append($ref_id,$obj_id);
$this->cache->appendToChecked($ref_id,$obj_id);
break;
}
else
{
$this->cache->appendToFailed($ref_id);
}
}
if($counter >= $this->settings->getMaxHits())
{
$this->limit_reached = true;
$this->cache->setResults($this->getResultIds());
$this->cache->save();
return false;
}
}
$this->cache->setResults($this->getResultIds());
$this->cache->save();
return true;
}

+ Here is the call graph for this function:

ilLuceneSearchResultFilter::getCandidates ( )

get result ids

Returns
array result ids

Definition at line 105 of file class.ilLuceneSearchResultFilter.php.

Referenced by filter().

{
return $this->result ? $this->result : array();
}

+ Here is the caller graph for this function:

static ilLuceneSearchResultFilter::getInstance (   $a_user_id)
static
Parameters
int$a_user_iduser_id
Returns

Definition at line 72 of file class.ilLuceneSearchResultFilter.php.

References $instance.

Referenced by __construct(), ilLuceneAdvancedSearchGUI\performSearch(), ilLuceneSearchGUI\performSearch(), ilLuceneAdvancedSearchGUI\showSavedResults(), and ilLuceneSearchGUI\showSavedResults().

{
if(self::$instance == null)
{
return self::$instance = new ilLuceneSearchResultFilter($a_user_id);
}
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::getMaxHits ( )

get max hits

Returns
int max hits per page

Definition at line 172 of file class.ilLuceneSearchResultFilter.php.

{
return $this->settings->getMaxHits();
}
ilLuceneSearchResultFilter::getRequiredPermission ( )

Get required permission.

Returns
string required rbac permission

Definition at line 123 of file class.ilLuceneSearchResultFilter.php.

References $required_permission.

Referenced by filter().

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::getResultIds ( )

get filtered ids

Returns
array array of filtered ref_ids

Definition at line 141 of file class.ilLuceneSearchResultFilter.php.

Referenced by filter().

{
return $this->checked ? $this->checked : array();
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::getResultObjIds ( )

get filtered ids

Returns
array array of filtered ref_ids

Definition at line 150 of file class.ilLuceneSearchResultFilter.php.

{
foreach($this->checked as $obj_id)
{
$obj_ids[] = $obj_id;
}
return $obj_ids ? $obj_ids : array();
}
ilLuceneSearchResultFilter::getResults ( )

get results

Returns
array array of ref_ids

Definition at line 163 of file class.ilLuceneSearchResultFilter.php.

{
return $this->checked ? $this->checked : array();
}
ilLuceneSearchResultFilter::getUserId ( )

Get user id.

Returns
int user_id

Definition at line 114 of file class.ilLuceneSearchResultFilter.php.

References $user_id.

Referenced by __construct().

{
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::isLimitReached ( )

Check if search max hits is reached.

Returns
bool max hits reached

Definition at line 132 of file class.ilLuceneSearchResultFilter.php.

References $limit_reached.

{
return (bool) $this->limit_reached;
}
ilLuceneSearchResultFilter::isOffsetReached (   $a_current_nr)
protected

Check if offset is reached.

Parameters
int$a_current_nrCurrent result number
Returns
bool

Definition at line 294 of file class.ilLuceneSearchResultFilter.php.

Referenced by filter().

{
return $a_current_nr < $this->offset ? false : true;
}

+ Here is the caller graph for this function:

ilLuceneSearchResultFilter::loadFromDb ( )

Load results from db.

Returns

Definition at line 181 of file class.ilLuceneSearchResultFilter.php.

{
$this->checked = $this->cache->getResults();
}
ilLuceneSearchResultFilter::setCandidates (   $a_ids)

Set result ids.

Parameters
mixed$a_idsLucene result ids or instance of Iterator
Returns
void

Definition at line 96 of file class.ilLuceneSearchResultFilter.php.

{
$this->result = $a_ids;
}

Field Documentation

ilLuceneSearchResultFilter::$cache
protected

Definition at line 42 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$checked = array()
protected

Definition at line 40 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$filters = array()
protected

Definition at line 47 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$instance = null
staticprotected

Definition at line 36 of file class.ilLuceneSearchResultFilter.php.

Referenced by getInstance().

ilLuceneSearchResultFilter::$limit_reached = false
protected

Definition at line 44 of file class.ilLuceneSearchResultFilter.php.

Referenced by isLimitReached().

ilLuceneSearchResultFilter::$offset = 0
protected

Definition at line 45 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$required_permission = 'visible'
protected

Definition at line 43 of file class.ilLuceneSearchResultFilter.php.

Referenced by getRequiredPermission().

ilLuceneSearchResultFilter::$result = array()
protected

Definition at line 39 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$settings
protected

Definition at line 41 of file class.ilLuceneSearchResultFilter.php.

ilLuceneSearchResultFilter::$user_id = null
protected

Definition at line 38 of file class.ilLuceneSearchResultFilter.php.

Referenced by getUserId().


The documentation for this class was generated from the following file: