ILIAS  Release_3_10_x_branch Revision 61812
 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
 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

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

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 61 of file class.ilUserSearchCache.php.

References 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 79 of file class.ilUserSearchCache.php.

References $instance.

Referenced by ilSearchResultPresentationGUI\ilSearchResultPresentationGUI(), 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 133 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 173 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 148 of file class.ilUserSearchCache.php.

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

Delete user entries.

public

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

References $res, and read().

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

+ 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 197 of file class.ilUserSearchCache.php.

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

get result page number

public

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

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

Get results.

public

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

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

Check if reference was already checked.

public

Parameters
intref_id

Definition at line 185 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 160 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 279 of file class.ilUserSearchCache.php.

References $res, and DB_FETCHMODE_OBJECT.

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)." ".
"AND search_type = ".$this->db->quote($this->search_type);
$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;
}
return true;
}

+ Here is the caller graph for this function:

ilUserSearchCache::save ( )

Save entries.

public

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

References $res.

{
if($this->usr_id == ANONYMOUS_USER_ID)
{
return false;
}
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id)." ".
"AND search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
$query = "INSERT INTO usr_search ".
"SET usr_id = ".$this->db->quote($this->usr_id).", ".
"search_result = '".addslashes(serialize($this->search_result))."', ".
"checked = '".addslashes(serialize($this->checked))."', ".
"failed = '".addslashes(serialize($this->failed))."', ".
"page = ".$this->db->quote($this->page_number).", ".
"search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
}
ilUserSearchCache::setResultPageNumber (   $a_number)

Set result page number.

public

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

{
if($a_number)
{
$this->page_number = $a_number;
}
}
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 121 of file class.ilUserSearchCache.php.

{
$this->search_result = $a_results;
}
ilUserSearchCache::switchSearchType (   $a_type)

switch to search type reads entries from database

public

Parameters
intsearch type

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

ilUserSearchCache::$db
private

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

ilUserSearchCache::$failed = array()
private

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

ilUserSearchCache::$instance = null
staticprivate

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

Referenced by _getInstance().

ilUserSearchCache::$page_number = 1
private

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

ilUserSearchCache::$search_result = array()
private

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

ilUserSearchCache::$search_type = self::DEFAULT_SEARCH
private

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

ilUserSearchCache::$usr_id
private

Definition at line 46 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::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: