/** * Search roles * @return */ function __performRoleSearch() { include_once 'Services/Search/classes/class.ilObjectSearchFactory.php'; $query_string = $_SESSION['rep_query']['role']['title']; if (!is_object($query_parser = $this->__parseQueryString($query_string))) { ilUtil::sendInfo($query_parser, true); return false; } // Perform like search include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($query_parser); $object_search->setFilter(array('role')); $this->__storeEntries($object_search->performSearch()); return true; }
/** * 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; } }
/** * Load input from form * @return * @param object $a_rule_id */ protected function loadRoleAssignmentRule($a_rule_id, $a_from_form = true) { if (is_object($this->rule)) { return true; } include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php'; $this->rule = ilLDAPRoleAssignmentRule::_getInstanceByRuleId($a_rule_id); if ($a_from_form) { if ($this->form->getInput('role_name') == 0) { $this->rule->setRoleId($this->form->getInput('role_id')); } elseif ($this->form->getInput('role_search')) { // Search role include_once './Services/Search/classes/class.ilQueryParser.php'; $parser = new ilQueryParser($this->form->getInput('role_search')); // TODO: Handle minWordLength $parser->setMinWordLength(1, true); $parser->setCombination(QP_COMBINATION_AND); $parser->parse(); include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($parser); $object_search->setFilter(array('role')); $res = $object_search->performSearch(); $entries = $res->getEntries(); if (count($entries) == 1) { $role = current($entries); $this->rule->setRoleId($role['obj_id']); } elseif (count($entries) > 1) { $this->rule->setRoleId(-1); } } $this->rule->setAttributeName($this->form->getInput('name')); $this->rule->setAttributeValue($this->form->getInput('value')); $this->rule->setDN($this->form->getInput('dn')); $this->rule->setMemberAttribute($this->form->getInput('at')); $this->rule->setMemberIsDN($this->form->getInput('isdn')); $this->rule->enableAddOnUpdate($this->form->getInput('add_missing')); $this->rule->enableRemoveOnUpdate($this->form->getInput('remove_deprecated')); $this->rule->setPluginId($this->form->getInput('plugin_id')); $this->rule->setType($this->form->getInput('type')); return true; } // LOAD from session $this->rule = ilLDAPRoleAssignmentRule::_getInstanceByRuleId($a_rule_id); $this->rule->setServerId(0); $this->rule->enableAddOnUpdate((int) $_SESSION['ldap_role_ass']['add_missing']); $this->rule->enableRemoveOnUpdate((int) $_SESSION['ldap_role_ass']['remove_deprecated']); $this->rule->setType(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['type'])); $this->rule->setDN(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['dn'])); $this->rule->setMemberAttribute(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['at'])); $this->rule->setMemberIsDN(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['isdn'])); $this->rule->setAttributeName(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['name'])); $this->rule->setAttributeValue(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['value'])); $this->rule->setPluginId(ilUtil::stripSlashes($_SESSION['ldap_role_ass']['plugin_id'])); return true; }
/** * This function is only used by the ajax request if searching for ILIAS references. It builds the html for the search results. */ public function searchObjects() { global $lng; $search = $_POST['search_for']; $dest = $_POST['dest']; $html = ""; include_once './Services/Search/classes/class.ilQueryParser.php'; $query_parser = new ilQueryParser($search); $query_parser->setMinWordLength(1, true); $query_parser->setCombination(QP_COMBINATION_AND); $query_parser->parse(); if (!$query_parser->validate()) { $html .= $query_parser->getMessage() . "<br />"; } // only like search since fulltext does not support search with less than 3 characters include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($query_parser); $res = $object_search->performSearch(); //$res->setRequiredPermission('copy'); $res->filter(ROOT_FOLDER_ID, true); if (!count($results = $res->getResultsByObjId())) { $html .= $lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />"; } $results = $this->parseSearchResults($results); foreach ($results as $entry) { $tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection"); foreach ((array) $entry['refs'] as $reference) { include_once './Services/Tree/classes/class.ilPathGUI.php'; $path = new ilPathGUI(); $tpl->setCurrentBlock('result'); $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " > " . $entry['title']); $tpl->setVariable('RESULT_REF', $reference); $tpl->setVariable('FIELD_ID', $dest); $tpl->parseCurrentBlock(); } $html .= $tpl->get(); } echo $html; exit; }
function searchObjects($sid, $types, $key, $combination, $user_id) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } if (!is_array($types)) { return $this->__raiseError('Types must be an array of object types.', 'Client'); } if ($combination != 'and' and $combination != 'or') { return $this->__raiseError('No valid combination given. Must be "and" or "or".', 'Client'); } // begin-patch fm include_once './Services/Search/classes/class.ilSearchSettings.php'; if (ilSearchSettings::getInstance()->enabledLucene()) { ilSearchSettings::getInstance()->setMaxHits(25); include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php'; $query_parser = new ilLuceneQueryParser($key); $query_parser->parse(); include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php'; $searcher = ilLuceneSearcher::getInstance($query_parser); $searcher->search(); include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php'; include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php'; $filter = ilLuceneSearchResultFilter::getInstance($user_id); $filter->setCandidates($searcher->getResult()); $filter->filter(); $result_ids = $filter->getResults(); $objs = array(); $objs[ROOT_FOLDER_ID] = ilObjectFactory::getInstanceByRefId(ROOT_FOLDER_ID, false); foreach ((array) $result_ids as $ref_id => $obj_id) { $obj = ilObjectFactory::getInstanceByRefId($ref_id, false); if ($obj instanceof ilObject) { $objs[] = $obj; } } include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php'; $highlighter = new ilLuceneHighlighterResultParser(); if ($filter->getResultObjIds()) { $highlighter = $searcher->highlight($filter->getResultObjIds()); } } else { 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); include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($query_parser); $object_search->setFilter($types); $res =& $object_search->performSearch(); if ($user_id) { $res->setUserId($user_id); } // begin-patch fm $res->setMaxHits(100); // begin-patch fm $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false); $counter = 0; $objs = array(); foreach ($res->getUniqueResults() as $entry) { $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'], false); if ($obj instanceof ilObject) { $objs[] = $obj; } } } if (!count($objs)) { //rku: todo: das ist nicht soap konform! - hier muss ein XML zurück geliefert werden return ''; } include_once './webservice/soap/classes/class.ilObjectXMLWriter.php'; $xml_writer = new ilObjectXMLWriter(); // begin-patch fm if (ilSearchSettings::getInstance()->enabledLucene()) { $xml_writer->enableReferences(false); $xml_writer->setMode(ilObjectXmlWriter::MODE_SEARCH_RESULT); $xml_writer->setHighlighter($highlighter); } $xml_writer->enablePermissionCheck(true); if ($user_id) { $xml_writer->setUserId($user_id); $xml_writer->enableOperations(true); } $xml_writer->setObjects($objs); if ($xml_writer->start()) { #$GLOBALS['ilLog']->write(__METHOD__.': '.$xml_writer->xmlDumpMem(true)); return $xml_writer->getXML(); } return $this->__raiseError('Cannot create object xml !', 'Server'); }
/** * * @param * @return */ protected function performRoleSearch() { // Perform like search include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($this->qp); $object_search->setFilter(array('role')); $res = $object_search->performSearch(); foreach ($res->getEntries() as $id => $data) { $tmp['id'] = $id; $roles[] = $tmp; } return $roles ? $roles : array(); }
/** * Search content that belongs to the current user and that meet the search criteria * */ public function searchContentFile() { /** * @var $ilAccess ilAccessHandler */ global $ilAccess; $this->initContentSearchForm(); if ($this->csform->checkInput()) { $allowedExt = array('ppt', 'pptx', 'flv', 'swf', 'pdf', 'gif', 'jpg', 'png', 'mp3', 'html'); $result = array(); include_once './Services/Search/classes/class.ilSearchSettings.php'; if (ilSearchSettings::getInstance()->enabledLucene()) { include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php'; include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php'; $qp = new ilLuceneQueryParser('+(type:file) ' . $this->csform->getInput('search_query')); $qp->parse(); $searcher = ilLuceneSearcher::getInstance($qp); $searcher->search(); include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php'; include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php'; $filter = ilLuceneSearchResultFilter::getInstance($this->user->getId()); $filter->addFilter(new ilLucenePathFilter(ROOT_FOLDER_ID)); $filter->setCandidates($searcher->getResult()); $filter->filter(); foreach ($filter->getResultIds() as $refId => $objId) { $obj = ilObjectFactory::getInstanceByRefId($refId); if (!in_array(strtolower($obj->getFileExtension()), $allowedExt)) { continue; } if (!$ilAccess->checkAccessOfUser($this->user->getId(), 'read', '', $refId, '', $objId)) { continue; } $result[$obj->getId()] = $obj->getId(); } } else { include_once 'Services/Search/classes/class.ilQueryParser.php'; $query_parser = new ilQueryParser($this->csform->getInput('search_query')); $query_parser->setCombination(QP_COMBINATION_OR); $query_parser->parse(); if (!$query_parser->validate()) { ilUtil::sendInfo($query_parser); $this->csform->setValuesByPost(); return $this->showAddContent(); } include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($query_parser); $object_search->setFilter(array('file')); $res = $object_search->performSearch(); $res->setUserId($this->user->getId()); $res->setMaxHits(999999); $res->filter(ROOT_FOLDER_ID, false); $res->setRequiredPermission('read'); foreach ($res->getUniqueResults() as $entry) { $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id']); if (!in_array(strtolower($obj->getFileExtension()), $allowedExt)) { continue; } $result[$obj->getId()] = $obj->getId(); } } if (count($result) > 0) { $this->showFileSearchResult($result); $_SESSION['contents']['search_result'] = $result; } else { ilUtil::sendInfo($this->txt('files_matches_in_no_results')); $this->csform->setValuesByPost(); $this->showAddContent(); } } else { $this->csform->setValuesByPost(); return $this->showAddContent(); } }
protected function chooseRole() { $this->tabs_gui->setSubTabActive('shib_role_assignment'); include_once './Services/Search/classes/class.ilQueryParser.php'; $parser = new ilQueryParser($_SESSION['shib_role_ass']['search']); $parser->setMinWordLength(1, true); $parser->setCombination(QP_COMBINATION_AND); $parser->parse(); include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($parser); $object_search->setFilter(array('role')); $res = $object_search->performSearch(); $entries = $res->getEntries(); include_once './Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php'; $table = new ilRoleSelectionTableGUI($this, 'chooseRole'); $table->setTitle($this->lng->txt('shib_role_selection')); $table->addMultiCommand('saveRoleSelection', $this->lng->txt('shib_choose_role')); $table->addCommandButton('roleAssignment', $this->lng->txt('cancel')); $table->parse($entries); $this->tpl->setContent($table->getHTML()); return true; }
/** * Search source * @return */ protected function searchSource() { global $tree, $ilObjDataCache, $lng, $ilCtrl, $tpl; if (isset($_POST['tit'])) { ilUtil::sendInfo($this->lng->txt('wizard_search_list')); $_SESSION['source_query'] = $_POST['tit']; } else { $_POST['tit'] = $_SESSION['source_query']; } $this->initFormSearch(); $this->form->setValuesByPost(); if (!$this->form->checkInput()) { ilUtil::sendFailure($lng->txt('msg_no_search_string'), true); $ilCtrl->returnToParent($this); return false; } include_once './Services/Search/classes/class.ilQueryParser.php'; $query_parser = new ilQueryParser($this->form->getInput('tit')); $query_parser->setMinWordLength(1, true); $query_parser->setCombination(QP_COMBINATION_AND); $query_parser->parse(); if (!$query_parser->validate()) { ilUtil::sendFailure($query_parser->getMessage(), true); $ilCtrl->returnToParent($this); } // only like search since fulltext does not support search with less than 3 characters include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php'; $object_search = new ilLikeObjectSearch($query_parser); $object_search->setFilter(array($_REQUEST['new_type'])); $res = $object_search->performSearch(); $res->setRequiredPermission('copy'); $res->filter(ROOT_FOLDER_ID, true); if (!count($results = $res->getResultsByObjId())) { ilUtil::sendFailure($this->lng->txt('search_no_match'), true); $ilCtrl->returnToParent($this); } include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php'; $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $_REQUEST['new_type']); $table->setSelectedReference($this->getSource()); $table->parseSearchResults($results); $tpl->setContent($table->getHTML()); }