ILIAS  Release_4_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

 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
 setRoot ($a_root)
 set root node of search
 getRoot ()
 get root node
 setItemFilter ($a_filter)
 getItemFilter ()
 deleteCachedEntries ()
 delete cached entries
 delete ()
 Delete user entries.
 save ()
 Save entries.

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

Private Member Functions

 __construct ($a_usr_id)
 Constructor.
 read ()
 Read user entries.

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()

Static Private Attributes

static $instance = null

Detailed Description

Class for storing search result.

Allows paging of result sets

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
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 67 of file class.ilUserSearchCache.php.

References $ilDB, DEFAULT_SEARCH, and read().

{
global $ilDB;
$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

static ilUserSearchCache::_getInstance (   $a_usr_id)
static

Get singleton instance.

public

Parameters
intusr_id

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

References $instance.

Referenced by ilLuceneSearchResultFilter\__construct(), ilShopResultPresentationGUI\ilShopResultPresentationGUI(), ilLuceneAdvancedSearchGUI\initUserSearchCache(), ilLuceneSearchGUI\initUserSearchCache(), ilSearchResult\initUserSearchCache(), ilSearchGUI\initUserSearchCache(), and ilAdvancedSearchGUI\initUserSearchCache().

{
if(is_object(self::$instance) and self::$instance)
{
}
return self::$instance = new ilUserSearchCache($a_usr_id);
}

+ Here is the caller graph for this function:

ilUserSearchCache::addResult (   $a_result_item)

Append result.

public

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

Definition at line 139 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 179 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 154 of file class.ilUserSearchCache.php.

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

Delete user entries.

public

Definition at line 337 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 288 of file class.ilUserSearchCache.php.

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

{
global $ilDB;
$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::getCheckedItems ( )

Get all checked items.

public

Returns
array array(ref_id => obj_id)

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

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

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

References $item_filter.

Referenced by save().

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

+ Here is the caller graph for this function:

ilUserSearchCache::getQuery ( )

get query

Returns

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

References $query.

Referenced by save().

{
return $this->query;
}

+ Here is the caller graph for this function:

ilUserSearchCache::getResultPageNumber ( )

get result page number

public

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

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

Get results.

public

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

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

get root node

Returns

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

Referenced by save().

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

+ 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 191 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 166 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 397 of file class.ilUserSearchCache.php.

References $_SESSION, $query, $res, $row, DB_FETCHMODE_OBJECT, 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->usr_id == ANONYMOUS_USER_ID)
{
return false;
}
$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);
}
// Item filter
if($_SESSION['lucene_item_filter'])
{
$this->setItemFilter(unserialize($_SESSION['lucene_item_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 356 of file class.ilUserSearchCache.php.

References $_SESSION, $ilDB, $ilLog, $query, $res, getItemFilter(), getQuery(), and getRoot().

{
global $ilDB,$ilLog;
if($this->usr_id == ANONYMOUS_USER_ID)
{
return false;
}
if(!$this->usr_id) $this->usr_id = 0;
if(!$this->page_number) $this->page_number = 0;
if(!$this->search_type) $this->search_type = 0;
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$ilDB->quote($this->usr_id ,'integer')." ".
"AND search_type = ".$ilDB->quote($this->search_type ,'integer');
$res = $ilDB->manipulate($query);
$ilDB->insert('usr_search',array(
'usr_id' => array('integer',$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',$this->page_number),
'search_type' => array('integer',$this->search_type),
'query' => array('clob',serialize($this->getQuery())),
'root' => array('integer',$this->getRoot())));
#if($this->getItemFilter())
{
$_SESSION['lucene_item_filter'] = serialize($this->getItemFilter());
}
}

+ Here is the call graph for this function:

ilUserSearchCache::setItemFilter (   $a_filter)

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

Referenced by read().

{
$this->item_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 238 of file class.ilUserSearchCache.php.

Referenced by read().

{
$this->query = $a_query;
}

+ Here is the caller graph for this function:

ilUserSearchCache::setResultPageNumber (   $a_number)

Set result page number.

public

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

Referenced by deleteCachedEntries().

{
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 127 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 258 of file class.ilUserSearchCache.php.

Referenced by read().

{
$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 102 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 52 of file class.ilUserSearchCache.php.

ilUserSearchCache::$db
private

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

ilUserSearchCache::$failed = array()
private

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

ilUserSearchCache::$instance = null
staticprivate

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

Referenced by _getInstance().

ilUserSearchCache::$item_filter = array()
private

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

Referenced by getItemFilter().

ilUserSearchCache::$page_number = 1
private

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

ilUserSearchCache::$query
private

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

Referenced by delete(), deleteCachedEntries(), getQuery(), read(), and save().

ilUserSearchCache::$root = ROOT_FOLDER_ID
private

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

ilUserSearchCache::$search_result = array()
private

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

ilUserSearchCache::$search_type = self::DEFAULT_SEARCH
private

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

ilUserSearchCache::$usr_id
private

Definition at line 48 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().

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::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: