ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserSearchCache Class Reference

Class for storing search result. More...

+ Collaboration diagram for ilUserSearchCache:

Public Member Functions

 isAnonymous ()
 Check if current user is anonymous user.
 switchSearchType ($a_type)
 switch to search type reads entries from database
 getResults ()
 Get results.
 setResults ($a_results)
 Set results.
 addResult ($a_result_item)
 Append result.
 appendToFailed ($a_ref_id)
 Append failed id.
 isFailed ($a_ref_id)
 check if reference has failed access
 appendToChecked ($a_ref_id, $a_obj_id)
 Append checked id.
 isChecked ($a_ref_id)
 Check if reference was already checked.
 getCheckedItems ()
 Get all checked items.
 setResultPageNumber ($a_number)
 Set result page number.
 getResultPageNumber ()
 get result page number
 setQuery ($a_query)
 set query
 getQuery ()
 get query
 getUrlEncodedQuery ()
 Urlencode query for further use in e.g glossariers (highlighting off search terms).
 setRoot ($a_root)
 set root node of search
 getRoot ()
 get root node
 setItemFilter ($a_filter)
 getItemFilter ()
 setMimeFilter ($a_filter)
 getMimeFilter ()
 deleteCachedEntries ()
 delete cached entries
 deleteCachedEntriesAnonymous ()
 Delete cached entries for anonymous user.
 delete ()
 Delete user entries.
 save ()
 Save entries.
 saveForAnonymous ()

Static Public Member Functions

static _getInstance ($a_usr_id)
 Get singleton instance.

Data Fields

const DEFAULT_SEARCH = 0
const ADVANCED_SEARCH = 1
const SHOP_CONTENT = 2
const SHOP_ADVANCED_SEARCH = 3
const ADVANCED_MD_SEARCH = 4
const LUCENE_DEFAULT = 5
const LUCENE_ADVANCED = 6
const LAST_QUERY = 7
const LUCENE_USER_SEARCH = 8

Private Member Functions

 __construct ($a_usr_id)
 Constructor.
 read ()
 Read user entries.
 readAnonymous ()
 Read from session for anonymous user.

Private Attributes

 $db
 $usr_id
 $search_type = self::DEFAULT_SEARCH
 $search_result = array()
 $checked = array()
 $failed = array()
 $page_number = 1
 $query
 $root = ROOT_FOLDER_ID
 $item_filter = array()
 $isAnonymous = false
 $mime_filter = array()

Static Private Attributes

static $instance = null

Detailed Description

Class for storing search result.

Allows paging of result sets

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

Definition at line 35 of file class.ilUserSearchCache.php.

Constructor & Destructor Documentation

ilUserSearchCache::__construct (   $a_usr_id)
private

Constructor.

private

Definition at line 77 of file class.ilUserSearchCache.php.

References $ilDB, DEFAULT_SEARCH, isAnonymous(), and read().

{
global $ilDB;
if($a_usr_id == ANONYMOUS_USER_ID)
{
$this->isAnonymous = true;
}
$this->db = $ilDB;
$this->usr_id = $a_usr_id;
$this->search_type = self::DEFAULT_SEARCH;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilUserSearchCache::addResult (   $a_result_item)

Append result.

public

Parameters
array(int,int,string)array(ref_id,obj_id,type)

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

{
$this->search_result[$a_result_item['ref_id']]['ref_id'] = $a_result_item['ref_id'];
$this->search_result[$a_result_item['ref_id']]['obj_id'] = $a_result_item['obj_id'];
$this->search_result[$a_result_item['ref_id']]['type'] = $a_result_item['type'];
return true;
}
ilUserSearchCache::appendToChecked (   $a_ref_id,
  $a_obj_id 
)

Append checked id.

public

Parameters
intchecked reference id
intchecked obj_id

Definition at line 203 of file class.ilUserSearchCache.php.

{
$this->checked[$a_ref_id] = $a_obj_id;
}
ilUserSearchCache::appendToFailed (   $a_ref_id)

Append failed id.

public

Parameters
intref_id of failed access

Definition at line 178 of file class.ilUserSearchCache.php.

{
$this->failed[$a_ref_id] = $a_ref_id;
}
ilUserSearchCache::delete ( )

Delete user entries.

public

Definition at line 407 of file class.ilUserSearchCache.php.

References $ilDB, $query, $res, and read().

{
global $ilDB;
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id ,'integer')." ".
"AND search_type = ".$this->db->quote($this->search_type ,'integer');
$res = $ilDB->manipulate($query);
$this->read();
return true;
}

+ Here is the call graph for this function:

ilUserSearchCache::deleteCachedEntries ( )

delete cached entries

Parameters
@return

