75 if($a_usr_id == ANONYMOUS_USER_ID)
81 $this->usr_id = $a_usr_id;
96 if(is_object(self::$instance) and self::$instance)
122 $this->search_type = $a_type;
135 return $this->search_result ? $this->search_result : array();
147 $this->search_result = $a_results;
159 $this->search_result[$a_result_item[
'ref_id']][
'ref_id'] = $a_result_item[
'ref_id'];
160 $this->search_result[$a_result_item[
'ref_id']][
'obj_id'] = $a_result_item[
'obj_id'];
161 $this->search_result[$a_result_item[
'ref_id']][
'type'] = $a_result_item[
'type'];
174 $this->failed[$a_ref_id] = $a_ref_id;
186 return in_array($a_ref_id,$this->failed) ?
true :
false;
199 $this->checked[$a_ref_id] = $a_obj_id;
211 return array_key_exists($a_ref_id,$this->checked) and $this->checked[$a_ref_id];
223 return $this->checked ? $this->checked : array();
236 $this->page_number = $a_number;
248 return $this->page_number ? $this->page_number : 1;
258 $this->query = $a_query;
281 return urlencode(str_replace(
'"',
'.',
$query[
'lom_content']));
283 return urlencode(str_replace(
'"',
'.', $this->
getQuery()));
293 $this->root = $a_root;
303 return $this->root ? $this->root : ROOT_FOLDER_ID;
308 $this->item_filter = $a_filter;
331 $query =
"SELECT COUNT(*) num FROM usr_search ".
332 "WHERE usr_id = ".$ilDB->quote($this->usr_id,
'integer').
" ".
333 "AND search_type = ".$ilDB->quote($this->search_type,
'integer');
339 $ilDB->update(
'usr_search',
341 'search_result' => array(
'clob',serialize(array(0))),
342 'checked' => array(
'clob',serialize(array(0))),
343 'failed' => array(
'clob',serialize(array(0))),
344 'page' => array(
'integer',0)),
346 'usr_id' => array(
'integer',(
int) $this->usr_id),
347 'search_type' => array(
'integer',(
int) $this->search_type)
352 $ilDB->insert(
'usr_search',
354 'search_result' => array(
'clob',serialize(array(0))),
355 'checked' => array(
'clob',serialize(array(0))),
356 'failed' => array(
'clob',serialize(array(0))),
357 'page' => array(
'integer',0),
358 'usr_id' => array(
'integer',(
int) $this->usr_id),
359 'search_type' => array(
'integer',(
int) $this->search_type)
364 $this->search_result = array();
365 $this->checked = array();
366 $this->failed = array();
376 $this->search_result = array();
377 $this->checked = array();
378 $this->failed = array();
391 public function delete()
395 $query =
"DELETE FROM usr_search ".
396 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
397 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
419 $query =
"DELETE FROM usr_search ".
420 "WHERE usr_id = ".$ilDB->quote($this->usr_id ,
'integer').
" ".
421 "AND ( search_type = ".$ilDB->quote($this->search_type ,
'integer').
' '.
422 "OR search_type = ".$ilDB->quote(self::LAST_QUERY,
'integer').
')';
425 $ilDB->insert(
'usr_search',array(
426 'usr_id' => array(
'integer',(
int) $this->usr_id),
427 'search_result' => array(
'clob',serialize($this->search_result)),
428 'checked' => array(
'clob',serialize($this->checked)),
429 'failed' => array(
'clob',serialize($this->failed)),
430 'page' => array(
'integer',(
int) $this->page_number),
431 'search_type' => array(
'integer',(
int) $this->search_type),
432 'query' => array(
'clob',serialize($this->
getQuery())),
433 'root' => array(
'integer',$this->
getRoot()),
434 'item_filter' => array(
'text',serialize($this->
getItemFilter()))));
438 $ilDB->insert(
'usr_search',
440 'usr_id' => array(
'integer',$this->usr_id),
441 'search_type' => array(
'integer',self::LAST_QUERY),
442 'query' => array(
'text',serialize($this->
getQuery()))
474 $this->failed = array();
475 $this->checked = array();
476 $this->search_result = array();
477 $this->page_number = 0;
484 $query =
"SELECT * FROM usr_search ".
485 "WHERE usr_id = ".$this->db->quote($this->usr_id ,
'integer').
" ".
486 "AND search_type = ".$this->db->quote($this->search_type ,
'integer');
491 $this->search_result = unserialize(stripslashes(
$row->search_result));
492 if(strlen(
$row->checked))
494 $this->checked = unserialize(stripslashes(
$row->checked));
496 if(strlen(
$row->failed))
498 $this->failed = unserialize(stripslashes(
$row->failed));
500 $this->page_number =
$row->page;
513 $this->search_result = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'search_result'];
514 $this->checked = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'checked'];
515 $this->failed = (array)
$_SESSION[
'usr_search_cache'][$this->search_type][
'failed'];
518 $this->
setQuery((
string)
$_SESSION[
'usr_search_cache'][$this->search_type][
'query']);
519 $this->
setRoot((
string)
$_SESSION[
'usr_search_cache'][$this->search_type][
'root']);