84 if ($a_usr_id == ANONYMOUS_USER_ID) {
89 $this->usr_id = $a_usr_id;
104 if (is_object(self::$instance) and self::$instance) {
142 return $this->search_result ? $this->search_result : array();
154 $this->search_result = $a_results;
166 $this->search_result[$a_result_item[
'ref_id']][
'ref_id'] = $a_result_item[
'ref_id'];
167 $this->search_result[$a_result_item[
'ref_id']][
'obj_id'] = $a_result_item[
'obj_id'];
168 $this->search_result[$a_result_item[
'ref_id']][
'type'] = $a_result_item[
'type'];
181 $this->failed[$a_ref_id] = $a_ref_id;
193 return in_array($a_ref_id, $this->failed) ? true :
false;
206 $this->checked[$a_ref_id] = $a_obj_id;
218 return array_key_exists($a_ref_id, $this->checked) and $this->checked[$a_ref_id];
230 return $this->checked ? $this->checked : array();
242 $this->page_number = $a_number;
254 return $this->page_number ? $this->page_number : 1;
264 $this->query = $a_query;
286 return urlencode(str_replace(
'"',
'.',
$query[
'lom_content']));
288 return urlencode(str_replace(
'"',
'.', $this->
getQuery()));
298 $this->root = $a_root;
308 return $this->root ? $this->root : ROOT_FOLDER_ID;
313 $this->item_filter = $a_filter;
323 $this->mime_filter = $a_filter;
334 $this->creation_filter = $a_filter;
358 $query =
"SELECT COUNT(*) num FROM usr_search " .
359 "WHERE usr_id = " . $ilDB->quote($this->usr_id,
'integer') .
" " .
360 "AND search_type = " .
$ilDB->quote($this->search_type,
'integer');
368 'search_result' => array(
'clob',serialize(array(0))),
369 'checked' => array(
'clob',serialize(array(0))),
370 'failed' => array(
'clob',serialize(array(0))),
371 'page' => array(
'integer',0)),
373 'usr_id' => array(
'integer',(
int) $this->usr_id),
374 'search_type' => array(
'integer',(
int) $this->search_type)
381 'search_result' => array(
'clob',serialize(array(0))),
382 'checked' => array(
'clob',serialize(array(0))),
383 'failed' => array(
'clob',serialize(array(0))),
384 'page' => array(
'integer',0),
385 'usr_id' => array(
'integer',(
int) $this->usr_id),
386 'search_type' => array(
'integer',(
int) $this->search_type)
392 $this->search_result = array();
393 $this->checked = array();
394 $this->failed = array();
404 $this->search_result = array();
405 $this->checked = array();
406 $this->failed = array();
419 public function delete()
423 $query =
"DELETE FROM usr_search " .
424 "WHERE usr_id = " . $this->db->quote($this->usr_id,
'integer') .
" " .
425 "AND search_type = " . $this->db->quote($this->search_type,
'integer');
446 $query =
"DELETE FROM usr_search " .
447 "WHERE usr_id = " . $ilDB->quote($this->usr_id,
'integer') .
" " .
448 "AND ( search_type = " .
$ilDB->quote($this->search_type,
'integer') .
' ' .
449 "OR search_type = " .
$ilDB->quote(self::LAST_QUERY,
'integer') .
')';
452 $ilDB->insert(
'usr_search', array(
453 'usr_id' => array(
'integer',(
int) $this->usr_id),
454 'search_result' => array(
'clob',serialize($this->search_result)),
455 'checked' => array(
'clob',serialize($this->checked)),
456 'failed' => array(
'clob',serialize($this->failed)),
457 'page' => array(
'integer',(
int) $this->page_number),
458 'search_type' => array(
'integer',(
int) $this->search_type),
459 'query' => array(
'clob',serialize($this->
getQuery())),
460 'root' => array(
'integer',$this->
getRoot()),
461 'item_filter' => array(
'text',serialize($this->
getItemFilter())),
462 'mime_filter' => array(
'text', serialize($this->
getMimeFilter())),
471 'usr_id' => array(
'integer',$this->usr_id),
472 'search_type' => array(
'integer',self::LAST_QUERY),
473 'query' => array(
'text',serialize($this->
getQuery()))
506 $this->failed = array();
507 $this->checked = array();
508 $this->search_result = array();
509 $this->page_number = 0;
515 $query =
"SELECT * FROM usr_search " .
516 "WHERE usr_id = " . $this->db->quote($this->usr_id,
'integer') .
" " .
517 "AND search_type = " . $this->db->quote($this->search_type,
'integer');
521 $this->search_result = unserialize(stripslashes(
$row->search_result));
522 if (strlen(
$row->checked)) {
523 $this->checked = unserialize(stripslashes(
$row->checked));
525 if (strlen(
$row->failed)) {
526 $this->failed = unserialize(stripslashes(
$row->failed));
528 $this->page_number =
$row->page;
542 $this->search_result = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'search_result'];
543 $this->checked = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'checked'];
544 $this->failed = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'failed'];
548 $this->
setRoot((
string)
$_SESSION[
'usr_search_cache'][$this->search_type][
'root']);
An exception for terminatinating execution or to throw for unit testing.
Class for storing search result.
addResult($a_result_item)
Append result.
deleteCachedEntriesAnonymous()
Delete cached entries for anonymous user.
isChecked($a_ref_id)
Check if reference was already checked.
readAnonymous()
Read from session for anonymous user.
getCheckedItems()
Get all checked items.
getResultPageNumber()
get result page number
switchSearchType($a_type)
switch to search type reads entries from database
appendToChecked($a_ref_id, $a_obj_id)
Append checked id.
setRoot($a_root)
set root node of search
getUrlEncodedQuery()
Urlencode query for further use in e.g glossariers (highlighting off search terms).
appendToFailed($a_ref_id)
Append failed id.
isFailed($a_ref_id)
check if reference has failed access
setResults($a_results)
Set results.
deleteCachedEntries()
delete cached entries
setQuery($a_query)
set query
static _getInstance($a_usr_id)
Get singleton instance.
isAnonymous()
Check if current user is anonymous user.
setCreationFilter($a_filter)
__construct($a_usr_id)
Constructor.
setResultPageNumber($a_number)
Set result page number.
foreach($_POST as $key=> $value) $res