/**
  * share perform search
  *
  * @access public
  * @return
  */
 public function sharePerformSearch()
 {
     global $ilTabs;
     $this->lng->loadLanguageModule('search');
     if (!$_GET['category_id']) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->returnToParent($this);
     }
     $this->ctrl->saveParameter($this, 'category_id');
     if (!isset($_POST['query'])) {
         $query = $_SESSION['cal_query'];
         $type = $_SESSION['cal_type'];
     } elseif ($_POST['query']) {
         $query = $_SESSION['cal_query'] = $_POST['query'];
         $type = $_SESSION['cal_type'] = $_POST['query_type'];
     }
     if (!$query) {
         ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
         $this->shareSearch();
         return false;
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $res_sum = new ilSearchResult();
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($query));
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     switch ($type) {
         case self::SEARCH_USER:
             $search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
             $search->enableActiveCheck(true);
             $search->setFields(array('login'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $search->setFields(array('firstname'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $search->setFields(array('lastname'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
             break;
         case self::SEARCH_ROLE:
             include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
             $search = new ilLikeObjectSearch($query_parser);
             $search->setFilter(array('role'));
             $res = $search->performSearch();
             $res_sum->mergeEntries($res);
             $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
             break;
     }
     if (!count($res_sum->getResults())) {
         ilUtil::sendFailure($this->lng->txt('search_no_match'));
         $this->shareSearch();
         return true;
     }
     $ilTabs->clearTargets();
     $ilTabs->setBackTarget($this->lng->txt("cal_back_to_search"), $this->ctrl->getLinkTarget($this, "shareSearch"));
     switch ($type) {
         case self::SEARCH_USER:
             $this->showUserList($res_sum->getResultIds());
             break;
         case self::SEARCH_ROLE:
             $this->showRoleList($res_sum->getResultIds());
             break;
     }
 }
 public function showResults()
 {
     global $lng, $ilUser, $rbacreview, $ilObjDataCache;
     $form = $this->initSearchForm();
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
     $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
     $this->tpl->setTitle($this->lng->txt("mail"));
     $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
     // #14109
     if (strlen($_SESSION['mail_search_search']) < 3) {
         if ($_GET["ref"] != "wsp") {
             $this->tpl->show();
         }
         return;
     }
     $abook = new ilAddressbook($ilUser->getId());
     $entries = $abook->searchUsers(addslashes(urldecode($_SESSION['mail_search_search'])));
     // remove all contacts who are not registered users for personal workspace
     if ($_GET["ref"] == "wsp") {
         foreach ($entries as $idx => $entry) {
             if (!$entry["login"]) {
                 unset($entries[$idx]);
             }
         }
     }
     if (count($entries)) {
         $tbl_addr = new ilTable2GUI($this);
         $tbl_addr->setTitle($lng->txt('mail_addressbook'));
         $tbl_addr->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($entries as $entry) {
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_cc[]', $entry['login'] ? $entry['login'] : $entry['email']) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $entry['login'] ? $entry['login'] : $entry['email']);
             } else {
                 $user_id = ilObjUser::_loginExists($entry["login"]);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_addr[]', $user_id);
             }
             $result[$counter]['login'] = $entry['login'];
             $result[$counter]['firstname'] = $entry['firstname'];
             $result[$counter]['lastname'] = $entry['lastname'];
             $id = ilObjUser::_lookupId($entry['login']);
             if (ilObjUser::_lookupPref($id, 'public_email') == 'y' || !$entry['login']) {
                 $has_mail_addr = true;
                 $result[$counter]['email'] = $entry['email'];
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_addr->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_addr->addColumn("", "", "1%");
         }
         $tbl_addr->addColumn($this->lng->txt('login'), 'login', "15%");
         $tbl_addr->addColumn($this->lng->txt('firstname'), 'firstname', "15%");
         $tbl_addr->addColumn($this->lng->txt('lastname'), 'lastname', "15%");
         if ($has_mail_addr) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_addr->addColumn($this->lng->txt('email'), 'email', "15%");
         }
         $tbl_addr->setData($result);
         $tbl_addr->setDefaultOrderField('login');
         $tbl_addr->setPrefix('addr_');
         $tbl_addr->enable('select_all');
         $tbl_addr->setSelectAllCheckbox('search_name_to_addr');
         $tbl_addr->setFormName('recipients');
         $this->tpl->setVariable('TABLE_ADDR', $tbl_addr->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $all_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
     $user_search->enableActiveCheck(true);
     $user_search->setFields(array('login'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('firstname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $user_search->setFields(array('lastname'));
     $result_obj = $user_search->performSearch();
     $all_results->mergeEntries($result_obj);
     $all_results->setMaxHits(100000);
     $all_results->preventOverwritingMaxhits(true);
     $all_results->filter(ROOT_FOLDER_ID, true);
     // Filter users (depends on setting in user accounts)
     include_once 'Services/User/classes/class.ilUserFilter.php';
     $users = ilUserFilter::getInstance()->filter($all_results->getResultIds());
     if (count($users)) {
         $tbl_users = new ilTable2GUI($this);
         $tbl_users->setTitle($lng->txt('system') . ': ' . $lng->txt('persons'));
         $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         foreach ($users as $user) {
             $login = ilObjUser::_lookupLogin($user);
             if ($_GET["ref"] != "wsp") {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $login) . ilUtil::formCheckbox(0, 'search_name_cc[]', $login) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $login);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_usr[]', $user);
             }
             $result[$counter]['login'] = $login;
             if (in_array(ilObjUser::_lookupPref($user, 'public_profile'), array('y', "g"))) {
                 $name = ilObjUser::_lookupName($user);
                 $result[$counter]['firstname'] = $name['firstname'];
                 $result[$counter]['lastname'] = $name['lastname'];
             } else {
                 $result[$counter]['firstname'] = '';
                 $result[$counter]['lastname'] = '';
             }
             if (ilObjUser::_lookupPref($user, 'public_email') == 'y') {
                 $has_mail_usr = true;
                 $result[$counter]['email'] = ilObjUser::_lookupEmail($user);
             }
             ++$counter;
         }
         if ($_GET["ref"] != "wsp") {
             $tbl_users->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
         } else {
             $tbl_users->addColumn("", "", "1%");
         }
         $tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
         $tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
         $tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
         if ($has_mail_usr == true) {
             foreach ($result as $key => $val) {
                 if ($val['email'] == '') {
                     $result[$key]['email'] = '&nbsp;';
                 }
             }
             $tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
         }
         $tbl_users->setData($result);
         $tbl_users->setDefaultOrderField('login');
         $tbl_users->setPrefix('usr_');
         $tbl_users->enable('select_all');
         $tbl_users->setSelectAllCheckbox('search_name_to_usr');
         $tbl_users->setFormName('recipients');
         $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
     }
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $group_results = new ilSearchResult();
     $query_parser = new ilQueryParser(addcslashes($_SESSION['mail_search_search'], '%_'));
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->setMinWordLength(3);
     $query_parser->parse();
     $search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
     $search->setFilter(array('grp'));
     $result = $search->performSearch();
     $group_results->mergeEntries($result);
     $group_results->setMaxHits(PHP_INT_MAX);
     $group_results->preventOverwritingMaxhits(true);
     $group_results->setRequiredPermission('read');
     $group_results->filter(ROOT_FOLDER_ID, true);
     $visible_groups = array();
     if ($group_results->getResults()) {
         $tbl_grp = new ilTable2GUI($this);
         $tbl_grp->setTitle($lng->txt('system') . ': ' . $lng->txt('groups'));
         $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'Services/Contact');
         $result = array();
         $counter = 0;
         $ilObjDataCache->preloadReferenceCache(array_keys($group_results->getResults()));
         $groups = $group_results->getResults();
         foreach ($groups as $grp) {
             if (!ilParticipants::hasParticipantListAccess($grp['obj_id'])) {
                 continue;
             }
             if ($_GET["ref"] != "wsp") {
                 $members = array();
                 $roles = $rbacreview->getAssignableChildRoles($grp['ref_id']);
                 foreach ($roles as $role) {
                     if (substr($role['title'], 0, 14) == 'il_grp_member_' || substr($role['title'], 0, 13) == 'il_grp_admin_') {
                         // does not work if Pear is enabled and Mailbox Address contain special chars!!
                         //array_push($members, $rbacreview->getRoleMailboxAddress($role['obj_id']));
                         // FIX for Mantis: 7523
                         array_push($members, '#' . $role['title']);
                     }
                 }
                 $str_members = implode(',', $members);
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_cc[]', $str_members) . ilUtil::formCheckbox(0, 'search_name_bcc[]', $str_members);
             } else {
                 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'search_name_to_grp[]', $grp['obj_id']);
             }
             $result[$counter]['title'] = $ilObjDataCache->lookupTitle($grp['obj_id']);
             $result[$counter]['description'] = $ilObjDataCache->lookupDescription($grp['obj_id']);
             ++$counter;
             $visible_groups[] = $grp;
         }
         if ($visible_groups) {
             $tbl_grp->setData($result);
             if ($_GET["ref"] != "wsp") {
                 $tbl_grp->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
             } else {
                 $tbl_grp->addColumn("", "", "1%");
             }
             $tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
             $tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
             $tbl_grp->setDefaultOrderField('title');
             $tbl_grp->setPrefix('grp_');
             $tbl_grp->enable('select_all');
             $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
             $tbl_grp->setFormName('recipients');
             $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
         }
     }
     if (count($users) || count($visible_groups) || count($entries)) {
         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
         $this->tpl->setVariable("ALT_ARROW", '');
         if ($_GET["ref"] != "wsp") {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
         } else {
             $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('wsp_share_with_users'));
         }
     } else {
         $this->lng->loadLanguageModule('search');
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     if ($_GET["ref"] != "wsp") {
         $this->tpl->show();
     }
 }
 function __performUserSearch()
 {
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     foreach (ilUserSearchOptions::_getSearchableFieldsInfo(!$this->isSearchableCheckEnabled()) as $info) {
         $name = $info['db'];
         $query_string = $_SESSION['rep_query']['usr'][$name];
         // continue if no query string is given
         if (!$query_string) {
             continue;
         }
         if (!is_object($query_parser = $this->__parseQueryString($query_string))) {
             ilUtil::sendInfo($query_parser);
             return false;
         }
         switch ($info['type']) {
             case FIELD_TYPE_UDF_SELECT:
                 // Do a phrase query for select fields
                 $query_parser = $this->__parseQueryString('"' . $query_string . '"');
             case FIELD_TYPE_UDF_TEXT:
                 $udf_search = ilObjectSearchFactory::_getUserDefinedFieldSearchInstance($query_parser);
                 $udf_search->setFields(array($name));
                 $result_obj = $udf_search->performSearch();
                 // Store entries
                 $this->__storeEntries($result_obj);
                 break;
             case FIELD_TYPE_SELECT:
                 // Do a phrase query for select fields
                 $query_parser = $this->__parseQueryString('"' . $query_string . '"');
             case FIELD_TYPE_TEXT:
                 $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
                 $user_search->setFields(array($name));
                 $result_obj = $user_search->performSearch();
                 // store entries
                 $this->__storeEntries($result_obj);
                 break;
         }
     }
 }
示例#4
0
 public function performSearch($oResult = null)
 {
     if (!is_object($oResult)) {
         $oResult = ilShopSearchResult::_getInstance(SHOP_CONTENT);
         if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(true);
             ilShopTopics::_getInstance()->setSortingType((int) $this->getSortingTypeTopics());
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
             ilShopTopics::_getInstance()->read();
         } else {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(false);
             ilShopTopics::_getInstance()->setSortingType((int) $this->settings->get('topics_sorting_type'));
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
             ilShopTopics::_getInstance()->read();
         }
         $topics = ilShopTopics::_getInstance()->getTopics();
         $oResult->setTopics($topics);
         $oResult->setResultPageNumber((int) $_GET['page_number']);
     }
     // query parser
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
     $query_parser->setMinWordLength(0);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         ilUtil::sendInfo($query_parser->getMessage());
     }
     // search
     $types = array('crs', 'lm', 'sahs', 'htlm', 'file', 'tst', 'exc', 'glo');
     if ($this->getType() == '' || $this->getType() == 'title' || $query_parser->getQueryString() == '') {
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $object_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
         $object_search->setFields(array('title'));
         $object_search->setFilter($types);
         $object_search->setCustomSearchResultObject($oResult);
         $object_search->setFilterShopTopicId((int) $this->getTopicId());
         $res = $object_search->performSearch();
     } else {
         if ($this->getType() == 'author') {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('contribute');
             $meta_search->setFilter($types);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $meta_search->setCustomSearchResultObject($oResult);
             $res = $meta_search->performSearch();
         } else {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('title');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res = $meta_search->performSearch();
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('keyword');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res->mergeEntries($meta_search->performSearch());
         }
     }
     $res->filter(ROOT_FOLDER_ID, true);
     $res->save();
     if (!count($res->getResults())) {
         ilUtil::sendInfo($this->lng->txt('payment_shop_not_objects_found'));
     }
     $this->showTopicsContent($res);
     $this->addPager($res);
     return;
 }
 function __searchObjects()
 {
     foreach ($this->search_fields as $field => $enabled) {
         // Disabled ?
         if (!$enabled) {
             continue;
         }
         $query_string = $_SESSION['search_usr_filter'][$field];
         if (!$query_string) {
             continue;
         }
         if (!is_object($query_parser = $this->__parseQueryString($query_string))) {
             ilUtil::sendInfo($query_parser);
             return false;
         }
         $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
         $user_search->setFields(array($field));
         // store entries
         $this->__storeEntries($result_obj = $user_search->performSearch());
     }
     // no filter entries
     if (is_object($this->result_obj)) {
         if ($this->enabled_member_filter) {
             $this->result_obj->addObserver($this, 'memberFilter');
         }
         $this->result_obj->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
         return $this->__toArray($this->result_obj->getResults());
     }
     return array();
 }
 private function searchObjects($query_parser)
 {
     // create new search result object and assign the sorted topics
     $oSearchResult = ilShopSearchResult::_getInstance(SHOP_ADVANCED_SEARCH);
     if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
         ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
         ilShopTopics::_getInstance()->enableCustomSorting(true);
         ilShopTopics::_getInstance()->setSortingType((int) $this->getSortingTypeTopics());
         ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
         ilShopTopics::_getInstance()->read();
     } else {
         ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
         ilShopTopics::_getInstance()->enableCustomSorting(false);
         ilShopTopics::_getInstance()->setSortingType((int) $this->settings->get('topics_sorting_type'));
         ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
         ilShopTopics::_getInstance()->read();
     }
     $oSearchResult->setTopics(ilShopTopics::_getInstance()->getTopics());
     $oSearchResult->setResultPageNumber((int) $_GET['page_number']);
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     $res = null;
     $obj_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
     $obj_search->setFilterShopTopicId((int) $this->getTopicId());
     $obj_search->setFilter($this->getFilter());
     $obj_search->setCustomSearchResultObject($oSearchResult);
     $res = $obj_search->performSearch();
     $meta_search_c = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_c->setMode('contribute');
     $meta_search_c->setFilter($this->getFilter());
     $meta_search_c->setFilterShopTopicId((int) $this->getTopicId());
     $meta_search_c->setCustomSearchResultObject($oSearchResult);
     $res->mergeEntries($meta_search_c->performSearch());
     $meta_search_t = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_t->setMode('title');
     $meta_search_t->setFilter($this->getFilter());
     $meta_search_t->setCustomSearchResultObject($oSearchResult);
     $meta_search_t->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_t->performSearch());
     $meta_search_k = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_k->setMode('keyword');
     $meta_search_k->setFilter($this->getFilter());
     $meta_search_k->setCustomSearchResultObject($oSearchResult);
     $meta_search_k->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_k->performSearch());
     return $res;
 }
