35 include_once
'Services/Search/classes/class.ilSearchResult.php';
36 include_once
'Services/Search/classes/class.ilSearchSettings.php';
37 include_once
'./Services/User/classes/class.ilUserAccountSettings.php';
38 include_once
'Services/Search/classes/class.ilQueryParser.php';
64 $this->lng->loadLanguageModule(
'search');
65 $this->lng->loadLanguageModule(
'crs');
67 $this->
setTitle($this->lng->txt(
'add_members_header'));
73 $this->result_obj->setMaxHits(1000000);
84 $this->search_title = $a_title;
102 $this->searchable_check = $a_status;
134 $toolbar = $ilToolbar;
138 if(!isset($a_options[
'auto_complete_name']))
140 $a_options[
'auto_complete_name'] = $lng->txt(
'obj_user');
142 if(!isset($a_options[
'auto_complete_size']))
144 $a_options[
'auto_complete_size'] = 15;
146 if(!isset($a_options[
'submit_name']))
148 $a_options[
'submit_name'] = $lng->txt(
'btn_add');
151 $ajax_url = $ilCtrl->getLinkTargetByClass(array(get_class($parent_object),
'ilRepositorySearchGUI'),
152 'doUserAutoComplete',
'',
true);
154 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
155 $ul =
new ilTextInputGUI($a_options[
'auto_complete_name'],
'user_login');
156 $ul->setDataSource($ajax_url);
157 $ul->setSize($a_options[
'auto_complete_size']);
158 $toolbar->addInputItem($ul,
true);
160 if(count((array) $a_options[
'user_type']))
162 include_once
'./Services/Form/classes/class.ilSelectInputGUI.php';
164 $si->setOptions($a_options[
'user_type']);
165 $toolbar->addInputItem(
$si);
168 $toolbar->addFormButton(
169 $a_options[
'submit_name'],
170 'addUserFromAutoComplete'
173 $toolbar->setFormAction(
174 $ilCtrl->getFormActionByClass(
176 get_class($parent_object),
177 'ilRepositorySearchGUI')
190 if(!isset(
$_GET[
'autoCompleteField']))
192 $a_fields = array(
'login',
'firstname',
'lastname',
'email');
193 $result_field =
'login';
197 $a_fields = array((
string)
$_GET[
'autoCompleteField']);
198 $result_field = (string) $_GET[
'autoCompleteField'];
201 $GLOBALS[
'ilLog']->write(print_r($a_fields,
true));
202 include_once
'./Services/User/classes/class.ilUserAutoComplete.php';
204 $auto->setSearchFields($a_fields);
205 $auto->setResultField($result_field);
206 $auto->enableFieldSearchableCheck(
true);
218 $_SESSION[
'search'][
'string'] = $this->
string = $a_str;
222 return $this->string;
233 $next_class = $this->ctrl->getNextClass($this);
234 $cmd = $this->ctrl->getCmd();
236 $this->ctrl->setReturn($this,
'');
262 $this->ctrl->returnToParent($this);
277 $class = $this->callback[
'class'];
278 $method = $this->callback[
'method'];
282 $class->$method(
$_POST[
'user']);
292 $class = $this->callback[
'class'];
293 $method = $this->callback[
'method'];
295 $users = explode(
',',
$_POST[
'user_login']);
297 foreach($users as $user)
302 $user_ids[] = $user_id;
306 $user_type = isset(
$_POST[
'user_type']) ?
$_POST[
'user_type'] : 0;
308 if(!$class->$method($user_ids,$user_type))
310 $GLOBALS[
'ilCtrl']->returnToParent($this);
319 $class = $this->callback[
'class'];
320 $method = $this->callback[
'method'];
323 if(!$class->$method((array)
$_POST[
'user'],$_POST[
'selectedCommand']))
329 public function setCallback(&$class,$method,$a_add_options = array())
331 $this->callback = array(
'class' => $class,
'method' => $method);
332 $this->add_options = $a_add_options ? $a_add_options : array();
338 $this->tpl->setContent($this->form->getHTML());
345 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
348 $this->form->setFormAction($this->ctrl->getFormAction($this,
'search'));
349 $this->form->setTitle($this->
getTitle());
350 $this->form->addCommandButton(
'performSearch', $this->lng->txt(
'search'));
351 $this->form->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
355 $kind->
setValue($this->search_type);
356 $this->form->addItem($kind);
359 $users =
new ilRadioOption($this->lng->txt(
'search_for_users'),
'usr');
362 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
365 switch($info[
'type'])
370 $sel =
new ilSelectInputGUI($info[
'lang'],
"rep_query[usr][".$info[
'db'].
"]");
371 $sel->setOptions($info[
'values']);
372 $users->addSubItem($sel);
378 if(isset($info[
'autoComplete']) and $info[
'autoComplete'])
380 $ilCtrl->setParameterByClass(get_class($this),
'autoCompleteField',$info[
'db']);
381 $ul =
new ilTextInputGUI($info[
'lang'],
"rep_query[usr][".$info[
'db'].
"]");
382 $ul->setDataSource($ilCtrl->getLinkTarget($this,
383 "doUserAutoComplete",
"",
true));
385 $ul->setMaxLength(120);
386 $users->addSubItem($ul);
390 $txt =
new ilTextInputGUI($info[
'lang'],
"rep_query[usr][".$info[
'db'].
"]");
392 $txt->setMaxLength(120);
393 $users->addSubItem($txt);
398 $kind->addOption($users);
403 $roles =
new ilRadioOption($this->lng->txt(
'search_for_role_members'),
'role');
404 $role =
new ilTextInputGUI($this->lng->txt(
'search_role_title'),
'rep_query[role][title]');
406 $role->setMaxLength(120);
408 $kind->addOption($roles);
411 $groups =
new ilRadioOption($this->lng->txt(
'search_for_crs_members'),
'crs');
412 $group =
new ilTextInputGUI($this->lng->txt(
'search_crs_title'),
'rep_query[crs][title]');
414 $group->setMaxLength(120);
416 $kind->addOption($groups);
419 $groups =
new ilRadioOption($this->lng->txt(
'search_for_grp_members'),
'grp');
420 $group =
new ilTextInputGUI($this->lng->txt(
'search_grp_title'),
'rep_query[grp][title]');
422 $group->setMaxLength(120);
424 $kind->addOption($groups);
445 $found_query =
false;
446 foreach((array)
$_POST[
'rep_query'][
$_POST[
'search_for']] as $field => $value)
462 if(
$_POST[
'cmd'][
'performSearch'])
467 switch($this->search_type)
488 $this->result_obj->setRequiredPermission(
'read');
489 $this->result_obj->addObserver($this,
'searchResultFilterListener');
493 if($this->search_type ==
'usr')
495 include_once
'./Services/User/classes/class.ilUserFilter.php';
496 $this->search_results = array_intersect(
497 $this->result_obj->getResultIds(),
503 $this->search_results = array();
504 foreach((array) $this->result_obj->getResults() as
$res)
506 $this->search_results[] =
$res[
'obj_id'];
510 if(!count($this->search_results))
517 if($this->result_obj->isLimitReached())
519 $message = sprintf($this->lng->txt(
'search_limit_reached'),$this->settings->getMaxHits());
530 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
531 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
536 $query_string =
$_SESSION[
'rep_query'][
'usr'][$name];
549 switch($info[
'type'])
557 $udf_search->setFields(array($name));
558 $result_obj = $udf_search->performSearch();
570 $user_search->setFields(array($name));
571 $result_obj = $user_search->performSearch();
586 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
588 $query_string =
$_SESSION[
'rep_query'][
'grp'][
'title'];
595 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
597 $object_search->setFilter(array(
'grp'));
609 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
611 $query_string =
$_SESSION[
'rep_query'][
'crs'][
'title'];
618 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
620 $object_search->setFilter(array(
'crs'));
632 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
634 $query_string =
$_SESSION[
'rep_query'][
'role'][
'title'];
642 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
644 $object_search->setFilter(array(
'role'));
659 $query_parser->setMinWordLength(1);
660 $query_parser->setGlobalMinLength(3);
661 $query_parser->parse();
663 if(!$query_parser->validate())
665 return $query_parser->getMessage();
667 return $query_parser;
673 if(is_array(
$_POST[
'rep_query']))
694 $this->search_type =
$_SESSION[
'rep_search_type'];
695 #echo $this->search_type;
707 foreach($this->search_results as
$result)
711 if(!
$_SESSION[
'rep_search'][$this->search_type])
727 return $_SESSION[
'rep_search'][
'usr'] = $a_usr_ids;
729 $_SESSION[
'rep_search'][
'usr'] = array();
734 return $_SESSION[
'rep_search'][
'usr'] ? array_unique(
$_SESSION[
'rep_search'][
'usr']) : array();
739 if($this->stored ==
false)
741 $this->result_obj->mergeEntries($new_res);
742 $this->stored =
true;
747 $this->result_obj->intersectEntries($new_res);
758 include_once
'./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
761 $this->lng->txt(
'search_new'),
762 $this->ctrl->getLinkTarget($this,
'showSearch')
764 $this->tpl->setVariable(
'ACTION_BUTTONS',$toolbar->getHTML());
772 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.rep_search_result.html',
'Services/Search');
775 switch($this->search_type)
802 $is_in_admin = (
$_REQUEST[
'baseClass'] ==
'ilAdministrationGUI');
806 $_SESSION[
"usr_search_link"] = $this->ctrl->getLinkTarget($this,
'show');
809 include_once
'./Services/Search/classes/class.ilRepositoryUserResultTableGUI.php';
812 if(count($this->add_options))
814 $table->addMultiItemSelectionButton(
817 'handleMultiCommand',
818 $this->lng->txt(
'execute')
823 $table->addMultiCommand(
'addUser', $this->lng->txt(
'btn_add'));
825 $table->parseUserIds($a_usr_ids);
827 $this->tpl->setVariable(
'RES_TABLE',$table->getHTML());
837 include_once
'./Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
840 $table->parseObjectIds($a_obj_ids);
842 $this->tpl->setVariable(
'RES_TABLE',$table->getHTML());
852 include_once
'./Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
855 $table->parseObjectIds($a_obj_ids);
857 $this->tpl->setVariable(
'RES_TABLE',$table->getHTML());
867 include_once
'./Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
870 $table->parseObjectIds($a_obj_ids);
872 $this->tpl->setVariable(
'RES_TABLE',$table->getHTML());
883 if (
$_GET[
"list_obj"] !=
"" && !is_array(
$_POST[
'obj']))
898 foreach(
$_POST[
'obj'] as $obj_id)
906 include_once
'./Services/Membership/classes/class.ilParticipants.php';
916 include_once
'./Services/User/classes/class.ilUserFilter.php';
921 $members = array_unique((array) $members);
924 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.rep_search_result.html',
'Services/Search');
952 if($a_data[
'type'] ==
'usr')
954 if($a_data[
'obj_id'] == ANONYMOUS_USER_ID)
969 $this->object_selection = (bool)$a_value;
979 if (
$_GET[
"list_obj"] !=
"" && !is_array(
$_POST[
'obj']))
990 $this->ctrl->setParameter($this->callback[
"class"],
"obj", implode(
";",
$_POST[
"obj"]));
991 $this->ctrl->redirect($this->callback[
"class"], $this->callback[
"method"]);