5include_once 
'./Services/Search/classes/class.ilQueryParser.php';
 
   50        $this->lng->loadLanguageModule(
"search");
 
   52        $this->user_id = $a_user_id;
 
   56        $this->read_db_result = $a_read;
 
   59        #$this->__readDBResult(); 
   65        $this->search_string = trim($a_search_str);
 
   70        $this->combination = $a_combination;
 
   74        $this->search_for = $a_search_for;
 
   78        $this->search_in = $a_search_in;
 
   82        $this->result = $a_result;
 
   90        $this->perform_update = $a_value;
 
   94        $this->allow_empty_search = $a_value;
 
   99        $this->min_word_length = $a_min_word_length;
 
  117        return $this->combination ? $this->combination : 
"or";
 
  121        return $this->search_for ? $this->search_for : array();
 
  125        return $this->search_in ? $this->search_in : array();
 
  130            return $this->search_in[
$a_type];
 
  137        return $this->result ? $this->result : array();
 
  163        $number += count($tmp_res[
"meta"]) + count($tmp_res[
"content"]);
 
  166        $number += count($tmp_res[
"meta"]) + count($tmp_res[
"content"]);
 
  175        if (!$this->qp->validate()) {
 
  186        $ilBench->start(
"Search", 
"performSearch");
 
  190        $result = array(
"usr" => array(),
 
  227        $ilBench->stop(
"Search", 
"performSearch");
 
  238        $this->parsed_str[
"and"] = $this->parsed_str[
"or"] = $this->parsed_str[
"not"] = array();
 
  240        foreach ($tmp_arr as $word) {
 
  241            #$word = trim($word); 
  244                if (substr($word, 0, 1) == 
'+') {
 
  245                    $this->parsed_str[
"all"][] = substr($word, 1);
 
  246                    $this->parsed_str[
"and"][] = substr($word, 1);
 
  250                if (substr($word, 0, 1) == 
'-') {
 
  252                    #$this->parsed_str["all"][] = substr($word,1);
 
  253                    $this->parsed_str[
"not"][] = substr($word, 1);
 
  258                    $this->parsed_str[
"all"][] = $word;
 
  259                    $this->parsed_str[
"and"][] = $word;
 
  264                    $this->parsed_str[
"all"][] = $word;
 
  265                    $this->parsed_str[
"or"][] = $word;
 
  277            $ilDB->manipulate(
"DELETE FROM usr_search " .
 
  278                "WHERE usr_id = " . 
$ilDB->quote($this->getUserId(), 
'integer') . 
" " .
 
  279                "AND search_type = 0 ");
 
  281            $ilDB->insert(
'usr_search', array(
 
  282                'usr_id'                => array(
'integer',$this->
getUserId()),
 
  283                'search_result' => array(
'clob',serialize($this->
getResults())),
 
  284                'checked'               => array(
'clob',serialize(array())),
 
  285                'failed'                => array(
'clob',serialize(array())),
 
  286                'page'                  => array(
'integer',0),
 
  287                'search_type'   => array(
'integer',0),
 
  288                'query'                 => array(
'text',
''),
 
  289                'root'                  => array(
'integer',ROOT_FOLDER_ID)));
 
  301        if ($this->
getUserId() != 0 and $this->
getUserId() != ANONYMOUS_USER_ID and $this->read_db_result) {
 
  302            $query = 
"SELECT search_result FROM usr_search " .
 
  307            if (
$res->numRows()) {
 
  309                $this->
setResult(unserialize(stripslashes(
$row->search_result)));
 
  333        if (is_array($a_results)) {
 
  334            foreach ($a_results as 
$result) {
 
  335                if ($ilAccess->checkAccess(
'read', 
'', 
$result[
'id'])) {
 
  341        return $checked_result ? $checked_result : array();
 
  349        $new_result = array();
 
  354        $this->result[
'lm'][
'meta'] = $this->
__checkAccess($this->result[
'lm'][
'meta'], 
'lm');
 
  355        if (is_array($this->result[
'lm'][
'meta'])) {
 
  356            foreach ($this->result[
'lm'][
'meta'] as 
$data) {
 
  357                if ($tree->isInTree(
$data[
'id'])) {
 
  358                    $new_result[
'lm'][
'meta'][] = 
$data;
 
  362        $this->result[
'lm'][
'content'] = $this->
__checkAccess($this->result[
'lm'][
'content'], 
'lm');
 
  363        if (is_array($this->result[
'lm'][
'content'])) {
 
  364            foreach ($this->result[
'lm'][
'content'] as 
$data) {
 
  365                if ($tree->isInTree(
$data[
'id'])) {
 
  366                    $new_result[
'lm'][
'content'][] = 
$data;
 
  370        $this->result[
'dbk'][
'meta'] = $this->
__checkAccess($this->result[
'dbk'][
'meta'], 
'dbk');
 
  371        if (is_array($this->result[
'dbk'][
'meta'])) {
 
  372            foreach ($this->result[
'dbk'][
'meta'] as 
$data) {
 
  373                if ($tree->isInTree(
$data[
'id'])) {
 
  374                    $new_result[
'dbk'][
'meta'][] = 
$data;
 
  378        $this->result[
'dbk'][
'content'] = $this->
__checkAccess($this->result[
'dbk'][
'content'], 
'dbk');
 
  379        if (is_array($this->result[
'dbk'][
'content'])) {
 
  380            foreach ($this->result[
'dbk'][
'content'] as 
$data) {
 
  381                if ($tree->isInTree(
$data[
'id'])) {
 
  382                    $new_result[
'dbk'][
'content'][] = 
$data;
 
  386        $this->result[
'grp'] = $this->
__checkAccess($this->result[
'grp'], 
'grp');
 
  387        if (is_array($this->result[
'grp'])) {
 
  388            foreach ($this->result[
'grp'] as 
$data) {
 
  389                if ($tree->isInTree(
$data[
'id'])) {
 
  390                    $new_result[
'grp'][] = 
$data;
 
  394        if (is_array($this->result[
'usr'])) {
 
  395            foreach ($this->result[
'usr'] as $user) {
 
  397                    $new_result[
'usr'][] = $user;
 
  401        if (is_array($this->result[
'role'])) {
 
  402            foreach ($this->result[
'role'] as $user) {
 
  404                    $new_result[
'role'][] = $user;
 
  415        $word = trim($a_word);
 
  417        if (!preg_match(
'/\*/', $word)) {
 
  418            return '%' . $word . 
'%';
 
  420        if (preg_match(
'/^\*/', $word)) {
 
  421            return str_replace(
'*', 
'%', $word);
 
  423            return '% ' . str_replace(
'*', 
'%', $word);
 
  433        include_once 
'Services/Search/classes/class.ilObjectSearchFactory.php';
 
  438        foreach (array(
"login",
"firstname",
"lastname",
"title",
 
  439                "email",
"institution",
"street",
"city",
"zipcode",
"country",
"phone_home",
"fax") as $field) {
 
  440            $user_search->setFields(array($field));
 
  441            $tmp_res = $user_search->performSearch();
 
  443            $res->mergeEntries($tmp_res);
 
  459        include_once 
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
 
  461        $object_search->setFilter(array(
$a_type));
 
  462        $res = $object_search->performSearch();
 
  466        foreach (
$res->getResultIds() as 
$id) {
 
  469        return $objs ? $objs : array();
 
  480        include_once 
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
 
  482        $object_search->setFilter(array(
'role'));
 
  484        $res = $object_search->performSearch();
 
  489        return $roles ? $roles : array();
 
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
initQueryParser()
init query parser
performObjectSearch($a_type)
perform object search
setSearchString($a_search_str)
setSearchIn($a_search_in)
setCombination($a_combination)
setSearchFor($a_search_for)
getSearchInByType($a_type)
__checkAccess($a_results, $a_type)
__construct($a_user_id=0, $a_read=false)
Constructor @access public.
setMinWordLength($a_min_word_length)
performUserSearch()
perform a search for users
setPerformUpdate($a_value)
if(!array_key_exists('StateId', $_REQUEST)) $id
catch(Exception $e) $message
redirection script todo: (a better solution should control the processing via a xml file)
foreach($_POST as $key=> $value) $res