38 include_once
'Services/Search/classes/class.ilSearchResult.php';
39 include_once
'Services/Search/classes/class.ilSearchSettings.php';
56 $this->lng->loadLanguageModule(
'search');
57 $this->lng->loadLanguageModule(
'crs');
63 $this->result_obj->setMaxHits(1000000);
75 $_SESSION[
'search'][
'string'] = $this->
string = $a_str;
90 $next_class = $this->ctrl->getNextClass($this);
91 $cmd = $this->ctrl->getCmd();
96 include_once(
'./Services/User/classes/class.ilObjUserGUI.php');
98 $this->gui_obj->setBackTarget($this->lng->txt(
"search_results"),
99 $this->ctrl->getLinkTarget($this,
"show"));
100 $ret =& $this->ctrl->forwardCommand($this->gui_obj);
146 $_SESSION[
"usr_search_mode"] =
"extended";
154 $_SESSION[
"usr_search_mode"] =
"extended";
157 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
160 $this->tpl->setCurrentBlock(
"btn_cell");
161 $this->tpl->setVariable(
"BTN_LINK",$this->ctrl->getLinkTarget($this,
'show'));
162 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt(
"search_user_simple"));
163 $this->tpl->parseCurrentBlock();
165 $this->tpl->setCurrentBlock(
"btn_cell");
166 $this->tpl->setVariable(
"BTN_LINK",$this->callback_class->ctrl->getLinkTarget($this->callback_class,
"importUserForm"));
167 $this->tpl->setVariable(
"BTN_TXT", $this->lng->txt(
"import_users"));
168 $this->tpl->parseCurrentBlock();
178 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
181 $this->tpl->setCurrentBlock(
"btn_cell");
182 $this->tpl->setVariable(
"BTN_LINK",$this->ctrl->getLinkTarget($this,
'showExtended'));
183 $this->tpl->setVariable(
"BTN_TXT",$this->lng->txt(
"search_user_extended"));
184 $this->tpl->parseCurrentBlock();
186 $this->tpl->setCurrentBlock(
"btn_cell");
187 $this->tpl->setVariable(
"BTN_LINK",$this->callback_class->ctrl->getLinkTarget($this->callback_class,
"importUserForm"));
188 $this->tpl->setVariable(
"BTN_TXT", $this->lng->txt(
"import_users"));
189 $this->tpl->parseCurrentBlock();
196 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.usr_search_simple.html',
'Services/Search');
198 $this->ctrl->setParameter($this,
'search',
'1');
200 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startSimple'));
201 $this->tpl->setVariable(
"TXT_SEARCH",$this->lng->txt(
"search"));
202 if(count(
$_SESSION[
'rep_search'][
'usr']))
203 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
'append_results'));
205 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search_user"));
210 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.rep_search.html',
'Services/Search');
211 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startExtended'));
213 $this->tpl->setVariable(
"ALT_IMG",$this->lng->txt(
'obj_usr'));
214 $this->tpl->setVariable(
"SEARCH_MEMBERS_HEADER",$this->lng->txt(
"search_user_extended"));
218 $this->tpl->setVariable(
"SEARCH_ASSIGN_USR",$this->lng->txt(
"search_for_users"));
219 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_USER",
ilUtil::formRadioButton($this->search_type ==
'usr',
"search_for",
"usr"));
224 $this->tpl->setVariable(
"SEARCH_ROW_TXT_GROUP",$this->lng->txt(
"search_for_grp_members"));
225 $this->tpl->setVariable(
"GROUP_TERM",$this->lng->txt(
'search_grp_title'));
226 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_GROUP",
ilUtil::formRadioButton($this->search_type ==
'grp',
"search_for",
"grp"));
227 $this->tpl->setVariable(
"GRP_VALUE",
$_SESSION[
'rep_query'][
'grp'][
'title']);
231 $this->tpl->setVariable(
"SEARCH_ROW_TXT_ROLE",$this->lng->txt(
"search_for_role_members"));
232 $this->tpl->setVariable(
"ROLE_TERM",$this->lng->txt(
'search_role_title'));
233 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_ROLE",
ilUtil::formRadioButton($this->search_type ==
'role',
"search_for",
"role"));
234 $this->tpl->setVariable(
"ROLE_VALUE",
$_SESSION[
'rep_query'][
'role'][
'title']);
237 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
"cancel"));
238 if(count(
$_SESSION[
'rep_search'][
'usr']))
240 $this->tpl->setVariable(
"BTN3_VALUE",$this->lng->txt(
'append_results'));
242 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search"));
262 if($_POST[
'cmd'][
'performSearchSimple'])
268 $_POST[
"search_fields"] = array (
"username",
"firstname",
"lastname",
"email");
271 $_POST[
'active'] = 1;
273 $_POST[
"search_string"] = trim($_POST[
"search_string"]) ? trim($_POST[
"search_string"]) : trim(urldecode(
$_GET[
"search_string"]));
274 $_SESSION[
'us_active'] = isset($_POST[
'active']) ? $_POST[
'active'] :
$_SESSION[
'us_active'];
277 if (empty($_POST[
"search_string"]))
279 $_POST[
"search_string"] =
"%";
285 if ($_POST[
"search_string"] ==
"%")
287 $_POST[
"search_string"] =
"";
290 $msg = $this->lng->txt(
"msg_no_search_result");
292 if ($_POST[
"search_string"] !=
"")
294 $msg .=
" ".$this->lng->txt(
"with").
" '".htmlspecialchars($_POST[
"search_string"]).
"'";
300 $ilErr->raiseError($msg,$ilErr->MESSAGE);
305 $this->ctrl->setParameterByClass(
"ilobjuserfoldergui",
"user_filter",
$_GET[
"user_filter"]);
306 $this->ctrl->redirectByClass(
"ilobjuserfoldergui",
"view");
312 $_SESSION[
'rep_search'][
'usr'] = array();
315 foreach($search_result as
$result)
320 if(!
$_SESSION[
'rep_search'][$this->search_type])
336 if($_POST[
'cmd'][
'performSearch'])
341 switch($this->search_type)
360 if(!count($this->result_obj->getResults()))
364 #$ilErr->raiseError($this->lng->txt('search_no_match'),$ilErr->MESSAGE);
367 if($this->result_obj->isLimitReached())
369 $message = sprintf($this->lng->txt(
'search_limit_reached'),$this->settings->getMaxHits());
373 if (
$_SESSION[
"usr_search_mode"] ==
"extended")
381 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
382 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
387 $query_string =
$_SESSION[
'rep_query'][
'usr'][$name];
388 $active_status =
$_SESSION[
'usr_query_active'];
401 switch($info[
'type'])
406 $udf_search->setFields(array($name));
407 $result_obj = $udf_search->performSearch();
416 $user_search->setFields(array($name));
418 if ($active_status == 1)
419 $user_search->enableActiveCheck(
true);
420 elseif ($active_status == 2)
421 $user_search->enableInactiveCheck(
true);
423 $result_obj = $user_search->performSearch();
434 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
436 $query_string =
$_SESSION[
'rep_query'][
'grp'][
'title'];
443 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
445 $object_search->setFilter(array(
'grp'));
453 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
455 $query_string =
$_SESSION[
'rep_query'][
'role'][
'title'];
463 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
465 $object_search->setFilter(array(
'role'));
478 include_once
'Services/Search/classes/class.ilQueryParser.php';
482 $query_parser->setMinWordLength(1,
true);
483 $query_parser->parse();
485 if(!$query_parser->validate())
487 return $query_parser->getMessage();
489 return $query_parser;
496 if(is_array($_POST[
'rep_query']))
498 $_SESSION[
'usr_query_active'] = ($_POST[
'usr_query_active']) ? $_POST[
'usr_query_active'] : 0;
499 $_SESSION[
'rep_query'] = $_POST[
'rep_query'];
507 if($_POST[
'search_for'])
510 $_SESSION[
'rep_search_type'] = $_POST[
'search_for'];
512 if(!$_POST[
'search_for'] and !
$_SESSION[
'rep_search_type'])
518 $this->search_type =
$_SESSION[
'rep_search_type'];
519 #echo $this->search_type;
528 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
531 $values = array(
'0' => $lng->txt(
'please_choose'),
532 '1' => $lng->txt(
'active'),
533 '2' => $lng->txt(
'inactive'));
535 $this->tpl->setCurrentBlock(
"select_field");
536 $this->tpl->setVariable(
"SELECT_NAME",$lng->txt(
'active'));
543 $this->tpl->parseCurrentBlock();
547 switch($info[
'type'])
551 $this->tpl->setCurrentBlock(
"select_field");
552 $this->tpl->setVariable(
"SELECT_NAME",$info[
'lang']);
556 "rep_query[usr][$name]",
560 $this->tpl->parseCurrentBlock();
565 $this->tpl->setCurrentBlock(
"text_field");
566 $this->tpl->setVariable(
"TEXT_NAME",$info[
'lang']);
569 $this->tpl->setVariable(
"USR_NAME",
"rep_query[usr][$name]");
570 $this->tpl->setVariable(
"USR_VALUE",
$_SESSION[
'rep_query'][
'usr'][$name]);
571 $this->tpl->parseCurrentBlock();
574 $this->tpl->setCurrentBlock(
"usr_rows");
575 $this->tpl->parseCurrentBlock();
586 foreach($this->result_obj->getResults() as
$result)
590 if(!
$_SESSION[
'rep_search'][$this->search_type])
606 return $_SESSION[
'rep_search'][
'usr'] = $a_usr_ids;
608 foreach($a_usr_ids as $usr_id)
610 $_SESSION[
'rep_search'][
'usr'][] = $usr_id;
612 return $_SESSION[
'rep_search'][
'usr'] ? array_unique(
$_SESSION[
'rep_search'][
'usr']) : array();
617 if($this->stored ==
false)
619 $this->result_obj->mergeEntries($new_res);
620 $this->stored =
true;
625 $this->result_obj->intersectEntries($new_res);
632 $user_ids = $user_ids ? $user_ids : array();
635 foreach($user_ids as $usr_id)
642 $user_ids[$counter] = $usr_id;
647 if ($tmp_obj->getActive())
649 if ($tmp_obj->getTimeLimitUnlimited())
651 $txt_access = $this->lng->txt(
"access_unlimited");
653 elseif ($tmp_obj->getTimeLimitUntil() < time())
655 $txt_access = $this->lng->txt(
"access_expired");
664 $txt_access = $this->lng->txt(
"inactive");
668 $f_result[$counter][] = $tmp_obj->getLogin();
669 $f_result[$counter][] = $tmp_obj->getFirstname();
670 $f_result[$counter][] = $tmp_obj->getLastname();
671 $f_result[$counter][] = $tmp_obj->getEmail();
672 $f_result[$counter][] = $txt_access;
673 $f_result[$counter][] = $tmp_obj->getLastLogin();
674 $f_result[$counter][] = $usr_id;
679 return $f_result ? $f_result : array();
684 $group_ids = $group_ids ? $group_ids : array();
687 foreach($group_ids as $group_id)
694 $grp_ids[$counter] = $group_id;
697 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
698 $f_result[$counter][] = $tmp_obj->getCountMembers();
703 return $f_result ? $f_result : array();
708 $role_ids = $role_ids ? $role_ids : array();
711 foreach($role_ids as $role_id)
714 if ($role_id == ANONYMOUS_ROLE_ID)
723 if ($tmp_obj->getCountMembers() == 0)
727 $role_ids[$counter] = $role_id;
730 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
731 $f_result[$counter][] = $tmp_obj->getCountMembers();
736 return $f_result ? $f_result : array();
744 switch($this->search_type)
763 if(
$_SESSION[
'search_append'] and $this->search_type !=
'usr')
778 $tpl =& $tbl->getTemplateObject();
781 $tpl->setCurrentBlock(
"tbl_form_header");
782 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
783 $tpl->parseCurrentBlock();
786 array(
"name" =>
"delete",
"lng" =>
"delete"),
787 array(
"name" =>
"activate",
"lng" =>
"activate"),
788 array(
"name" =>
"deactivate",
"lng" =>
"deactivate"),
789 array(
"name" =>
"accessRestrict",
"lng" =>
"accessRestrict"),
790 array(
"name" =>
"accessFree",
"lng" =>
"accessFree"),
791 array(
"name" =>
"export",
"lng" =>
"export")
794 if (count($operations) > 0)
796 $select =
"<select name=\"selectedAction\">\n";
797 foreach ($operations as $val)
799 $select .=
"<option value=\"" . $val[
"name"] .
"\"";
800 if (strcmp($_POST[
"selectedAction"], $val[
"name"]) == 0)
802 $select .=
" selected=\"selected\"";
805 $select .= $this->lng->txt($val[
"lng"]);
806 $select .=
"</option>";
808 $select .=
"</select>";
809 $tpl->setCurrentBlock(
"tbl_action_select");
810 $tpl->setVariable(
"SELECT_ACTION", $select);
811 $tpl->setVariable(
"BTN_NAME",
"userAction");
812 $tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"submit"));
813 $tpl->parseCurrentBlock();
816 $tpl->setCurrentBlock(
"tbl_action_row");
817 $tpl->setVariable(
"COLUMN_COUNTS",7);
819 $tpl->parseCurrentBlock();
821 $tbl->setTitle($this->lng->txt(
"search_results"),
"icon_usr.gif",$this->lng->txt(
"search_results"));
822 $tbl->setHeaderNames(array(
"",
823 $this->lng->txt(
"username"),
824 $this->lng->txt(
"firstname"),
825 $this->lng->txt(
"lastname"),
826 $this->lng->txt(
"email"),
827 $this->lng->txt(
"access_until"),
828 $this->lng->txt(
"last_login")));
829 $tbl->setHeaderVars(array(
"",
836 array(
"ref_id" =>
$_GET[
'ref_id'],
837 "cmd" => (
$_SESSION[
'usr_search_mode'] ==
'extended') ?
'showExtended' :
'show',
838 "cmdClass" =>
"iladminusersearchgui",
839 "cmdNode" =>
$_GET[
"cmdNode"],
840 "baseClass" =>
"ilAdministrationGUI"));
842 $tbl->setColumnWidth(array(
"",
"15%",
"15%",
"15%",
"20%",
"15%",
"20%"));
847 $this->tpl->setVariable($tpl_var,$tbl->tpl->get());
860 $tpl =& $tbl->getTemplateObject();
862 $tpl->setCurrentBlock(
"tbl_form_header");
863 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
864 $tpl->parseCurrentBlock();
866 $tpl->setCurrentBlock(
"tbl_action_btn");
867 $tpl->setVariable(
"BTN_NAME",
"listUsersGroup");
868 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
869 $tpl->parseCurrentBlock();
871 if (!empty($a_grp_ids))
873 $tpl->setCurrentBlock(
"tbl_select_all");
874 $tpl->setVariable(
"COLUMN_COUNTS",4);
875 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
876 $tpl->parseCurrentBlock();
879 $tpl->setCurrentBlock(
"tbl_action_row");
880 $tpl->setVariable(
"COLUMN_COUNTS",5);
882 $tpl->parseCurrentBlock();
884 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_grp.gif",$this->lng->txt(
"crs_header_edit_members"));
885 $tbl->setHeaderNames(array(
"",
886 $this->lng->txt(
"obj_grp"),
887 $this->lng->txt(
"crs_count_members")));
888 $tbl->setHeaderVars(array(
"",
891 array(
"ref_id" =>
$_GET[
'ref_id'],
893 "cmdClass" =>
"ilsearchgui",
894 "cmdNode" =>
$_GET[
"cmdNode"]));
896 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
902 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
914 $tpl =& $tbl->getTemplateObject();
916 $tpl->setCurrentBlock(
"tbl_form_header");
917 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
918 $tpl->parseCurrentBlock();
920 $tpl->setCurrentBlock(
"tbl_action_btn");
921 $tpl->setVariable(
"BTN_NAME",
"listUsersRole");
922 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
923 $tpl->parseCurrentBlock();
925 if (!empty($a_role_ids))
927 $tpl->setCurrentBlock(
"tbl_select_all");
928 $tpl->setVariable(
"COLUMN_COUNTS",4);
929 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
930 $tpl->parseCurrentBlock();
933 $tpl->setCurrentBlock(
"tbl_action_row");
934 $tpl->setVariable(
"COLUMN_COUNTS",5);
936 $tpl->parseCurrentBlock();
938 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_role.gif",$this->lng->txt(
"crs_header_edit_members"));
939 $tbl->setHeaderNames(array(
"",
940 $this->lng->txt(
"objs_role"),
941 $this->lng->txt(
"crs_count_members")));
942 $tbl->setHeaderVars(array(
"",
945 array(
"ref_id" =>
$_GET[
'ref_id'],
947 "cmdClass" =>
"iladminusersearchgui",
948 "cmdNode" =>
$_GET[
"cmdNode"]));
950 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
956 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
964 global $rbacsystem,$tree;
966 $_SESSION[
"crs_group"] = $_POST[
"group"] = $_POST[
"group"] ? $_POST[
"group"] :
$_SESSION[
"crs_group"];
968 if(!is_array($_POST[
"group"]))
980 foreach($_POST[
"group"] as $group_id)
986 $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
999 global $rbacsystem,$rbacreview,$tree;
1001 $_SESSION[
"crs_role"] = $_POST[
"role"] = $_POST[
"role"] ? $_POST[
"role"] :
$_SESSION[
"crs_role"];
1003 if(!is_array($_POST[
"role"]))
1015 foreach($_POST[
"role"] as $role_id)
1017 $members = array_merge($rbacreview->assignedUsers($role_id),$members);
1036 $offset =
$_GET[
"offset"];
1037 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1038 $direction =
$_GET[
"sort_order"];
1039 $tbl->setLimit(1000000);
1043 $offset =
$_GET[
"offset"];
1044 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1045 $direction =
$_GET[
"sort_order"];
1046 $tbl->setLimit(1000000);
1050 $offset =
$_GET[
"offset"];
1052 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1054 $_GET[
"sort_by"] =
"login";
1056 $order =
$_GET[
"sort_by"];
1057 $direction =
$_GET[
"sort_order"];
1058 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1062 $tbl->setOrderColumn($order);
1063 $tbl->setOrderDirection($direction);
1064 $tbl->setOffset($offset);
1065 $tbl->setMaxCount(count($result_set));
1066 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1067 $tbl->setData($result_set);
1072 include_once
"./Services/Table/classes/class.ilTableGUI.php";
1082 $_SESSION[
"usr_search_link"] = $this->ctrl->getLinkTarget($this,
'show');
1084 $tbl->disable(
"auto_sort");
1085 $tbl->enable(
"select_all");
1086 $tbl->setFormName(
"cmd");
1087 $tbl->setSelectAllCheckbox(
"id");
1089 $offset =
$_GET[
"offset"];
1091 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1093 $_GET[
"sort_by"] =
"login";
1095 $order =
$_GET[
"sort_by"];
1096 $direction =
$_GET[
"sort_order"];
1097 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1099 $tbl->setOrderColumn($order);
1100 $tbl->setOrderDirection($direction);
1101 $tbl->setOffset($offset);
1102 $tbl->setMaxCount(count($result_set));
1103 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1107 foreach ($tbl->header_vars as $key => $val)
1118 $result_set = array_slice($result_set,$offset,$ilUser->getPref(
'hits_per_page'));
1121 foreach ($result_set as $i => $row)
1123 foreach ($row as $key => $cell)
1128 $link =
"ilias.php?ref_id=7&admin_mode=settings&obj_id=".$row[7].
"&search=1&cmd=view&cmdClass=ilobjusergui&cmdNode=".
$_SESSION[
"usergui_cmd_node"].
"&baseClass=ilAdministrationGUI";
1132 $result_set[$i][$key] =
"<a href=\"".$link.
"\">".$cell.
"</a>";
1137 if ($cell == $this->lng->txt(
"access_unlimited"))
1139 $result_set[$i][$key] =
"<span class=\"smallgreen\">".$cell.
"</span>";
1141 elseif (in_array($cell, array($this->lng->txt(
"access_expired"), $this->lng->txt(
"inactive"))))
1143 $result_set[$i][$key] =
"<span class=\"smallred\">".$cell.
"</span>";
1147 $result_set[$i][$key] =
"<span class=\"small\">".$cell.
"</span>";
1151 unset($result_set[$i][7]);
1155 $tbl->setData($result_set);
1160 $this->callback_class = $class;
1170 session_unregister(
"saved_post");
1171 $class =& $this->callback_class;
1173 $script = $class->ctrl->getLinkTargetByClass(
'ilAdminUserSearchGUI',
'show');
1180 $method = $_POST[
"selectedAction"];
1181 $_SESSION[
'user_" . $method . "_search'] =
true;
1182 $class =& $this->callback_class;
1183 $class->showActionConfirmation($method);
1191 $class =& $this->callback_class;
1193 $class->deleteObject();
1200 $this->ctrl->returnToParent($this);