Definition at line 337 of file class.ilUserSearchCache.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, deleteCachedEntriesAnonymous(), isAnonymous(), and setResultPageNumber().

{
global $ilDB;
if($this->isAnonymous())
{
}
$query = "SELECT COUNT(*) num FROM usr_search ".
"WHERE usr_id = ".$ilDB->quote($this->usr_id,'integer')." ".
"AND search_type = ".$ilDB->quote($this->search_type,'integer');
$res = $ilDB->query($query);
if($row->num > 0)
{
$ilDB->update('usr_search',
array(
'search_result' => array('clob',serialize(array(0))),
'checked' => array('clob',serialize(array(0))),
'failed' => array('clob',serialize(array(0))),
'page' => array('integer',0)),
array(
'usr_id' => array('integer',(int) $this->usr_id),
'search_type' => array('integer',(int) $this->search_type)
));
}
else
{
$ilDB->insert('usr_search',
array(
'search_result' => array('clob',serialize(array(0))),
'checked' => array('clob',serialize(array(0))),
'failed' => array('clob',serialize(array(0))),
'page' => array('integer',0),
'usr_id' => array('integer',(int) $this->usr_id),
'search_type' => array('integer',(int) $this->search_type)
));
}
$this->search_result = array();
$this->checked = array();
$this->failed = array();
}

+ Here is the call graph for this function:

ilUserSearchCache::deleteCachedEntriesAnonymous ( )

Delete cached entries for anonymous user.

Returns
bool

Definition at line 389 of file class.ilUserSearchCache.php.

References setResultPageNumber().

Referenced by deleteCachedEntries().

