5 include_once
'./Services/Search/classes/class.ilQueryParser.php';
54 $this->lng->loadLanguageModule(
"search");
56 $this->user_id = $a_user_id;
60 $this->read_db_result = $a_read;
63 #$this->__readDBResult(); 69 $this->search_string = trim($a_search_str);
74 $this->combination = $a_combination;
78 $this->search_for = $a_search_for;
82 $this->search_in = $a_search_in;
86 $this->result = $a_result;
94 $this->perform_update = $a_value;
98 $this->allow_empty_search = $a_value;
103 $this->min_word_length = $a_min_word_length;
121 return $this->combination ? $this->combination :
"or";
125 return $this->search_for ? $this->search_for : array();
129 return $this->search_in ? $this->search_in : array();
134 return $this->search_in[
$a_type];
141 return $this->result ? $this->result : array();
167 $number += count($tmp_res[
"meta"]) + count($tmp_res[
"content"]);
170 $number += count($tmp_res[
"meta"]) + count($tmp_res[
"content"]);
179 if (!$this->qp->validate()) {
190 $objDefinition = $DIC[
'objDefinition'];
193 $ilBench->start(
"Search",
"performSearch");
197 $result = array(
"usr" => array(),
234 $ilBench->stop(
"Search",
"performSearch");
245 $this->parsed_str[
"and"] = $this->parsed_str[
"or"] = $this->parsed_str[
"not"] = array();
247 foreach ($tmp_arr as $word) {
248 #$word = trim($word); 251 if (substr($word, 0, 1) ==
'+') {
252 $this->parsed_str[
"all"][] = substr($word, 1);
253 $this->parsed_str[
"and"][] = substr($word, 1);
257 if (substr($word, 0, 1) ==
'-') {
259 #$this->parsed_str["all"][] = substr($word,1); 260 $this->parsed_str[
"not"][] = substr($word, 1);
265 $this->parsed_str[
"all"][] = $word;
266 $this->parsed_str[
"and"][] = $word;
271 $this->parsed_str[
"all"][] = $word;
272 $this->parsed_str[
"or"][] = $word;
283 $ilDB = $DIC[
'ilDB'];
286 $ilDB->manipulate(
"DELETE FROM usr_search " .
287 "WHERE usr_id = " .
$ilDB->quote($this->getUserId(),
'integer') .
" " .
288 "AND search_type = 0 ");
290 $ilDB->insert(
'usr_search', array(
291 'usr_id' => array(
'integer',$this->
getUserId()),
292 'search_result' => array(
'clob',serialize($this->
getResults())),
293 'checked' => array(
'clob',serialize(array())),
294 'failed' => array(
'clob',serialize(array())),
295 'page' => array(
'integer',0),
296 'search_type' => array(
'integer',0),
297 'query' => array(
'text',
''),
298 'root' => array(
'integer',ROOT_FOLDER_ID)));
310 $ilDB = $DIC[
'ilDB'];
313 $query =
"SELECT search_result FROM usr_search " .
318 if (
$res->numRows()) {
320 $this->
setResult(unserialize(stripslashes(
$row->search_result)));
344 $ilAccess = $DIC[
'ilAccess'];
346 if (is_array($a_results)) {
347 foreach ($a_results as
$result) {
348 if ($ilAccess->checkAccess(
'read',
'', $result[
'id'])) {
354 return $checked_result ? $checked_result : array();
362 $tree = $DIC[
'tree'];
364 $new_result = array();
369 $this->result[
'lm'][
'meta'] = $this->
__checkAccess($this->result[
'lm'][
'meta'],
'lm');
370 if (is_array($this->result[
'lm'][
'meta'])) {
371 foreach ($this->result[
'lm'][
'meta'] as
$data) {
372 if (
$tree->isInTree($data[
'id'])) {
373 $new_result[
'lm'][
'meta'][] =
$data;
377 $this->result[
'lm'][
'content'] = $this->
__checkAccess($this->result[
'lm'][
'content'],
'lm');
378 if (is_array($this->result[
'lm'][
'content'])) {
379 foreach ($this->result[
'lm'][
'content'] as
$data) {
380 if (
$tree->isInTree($data[
'id'])) {
381 $new_result[
'lm'][
'content'][] =
$data;
385 $this->result[
'dbk'][
'meta'] = $this->
__checkAccess($this->result[
'dbk'][
'meta'],
'dbk');
386 if (is_array($this->result[
'dbk'][
'meta'])) {
387 foreach ($this->result[
'dbk'][
'meta'] as
$data) {
388 if (
$tree->isInTree($data[
'id'])) {
389 $new_result[
'dbk'][
'meta'][] =
$data;
393 $this->result[
'dbk'][
'content'] = $this->
__checkAccess($this->result[
'dbk'][
'content'],
'dbk');
394 if (is_array($this->result[
'dbk'][
'content'])) {
395 foreach ($this->result[
'dbk'][
'content'] as
$data) {
396 if (
$tree->isInTree($data[
'id'])) {
397 $new_result[
'dbk'][
'content'][] =
$data;
401 $this->result[
'grp'] = $this->
__checkAccess($this->result[
'grp'],
'grp');
402 if (is_array($this->result[
'grp'])) {
403 foreach ($this->result[
'grp'] as
$data) {
404 if (
$tree->isInTree($data[
'id'])) {
405 $new_result[
'grp'][] =
$data;
409 if (is_array($this->result[
'usr'])) {
410 foreach ($this->result[
'usr'] as
$user) {
412 $new_result[
'usr'][] =
$user;
416 if (is_array($this->result[
'role'])) {
417 foreach ($this->result[
'role'] as
$user) {
419 $new_result[
'role'][] =
$user;
430 $word = trim($a_word);
432 if (!preg_match(
'/\*/', $word)) {
433 return '%' . $word .
'%';
435 if (preg_match(
'/^\*/', $word)) {
436 return str_replace(
'*',
'%', $word);
438 return '% ' . str_replace(
'*',
'%', $word);
448 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
453 foreach (array(
"login",
"firstname",
"lastname",
"title",
454 "email",
"institution",
"street",
"city",
"zipcode",
"country",
"phone_home",
"fax") as $field) {
455 $user_search->setFields(array($field));
456 $tmp_res = $user_search->performSearch();
458 $res->mergeEntries($tmp_res);
474 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
476 $object_search->setFilter(array(
$a_type));
477 $res = $object_search->performSearch();
481 foreach (
$res->getResultIds() as
$id) {
482 $objs[$counter++][
'id'] =
$id;
484 return $objs ? $objs : array();
495 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
497 $object_search->setFilter(array(
'role'));
499 $res = $object_search->performSearch();
504 return $roles ? $roles : array();
setSearchString($a_search_str)
setMinWordLength($a_min_word_length)
__checkAccess($a_results, $a_type)
performUserSearch()
perform a search for users
if(!array_key_exists('StateId', $_REQUEST)) $id
catch(Exception $e) $message
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
performObjectSearch($a_type)
perform object search
foreach($_POST as $key=> $value) $res
redirection script todo: (a better solution should control the processing via a xml file) ...
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
setCombination($a_combination)
setSearchIn($a_search_in)
setPerformUpdate($a_value)
setSearchFor($a_search_for)
__construct($a_user_id=0, $a_read=false)
Constructor public.
getSearchInByType($a_type)
initQueryParser()
init query parser