86 if($a_usr_id == ANONYMOUS_USER_ID)
92 $this->usr_id = $a_usr_id;
107 if(is_object(self::$instance) and self::$instance)
109 return self::$instance;
133 $this->search_type = $a_type;
146 return $this->search_result ? $this->search_result : array();
158 $this->search_result = $a_results;
170 $this->search_result[$a_result_item[
'ref_id']][
'ref_id'] = $a_result_item[
'ref_id'];
171 $this->search_result[$a_result_item[
'ref_id']][
'obj_id'] = $a_result_item[
'obj_id'];
172 $this->search_result[$a_result_item[
'ref_id']][
'type'] = $a_result_item[
'type'];
185 $this->failed[$a_ref_id] = $a_ref_id;
197 return in_array($a_ref_id,$this->failed) ? true :
false;
210 $this->checked[$a_ref_id] = $a_obj_id;
222 return array_key_exists($a_ref_id,$this->checked) and $this->checked[$a_ref_id];
234 return $this->checked ? $this->checked : array();
247 $this->page_number = $a_number;
259 return $this->page_number ? $this->page_number : 1;
269 $this->query = $a_query;
292 return urlencode(str_replace(
'"',
'.',
$query[
'lom_content']));
294 return urlencode(str_replace(
'"',
'.', $this->
getQuery()));
304 $this->root = $a_root;
314 return $this->root ? $this->root : ROOT_FOLDER_ID;
319 $this->item_filter = $a_filter;
329 $this->mime_filter = $a_filter;
340 $this->creation_filter = $a_filter;
365 $query =
"SELECT COUNT(*) num FROM usr_search ".
366 "WHERE usr_id = ".$ilDB->quote($this->usr_id,
'integer').
" ".
367 "AND search_type = ".$ilDB->quote($this->search_type,
'integer');
373 $ilDB->update(
'usr_search',
375 'search_result' => array(
'clob',serialize(array(0))),
376 'checked' => array(
'clob',serialize(array(0))),
377 'failed' => array(
'clob',serialize(array(0))),
378 'page' => array(
'integer',0)),
380 'usr_id' => array(
'integer',(
int) $this->usr_id),
381 'search_type' => array(
'integer',(
int) $this->search_type)
386 $ilDB->insert(
'usr_search',
388 'search_result' => array(
'clob',serialize(array(0))),
389 'checked' => array(
'clob',serialize(array(0))),
390 'failed' => array(
'clob',serialize(array(0))),
391 'page' => array(
'integer',0),
392 'usr_id' => array(
'integer',(
int) $this->usr_id),
393 'search_type' => array(
'integer',(
int) $this->search_type)
398 $this->search_result = array();
399 $this->checked = array();
400 $this->failed = array();
410 $this->search_result = array();
411 $this->checked = array();
412 $this->failed = array();
425 public function delete()
429 $query =
"DELETE FROM usr_search ".
430 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
431 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
453 $query =
"DELETE FROM usr_search ".
454 "WHERE usr_id = ".$ilDB->quote($this->usr_id ,
'integer').
" ".
455 "AND ( search_type = ".$ilDB->quote($this->search_type ,
'integer').
' '.
456 "OR search_type = ".$ilDB->quote(self::LAST_QUERY,
'integer').
')';
459 $ilDB->insert(
'usr_search',array(
460 'usr_id' => array(
'integer',(
int) $this->usr_id),
461 'search_result' => array(
'clob',serialize($this->search_result)),
462 'checked' => array(
'clob',serialize($this->checked)),
463 'failed' => array(
'clob',serialize($this->failed)),
464 'page' => array(
'integer',(
int) $this->page_number),
465 'search_type' => array(
'integer',(
int) $this->search_type),
466 'query' => array(
'clob',serialize($this->
getQuery())),
467 'root' => array(
'integer',$this->
getRoot()),
468 'item_filter' => array(
'text',serialize($this->
getItemFilter())),
469 'mime_filter' => array(
'text', serialize($this->
getMimeFilter())),
475 $ilDB->insert(
'usr_search',
477 'usr_id' => array(
'integer',$this->usr_id),
478 'search_type' => array(
'integer',self::LAST_QUERY),
479 'query' => array(
'text',serialize($this->
getQuery()))
513 $this->failed = array();
514 $this->checked = array();
515 $this->search_result = array();
516 $this->page_number = 0;
523 $query =
"SELECT * FROM usr_search ".
524 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
525 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
530 $this->search_result = unserialize(stripslashes(
$row->search_result));
531 if(strlen(
$row->checked))
533 $this->checked = unserialize(stripslashes(
$row->checked));
535 if(strlen(
$row->failed))
537 $this->failed = unserialize(stripslashes(
$row->failed));
539 $this->page_number =
$row->page;
553 $this->search_result = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'search_result'];
554 $this->checked = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'checked'];
555 $this->failed = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'failed'];
559 $this->
setRoot((
string)
$_SESSION[
'usr_search_cache'][$this->search_type][
'root']);
setQuery($a_query)
set query
isChecked($a_ref_id)
Check if reference was already checked.
addResult($a_result_item)
Append result.
__construct($a_usr_id)
Constructor.
getCheckedItems()
Get all checked items.
deleteCachedEntries()
delete cached entries
setCreationFilter($a_filter)
switchSearchType($a_type)
switch to search type reads entries from database
deleteCachedEntriesAnonymous()
Delete cached entries for anonymous user.
readAnonymous()
Read from session for anonymous user.
getResultPageNumber()
get result page number
const DB_FETCHMODE_OBJECT
getUrlEncodedQuery()
Urlencode query for further use in e.g glossariers (highlighting off search terms).
static _getInstance($a_usr_id)
Get singleton instance.
setResults($a_results)
Set results.
setRoot($a_root)
set root node of search
isFailed($a_ref_id)
check if reference has failed access
appendToFailed($a_ref_id)
Append failed id.
isAnonymous()
Check if current user is anonymous user.
const SHOP_ADVANCED_SEARCH
Class for storing search result.
appendToChecked($a_ref_id, $a_obj_id)
Append checked id.
setResultPageNumber($a_number)
Set result page number.