81 if($a_usr_id == ANONYMOUS_USER_ID)
87 $this->usr_id = $a_usr_id;
102 if(is_object(self::$instance) and self::$instance)
128 $this->search_type = $a_type;
141 return $this->search_result ? $this->search_result : array();
153 $this->search_result = $a_results;
165 $this->search_result[$a_result_item[
'ref_id']][
'ref_id'] = $a_result_item[
'ref_id'];
166 $this->search_result[$a_result_item[
'ref_id']][
'obj_id'] = $a_result_item[
'obj_id'];
167 $this->search_result[$a_result_item[
'ref_id']][
'type'] = $a_result_item[
'type'];
180 $this->failed[$a_ref_id] = $a_ref_id;
192 return in_array($a_ref_id,$this->failed) ?
true :
false;
205 $this->checked[$a_ref_id] = $a_obj_id;
217 return array_key_exists($a_ref_id,$this->checked) and $this->checked[$a_ref_id];
229 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;
287 return urlencode(str_replace(
'"',
'.',
$query[
'lom_content']));
289 return urlencode(str_replace(
'"',
'.', $this->
getQuery()));
299 $this->root = $a_root;
309 return $this->root ? $this->root : ROOT_FOLDER_ID;
314 $this->item_filter = $a_filter;
324 $this->mime_filter = $a_filter;
347 $query =
"SELECT COUNT(*) num FROM usr_search ".
348 "WHERE usr_id = ".$ilDB->quote($this->usr_id,
'integer').
" ".
349 "AND search_type = ".$ilDB->quote($this->search_type,
'integer');
355 $ilDB->update(
'usr_search',
357 'search_result' => array(
'clob',serialize(array(0))),
358 'checked' => array(
'clob',serialize(array(0))),
359 'failed' => array(
'clob',serialize(array(0))),
360 'page' => array(
'integer',0)),
362 'usr_id' => array(
'integer',(
int) $this->usr_id),
363 'search_type' => array(
'integer',(
int) $this->search_type)
368 $ilDB->insert(
'usr_search',
370 'search_result' => array(
'clob',serialize(array(0))),
371 'checked' => array(
'clob',serialize(array(0))),
372 'failed' => array(
'clob',serialize(array(0))),
373 'page' => array(
'integer',0),
374 'usr_id' => array(
'integer',(
int) $this->usr_id),
375 'search_type' => array(
'integer',(
int) $this->search_type)
380 $this->search_result = array();
381 $this->checked = array();
382 $this->failed = array();
392 $this->search_result = array();
393 $this->checked = array();
394 $this->failed = array();
407 public function delete()
411 $query =
"DELETE FROM usr_search ".
412 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
413 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
435 $query =
"DELETE FROM usr_search ".
436 "WHERE usr_id = ".$ilDB->quote($this->usr_id ,
'integer').
" ".
437 "AND ( search_type = ".$ilDB->quote($this->search_type ,
'integer').
' '.
438 "OR search_type = ".$ilDB->quote(self::LAST_QUERY,
'integer').
')';
441 $ilDB->insert(
'usr_search',array(
442 'usr_id' => array(
'integer',(
int) $this->usr_id),
443 'search_result' => array(
'clob',serialize($this->search_result)),
444 'checked' => array(
'clob',serialize($this->checked)),
445 'failed' => array(
'clob',serialize($this->failed)),
446 'page' => array(
'integer',(
int) $this->page_number),
447 'search_type' => array(
'integer',(
int) $this->search_type),
448 'query' => array(
'clob',serialize($this->
getQuery())),
449 'root' => array(
'integer',$this->
getRoot()),
450 'item_filter' => array(
'text',serialize($this->
getItemFilter())),
451 'mime_filter' => array(
'text', serialize($this->
getMimeFilter()))
456 $ilDB->insert(
'usr_search',
458 'usr_id' => array(
'integer',$this->usr_id),
459 'search_type' => array(
'integer',self::LAST_QUERY),
460 'query' => array(
'text',serialize($this->
getQuery()))
493 $this->failed = array();
494 $this->checked = array();
495 $this->search_result = array();
496 $this->page_number = 0;
503 $query =
"SELECT * FROM usr_search ".
504 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
505 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
510 $this->search_result = unserialize(stripslashes(
$row->search_result));
511 if(strlen(
$row->checked))
513 $this->checked = unserialize(stripslashes(
$row->checked));
515 if(strlen(
$row->failed))
517 $this->failed = unserialize(stripslashes(
$row->failed));
519 $this->page_number =
$row->page;
532 $this->search_result = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'search_result'];
533 $this->checked = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'checked'];
534 $this->failed = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'failed'];
538 $this->
setRoot((
string)
$_SESSION[
'usr_search_cache'][$this->search_type][
'root']);