{
$this->search_result = array();
$this->checked = array();
$this->failed = array();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserSearchCache::getCheckedItems ( )

Get all checked items.

public

Returns
array array(ref_id => obj_id)

Definition at line 227 of file class.ilUserSearchCache.php.

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

Definition at line 317 of file class.ilUserSearchCache.php.

References $item_filter.

Referenced by save(), and saveForAnonymous().

{
return (array) $this->item_filter;
}

+ Here is the caller graph for this function:

ilUserSearchCache::getMimeFilter ( )

Definition at line 327 of file class.ilUserSearchCache.php.

References $mime_filter.

Referenced by save(), and saveForAnonymous().

{
return (array) $this->mime_filter;
}

+ Here is the caller graph for this function:

ilUserSearchCache::getQuery ( )

get query

Returns

Definition at line 272 of file class.ilUserSearchCache.php.

References $query.

Referenced by getUrlEncodedQuery(), save(), and saveForAnonymous().

{
return $this->query;
}

+ Here is the caller graph for this function:

ilUserSearchCache::getResultPageNumber ( )

get result page number

public

Definition at line 252 of file class.ilUserSearchCache.php.

{
return $this->page_number ? $this->page_number : 1;
}
ilUserSearchCache::getResults ( )

Get results.

public

Definition at line 139 of file class.ilUserSearchCache.php.

{
return $this->search_result ? $this->search_result : array();
}
ilUserSearchCache::getRoot ( )

get root node

Returns

Definition at line 307 of file class.ilUserSearchCache.php.

Referenced by save(), and saveForAnonymous().

{
return $this->root ? $this->root : ROOT_FOLDER_ID;
}

+ Here is the caller graph for this function:

ilUserSearchCache::getUrlEncodedQuery ( )

Urlencode query for further use in e.g glossariers (highlighting off search terms).

Returns

Definition at line 281 of file class.ilUserSearchCache.php.

References $query, and getQuery().

{
if(is_array($this->getQuery()))
{
$query = $this->getQuery();
return urlencode(str_replace('"', '.', $query['lom_content']));
}
return urlencode(str_replace('"', '.', $this->getQuery()));
}

+ Here is the call graph for this function:

ilUserSearchCache::isAnonymous ( )

Check if current user is anonymous user.

Returns
bool

Definition at line 113 of file class.ilUserSearchCache.php.

References $isAnonymous.

Referenced by __construct(), deleteCachedEntries(), read(), and save().

{
}

+ Here is the caller graph for this function:

ilUserSearchCache::isChecked (   $a_ref_id)

Check if reference was already checked.

public

Parameters
intref_id

Definition at line 215 of file class.ilUserSearchCache.php.

{
return array_key_exists($a_ref_id,$this->checked) and $this->checked[$a_ref_id];
}
ilUserSearchCache::isFailed (   $a_ref_id)

check if reference has failed access

public

Parameters
intref_id

Definition at line 190 of file class.ilUserSearchCache.php.

{
return in_array($a_ref_id,$this->failed) ? true : false;
}
ilUserSearchCache::read ( )
private

Read user entries.

private

Definition at line 491 of file class.ilUserSearchCache.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, isAnonymous(), readAnonymous(), setItemFilter(), setQuery(), and setRoot().

Referenced by __construct(), delete(), and switchSearchType().

{
$this->failed = array();
$this->checked = array();
$this->search_result = array();
$this->page_number = 0;
if($this->isAnonymous())
{
return $this->readAnonymous();
}
$query = "SELECT * FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id ,'integer')." ".
"AND search_type = ".$this->db->quote($this->search_type ,'integer');
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->search_result = unserialize(stripslashes($row->search_result));
if(strlen($row->checked))
{
$this->checked = unserialize(stripslashes($row->checked));
}
if(strlen($row->failed))
{
$this->failed = unserialize(stripslashes($row->failed));
}
$this->page_number = $row->page;
$this->setQuery(unserialize($row->query));
$this->setRoot($row->root);
$this->setItemFilter(unserialize($row->item_filter));
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserSearchCache::readAnonymous ( )
private

Read from session for anonymous user.

Definition at line 530 of file class.ilUserSearchCache.php.

References $_SESSION, $search_type, setItemFilter(), setMimeFilter(), setQuery(), and setRoot().

Referenced by read().

{
$this->search_result = (array) $_SESSION['usr_search_cache'][$this->search_type]['search_result'];
$this->checked = (array) $_SESSION['usr_search_cache'][$this->search_type]['checked'];
$this->failed = (array) $_SESSION['usr_search_cache'][$this->search_type]['failed'];
$this->page_number = $_SESSION['usr_search_cache'][$this->search_type]['page_number'];
$this->setQuery($_SESSION['usr_search_cache'][$this->search_type]['query']);
$this->setRoot((string) $_SESSION['usr_search_cache'][$this->search_type]['root']);
$this->setItemFilter((array) $_SESSION['usr_search_cache'][$this->search_type]['item_filter']);
$this->setMimeFilter((array) $_SESSION['usr_search_cache'][$this->search_type]['mime_filter']);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserSearchCache::save ( )

Save entries.

public

Definition at line 426 of file class.ilUserSearchCache.php.

References $ilDB, $ilLog, $query, $res, getItemFilter(), getMimeFilter(), getQuery(), getRoot(), isAnonymous(), and saveForAnonymous().

{
global $ilDB,$ilLog;
if($this->isAnonymous())
{
return $this->saveForAnonymous();
}
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$ilDB->quote($this->usr_id ,'integer')." ".
"AND ( search_type = ".$ilDB->quote($this->search_type ,'integer').' '.
"OR search_type = ".$ilDB->quote(self::LAST_QUERY,'integer'). ')';
$res = $ilDB->manipulate($query);
$ilDB->insert('usr_search',array(
'usr_id' => array('integer',(int) $this->usr_id),
'search_result' => array('clob',serialize($this->search_result)),
'checked' => array('clob',serialize($this->checked)),
'failed' => array('clob',serialize($this->failed)),
'page' => array('integer',(int) $this->page_number),
'search_type' => array('integer',(int) $this->search_type),
'query' => array('clob',serialize($this->getQuery())),
'root' => array('integer',$this->getRoot()),
'item_filter' => array('text',serialize($this->getItemFilter())),
'mime_filter' => array('text', serialize($this->getMimeFilter()))
));
// Write last query information
$ilDB->insert('usr_search',
array(
'usr_id' => array('integer',$this->usr_id),
'search_type' => array('integer',self::LAST_QUERY),
'query' => array('text',serialize($this->getQuery()))
)
);
}

+ Here is the call graph for this function:

ilUserSearchCache::saveForAnonymous ( )

Definition at line 465 of file class.ilUserSearchCache.php.

References $_SESSION, $checked, $failed, $page_number, $search_result, $search_type, getItemFilter(), getMimeFilter(), getQuery(), getRoot(), and LAST_QUERY.

Referenced by save().

{
unset($_SESSION['usr_search_cache']);
$_SESSION['usr_search_cache'][$this->search_type]['search_result'] = $this->search_result;
$_SESSION['usr_search_cache'][$this->search_type]['checked'] = $this->checked;
$_SESSION['usr_search_cache'][$this->search_type]['failed'] = $this->failed;
$_SESSION['usr_search_cache'][$this->search_type]['page'] = $this->page_number;
$_SESSION['usr_search_cache'][$this->search_type]['query'] = $this->getQuery();
$_SESSION['usr_search_cache'][$this->search_type]['root'] = $this->getRoot();
$_SESSION['usr_search_cache'][$this->search_type]['item_filter'] = $this->getItemFilter();
$_SESSION['usr_search_cache'][$this->search_type]['mime_filter'] = $this->getMimeFilter();
$_SESSION['usr_search_cache'][self::LAST_QUERY]['query'] = $this->getQuery();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserSearchCache::setItemFilter (   $a_filter)

Definition at line 312 of file class.ilUserSearchCache.php.

Referenced by read(), and readAnonymous().

{
$this->item_filter = $a_filter;
}

+ Here is the caller graph for this function:

ilUserSearchCache::setMimeFilter (   $a_filter)

Definition at line 322 of file class.ilUserSearchCache.php.

Referenced by readAnonymous().

{
$this->mime_filter = $a_filter;
}

+ Here is the caller graph for this function:

ilUserSearchCache::setQuery (   $a_query)

set query

Parameters
mixedquery string or array (for advanced search)
Returns

Definition at line 262 of file class.ilUserSearchCache.php.

Referenced by read(), and readAnonymous().

{
$this->query = $a_query;
}

+ Here is the caller graph for this function:

ilUserSearchCache::setResultPageNumber (   $a_number)

Set result page number.

public

Definition at line 238 of file class.ilUserSearchCache.php.

Referenced by deleteCachedEntries(), and deleteCachedEntriesAnonymous().

{
if($a_number)
{
$this->page_number = $a_number;
}
}

+ Here is the caller graph for this function:

ilUserSearchCache::setResults (   $a_results)

Set results.

public

Parameters
array(int=> array(int,int,string)) array(ref_id => array(ref_id,obj_id,type))

Definition at line 151 of file class.ilUserSearchCache.php.

{
$this->search_result = $a_results;
}
ilUserSearchCache::setRoot (   $a_root)

set root node of search

Parameters
introot id
Returns

Definition at line 297 of file class.ilUserSearchCache.php.

Referenced by read(), and readAnonymous().

{
$this->root = $a_root;
}

+ Here is the caller graph for this function:

ilUserSearchCache::switchSearchType (   $a_type)

switch to search type reads entries from database

public

Parameters
intsearch type

Definition at line 126 of file class.ilUserSearchCache.php.

References read().

{
$this->search_type = $a_type;
$this->read();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilUserSearchCache::$checked = array()
private

Definition at line 56 of file class.ilUserSearchCache.php.

Referenced by saveForAnonymous().

ilUserSearchCache::$db
private

Definition at line 50 of file class.ilUserSearchCache.php.

ilUserSearchCache::$failed = array()
private

Definition at line 57 of file class.ilUserSearchCache.php.

Referenced by saveForAnonymous().

ilUserSearchCache::$instance = null
staticprivate

Definition at line 49 of file class.ilUserSearchCache.php.

Referenced by _getInstance().

ilUserSearchCache::$isAnonymous = false
private

Definition at line 64 of file class.ilUserSearchCache.php.

Referenced by isAnonymous().

ilUserSearchCache::$item_filter = array()
private

Definition at line 62 of file class.ilUserSearchCache.php.

Referenced by getItemFilter().

ilUserSearchCache::$mime_filter = array()
private

Definition at line 67 of file class.ilUserSearchCache.php.

Referenced by getMimeFilter().

ilUserSearchCache::$page_number = 1
private

Definition at line 58 of file class.ilUserSearchCache.php.

Referenced by saveForAnonymous().

ilUserSearchCache::$query
private
ilUserSearchCache::$root = ROOT_FOLDER_ID
private

Definition at line 60 of file class.ilUserSearchCache.php.

ilUserSearchCache::$search_result = array()
private

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

Referenced by saveForAnonymous().

ilUserSearchCache::$search_type = self::DEFAULT_SEARCH
private

Definition at line 53 of file class.ilUserSearchCache.php.

Referenced by readAnonymous(), and saveForAnonymous().

ilUserSearchCache::$usr_id
private

Definition at line 52 of file class.ilUserSearchCache.php.

const ilUserSearchCache::ADVANCED_MD_SEARCH = 4

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

Referenced by ilAdvancedSearchGUI\initSearchType().

const ilUserSearchCache::ADVANCED_SEARCH = 1
const ilUserSearchCache::DEFAULT_SEARCH = 0

Definition at line 37 of file class.ilUserSearchCache.php.

Referenced by __construct(), and ilSearchGUI\initUserSearchCache().

const ilUserSearchCache::LAST_QUERY = 7
const ilUserSearchCache::LUCENE_ADVANCED = 6
const ilUserSearchCache::LUCENE_DEFAULT = 5

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

Referenced by ilLuceneSearchGUI\initUserSearchCache().

const ilUserSearchCache::LUCENE_USER_SEARCH = 8
const ilUserSearchCache::SHOP_ADVANCED_SEARCH = 3

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

const ilUserSearchCache::SHOP_CONTENT = 2

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


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