86 if ($a_usr_id == ANONYMOUS_USER_ID) {
91 $this->usr_id = $a_usr_id;
106 if (is_object(self::$instance)
and self::$instance) {
107 return self::$instance;
144 return $this->search_result ? $this->search_result : array();
156 $this->search_result = $a_results;
168 $this->search_result[$a_result_item[
'ref_id']][
'ref_id'] = $a_result_item[
'ref_id'];
169 $this->search_result[$a_result_item[
'ref_id']][
'obj_id'] = $a_result_item[
'obj_id'];
170 $this->search_result[$a_result_item[
'ref_id']][
'type'] = $a_result_item[
'type'];
183 $this->failed[$a_ref_id] = $a_ref_id;
195 return in_array($a_ref_id, $this->failed) ? true :
false;
208 $this->checked[$a_ref_id] = $a_obj_id;
220 return array_key_exists($a_ref_id, $this->checked)
and $this->checked[$a_ref_id];
232 return $this->checked ? $this->checked : array();
244 $this->page_number = $a_number;
256 return $this->page_number ? $this->page_number : 1;
266 $this->query = $a_query;
288 return urlencode(str_replace(
'"',
'.',
$query[
'lom_content']));
290 return urlencode(str_replace(
'"',
'.', $this->
getQuery()));
300 $this->root = $a_root;
310 return $this->root ? $this->root : ROOT_FOLDER_ID;
315 $this->item_filter = $a_filter;
325 $this->mime_filter = $a_filter;
336 $this->creation_filter = $a_filter;
355 $ilDB = $DIC[
'ilDB'];
362 $query =
"SELECT COUNT(*) num FROM usr_search " .
363 "WHERE usr_id = " .
$ilDB->quote($this->usr_id,
'integer') .
" " .
364 "AND search_type = " .
$ilDB->quote($this->search_type,
'integer');
372 'search_result' => array(
'clob',serialize(array(0))),
373 'checked' => array(
'clob',serialize(array(0))),
374 'failed' => array(
'clob',serialize(array(0))),
375 'page' => array(
'integer',0)),
377 'usr_id' => array(
'integer',(
int) $this->usr_id),
378 'search_type' => array(
'integer',(
int) $this->search_type)
385 'search_result' => array(
'clob',serialize(array(0))),
386 'checked' => array(
'clob',serialize(array(0))),
387 'failed' => array(
'clob',serialize(array(0))),
388 'page' => array(
'integer',0),
389 'usr_id' => array(
'integer',(
int) $this->usr_id),
390 'search_type' => array(
'integer',(
int) $this->search_type)
396 $this->search_result = array();
397 $this->checked = array();
398 $this->failed = array();
408 $this->search_result = array();
409 $this->checked = array();
410 $this->failed = array();
423 public function delete()
427 $ilDB = $DIC[
'ilDB'];
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');
448 $ilDB = $DIC[
'ilDB'];
454 $query =
"DELETE FROM usr_search " .
455 "WHERE usr_id = " .
$ilDB->quote($this->usr_id,
'integer') .
" " .
456 "AND ( search_type = " .
$ilDB->quote($this->search_type,
'integer') .
' ' .
457 "OR search_type = " .
$ilDB->quote(self::LAST_QUERY,
'integer') .
')';
460 $ilDB->insert(
'usr_search', array(
461 'usr_id' => array(
'integer',(
int) $this->usr_id),
462 'search_result' => array(
'clob',serialize($this->search_result)),
463 'checked' => array(
'clob',serialize($this->checked)),
464 'failed' => array(
'clob',serialize($this->failed)),
465 'page' => array(
'integer',(
int) $this->page_number),
466 'search_type' => array(
'integer',(
int) $this->search_type),
467 'query' => array(
'clob',serialize($this->
getQuery())),
468 'root' => array(
'integer',$this->
getRoot()),
469 'item_filter' => array(
'text',serialize($this->
getItemFilter())),
470 'mime_filter' => array(
'text', serialize($this->
getMimeFilter())),
479 'usr_id' => array(
'integer',$this->usr_id),
480 'search_type' => array(
'integer',self::LAST_QUERY),
481 'query' => array(
'text',serialize($this->
getQuery()))
514 $this->failed = array();
515 $this->checked = array();
516 $this->search_result = array();
517 $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');
529 $this->search_result = unserialize(stripslashes(
$row->search_result));
530 if (strlen(
$row->checked)) {
531 $this->checked = unserialize(stripslashes(
$row->checked));
533 if (strlen(
$row->failed)) {
534 $this->failed = unserialize(stripslashes(
$row->failed));
536 $this->page_number =
$row->page;
550 $this->search_result = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'search_result'];
551 $this->checked = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'checked'];
552 $this->failed = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'failed'];
556 $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
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.
foreach($_POST as $key=> $value) $res
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.
Class for storing search result.
appendToChecked($a_ref_id, $a_obj_id)
Append checked id.
setResultPageNumber($a_number)
Set result page number.