示例#7
0
 /**
  * perform a search for users 
  * @return
  */
 protected function performUserSearch()
 {
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     $user_search = ilObjectSearchFactory::_getUserSearchInstance($this->qp);
     $res = new ilSearchResult($this->getUserId());
     foreach (array("login", "firstname", "lastname", "title", "email", "institution", "street", "city", "zipcode", "country", "phone_home", "fax") as $field) {
         $user_search->setFields(array($field));
         $tmp_res = $user_search->performSearch();
         $res->mergeEntries($tmp_res);
     }
     foreach ($res->getEntries() as $id => $data) {
         $tmp['id'] = $id;
         $users[] = $tmp;
     }
     return $users ? $users : array();
 }
示例#8
0
 /**
  * Search in object meta data (keyword)
  * @return object result object
  * @access public
  */
 function &__searchMeta(&$query_parser, $a_type)
 {
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     $meta_search =& ilObjectSearchFactory::_getMetaDataSearchInstance($query_parser);
     if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
         $meta_search->setFilter($this->__getFilter());
     }
     switch ($a_type) {
         case 'keyword':
             $meta_search->setMode('keyword');
             break;
         case 'contribute':
             $meta_search->setMode('contribute');
             break;
         case 'title':
             $meta_search->setMode('title');
             break;
         case 'description':
             $meta_search->setMode('description');
             break;
     }
     return $meta_search->performSearch();
 }
 /**
  * search for roles.
  *
  * @param String $sid
  * @param String $searchterms comma separated search terms
  * @param String $operator must be or or and
  * @param String  $role_type can be empty which means "local & global", "local", "global", "user" = roles of user, "user_login" or "template"
  *
  */
 function searchRoles($sid, $key, $combination, $role_type)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacsystem, $rbacreview, $ilUser, $ilDB;
     if (strcasecmp($role_type, "") != 0 && strcasecmp($role_type, "local") != 0 && strcasecmp($role_type, "global") != 0 && strcasecmp($role_type, "template") != 0) {
         return $this->__raiseError('Called service with wrong role_type parameter \'' . $role_type . '\'', 'Client');
     }
     if ($combination != 'and' and $combination != 'or') {
         return $this->__raiseError('No valid combination given. Must be "and" or "or".', 'Client');
     }
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $query_parser =& new ilQueryParser($key);
     $query_parser->setMinWordLength(3);
     $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $this->__raiseError($query_parser->getMessage(), 'Client');
     }
     include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
     $object_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
     $object_search->setFilter(array("role", "rolt"));
     $res = $object_search->performSearch();
     $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false);
     $obj_ids = array();
     foreach ($res->getUniqueResults() as $entry) {
         $obj_ids[] = $entry['obj_id'];
     }
     $roles = array();
     if (count($obj_ids) > 0) {
         #print_r($obj_ids);
         $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type == "template");
     }
     #print_r($roles);
     include_once './webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
     $xml_writer = new ilSoapRoleObjectXMLWriter();
     $xml_writer->setObjects($roles);
     $xml_writer->setType($role_type);
     if ($xml_writer->start()) {
         return $xml_writer->getXML();
     }
 }
 function &__performKeywordSearch()
 {
     // Return if 'any'
     if (!$this->options['lom_keyword']) {
         return false;
     }
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword']));
     #$query_parser->setCombination($this->options['keyword_ao']);
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->parse();
     $meta_search =& ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
     $meta_search->setFilter($this->filter);
     $meta_search->setMode('keyword');
     $meta_search->setOptions($this->options);
     $res =& $meta_search->performSearch();
     return $res;
 }
示例#11
0
 /**
  * Search in Wiki
  */
 static function _performSearch($a_wiki_id, $a_searchterm)
 {
     // query parser
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($a_searchterm);
     $query_parser->setCombination("or");
     $query_parser->parse();
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $search_result = new ilSearchResult();
     if ($query_parser->validate()) {
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $wiki_search =& ilObjectSearchFactory::_getWikiContentSearchInstance($query_parser);
         $wiki_search->setFilter(array('wpg'));
         $search_result->mergeEntries($wiki_search->performSearch());
     }
     $entries = $search_result->getEntries();
     $found_pages = array();
     foreach ($entries as $entry) {
         if ($entry["obj_id"] == $a_wiki_id && is_array($entry["child"])) {
             foreach ($entry["child"] as $child) {
                 $found_pages[] = array("page_id" => $child);
             }
         }
     }
     return $found_pages;
 }
 public function searchModerators()
 {
     if (!is_object($oQueryParser = $this->parseQueryString(ilUtil::stripSlashes($_POST['search_query'])))) {
         ilUtil::sendInfo($oQueryParser);
         return $this->searchModeratorsForm();
     }
     $oUserSearchFirstname = ilObjectSearchFactory::_getUserSearchInstance($oQueryParser);
     $oUserSearchFirstname->setFields(array('firstname'));
     /** @var $oSearchResult ilObjectSearchFactory */
     $oSearchResult = $oUserSearchFirstname->performSearch();
     $oUserSearchLastname = ilObjectSearchFactory::_getUserSearchInstance($oQueryParser);
     $oUserSearchLastname->setFields(array('lastname'));
     $oSearchResultLastname = $oUserSearchLastname->performSearch();
     $oSearchResult->mergeEntries($oSearchResultLastname);
     $oUserSearchLogin = ilObjectSearchFactory::_getUserSearchInstance($oQueryParser);
     $oUserSearchLogin->setFields(array('login'));
     $oSearchResultLogin = $oUserSearchLogin->performSearch();
     $oSearchResult->mergeEntries($oSearchResultLogin);
     $oSearchResult->filter(ROOT_FOLDER_ID, $oQueryParser->getCombination() == 'and');
     $search_results = $oSearchResult->getUniqueResults();
     if (is_array($search_results) && count($search_results)) {
         $_SESSION['frm']['moderators']['search_result'] = $search_results;
         return $this->showModeratorsSearchResult($search_results);
     } else {
         ilUtil::sendInfo($this->lng->txt('frm_moderators_matches_in_no_results'));
         return $this->searchModeratorsForm();
     }
 }