ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjUserFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./classes/class.ilObjectGUI.php";
5 
19 {
20  var $ctrl;
21 
26  function ilObjUserFolderGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
27  {
28  // TODO: move this to class.ilias.php
29  define('USER_FOLDER_ID',7);
30 
31  $this->type = "usrf";
32  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
33 
34  $this->lng->loadLanguageModule('search');
35  $this->lng->loadLanguageModule("user");
36  }
37 
38  function setUserOwnerId($a_id)
39  {
40  $this->user_owner_id = $a_id;
41  }
42  function getUserOwnerId()
43  {
44  return $this->user_owner_id ? $this->user_owner_id : USER_FOLDER_ID;
45  }
46 
47  function &executeCommand()
48  {
49  $next_class = $this->ctrl->getNextClass($this);
50  $cmd = $this->ctrl->getCmd();
51  $this->prepareOutput();
52 
53  switch($next_class)
54  {
55  case 'ilusertablegui':
56  include_once("./Services/User/classes/class.ilUserTableGUI.php");
57  $u_table = new ilUserTableGUI($this, "view");
58  $u_table->initFilter();
59  $this->ctrl->setReturn($this,'view');
60  $this->ctrl->forwardCommand($u_table);
61  break;
62 
63  case 'ilpermissiongui':
64  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret =& $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  case 'iladminusersearchgui':
70  include_once('./Services/Search/classes/class.ilAdminUserSearchGUI.php');
71  $user_search =& new ilAdminUserSearchGUI();
72  $user_search->setCallbackClass($this);
73 
74  $this->tabs_gui->setTabActive('search_user_extended');
75  $this->ctrl->setReturn($this,'view');
76  $ret =& $this->ctrl->forwardCommand($user_search);
77  break;
78 
79  default:
80  if(!$cmd)
81  {
82  $cmd = "view";
83  }
84  $cmd .= "Object";
85 
86  $this->$cmd();
87 
88  break;
89  }
90  return true;
91  }
92 
94  {
95  global $ilErr,$rbacsystem;
96 
97  if (!$rbacsystem->checkAccess("read",$this->object->getRefId()))
98  {
99  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
100  }
101 
102  include_once './Services/Excel/classes/class.ilExcelWriterAdapter.php';
103 
104  $pewa =& new ilExcelWriterAdapter('learning_progress.xls');
105 
106  // add/fill worksheet
107  $this->_addLearningProgressWorksheet($pewa);
108 
109  // HEADER SENT
110 
111  $workbook =& $pewa->getWorkbook();
112  $workbook->close();
113  }
114 
116  {
117  include_once 'Services/Excel/classes/class.ilExcelUtils.php';
118 
119  $workbook =& $pewa->getWorkbook();
120  $worksheet =& $workbook->addWorksheet($this->lng->txt('objs_usr'));
121 
122  // SHOW HEADER
123  $worksheet->mergeCells(0,0,0,4);
124  $worksheet->setColumn(1,0,32);
125  $worksheet->setColumn(1,1,32);
126  $worksheet->setColumn(1,2,32);
127  $worksheet->setColumn(1,3,32);
128  $worksheet->setColumn(1,4,32);
129 
130  $title = $this->lng->txt('learning_progress');
131  $title .= ' '.$this->lng->txt('as_of').': ';
132  $title .= strftime('%Y-%m-%d %R',time());
133 
134  $worksheet->writeString(0,0,ilExcelUtils::_convert_text($title),$pewa->getFormatTitle());
135 
136  $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('login')),$pewa->getFormatHeader());
137  $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('lastname')),$pewa->getFormatHeader());
138  $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('firstname')),$pewa->getFormatHeader());
139  $worksheet->writeString(1,3,ilExcelUtils::_convert_text($this->lng->txt('online_time')),$pewa->getFormatHeader());
140  $worksheet->writeString(1,4,ilExcelUtils::_convert_text($this->lng->txt('last_login')),$pewa->getFormatHeader());
141 
142 
143  $usr_data = ilObjUser::_getAllUserData(array("login","firstname","lastname",'last_login','online_time'),1);
144  $usr_data = ilUtil::sortArray($usr_data,$_SESSION["usrf_sort_by"],$_SESSION["usrf_sort_order"]);
145 
146  $counter = 2;
147 
148  foreach($usr_data as $user)
149  {
150  $worksheet->writeString($counter,0,$user['login']);
151  $worksheet->writeString($counter,1,$user['lastname']);
152  $worksheet->writeString($counter,2,$user['firstname']);
153  $worksheet->writeString($counter,3,ilFormat::_secondsToShortString($user['online_time']),
154  $pewa->getFormatDayTime());
155  $worksheet->writeString($counter,4,$user['last_login'],
156  $pewa->getFormatDate());
157 
158  ++$counter;
159  }
160  }
161 
162 
164  {
165  include_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
166  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
167 
169 
170  global $ilUser,$rbacsystem;
171 
172  $this->max_count = $ilUser->getPref('hits_per_page');
173 
174  if (!$rbacsystem->checkAccess("read",$this->object->getRefId()))
175  {
176  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
177  }
178 
179  $_SESSION['usrf_sort_by'] = $_GET['sort_by'] ? $_GET['sort_by'] : ($_SESSION['usrf_sort_by'] ?
180  $_SESSION['usrf_sort_by'] : 'login');
181 
182  $_SESSION['usrf_sort_order'] = $_GET['sort_order'] ? $_GET['sort_order'] : ($_SESSION['usrf_sort_order'] ?
183  $_SESSION['usrf_sort_order'] : 'asc');
184 
185 
186  // Excel export
187  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
188 
189  // display button
190  $this->lng->loadLanguageModule('payment');
191  $this->tpl->setCurrentBlock("btn_cell");
192  $this->tpl->setVariable("BTN_LINK",
193  $this->ctrl->getLinkTarget($this, "learningProgressExcelExport"));
194  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("excel_export"));
195  $this->tpl->parseCurrentBlock();
196 
197  //prepare objectlist
198  $data["cols"] = array("login", "firstname", "lastname", "online_time",'last_login');
199 
200  $usr_data = ilObjUser::_getAllUserData(array("login","firstname","lastname",'last_login','online_time'),1);
201  $num_users = count($usr_data) - 1;
202 
203 
204  // sort and slice array
205  $usr_data = ilUtil::sortArray($usr_data,$_SESSION["usrf_sort_by"],$_SESSION["usrf_sort_order"]);
206  $usr_data = array_slice($usr_data,$_GET["offset"],$this->max_count);
207 
208  foreach ($usr_data as $val)
209  {
210  if ($val["usr_id"] == ANONYMOUS_USER_ID)
211  {
212  continue;
213  }
214 
215  $data["data"]["$val[usr_id]"] = array(
216  "login" => $val["login"],
217  "firstname" => $val["firstname"],
218  "lastname" => $val["lastname"],
219  "online_time" => ilFormat::_secondsToShortString($val['online_time']),
220  "last_login" => ilDatePresentation::formatDate(new ilDateTime($val['last_login'],IL_CAL_DATETIME))
221  );
222  }
223 
224  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_list.html");
225 
226  // Show Table
227 
228  include_once "./Services/Table/classes/class.ilTableGUI.php";
229  $this->tpl->addBlockfile("USR_TABLE", "user_table", "tpl.table.html");
230  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_tbl_row.html");
231 
232  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
233 
234  // create table
235  $tbl = new ilTableGUI();
236 
237  // title & header columns
238  $tbl->setTitle($this->object->getTitle(),"icon_usr.gif",
239  $this->lng->txt("obj_".$this->object->getType()));
240 
241  foreach ($data["cols"] as $val)
242  {
243  $header_names[] = $this->lng->txt($val);
244  }
245 
246  $tbl->setHeaderNames($header_names);
247 
248  $header_params = $this->ctrl->getParameterArray($this, "learningProgress");
249  $tbl->setHeaderVars($data["cols"],$header_params);
250  $tbl->setColumnWidth(array("20%","20%","20%","20%"));
251 
252 
253  // control
254  //$tbl->enable("hits");
255  $tbl->setOrderColumn($_GET["sort_by"]);
256  $tbl->setOrderDirection($_GET["sort_order"]);
257  $tbl->setLimit($this->max_count);
258  $tbl->setOffset($_GET["offset"]);
259  $tbl->setMaxCount($num_users);
260 
261  // footer
262  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
263 
264  // render table
265  $tbl->render();
266 
267  //table cell
268  $counter = 0;
269  foreach($data['data'] as $usr_id => $fields)
270  {
271  // color changing
272  $css_row = ilUtil::switchColor($counter++,"tblrow1","tblrow2");
273 
274  $this->tpl->setVariable("CSS_ROW", $css_row);
275 
276  foreach ($fields as $key => $val)
277  {
278  //build link
279 
280  // dirty workaround to have ids for function showActions (checkbox toggle option)
281  $this->ids[] = $ctrl["obj_id"];
282 
283  if ($key == "login" and $lp_active)
284  {
285  $this->ctrl->setParameterByClass("illearningprogressgui", "ref_id",$this->object->getRefId());
286  $this->ctrl->setParameterByClass("illearningprogressgui", "obj_id", $usr_id);
287  $link = $this->ctrl->getLinkTargetByClass(array("ilobjusergui",'illearningprogressgui'), "");
288 
289  $this->tpl->setCurrentBlock("begin_link");
290  $this->tpl->setVariable("LINK_TARGET", $link);
291  $this->tpl->parseCurrentBlock();
292  $this->tpl->touchBlock("end_link");
293  }
294 
295  $this->tpl->setCurrentBlock("text");
296  $this->tpl->setVariable("TEXT_CONTENT", $val);
297  $this->tpl->parseCurrentBlock();
298  $this->tpl->setCurrentBlock("table_cell");
299  $this->tpl->parseCurrentBlock();
300  } //foreach
301 
302  $this->tpl->setCurrentBlock("tbl_content");
303  $this->tpl->setVariable("CSS_ROW", $css_row);
304  $this->tpl->parseCurrentBlock();
305  } //for
306  }
307 
312  function resetFilterObject()
313  {
314  include_once("./Services/User/classes/class.ilUserTableGUI.php");
315  $utab = new ilUserTableGUI($this, "view");
316  $utab->resetOffset();
317  $utab->resetFilter();
318 
319  // from "old" implementation
320  $this->viewObject(TRUE);
321  }
322 
326  function addUserObject()
327  {
328  global $ilCtrl;
329 
330  $ilCtrl->setParameterByClass("ilobjusergui", "new_type", "usr");
331  $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjusergui"), "create");
332  }
333 
334 
338  function applyFilterObject()
339  {
340  global $ilTabs;
341 
342  include_once("./Services/User/classes/class.ilUserTableGUI.php");
343  $utab = new ilUserTableGUI($this, "view");
344  $utab->resetOffset();
345  $utab->writeFilterToSession();
346  $this->viewObject();
347  $ilTabs->activateTab("obj_usrf");
348  }
349 
355  function viewObject($reset_filter = FALSE)
356  {
357  global $rbacsystem, $ilUser, $ilToolbar, $tpl;
358 
359  // toolbar
360  /*$ilToolbar->addButton($this->lng->txt("search_user_extended"),
361  $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','startExtended'));
362  if ($_SESSION['rep_search']['usr']) // last search result
363  {
364  $ilToolbar->addButton($this->lng->txt("last_search_result"),
365  $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show'));
366  }*/
367  //$ilToolbar->addButton($this->lng->txt("import_users"),
368  // $this->ctrl->getLinkTarget($this, "importUserForm"));
369 
370 if (true)
371 {
372  include_once("./Services/User/classes/class.ilUserTableGUI.php");
373  $utab = new ilUserTableGUI($this, "view");
374  $tpl->setContent($utab->getHTML());
375  return;
376 }
377 
378 
379  if ($reset_filter)
380  {
381  $_SESSION["user_filter"] = 1;
382  }
383  else
384  {
385  $_SESSION["usergui_cmd_node"] = $this->ctrl->getNodeIdForTargetClass($this->ctrl->getCmdNode(),"ilobjusergui");
386  $this->ctrl->saveParameter($this, "user_filter_date_y");
387  $this->ctrl->saveParameter($this, "user_filter_date_m");
388  $this->ctrl->saveParameter($this, "user_filter_date_d");
389  $this->ctrl->saveParameter($this, "selected_course");
390  $this->ctrl->saveParameter($this, "selected_group");
391  $this->ctrl->saveParameter($this, "selected_role");
392  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "user_filter_date_y");
393  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "user_filter_date_m");
394  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "user_filter_date_d");
395  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "selected_course");
396  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "selected_group");
397  $this->ctrl->saveParameterByClass("ilAdminUserSearchGUI", "selected_role");
398  if (strlen($_GET["user_filter_date_y"].$_GET["user_filter_date_m"].$_GET["user_filter_date_d"]))
399  {
400  $_SESSION["user_filter_data"] = array(
401  "y" => $_GET["user_filter_date_y"],
402  "m" => $_GET["user_filter_date_m"],
403  "d" => $_GET["user_filter_date_d"],
404  );
405  }
406  if (strlen($_GET["selected_course"]))
407  {
408  $_SESSION["user_filter_data"] = $_GET["selected_course"];
409  }
410  if (strlen($_GET["selected_group"]))
411  {
412  $_SESSION["user_filter_data"] = $_GET["selected_group"];
413  }
414  if (strlen($_GET["selected_role"]))
415  {
416  $_SESSION["user_filter_data"] = $_GET["selected_role"];
417  }
418  if (isset($_POST["user_filter"]))
419  {
420  $_SESSION["user_filter"] = $_POST["user_filter"];
421  switch ($_POST["user_filter"])
422  {
423  case 4:
424  $_SESSION["user_filter_data"] = $_POST["date"];
425  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "user_filter_date_y", $_POST["date"]["y"]);
426  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "user_filter_date_m", $_POST["date"]["m"]);
427  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "user_filter_date_d", $_POST["date"]["d"]);
428  $this->ctrl->setParameter($this, "user_filter_date_y", $_POST["date"]["y"]);
429  $this->ctrl->setParameter($this, "user_filter_date_m", $_POST["date"]["m"]);
430  $this->ctrl->setParameter($this, "user_filter_date_d", $_POST["date"]["d"]);
431  break;
432  case 5:
433  $_SESSION["user_filter_data"] = $_POST["courseId"];
434  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "selected_course", $_POST["courseId"]);
435  $this->ctrl->setParameter($this, "selected_course", $_POST["courseId"]);
436  break;
437  case 6:
438  $_SESSION["user_filter_data"] = $_POST["groupId"];
439  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "selected_group", $_POST["groupId"]);
440  $this->ctrl->setParameter($this, "selected_group", $_POST["groupId"]);
441  break;
442  case 7:
443  $_SESSION["user_filter_data"] = $_POST["roleId"];
444  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "selected_role", $_POST["roleId"]);
445  $this->ctrl->setParameter($this, "selected_role", $_POST["roleId"]);
446  break;
447  }
448  }
449  if (!isset($_SESSION["user_filter"]))
450  {
451  $_SESSION["user_filter"] = 1;
452  }
453  }
454 
455  // keep offset/sorting
456  if (isset($_GET["sort_by"]))
457  {
458  $_SESSION["user_folder_sort_by"] = $_GET["sort_by"];
459  }
460  if (isset($_GET["sort_order"]))
461  {
462  $_SESSION["user_folder_order"] = $_GET["sort_order"];
463  }
464  if (isset($_GET["offset"]))
465  {
466  $_SESSION["user_folder_offset"] = $_GET["offset"];
467  }
468  $_GET["offset"] = $_SESSION["user_folder_offset"];
469  $_GET["sort_order"] = $_SESSION["user_folder_order"] ? $_SESSION["user_folder_order"] : "asc";
470  $_GET["sort_by"] = $_SESSION["user_folder_sort_by"] ? $_SESSION["user_folder_sort_by"] : "login";
471 
472  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
473  {
474  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
475  }
476 
477  //prepare objectlist
478  $this->data = array();
479  $this->data["data"] = array();
480  $this->data["ctrl"] = array();
481 
482  $this->data["cols"] = array("", "login", "firstname", "lastname","email","access_until", "last_login");
483 
484  $usr_data = ilObjUser::_getAllUserData(array("login","firstname","lastname","email","time_limit_until","time_limit_unlimited","last_login", "active"), $_SESSION["user_filter"]);
485 
486  // fetch current time outside loop
487  $current_time = time();
488 
489  foreach ($usr_data as $val)
490  {
491  if ($val["usr_id"] == ANONYMOUS_USER_ID)
492  {
493  continue;
494  }
495 
496  // determine txt_access
497  // Note: If you do changes here, you have to change the corresponding
498  // code in ilAdminUserSearchGUI::__fillUserTable as well.
499  if ($val['active'])
500  {
501  if ($val["time_limit_unlimited"])
502  {
503  $txt_access = $this->lng->txt("access_unlimited");
504  }
505  elseif ($val["time_limit_until"] < $current_time)
506  {
507  $txt_access = $this->lng->txt("access_expired");
508  }
509  else
510  {
511  $txt_access = ilDatePresentation::formatDate(new ilDateTime($val["time_limit_until"],IL_CAL_UNIX));
512  }
513  }
514  else
515  {
516  $txt_access = $this->lng->txt("inactive");
517  }
518  //visible data part
519  $this->data["data"][] = array(
520  "login" => $val["login"],
521  "firstname" => $val["firstname"],
522  "lastname" => $val["lastname"],
523  "email" => $val["email"],
524  "access_until" => $txt_access,
525  "last_login" => $val["last_login"],
526  "obj_id" => $val["usr_id"]
527  );
528  }
529 
530  $this->maxcount = count($this->data["data"]);
531 
532  if ($_GET["offset"] >= $this->maxcount)
533  {
534  $_GET["offset"] = $_SESSION["user_folder_offset"] = 0;
535  }
536 
537  // TODO: correct this in objectGUI
538  if ($_GET["sort_by"] == "name")
539  {
540  $_GET["sort_by"] = "login";
541  }
542 
543  //var_dump("<pre>",$this->data["data"],"</pre>");
544  // sorting array
545  $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
546  $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
547  //var_dump("<pre>",$this->data["data"],"</pre>");
548  // now compute control information
549  foreach ($this->data["data"] as $key => $val)
550  {
551  $this->data["ctrl"][$key] = array(
552  "ref_id" => $this->id,
553  "obj_id" => $val["obj_id"]
554  );
555  $tmp[] = $val["obj_id"];
556  unset($this->data["data"][$key]["obj_id"]);
557  }
558 
559  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_list.html");
560 
561  switch ($_SESSION["user_filter"])
562  {
563  case 4:
564  $this->tpl->setCurrentBlock("filter_date");
565  $this->tpl->setVariable("DATE_SELECTION", ilUtil::makeDateSelect("date", $_SESSION["user_filter_data"]["y"], $_SESSION["user_filter_data"]["m"], $_SESSION["user_filter_data"]["d"]));
566  $this->tpl->setVariable("TEXT_FILTER_DATE", $this->lng->txt("before"));
567  $this->tpl->parseCurrentBlock();
568  break;
569  case 5:
570  $this->tpl->setCurrentBlock("filter_course");
571  $courses = ilUtil::_getObjectsByOperations("crs", "read", $ilUser->getId(), -1);
572  $options = ilObject::_prepareCloneSelection($courses, "crs");
573  $select = ilUtil::formSelect($_SESSION["user_filter_data"], "courseId" ,$options,false,true);
574  $this->tpl->setVariable("COURSE_SELECTION", $select);
575  $this->tpl->setVariable("TEXT_FILTER_COURSE", $this->lng->txt("course"));
576  $this->tpl->parseCurrentBlock();
577  break;
578  case 6:
579  $this->tpl->setCurrentBlock("filter_group");
580  $groups = ilUtil::_getObjectsByOperations("grp", "read", $ilUser->getId(), -1);
581  $options = ilObject::_prepareCloneSelection($groups, "grp");
582  $select = ilUtil::formSelect($_SESSION["user_filter_data"], "groupId" ,$options,false,true);
583  $this->tpl->setVariable("GROUP_SELECTION", $select);
584  $this->tpl->setVariable("TEXT_FILTER_GROUP", $this->lng->txt("grp"));
585  $this->tpl->parseCurrentBlock();
586  break;
587  case 7:
588  global $rbacreview;
589  $this->tpl->setCurrentBlock("filter_role");
590  $roles = $rbacreview->getRolesByFilter(2, $ilUser->getId());
591  $options = array();
592  foreach ($roles as $role)
593  {
594  $options[$role["rol_id"]] = $role["title"];
595  }
596  $select = ilUtil::formSelect($_SESSION["user_filter_data"], "roleId" ,$options, false, true);
597  $this->tpl->setVariable("ROLE_SELECTION", $select);
598  $this->tpl->setVariable("TEXT_FILTER_ROLE", $this->lng->txt("role"));
599  $this->tpl->parseCurrentBlock();
600  break;
601  }
602  $this->tpl->setCurrentBlock("filter");
603  $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
604  $this->tpl->setVariable("SELECT_FILTER",$this->__buildUserFilterSelect());
605  $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
606  $this->tpl->setVariable("FILTER_NAME",'view');
607  $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
608  $this->tpl->setVariable("FILTER_VALUE_RESET",$this->lng->txt('reset_filter'));
609  $this->tpl->parseCurrentBlock();
610 
611  $this->tpl->setCurrentBlock("search");
612  $this->tpl->setVariable("SEARCH_TXT_SEARCH",$this->lng->txt('search'));
613  $this->ctrl->setParameterByClass("ilAdminUserSearchGUI", "user_filter", $_SESSION["user_filter"]);
614  $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormActionByClass('ilAdminUserSearchGUI','startSimple'));
615  $this->tpl->setVariable("SEARCH_NAME",'startSimple');
616  $this->tpl->setVariable("SEARCH_VALUE",$this->lng->txt('search_users'));
617  $this->tpl->parseCurrentBlock();
618 
619  $this->displayList();
620  } //function
621 
622 
628  function displayList()
629  {
630  global $lng;
631 
632  if (!is_array($this->data["data"][0]))
633  {
634  ilUtil::sendInfo($this->lng->txt("usr_filter_empty_result")); return;
635  }
636 
637  include_once "./Services/Table/classes/class.ilTableGUI.php";
638 
639  // load template for table
640  $this->tpl->addBlockfile("USR_TABLE", "user_table", "tpl.table.html");
641  // load template for table content data
642  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
643 
644  $num = 0;
645 
646  //$obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
647  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
648 
649  // create table
650  $tbl = new ilTableGUI();
651 
652  // title & header columns
653  $tbl->setTitle($this->object->getTitle(),"icon_usr.gif", $this->lng->txt("obj_".$this->object->getType()));
654 
655  foreach ($this->data["cols"] as $val)
656  {
657  $header_names[] = $this->lng->txt($val);
658  }
659 
660  $tbl->setHeaderNames($header_names);
661 
662  $header_params = $this->ctrl->getParameterArray($this, "view");
663  $tbl->setHeaderVars($this->data["cols"],$header_params);
664  $tbl->setColumnWidth(array("","15%","15%","15%","20%","15%","20%"));
665 
666  $tbl->enable("select_all");
667  $tbl->enable("numinfo_header");
668  $tbl->setFormName("cmd");
669  $tbl->setSelectAllCheckbox("id");
670 
671  // control
672  $tbl->setOrderColumn($_GET["sort_by"]);
673  $tbl->setOrderDirection($_GET["sort_order"]);
674  $tbl->setLimit($_GET["limit"]);
675  $tbl->setOffset($_GET["offset"]);
676  $tbl->setMaxCount($this->maxcount);
677  // footer
678  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
679 
680  // render table
681  $tbl->render();
682 
683  if (is_array($this->data["data"][0]))
684  {
685  //table cell
686  for ($i=0; $i < count($this->data["data"]); $i++)
687  {
688  $data = $this->data["data"][$i];
689  $ctrl = $this->data["ctrl"][$i];
690 
691  // color changing
692  $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
693 
694  $this->tpl->setCurrentBlock("checkbox");
695  $this->tpl->setVariable("CHECKBOX_ID", $ctrl["obj_id"]);
696  $this->tpl->setVariable("CSS_ROW", $css_row);
697  $this->tpl->parseCurrentBlock();
698 
699  $this->tpl->setCurrentBlock("table_cell");
700  $this->tpl->setVariable("CELLSTYLE", "tblrow1");
701  $this->tpl->parseCurrentBlock();
702 
703  foreach ($data as $key => $val)
704  {
705  //build link
706  $this->ctrl->setParameterByClass("ilobjusergui", "ref_id", "7");
707  $this->ctrl->setParameterByClass("ilobjusergui", "obj_id", $ctrl["obj_id"]);
708  $link = $this->ctrl->getLinkTargetByClass("ilobjusergui", "view");
709 
710  // dirty workaround to have ids for function showActions (checkbox toggle option)
711  $this->ids[] = $ctrl["obj_id"];
712 
713  if ($key == "login")
714  {
715  $this->tpl->setCurrentBlock("begin_link");
716  $this->tpl->setVariable("LINK_TARGET", $link);
717  $this->tpl->parseCurrentBlock();
718  $this->tpl->touchBlock("end_link");
719  }
720 
721  if ($key == "access_until")
722  {
723  if ($val == $this->lng->txt("access_unlimited"))
724  {
725  $val = "<span class=\"smallgreen\">".$val."</span>";
726  }
727  elseif ($val == $this->lng->txt("access_expired") ||
728  $val == $this->lng->txt("inactive"))
729  {
730  $val = "<span class=\"smallred\">".$val."</span>";
731  }
732  else
733  {
734  $val = "<span class=\"small\">".$val."</span>";
735  }
736  }
737 
738  if ($key == "last_login")
739  {
741  }
742 
743  if ($key != "access_until")
744  {
745  $val = "<span class=\"small\">".$val."</span>";
746  }
747 
748  $this->tpl->setCurrentBlock("text");
749  $this->tpl->setVariable("TEXT_CONTENT", $val);
750  $this->tpl->parseCurrentBlock();
751  $this->tpl->setCurrentBlock("table_cell");
752  $this->tpl->parseCurrentBlock();
753  } //foreach
754 
755  $this->tpl->setCurrentBlock("tbl_content");
756  $this->tpl->setVariable("CSS_ROW", $css_row);
757  $this->tpl->parseCurrentBlock();
758  } //for
759  }
760  $this->showActions(true);
761 
762 
763 
764  }
765 
772  function showActions($with_subobjects = false)
773  {
774  global $rbacsystem;
775 
776  $operations = array();
777 //var_dump($this->actions);
778  if ($this->actions == "")
779  {
780  $d = array(
781  "delete" => array("name" => "delete", "lng" => "delete"),
782  "activate" => array("name" => "activate", "lng" => "activate"),
783  "deactivate" => array("name" => "deactivate", "lng" => "deactivate"),
784  "accessRestrict" => array("name" => "accessRestrict", "lng" => "accessRestrict"),
785  "accessFree" => array("name" => "accessFree", "lng" => "accessFree"),
786  "export" => array("name" => "export", "lng" => "export")
787  );
788  }
789  else
790  {
791  $d = $this->actions;
792  }
793  foreach ($d as $row)
794  {
795  if ($rbacsystem->checkAccess($row["name"],$this->object->getRefId()))
796  {
797  $operations[] = $row;
798  }
799  }
800 
801  if (count($operations) > 0)
802  {
803  $select = "<select name=\"selectedAction\">\n";
804  foreach ($operations as $val)
805  {
806  $select .= "<option value=\"" . $val["name"] . "\"";
807  if (strcmp($_POST["selectedAction"], $val["name"]) == 0)
808  {
809  $select .= " selected=\"selected\"";
810  }
811  $select .= ">";
812  $select .= $this->lng->txt($val["lng"]);
813  $select .= "</option>";
814  }
815  $select .= "</select>";
816  $this->tpl->setCurrentBlock("tbl_action_select");
817  $this->tpl->setVariable("SELECT_ACTION", $select);
818  $this->tpl->setVariable("BTN_NAME", "userAction");
819  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("submit"));
820  $this->tpl->parseCurrentBlock();
821  }
822 
823  if ($with_subobjects === true)
824  {
825  $subobjs = $this->showPossibleSubObjects();
826  }
827 
828  if ((count($operations) > 0) or $subobjs === true)
829  {
830  $this->tpl->setCurrentBlock("tbl_action_row");
831  $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
832  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
833  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
834  $this->tpl->parseCurrentBlock();
835  }
836  }
837 
845  {
846  global $rbacsystem;
847 
848  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
849 
850  if (!$rbacsystem->checkAccess('create_user',$this->object->getRefId()))
851  {
852  unset($d["usr"]);
853  }
854 
855  if (count($d) > 0)
856  {
857  foreach ($d as $row)
858  {
859  $count = 0;
860  if ($row["max"] > 0)
861  {
862  //how many elements are present?
863  for ($i=0; $i<count($this->data["ctrl"]); $i++)
864  {
865  if ($this->data["ctrl"][$i]["type"] == $row["name"])
866  {
867  $count++;
868  }
869  }
870  }
871  if ($row["max"] == "" || $count < $row["max"])
872  {
873  $subobj[] = $row["name"];
874  }
875  }
876  }
877 
878  if (is_array($subobj))
879  {
880  //build form
881  $opts = ilUtil::formSelect(12,"new_type",$subobj);
882  $this->tpl->setCurrentBlock("add_object");
883  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
884  $this->tpl->setVariable("BTN_NAME", "create");
885  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
886  $this->tpl->parseCurrentBlock();
887 
888  return true;
889  }
890 
891  return false;
892  }
893 
895  {
896  session_unregister("saved_post");
897  $this->ctrl->returnToParent($this);
898  }
899 
906  {
907  $this->cancelUserFolderAction();
908  }
909 
916  {
917  global $rbacsystem, $ilUser;
918 
919  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
920  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
921  {
922  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
923  }
924 
925  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
926 
927  // FOR ALL SELECTED OBJECTS
928  foreach ($_SESSION["saved_post"] as $id)
929  {
930  // instatiate correct object class (usr)
931  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
932  $obj->setActive(TRUE, $ilUser->getId());
933  $obj->update();
934  }
935 
936  ilUtil::sendSuccess($this->lng->txt("user_activated"),true);
937 
938  if ($_SESSION['user_activate_search'] == true)
939  {
940  session_unregister("user_activate_search");
941  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show');
942  ilUtil::redirect($script);
943  }
944  else
945  {
946  $this->ctrl->redirect($this, "view");
947  }
948  }
949 
956  {
957  $this->cancelUserFolderAction();
958  }
959 
966  {
967  global $rbacsystem, $ilUser;
968 
969  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
970  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
971  {
972  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
973  }
974 
975  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
976 
977  // FOR ALL SELECTED OBJECTS
978  foreach ($_SESSION["saved_post"] as $id)
979  {
980  // instatiate correct object class (usr)
981  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
982  $obj->setActive(FALSE, $ilUser->getId());
983  $obj->update();
984  }
985 
986  // Feedback
987  ilUtil::sendSuccess($this->lng->txt("user_deactivated"),true);
988 
989  if ($_SESSION['user_deactivate_search'] == true)
990  {
991  session_unregister("user_deactivate_search");
992  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show');
993  ilUtil::redirect($script);
994  }
995  else
996  {
997  $this->ctrl->redirect($this, "view");
998  }
999  }
1000 
1002  {
1003  $this->cancelUserFolderAction();
1004  }
1005 
1007  {
1008  global $rbacsystem, $ilUser;
1009 
1010  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
1011  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
1012  {
1013  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
1014  }
1015 
1016  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
1017 
1018  // FOR ALL SELECTED OBJECTS
1019  foreach ($_SESSION["saved_post"] as $id)
1020  {
1021  // instatiate correct object class (usr)
1022  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
1023  $obj->setTimeLimitOwner($ilUser->getId());
1024  $obj->setTimeLimitUnlimited(1);
1025  $obj->setTimeLimitFrom("");
1026  $obj->setTimeLimitUntil("");
1027  $obj->setTimeLimitMessage(0);
1028  $obj->update();
1029  }
1030 
1031  // Feedback
1032  ilUtil::sendSuccess($this->lng->txt("access_free_granted"),true);
1033 
1034  if ($_SESSION['user_accessFree_search'] == true)
1035  {
1036  session_unregister("user_accessFree_search");
1037  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show');
1038  ilUtil::redirect($script);
1039  }
1040  else
1041  {
1042  $this->ctrl->redirect($this, "view");
1043  }
1044  }
1045 
1047  {
1048  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
1049  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1050  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("time_limit_add_time_limit_for_selected"));
1051  include_once "./classes/class.ilTemplate.php";
1052  $tsTemplate = new ilTemplate("tpl.time.limit.html", TRUE, TRUE);
1053  $from = (array_key_exists("from", $_GET)) ? $_GET["from"] : time();
1054  $until = (array_key_exists("until", $_GET)) ? $_GET["until"] : time();
1055  $fromA = getdate($from);
1056  $untilA = getdate($until);
1057  $fromDate = ilUtil::makeDateSelect("fromDate", $fromA["year"], $fromA["mon"], $fromA["mday"]);
1058  $fromTime = ilUtil::makeTimeSelect("fromTime", TRUE, $fromA["hours"], $fromA["minutes"]);
1059  $untilDate = ilUtil::makeDateSelect("untilDate", $untilA["year"], $untilA["mon"], $untilA["mday"]);
1060  $untilTime = ilUtil::makeTimeSelect("untilTime", TRUE, $untilA["hours"], $untilA["minutes"]);
1061  $tsTemplate->setVariable("TEXT_FROM", $this->lng->txt("access_from") . ": ");
1062  $tsTemplate->setVariable("TEXT_UNTIL", $this->lng->txt("access_until") . ": ");
1063  $tsTemplate->setVariable("DATE_FROM", $fromDate);
1064  $tsTemplate->setVariable("TIME_FROM", $fromTime);
1065  $tsTemplate->setVariable("DATE_UNTIL", $untilDate);
1066  $tsTemplate->setVariable("TIME_UNTIL", $untilTime);
1067  $this->tpl->setVariable("TXT_CONTENT", $tsTemplate->get());
1068  $this->tpl->setVariable("CMD_CANCEL", "cancelaccessRestrict");
1069  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1070  $this->tpl->setVariable("CMD_OK", "confirmaccessRestrict");
1071  $this->tpl->setVariable("TXT_OK", $this->lng->txt("confirm"));
1072  $this->tpl->parseCurrentBlock();
1073  }
1074 
1076  {
1077  $this->cancelUserFolderAction();
1078  }
1079 
1081  {
1082  $timefrom = mktime($_POST["fromTime"]["h"], $_POST["fromTime"]["m"], 0, $_POST["fromDate"]["m"], $_POST["fromDate"]["d"], $_POST["fromDate"]["y"]);
1083  $timeuntil = mktime($_POST["untilTime"]["h"], $_POST["untilTime"]["m"], 0, $_POST["untilDate"]["m"], $_POST["untilDate"]["d"], $_POST["untilDate"]["y"]);
1084  if ($timeuntil <= $timefrom)
1085  {
1086  ilUtil::sendFailure($this->lng->txt("time_limit_not_valid"), TRUE);
1087  $this->ctrl->setParameter($this, "from", $timefrom);
1088  $this->ctrl->setParameter($this, "until", $timeuntil);
1089  $this->ctrl->redirect($this, "setAccessRestriction");
1090  }
1091 
1092  global $rbacsystem, $ilUser;
1093 
1094  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
1095  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
1096  {
1097  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
1098  }
1099 
1100  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
1101 
1102  // FOR ALL SELECTED OBJECTS
1103  foreach ($_SESSION["saved_post"] as $id)
1104  {
1105  // instatiate correct object class (usr)
1106  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
1107  $obj->setTimeLimitOwner($ilUser->getId());
1108  $obj->setTimeLimitUnlimited(0);
1109  $obj->setTimeLimitFrom($timefrom);
1110  $obj->setTimeLimitUntil($timeuntil);
1111  $obj->setTimeLimitMessage(0);
1112  $obj->update();
1113  }
1114 
1115  // Feedback
1116  ilUtil::sendSuccess($this->lng->txt("access_restricted"),true);
1117 
1118  if ($_SESSION['user_accessRestrict_search'] == true)
1119  {
1120  session_unregister("user_accessRestrict_search");
1121  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show');
1122  ilUtil::redirect($script);
1123  }
1124  else
1125  {
1126  $this->ctrl->redirect($this, "view");
1127  }
1128  }
1129 
1136  {
1137  $this->cancelUserFolderAction();
1138  }
1139 
1146  {
1147  global $rbacsystem, $ilCtrl;
1148 
1149  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
1150  if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
1151  {
1152  ilUtil::sendFailure($this->lng->txt("msg_no_perm_delete"), true);
1153  $ilCtrl->redirect($this, "view");
1154  }
1155 
1156  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
1157 
1158  if (in_array($_SESSION["AccountId"],$_SESSION["saved_post"]))
1159  {
1160  $this->ilias->raiseError($this->lng->txt("msg_no_delete_yourself"),$this->ilias->error_obj->WARNING);
1161  }
1162 
1163  // FOR ALL SELECTED OBJECTS
1164  foreach ($_SESSION["saved_post"] as $id)
1165  {
1166  // instatiate correct object class (usr)
1167  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
1168  $obj->delete();
1169  }
1170 
1171  // Feedback
1172  ilUtil::sendSuccess($this->lng->txt("user_deleted"),true);
1173 
1174  // now unset the delete users in session
1175  #unset($_SESSION['saved_post']);
1176 
1177  if ($_SESSION['user_delete_search'] == true)
1178  {
1179  session_unregister("user_delete_search");
1180  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show');
1181  ilUtil::redirect($script);
1182  }
1183  else
1184  {
1185  $this->ctrl->redirect($this, "view");
1186  }
1187  }
1188 
1195  {
1196  $this->cancelUserFolderAction();
1197  }
1198 
1205  {
1206  $user_data_filter = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
1207  session_unregister("saved_post");
1208  $this->object->buildExportFile($_POST["export_type"], $user_data_filter);
1209  ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
1210  }
1211 
1215  function deleteObject()
1216  {
1217  if(!isset($_POST["id"]))
1218  {
1219  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1220  }
1221  // SAVE POST VALUES
1222  $_SESSION["saved_post"] = $_POST["id"];
1223 
1224  unset($this->data);
1225  $this->data["cols"] = array("type", "title", "description", "last_change");
1226 
1227  foreach($_POST["id"] as $id)
1228  {
1229  $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
1230 
1231  $this->data["data"]["$id"] = array(
1232  "type" => $obj_data->getType(),
1233  "title" => $obj_data->getTitle(),
1234  "desc" => $obj_data->getDescription(),
1235  "last_update" => $obj_data->getLastUpdateDate());
1236  }
1237 
1238  $this->data["buttons"] = array( "cancelDelete" => $this->lng->txt("cancel"),
1239  "confirmedDelete" => $this->lng->txt("confirm"));
1240 
1241  $this->getTemplateFile("confirm");
1242 
1243  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1244 
1245  $this->tpl->setVariable("FORMACTION",
1246  $this->ctrl->getFormAction($this));
1247 
1248  // BEGIN TABLE HEADER
1249  foreach ($this->data["cols"] as $key)
1250  {
1251  $this->tpl->setCurrentBlock("table_header");
1252  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1253  $this->tpl->parseCurrentBlock();
1254  }
1255  // END TABLE HEADER
1256 
1257  // BEGIN TABLE DATA
1258  $counter = 0;
1259 
1260  foreach($this->data["data"] as $key => $value)
1261  {
1262  // BEGIN TABLE CELL
1263  foreach($value as $key => $cell_data)
1264  {
1265  $this->tpl->setCurrentBlock("table_cell");
1266 
1267  // CREATE TEXT STRING
1268  if($key == "type")
1269  {
1270  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
1271  }
1272  else
1273  {
1274  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
1275  }
1276  $this->tpl->parseCurrentBlock();
1277  }
1278 
1279  $this->tpl->setCurrentBlock("table_row");
1280  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1281  $this->tpl->parseCurrentBlock();
1282  // END TABLE CELL
1283  }
1284  // END TABLE DATA
1285 
1286  // BEGIN OPERATION_BTN
1287  foreach($this->data["buttons"] as $name => $value)
1288  {
1289  $this->tpl->setCurrentBlock("operation_btn");
1290  $this->tpl->setVariable("BTN_NAME",$name);
1291  $this->tpl->setVariable("BTN_VALUE",$value);
1292  $this->tpl->parseCurrentBlock();
1293  }
1294  }
1295 
1297  {
1298  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
1299  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1300  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("export_format_selection"));
1301  $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
1302  $options = array();
1303  foreach ($export_types as $type)
1304  {
1305  $options[$type] = $this->lng->txt($type);
1306  }
1307  $select = ilUtil::formSelect("userfolder_export_xml", "export_type" ,$options, false, true);
1308  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("export_format") . ": " . $select);
1309  $this->tpl->setVariable("CMD_CANCEL", "cancelexport");
1310  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
1311  $this->tpl->setVariable("CMD_OK", "confirmexport");
1312  $this->tpl->setVariable("TXT_OK", $this->lng->txt("confirm"));
1313  $this->tpl->parseCurrentBlock();
1314  }
1315 
1319  function showActionConfirmation($action)
1320  {
1321  if(!isset($_POST["id"]))
1322  {
1323  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1324  }
1325  // SAVE POST VALUES
1326  $_SESSION["saved_post"] = $_POST["id"];
1327 
1328  if (strcmp($action, "export") == 0) return $this->selectExportFormat();
1329  if (strcmp($action, "accessRestrict") == 0) return $this->setAccessRestrictionObject();
1330 
1331  unset($this->data);
1332  $this->data["cols"] = array("type", "title", "description", "last_change");
1333 
1334  foreach($_POST["id"] as $id)
1335  {
1336  $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
1337 
1338  $this->data["data"]["$id"] = array(
1339  "type" => $obj_data->getType(),
1340  "title" => $obj_data->getTitle(),
1341  "desc" => $obj_data->getDescription(),
1342  "last_update" => $obj_data->getLastUpdateDate());
1343  }
1344 
1345  $this->data["buttons"] = array( "cancel" . $action => $this->lng->txt("cancel"),
1346  "confirm" . $action => $this->lng->txt("confirm"));
1347 
1348  $this->getTemplateFile("confirm");
1349 
1350  ilUtil::sendQuestion($this->lng->txt("info_" . $action . "_sure"));
1351 
1352  $this->tpl->setVariable("FORMACTION",
1353  $this->ctrl->getFormAction($this));
1354 
1355  // BEGIN TABLE HEADER
1356  foreach ($this->data["cols"] as $key)
1357  {
1358  $this->tpl->setCurrentBlock("table_header");
1359  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1360  $this->tpl->parseCurrentBlock();
1361  }
1362  // END TABLE HEADER
1363 
1364  // BEGIN TABLE DATA
1365  $counter = 0;
1366 
1367  foreach($this->data["data"] as $key => $value)
1368  {
1369  // BEGIN TABLE CELL
1370  foreach($value as $key => $cell_data)
1371  {
1372  $this->tpl->setCurrentBlock("table_cell");
1373 
1374  // CREATE TEXT STRING
1375  if($key == "type")
1376  {
1377  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
1378  }
1379  else
1380  {
1381  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
1382  }
1383  $this->tpl->parseCurrentBlock();
1384  }
1385 
1386  $this->tpl->setCurrentBlock("table_row");
1387  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1388  $this->tpl->parseCurrentBlock();
1389  // END TABLE CELL
1390  }
1391  // END TABLE DATA
1392 
1393  // BEGIN OPERATION_BTN
1394  foreach($this->data["buttons"] as $name => $value)
1395  {
1396  $this->tpl->setCurrentBlock("operation_btn");
1397  $this->tpl->setVariable("BTN_NAME",$name);
1398  $this->tpl->setVariable("BTN_VALUE",$value);
1399  $this->tpl->parseCurrentBlock();
1400  }
1401  }
1402 
1407  {
1408  $_POST["selectedAction"] = "delete";
1409  $this->showActionConfirmation($_POST["selectedAction"]);
1410  }
1411 
1416  {
1417  $_POST["selectedAction"] = "activate";
1418  $this->showActionConfirmation($_POST["selectedAction"]);
1419  }
1420 
1425  {
1426  $_POST["selectedAction"] = "deactivate";
1427  $this->showActionConfirmation($_POST["selectedAction"]);
1428  }
1429 
1434  {
1435  $_POST["selectedAction"] = "accessRestrict";
1436  $this->showActionConfirmation($_POST["selectedAction"]);
1437  }
1438 
1442  function freeAccessObject()
1443  {
1444  $_POST["selectedAction"] = "accessFree";
1445  $this->showActionConfirmation($_POST["selectedAction"]);
1446  }
1447 
1452  {
1453  $_POST["selectedAction"] = "export";
1454  $this->showActionConfirmation($_POST["selectedAction"]);
1455  }
1456 
1457  function userActionObject()
1458  {
1459  $this->showActionConfirmation($_POST["selectedAction"]);
1460  }
1461 
1467  // presumably deprecated
1468  // functionality moved to search/classes/iladminusersearch
1469  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
1471  {
1472  $this->tabs_gui->setTabActive('obj_usrf');
1473 
1474  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_search_form.html");
1475 
1476  $this->tpl->setVariable("FORMACTION",
1477  $this->ctrl->getFormAction($this));
1478  $this->tpl->setVariable("USERNAME_CHECKED", " checked=\"checked\"");
1479  $this->tpl->setVariable("FIRSTNAME_CHECKED", " checked=\"checked\"");
1480  $this->tpl->setVariable("LASTNAME_CHECKED", " checked=\"checked\"");
1481  $this->tpl->setVariable("EMAIL_CHECKED", " checked=\"checked\"");
1482  $this->tpl->setVariable("ACTIVE_CHECKED", " checked=\"checked\"");
1483  $this->tpl->setVariable("TXT_SEARCH_USER",$this->lng->txt("search_user"));
1484  $this->tpl->setVariable("TXT_SEARCH_IN",$this->lng->txt("search_in"));
1485  $this->tpl->setVariable("TXT_SEARCH_USERNAME",$this->lng->txt("username"));
1486  $this->tpl->setVariable("TXT_SEARCH_FIRSTNAME",$this->lng->txt("firstname"));
1487  $this->tpl->setVariable("TXT_SEARCH_LASTNAME",$this->lng->txt("lastname"));
1488  $this->tpl->setVariable("TXT_SEARCH_EMAIL",$this->lng->txt("email"));
1489  $this->tpl->setVariable("TXT_SEARCH_ACTIVE",$this->lng->txt("search_active"));
1490  $this->tpl->setVariable("TXT_SEARCH_INACTIVE",$this->lng->txt("search_inactive"));
1491  $this->tpl->setVariable("BUTTON_SEARCH",$this->lng->txt("search"));
1492  $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
1493  $this->tpl->setVariable("TXT_SEARCH_NOTE",$this->lng->txt("search_note"));
1494  $this->tpl->setVariable("ACTIVE_CHECKED","checked=\"checked\"");
1495  }
1496 
1497  // presumably deprecated
1498  // functionality moved to search/classes/iladminusersearch
1499  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
1501  {
1502  $this->ctrl->redirect($this, "view");
1503  }
1504 
1505  // presumably deprecated
1506  // functionality moved to search/classes/iladminusersearch
1507  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
1508  function searchUserObject()
1509  {
1510  global $rbacreview;
1511 
1512  $obj_str = "&obj_id=".$this->obj_id;
1513 
1514  $_POST["search_string"] = trim($_POST["search_string"]) ? trim($_POST["search_string"]) : trim(urldecode($_GET["search_string"]));
1515  //$_POST["search_fields"] = $_POST["search_fields"] ? $_POST["search_fields"] : explode(",",urldecode($_GET["search_fields"]));
1516  $_SESSION['us_active'] = isset($_POST['active']) ? $_POST['active'] : $_SESSION['us_active'];
1517 
1518  $_POST["search_fields"] = array ("username","firstname","lastname","email");
1519 
1520  if (empty($_POST["search_string"]))
1521  {
1522  $_POST["search_string"] = "%";
1523  }
1524 
1525  if (empty($_POST["search_fields"]))
1526  {
1527  $_POST["search_fields"] = array();
1528  }
1529  if (count($search_result = ilObjUser::searchUsers($_POST["search_string"],$_SESSION['us_active'])) == 0)
1530  {
1531  if ($_POST["search_string"] == "%")
1532  {
1533  $_POST["search_string"] = "";
1534  }
1535  $msg = $this->lng->txt("msg_no_search_result");
1536  if ($_POST["search_string"] != "")
1537  {
1538  $msg .= " ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'";
1539  }
1540  ilUtil::sendInfo($msg, true);
1541  $this->ctrl->redirect($this, "searchUserForm");
1542  }
1543  //add template for buttons
1544  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1545 
1546  // display button
1547  $this->tpl->setCurrentBlock("btn_cell");
1548  $this->tpl->setVariable("BTN_LINK",
1549  $this->ctrl->getLinkTarget($this, "searchUserForm"));
1550  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("search_new"));
1551  $this->tpl->parseCurrentBlock();
1552 
1553  $this->data["cols"] = array("", "login", "firstname", "lastname", "email", "active");
1554 
1555  if($_SESSION['us_active'] == 1)
1556  {
1557  $searchActive = true;
1558  }
1559  else
1560  {
1561  $searchInactive = true;
1562  }
1563 
1564  foreach ($search_result as $key => $val)
1565  {
1566  $val["active_text"] = $this->lng->txt("inactive");
1567  if ($val["active"])
1568  {
1569  $val["active_text"] = $this->lng->txt("active");
1570  }
1571 
1572  // check if the fields are set
1573  $searchStringToLower = strtolower($_POST["search_string"]);
1574  $displaySearchResult = false;
1575  if (in_array("username", $_POST["search_fields"]))
1576  if (strpos(strtolower($val["login"]), strtolower($_POST["search_string"])) !== false)
1577  $displaySearchResult = true;
1578  if (in_array("firstname", $_POST["search_fields"]))
1579  if (strpos(strtolower($val["firstname"]), strtolower($_POST["search_string"])) !== false)
1580  $displaySearchResult = true;
1581  if (in_array("lastname", $_POST["search_fields"]))
1582  if (strpos(strtolower($val["lastname"]), strtolower($_POST["search_string"])) !== false)
1583  $displaySearchResult = true;
1584  if (in_array("email", $_POST["search_fields"]))
1585  if (strpos(strtolower($val["email"]), strtolower($_POST["search_string"])) !== false)
1586  $displaySearchResult = true;
1587  if (($val["active"] == 1) && ($searchActive == true) ||
1588  ($val["active"] == 0) && ($searchInactive == true))
1589  {
1590  if ((strcmp($_POST["search_string"], "%") == 0) || $displaySearchResult)
1591  {
1592  //visible data part
1593  $this->data["data"][] = array(
1594  "login" => $val["login"],
1595  "firstname" => $val["firstname"],
1596  "lastname" => $val["lastname"],
1597  "email" => $val["email"],
1598  "active" => $val["active_text"],
1599  "obj_id" => $val["usr_id"]
1600  );
1601  }
1602  }
1603  }
1604  if (count($this->data["data"]) == 0)
1605  {
1606  ilUtil::sendInfo($this->lng->txt("msg_no_search_result")." ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'",true);
1607 
1608  $this->ctrl->redirect($this, "searchUserForm");
1609  }
1610 
1611  $this->maxcount = count($this->data["data"]);
1612 
1613  // TODO: correct this in objectGUI
1614  if ($_GET["sort_by"] == "name")
1615  {
1616  $_GET["sort_by"] = "login";
1617  }
1618 
1619  // sorting array
1620  $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
1621  $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
1622 
1623  // now compute control information
1624  foreach ($this->data["data"] as $key => $val)
1625  {
1626  $this->data["ctrl"][$key] = array(
1627  "ref_id" => $this->id,
1628  "obj_id" => $val["obj_id"]
1629  );
1630  $tmp[] = $val["obj_id"];
1631  unset($this->data["data"][$key]["obj_id"]);
1632  }
1633 
1634  // remember filtered users
1635  $_SESSION["user_list"] = $tmp;
1636 
1637  // load template for table
1638  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1639  // load template for table content data
1640  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1641 
1642  $num = 0;
1643 
1644  $this->ctrl->setParameter($this, "sort_by", "name");
1645  $this->ctrl->setParameter($this, "sort_order", $_GET["sort_order"]);
1646  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
1647  $this->tpl->setVariable("FORMACTION",
1648  $this->ctrl->getFormAction($this));
1649 
1650  // create table
1651  include_once "./Services/Table/classes/class.ilTableGUI.php";
1652  $tbl = new ilTableGUI();
1653 
1654  // title & header columns
1655  $tbl->setTitle($this->lng->txt("search_result"),"icon_".$this->object->getType().".gif",$this->lng->txt("obj_".$this->object->getType()));
1656  $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
1657 
1658  foreach ($this->data["cols"] as $val)
1659  {
1660  $header_names[] = $this->lng->txt($val);
1661  }
1662 
1663  $tbl->setHeaderNames($header_names);
1664 
1665  $header_params = $this->ctrl->getParameterArray($this, "searchUser");
1666  $header_params["search_string"] = urlencode($_POST["search_string"]);
1667  $header_params["search_fields"] = urlencode(implode(",",$_POST["search_fields"]));
1668 
1669  $tbl->setHeaderVars($this->data["cols"],$header_params);
1670  $tbl->setColumnWidth(array("","25%","25$%","25%","25%"));
1671 
1672  // control
1673  $tbl->enable("hits");
1674  $tbl->setOrderColumn($_GET["sort_by"]);
1675  $tbl->setOrderDirection($_GET["sort_order"]);
1676  $tbl->setLimit($_GET["limit"]);
1677  $tbl->setOffset($_GET["offset"]);
1678  $tbl->setMaxCount($this->maxcount);
1679 
1680  $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1681 
1682  // footer
1683  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1684 
1685  // render table
1686  $tbl->render();
1687 
1688  if (is_array($this->data["data"][0]))
1689  {
1690  //table cell
1691  for ($i=0; $i < count($this->data["data"]); $i++)
1692  {
1693  $data = $this->data["data"][$i];
1694  $ctrl = $this->data["ctrl"][$i];
1695 
1696  // dirty workaround to have ids for function showActions (checkbox toggle option)
1697  $this->ids[] = $ctrl["obj_id"];
1698 
1699  // color changing
1700  $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
1701 
1702  $this->tpl->setCurrentBlock("checkbox");
1703  $this->tpl->setVariable("CHECKBOX_ID", $ctrl["obj_id"]);
1704  //$this->tpl->setVariable("CHECKED", $checked);
1705  $this->tpl->setVariable("CSS_ROW", $css_row);
1706  $this->tpl->parseCurrentBlock();
1707 
1708  $this->tpl->setCurrentBlock("table_cell");
1709  $this->tpl->setVariable("CELLSTYLE", "tblrow1");
1710  $this->tpl->parseCurrentBlock();
1711 
1712  foreach ($data as $key => $val)
1713  {
1714  //build link
1715  $this->ctrl->setParameterByClass("ilobjusergui", "ref_id", "7");
1716  $this->ctrl->setParameterByClass("ilobjusergui", "obj_id", $ctrl["obj_id"]);
1717  $link = $this->ctrl->getLinkTargetByClass("ilobjusergui", "view");
1718 
1719  if ($key == "login")
1720  {
1721  $this->tpl->setCurrentBlock("begin_link");
1722  $this->tpl->setVariable("LINK_TARGET", $link);
1723  $this->tpl->parseCurrentBlock();
1724  $this->tpl->touchBlock("end_link");
1725  }
1726 
1727  $this->tpl->setCurrentBlock("text");
1728  $this->tpl->setVariable("TEXT_CONTENT", $val);
1729  $this->tpl->parseCurrentBlock();
1730  $this->tpl->setCurrentBlock("table_cell");
1731  $this->tpl->parseCurrentBlock();
1732  } //foreach
1733 
1734  $this->tpl->setCurrentBlock("tbl_content");
1735  $this->tpl->setVariable("CSS_ROW", $css_row);
1736  $this->tpl->parseCurrentBlock();
1737  } //for
1738 
1739  $this->showActions(true);
1740  }
1741  }
1742 
1743 
1748  {
1749  global $tpl, $rbacsystem;
1750 
1751  // Blind out tabs for local user import
1752  if($this->ctrl->getTargetScript() == 'repository.php')
1753  {
1754  $this->tabs_gui->clearTargets();
1755  }
1756 
1757  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1758  {
1759  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1760  }
1761 
1762  $this->initUserImportForm();
1763  $tpl->setContent($this->form->getHTML());
1764 
1765  //$this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_form.html");
1766  }
1767 
1773  public function initUserImportForm()
1774  {
1775  global $lng, $ilCtrl;
1776 
1777  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1778  $this->form = new ilPropertyFormGUI();
1779 
1780  // Import File
1781  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1782  $fi = new ilFileInputGUI($lng->txt("import_file"), "importFile");
1783  $fi->setSuffixes(array("xml", "zip"));
1784  //$fi->enableFileNameSelection();
1785  //$fi->setInfo($lng->txt(""));
1786  $this->form->addItem($fi);
1787 
1788  $this->form->addCommandButton("importUserRoleAssignment", $lng->txt("import"));
1789  $this->form->addCommandButton("importCancelled", $lng->txt("cancel"));
1790 
1791  $this->form->setTitle($lng->txt("import_users"));
1792  $this->form->setFormAction($ilCtrl->getFormAction($this));
1793 
1794  }
1795 
1796 
1803  {
1804  // purge user import directory
1805  $import_dir = $this->getImportDir();
1806  if (@is_dir($import_dir))
1807  {
1808  ilUtil::delDir($import_dir);
1809  }
1810 
1811  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
1812  {
1813  $this->ctrl->redirect($this, "view");
1814  //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
1815  }
1816  else
1817  {
1818  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
1819  }
1820  }
1821 
1825  function getImportDir()
1826  {
1827  // For each user session a different directory must be used to prevent
1828  // that one user session overwrites the import data that another session
1829  // is currently importing.
1830  global $ilUser;
1831  $importDir = ilUtil::getDataDir().'/user_import/usr_'.$ilUser->getId().'_'.session_id();
1832  ilUtil::makeDirParents($importDir);
1833  return $importDir;
1834  }
1835 
1840  {
1841  global $ilUser,$rbacreview, $tpl, $lng, $ilCtrl;;
1842 
1843  // Blind out tabs for local user import
1844  if($this->ctrl->getTargetScript() == 'repository.php')
1845  {
1846  $this->tabs_gui->clearTargets();
1847  }
1848 
1849  $this->initUserImportForm();
1850  if ($this->form->checkInput())
1851  {
1852  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1853  include_once './Services/User/classes/class.ilUserImportParser.php';
1854 
1855  global $rbacreview, $rbacsystem, $tree, $lng;
1856 
1857 
1858  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html");
1859 
1860  $import_dir = $this->getImportDir();
1861 
1862  // recreate user import directory
1863  if (@is_dir($import_dir))
1864  {
1865  ilUtil::delDir($import_dir);
1866  }
1867  ilUtil::makeDir($import_dir);
1868 
1869  // move uploaded file to user import directory
1870  $file_name = $_FILES["importFile"]["name"];
1871  $parts = pathinfo($file_name);
1872  $full_path = $import_dir."/".$file_name;
1873 
1874  // check if import file exists
1875  if (!is_file($_FILES["importFile"]["tmp_name"]))
1876  {
1877  ilUtil::delDir($import_dir);
1878  $this->ilias->raiseError($this->lng->txt("no_import_file_found")
1879  , $this->ilias->error_obj->MESSAGE);
1880  }
1881  ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"],
1882  $_FILES["importFile"]["name"], $full_path);
1883 
1884  // handle zip file
1885  if (strtolower($parts["extension"]) == "zip")
1886  {
1887  // unzip file
1888  ilUtil::unzip($full_path);
1889 
1890  $xml_file = null;
1891  $file_list = ilUtil::getDir($import_dir);
1892  foreach ($file_list as $a_file)
1893  {
1894  if (substr($a_file['entry'],-4) == '.xml')
1895  {
1896  $xml_file = $import_dir."/".$a_file['entry'];
1897  break;
1898  }
1899  }
1900  if (is_null($xml_file))
1901  {
1902  $subdir = basename($parts["basename"],".".$parts["extension"]);
1903  $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
1904  }
1905  }
1906  // handle xml file
1907  else
1908  {
1909  $xml_file = $full_path;
1910  }
1911 
1912  // check xml file
1913  if (!is_file($xml_file))
1914  {
1915  ilUtil::delDir($import_dir);
1916  $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip")
1917  ." ".$subdir."/".$subdir.".xml", $this->ilias->error_obj->MESSAGE);
1918  }
1919 
1920  require_once("./Services/User/classes/class.ilUserImportParser.php");
1921 
1922  // Verify the data
1923  // ---------------
1924  $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
1925  $importParser->startParsing();
1926  switch ($importParser->getErrorLevel())
1927  {
1928  case IL_IMPORT_SUCCESS :
1929  break;
1930  case IL_IMPORT_WARNING :
1931  $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
1932  break;
1933  case IL_IMPORT_FAILURE :
1934  ilUtil::delDir($import_dir);
1935  $this->ilias->raiseError(
1936  $lng->txt("verification_failed").$importParser->getProtocolAsHTML($lng->txt("verification_failure_log")),
1937  $this->ilias->error_obj->MESSAGE
1938  );
1939  return;
1940  }
1941 
1942  // Create the role selection form
1943  // ------------------------------
1944  $this->tpl->setCurrentBlock("role_selection_form");
1945  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1946  $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
1947  $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
1948  $this->tpl->setVariable("IMPORT_FILE", $file_name);
1949  $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
1950  $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
1951  $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
1952  $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
1953  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1954  $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
1955 
1956  // Extract the roles
1957  $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
1958  $importParser->startParsing();
1959  $roles = $importParser->getCollectedRoles();
1960 
1961  // get global roles
1962  $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
1963  $gl_roles = array();
1964  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1965  foreach ($all_gl_roles as $obj_data)
1966  {
1967  // check assignment permission if called from local admin
1968  if($this->object->getRefId() != USER_FOLDER_ID)
1969  {
1970  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
1971  {
1972  continue;
1973  }
1974  }
1975  // exclude anonymous role from list
1976  if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
1977  {
1978  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
1979  if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$roles_of_user))
1980  {
1981  $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
1982  }
1983  }
1984  }
1985 
1986  // global roles
1987  $got_globals = false;
1988  foreach($roles as $role_id => $role)
1989  {
1990  if ($role["type"] == "Global")
1991  {
1992  if (! $got_globals)
1993  {
1994  $got_globals = true;
1995 
1996  $this->tpl->setCurrentBlock("global_role_section");
1997  $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
1998  $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
1999  }
2000 
2001  // pre selection for role
2002  $pre_select = array_search($role[name], $gl_roles);
2003  if (! $pre_select)
2004  {
2005  switch($role["name"])
2006  {
2007  case "Administrator": // ILIAS 2/3 Administrator
2008  $pre_select = array_search("Administrator", $gl_roles);
2009  break;
2010 
2011  case "Autor": // ILIAS 2 Author
2012  $pre_select = array_search("User", $gl_roles);
2013  break;
2014 
2015  case "Lerner": // ILIAS 2 Learner
2016  $pre_select = array_search("User", $gl_roles);
2017  break;
2018 
2019  case "Gast": // ILIAS 2 Guest
2020  $pre_select = array_search("Guest", $gl_roles);
2021  break;
2022 
2023  default:
2024  $pre_select = array_search("User", $gl_roles);
2025  break;
2026  }
2027  }
2028  $this->tpl->setCurrentBlock("global_role");
2029  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $gl_roles, false, true);
2030  $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"]." [".$role_id."]");
2031  $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
2032  $this->tpl->parseCurrentBlock();
2033  }
2034  }
2035 
2036  // Check if local roles need to be assigned
2037  $got_locals = false;
2038  foreach($roles as $role_id => $role)
2039  {
2040  if ($role["type"] == "Local")
2041  {
2042  $got_locals = true;
2043  break;
2044  }
2045  }
2046 
2047  if ($got_locals)
2048  {
2049  $this->tpl->setCurrentBlock("local_role_section");
2050  $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
2051  $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
2052 
2053 
2054  // get local roles
2055  if ($this->object->getRefId() == USER_FOLDER_ID)
2056  {
2057  // The import function has been invoked from the user folder
2058  // object. In this case, we show only matching roles,
2059  // because the user folder object is considered the parent of all
2060  // local roles and may contains thousands of roles on large ILIAS
2061  // installations.
2062  $loc_roles = array();
2063  foreach($roles as $role_id => $role)
2064  {
2065  if ($role["type"] == "Local")
2066  {
2067  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
2068  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
2069  foreach ($matching_role_ids as $mid) {
2070  if (! in_array($mid, $loc_roles)) {
2071  $loc_roles[] = array('obj_id'=>$mid);
2072  }
2073  }
2074  }
2075  }
2076  } else {
2077  // The import function has been invoked from a locally
2078  // administrated category. In this case, we show all roles
2079  // contained in the subtree of the category.
2080  $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
2081  }
2082  $l_roles = array();
2083 
2084  // create a search array with .
2085  $l_roles_mailbox_searcharray = array();
2086  foreach ($loc_roles as $key => $loc_role)
2087  {
2088  // fetch context path of role
2089  $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"],true);
2090 
2091  // only process role folders that are not set to status "deleted"
2092  // and for which the user has write permissions.
2093  // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
2094  // (The ROLE_FOLDER_ID folder contains the global roles).
2095  if (!$rbacreview->isDeleted($rolf[0])
2096  && $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0]))
2097  && $rolf[0] != ROLE_FOLDER_ID
2098  )
2099  {
2100  // A local role is only displayed, if it is contained in the subtree of
2101  // the localy administrated category. If the import function has been
2102  // invoked from the user folder object, we show all local roles, because
2103  // the user folder object is considered the parent of all local roles.
2104  // Thus, if we start from the user folder object, we initialize the
2105  // isInSubtree variable with true. In all other cases it is initialized
2106  // with false, and only set to true if we find the object id of the
2107  // locally administrated category in the tree path to the local role.
2108  $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
2109 
2110  $path = "";
2111  if ($this->tree->isInTree($rolf[0]))
2112  {
2113  // Create path. Paths which have more than 4 segments
2114  // are truncated in the middle.
2115  $tmpPath = $this->tree->getPathFull($rolf[0]);
2116  for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++)
2117  {
2118  if ($i > 1)
2119  {
2120  $path = $path.' > ';
2121  }
2122  if ($i < 3 || $i > $n - 3)
2123  {
2124  $path = $path.$tmpPath[$i]['title'];
2125  }
2126  else if ($i == 3 || $i == $n - 3)
2127  {
2128  $path = $path.'...';
2129  }
2130 
2131  $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
2132  }
2133  }
2134  else
2135  {
2136  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$loc_role["obj_id"].")</b>";
2137  }
2138  $roleMailboxAddress = $rbacreview->getRoleMailboxAddress($loc_role['obj_id']);
2139  $l_roles[$loc_role['obj_id']] = $roleMailboxAddress.', '.$path;
2140  }
2141  } //foreach role
2142 
2143  $l_roles[""] = "";
2144  natcasesort($l_roles);
2145  $l_roles[""] = $this->lng->txt("usrimport_ignore_role");
2146  foreach($roles as $role_id => $role)
2147  {
2148  if ($role["type"] == "Local")
2149  {
2150  $this->tpl->setCurrentBlock("local_role");
2151  $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);
2152  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
2153  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
2154  $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : "";
2155  if ($this->object->getRefId() == USER_FOLDER_ID) {
2156  // There are too many roles in a large ILIAS installation
2157  // that's why whe show only a choice with the the option "ignore",
2158  // and the matching roles.
2159  $selectable_roles = array();
2160  $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role");
2161  foreach ($matching_role_ids as $id)
2162  {
2163  $selectable_roles[$id] = $l_roles[$id];
2164  }
2165  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $selectable_roles, false, true);
2166  } else {
2167  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $l_roles, false, true);
2168  }
2169  $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
2170  $this->tpl->parseCurrentBlock();
2171  }
2172  }
2173  }
2174  //
2175 
2176  $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
2177  $handlers = array(
2178  IL_IGNORE_ON_CONFLICT => "ignore_on_conflict",
2179  IL_UPDATE_ON_CONFLICT => "update_on_conflict"
2180  );
2181  $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\n','<br>',$this->lng->txt("usrimport_conflict_handling_info")));
2182  $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
2183  $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
2184 
2185  // new account mail
2186  $this->lng->loadLanguageModule("mail");
2187  include_once './Services/User/classes/class.ilObjUserFolder.php';
2188  $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
2189  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
2190  {
2191  $this->tpl->setCurrentBlock("inform_user");
2192  $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail"));
2193  if (true)
2194  {
2195  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
2196  }
2197  $this->tpl->setVariable("TXT_INFORM_USER_MAIL",
2198  $this->lng->txt("user_send_new_account_mail"));
2199  $this->tpl->parseCurrentBlock();
2200  }
2201  }
2202  else
2203  {
2204  $this->form->setValuesByPost();
2205  $tpl->setContent($this->form->getHtml());
2206  }
2207  }
2208 
2213  {
2214  global $rbacreview,$ilUser;
2215 
2216  // Blind out tabs for local user import
2217  if($this->ctrl->getTargetScript() == 'repository.php')
2218  {
2219  $this->tabs_gui->clearTargets();
2220  }
2221 
2222  include_once './Services/AccessControl/classes/class.ilObjRole.php';
2223  include_once './Services/User/classes/class.ilUserImportParser.php';
2224 
2225  global $rbacreview, $rbacsystem, $tree, $lng;
2226 
2227  switch ($_POST["conflict_handling_choice"])
2228  {
2229  case "update_on_conflict" :
2230  $rule = IL_UPDATE_ON_CONFLICT;
2231  break;
2232  case "ignore_on_conflict" :
2233  default :
2234  $rule = IL_IGNORE_ON_CONFLICT;
2235  break;
2236  }
2237  $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
2238  $importParser->setFolderId($this->getUserOwnerId());
2239  $import_dir = $this->getImportDir();
2240 
2241  // Catch hack attempts
2242  // We check here again, if the role folders are in the tree, and if the
2243  // user has permission on the roles.
2244  if ($_POST["role_assign"])
2245  {
2246  $global_roles = $rbacreview->getGlobalRoles();
2247  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
2248  foreach ($_POST["role_assign"] as $role_id)
2249  {
2250  if ($role_id != "")
2251  {
2252  if (in_array($role_id, $global_roles))
2253  {
2254  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user))
2255  {
2256  if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$roles_of_user)
2257  || ($this->object->getRefId() != USER_FOLDER_ID
2258  && ! ilObjRole::_getAssignUsersStatus($role_id))
2259  )
2260  {
2261  ilUtil::delDir($import_dir);
2262  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
2263  $this->ilias->error_obj->MESSAGE);
2264  }
2265  }
2266  }
2267  else
2268  {
2269  $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
2270  if ($rbacreview->isDeleted($rolf[0])
2271  || ! $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0])))
2272  {
2273  ilUtil::delDir($import_dir);
2274  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
2275  $this->ilias->error_obj->MESSAGE);
2276  return;
2277  }
2278  }
2279  }
2280  }
2281  }
2282 
2283  $importParser->setRoleAssignment($_POST["role_assign"]);
2284  $importParser->startParsing();
2285 
2286  // purge user import directory
2287  ilUtil::delDir($import_dir);
2288 
2289  switch ($importParser->getErrorLevel())
2290  {
2291  case IL_IMPORT_SUCCESS :
2292  ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
2293  break;
2294  case IL_IMPORT_WARNING :
2295  ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings").$importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
2296  break;
2297  case IL_IMPORT_FAILURE :
2298  $this->ilias->raiseError(
2299  $this->lng->txt("user_import_failed")
2300  .$importParser->getProtocolAsHTML($lng->txt("import_failure_log")),
2301  $this->ilias->error_obj->MESSAGE
2302  );
2303  break;
2304  }
2305 
2306  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
2307  {
2308  $this->ctrl->redirect($this, "view");
2309  //ilUtil::redirect($this->ctrl->getLinkTarget($this));
2310  }
2311  else
2312  {
2313  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2314  }
2315  }
2316 
2317 
2319  {
2320  global $rbacsystem,$ilias;
2321 
2322  unset($_SESSION['applied_users']);
2323 
2324  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
2325  {
2326  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2327  }
2328 
2329  if(!count($app_users =& $ilias->account->getAppliedUsers()))
2330  {
2331  ilUtil::sendFailure($this->lng->txt('no_users_applied'));
2332 
2333  return false;
2334  }
2335 
2336  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_applied_users.html");
2337  $this->lng->loadLanguageModule('crs');
2338 
2339  $counter = 0;
2340  foreach($app_users as $usr_id)
2341  {
2342  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
2343 
2344  $f_result[$counter][] = ilUtil::formCheckbox(0,"users[]",$usr_id);
2345  $f_result[$counter][] = $tmp_user->getLogin();
2346  $f_result[$counter][] = $tmp_user->getFirstname();
2347  $f_result[$counter][] = $tmp_user->getLastname();
2348 
2349  if($tmp_user->getTimeLimitUnlimited())
2350  {
2351  $f_result[$counter][] = "<b>".$this->lng->txt('crs_unlimited')."</b>";
2352  }
2353  else
2354  {
2355  $limit = "<b>".$this->lng->txt('crs_from').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitFrom()).'<br />';
2356  $limit .= "<b>".$this->lng->txt('crs_to').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitUntil());
2357 
2358  $f_result[$counter][] = $limit;
2359  }
2360  ++$counter;
2361  }
2362 
2363  $this->__showAppliedUsersTable($f_result);
2364 
2365  return true;
2366  }
2367 
2369  {
2370  global $rbacsystem;
2371 
2372  if(!$rbacsystem->checkAccess("write", $this->ref_id))
2373  {
2374  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2375  }
2376 
2377  $this->lng->loadLanguageModule('crs');
2378 
2379  $_POST['users'] = $_SESSION['applied_users'] = ($_SESSION['applied_users'] ? $_SESSION['applied_users'] : $_POST['users']);
2380 
2381  if(!isset($_SESSION['error_post_vars']))
2382  {
2383  ilUtil::sendInfo($this->lng->txt('time_limit_add_time_limit_for_selected'));
2384  }
2385 
2386  if(!count($_POST["users"]))
2387  {
2388  ilUtil::sendFailure($this->lng->txt("time_limit_no_users_selected"));
2389  $this->appliedUsersObject();
2390 
2391  return false;
2392  }
2393 
2394  $counter = 0;
2395  foreach($_POST['users'] as $usr_id)
2396  {
2397  if($counter)
2398  {
2399  $title .= ', ';
2400  }
2401  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
2402  $title .= $tmp_user->getLogin();
2403  ++$counter;
2404  }
2405  if(strlen($title) > 79)
2406  {
2407  $title = substr($title,0,80);
2408  $title .= '...';
2409  }
2410 
2411 
2412  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_edit_applied_users.html");
2413  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2414 
2415  // LOAD SAVED DATA IN CASE OF ERROR
2416  $time_limit_unlimited = $_SESSION["error_post_vars"]["au"]["time_limit_unlimited"] ?
2417  1 : 0;
2418 
2419  $time_limit_start = $_SESSION["error_post_vars"]["au"]["time_limit_start"] ?
2420  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_start"]) :
2421  time();
2422  $time_limit_end = $_SESSION["error_post_vars"]["au"]["time_limit_end"] ?
2423  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_end"]) :
2424  time();
2425 
2426 
2427  // SET TEXT VARIABLES
2428  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_usr"));
2429  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_usr_b.gif"));
2430  $this->tpl->setVariable("TITLE",$title);
2431  $this->tpl->setVariable("TXT_TIME_LIMIT",$this->lng->txt("time_limit"));
2432  $this->tpl->setVariable("TXT_TIME_LIMIT_START",$this->lng->txt("crs_start"));
2433  $this->tpl->setVariable("TXT_TIME_LIMIT_END",$this->lng->txt("crs_end"));
2434  $this->tpl->setVariable("CMD_SUBMIT","updateAppliedUsers");
2435  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
2436  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
2437 
2438 
2439 
2440  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_DAY",$this->__getDateSelect("day","au[time_limit_start][day]",
2441  date("d",$time_limit_start)));
2442  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MONTH",$this->__getDateSelect("month","au[time_limit_start][month]",
2443  date("m",$time_limit_start)));
2444  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_YEAR",$this->__getDateSelect("year","au[time_limit_start][year]",
2445  date("Y",$time_limit_start)));
2446  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_HOUR",$this->__getDateSelect("hour","au[time_limit_start][hour]",
2447  date("G",$time_limit_start)));
2448  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MINUTE",$this->__getDateSelect("minute","au[time_limit_start][minute]",
2449  date("i",$time_limit_start)));
2450  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_DAY",$this->__getDateSelect("day","au[time_limit_end][day]",
2451  date("d",$time_limit_end)));
2452  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MONTH",$this->__getDateSelect("month","au[time_limit_end][month]",
2453  date("m",$time_limit_end)));
2454  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_YEAR",$this->__getDateSelect("year","au[time_limit_end][year]",
2455  date("Y",$time_limit_end)));
2456  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_HOUR",$this->__getDateSelect("hour","au[time_limit_end][hour]",
2457  date("G",$time_limit_end)));
2458  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MINUTE",$this->__getDateSelect("minute","au[time_limit_end][minute]",
2459  date("i",$time_limit_end)));
2460  if($this->ilias->account->getTimeLimitUnlimited())
2461  {
2462  $this->tpl->setVariable("ROWSPAN",3);
2463  $this->tpl->setCurrentBlock("unlimited");
2464  $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED",$this->lng->txt("crs_unlimited"));
2465  $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"au[time_limit_unlimited]",1));
2466  $this->tpl->parseCurrentBlock();
2467  }
2468  else
2469  {
2470  $this->tpl->setVariable("ROWSPAN",2);
2471  }
2472  }
2473 
2475  {
2476  global $rbacsystem;
2477 
2478  if(!$rbacsystem->checkAccess("write", $this->ref_id))
2479  {
2480  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2481  }
2482 
2483  $start = $this->__toUnix($_POST['au']['time_limit_start']);
2484  $end = $this->__toUnix($_POST['au']['time_limit_end']);
2485 
2486  if(!$_POST['au']['time_limit_unlimited'])
2487  {
2488  if($start > $end)
2489  {
2490  $_SESSION['error_post_vars'] = $_POST;
2491  ilUtil::sendFailure($this->lng->txt('time_limit_not_valid'));
2492  $this->editAppliedUsersObject();
2493 
2494  return false;
2495  }
2496  }
2497  #if(!$this->ilias->account->getTimeLimitUnlimited())
2498  #{
2499  # if($start < $this->ilias->account->getTimeLimitFrom() or
2500  # $end > $this->ilias->account->getTimeLimitUntil())
2501  # {
2502  # $_SESSION['error_post_vars'] = $_POST;
2503  # ilUtil::sendInfo($this->lng->txt('time_limit_not_within_owners'));
2504  # $this->editAppliedUsersObject();
2505 
2506  # return false;
2507  # }
2508  #}
2509 
2510  foreach($_SESSION['applied_users'] as $usr_id)
2511  {
2512  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
2513 
2514  $tmp_user->setTimeLimitUnlimited((int) $_POST['au']['time_limit_unlimited']);
2515  $tmp_user->setTimeLimitFrom($start);
2516  $tmp_user->setTimeLimitUntil($end);
2517  $tmp_user->setTimeLimitMessage(0);
2518  $tmp_user->update();
2519 
2520  unset($tmp_user);
2521  }
2522 
2523  unset($_SESSION['applied_users']);
2524  ilUtil::sendSuccess($this->lng->txt('time_limit_users_updated'));
2525  $this->appliedUsersObject();
2526 
2527  return true;
2528  }
2529 
2530  function __showAppliedUsersTable($a_result_set)
2531  {
2532  $tbl =& $this->__initTableGUI();
2533  $tpl =& $tbl->getTemplateObject();
2534 
2535  // SET FORMAACTION
2536  $tpl->setCurrentBlock("tbl_form_header");
2537 
2538  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2539  $tpl->parseCurrentBlock();
2540 
2541  $tpl->setCurrentBlock("tbl_action_btn");
2542  $tpl->setVariable("BTN_NAME",'editAppliedUsers');
2543  $tpl->setVariable("BTN_VALUE",$this->lng->txt('edit'));
2544  $tpl->parseCurrentBlock();
2545 
2546  $tpl->setCurrentBlock("tbl_action_row");
2547  $tpl->setVariable("COLUMN_COUNTS",5);
2548  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2549  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2550  $tpl->parseCurrentBlock();
2551 
2552 
2553 
2554  $tbl->setTitle($this->lng->txt("time_limit_applied_users"),"icon_usr_b.gif",$this->lng->txt("users"));
2555  $tbl->setHeaderNames(array('',
2556  $this->lng->txt("login"),
2557  $this->lng->txt("firstname"),
2558  $this->lng->txt("lastname"),
2559  $this->lng->txt("time_limits")));
2560  $header_params = $this->ctrl->getParameterArray($this, "appliedUsers");
2561  $tbl->setHeaderVars(array("",
2562  "login",
2563  "firstname",
2564  "lastname",
2565  "time_limit"),
2566  array($header_params));
2567  $tbl->setColumnWidth(array("3%","19%","19%","19%","40%"));
2568 
2569 
2570  $this->__setTableGUIBasicData($tbl,$a_result_set);
2571  $tbl->render();
2572 
2573  $this->tpl->setVariable("APPLIED_USERS",$tbl->tpl->get());
2574 
2575  return true;
2576  }
2577 
2578  function &__initTableGUI()
2579  {
2580  include_once "./Services/Table/classes/class.ilTableGUI.php";
2581 
2582  return new ilTableGUI(0,false);
2583  }
2584 
2585  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
2586  {
2587  $offset = $_GET["offset"];
2588  $order = $_GET["sort_by"];
2589  $direction = $_GET["sort_order"];
2590 
2591  //$tbl->enable("hits");
2592  $tbl->setOrderColumn($order);
2593  $tbl->setOrderDirection($direction);
2594  $tbl->setOffset($offset);
2595  $tbl->setLimit($_GET["limit"]);
2596  $tbl->setMaxCount(count($result_set));
2597  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2598  $tbl->setData($result_set);
2599  }
2600 
2601  function __getDateSelect($a_type,$a_varname,$a_selected)
2602  {
2603  switch($a_type)
2604  {
2605  case "minute":
2606  for($i=0;$i<=60;$i++)
2607  {
2608  $days[$i] = $i < 10 ? "0".$i : $i;
2609  }
2610  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2611 
2612  case "hour":
2613  for($i=0;$i<24;$i++)
2614  {
2615  $days[$i] = $i < 10 ? "0".$i : $i;
2616  }
2617  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2618 
2619  case "day":
2620  for($i=1;$i<32;$i++)
2621  {
2622  $days[$i] = $i < 10 ? "0".$i : $i;
2623  }
2624  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2625 
2626  case "month":
2627  for($i=1;$i<13;$i++)
2628  {
2629  $month[$i] = $i < 10 ? "0".$i : $i;
2630  }
2631  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
2632 
2633  case "year":
2634  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
2635  {
2636  $year[$i] = $i;
2637  }
2638  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
2639  }
2640  }
2641  function __toUnix($a_time_arr)
2642  {
2643  return mktime($a_time_arr["hour"],
2644  $a_time_arr["minute"],
2645  $a_time_arr["second"],
2646  $a_time_arr["month"],
2647  $a_time_arr["day"],
2648  $a_time_arr["year"]);
2649  }
2650 
2652  {
2654  $this->viewObject();
2655  }
2656 
2657 
2662  {
2663  global $lng, $tpl;
2664 
2665  $lng->loadLanguageModule("administration");
2666 
2667  unset($_SESSION['select_num_values']);
2668  unset($_SESSION['num_values']);
2669 
2670  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2671 
2672  $this->setSubTabs('settings');
2673  $this->tabs_gui->setTabActive('settings');
2674  $this->tabs_gui->setSubTabActive('user_defined_fields');
2675 
2676 if (true)
2677 {
2678  include_once("./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
2679  $tab = new ilCustomUserFieldSettingsTableGUI($this, "listUserDefinedFields");
2680  if($this->confirm_change) $tab->setConfirmChange();
2681  $tpl->setContent($tab->getHTML());
2682 }
2683 else
2684 {
2685 
2686  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_list_user_defined.html');
2687  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2688 
2689  if ($this->confirm_change == 1)
2690  {
2691  $this->tpl->setVariable("CONFIRM_MESSAGE", $this->lng->txt("confirm_message_course_export"));
2692  $this->tpl->setVariable("BUTTON_CONFIRM", $this->lng->txt("confirm"));
2693  $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
2694  }
2695 
2696  $this->tpl->setVariable("TXT_OVERVIEW",$this->lng->txt('user_defined_list'));
2697 
2698  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('add_user_defined_field'));
2699 
2700  $user_field_definitions =& ilUserDefinedFields::_getInstance();
2701 
2702  if(!count($definitions = $user_field_definitions->getDefinitions()))
2703  {
2704  $this->tpl->setCurrentBlock("no_content");
2705  $this->tpl->setVariable("NO_FIELDS",$this->lng->txt('no_user_defined_fields_defined'));
2706  $this->tpl->parseCurrentBlock();
2707  }
2708  else
2709  {
2710  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
2711  }
2712 
2713  foreach($definitions as $field_id => $definition)
2714  {
2715  $this->tpl->setCurrentBlock("user_defined");
2716  $this->tpl->setVariable("TXT_VISIBLE", $this->lng->txt("visible"));
2717  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("changeable"));
2718  $this->tpl->setVariable("TXT_REQUIRED", $this->lng->txt("required_field"));
2719  if ($definition["field_type"] != UDF_TYPE_WYSIWYG)
2720  {
2721  $this->tpl->setVariable("TXT_SEARCHABLE", $this->lng->txt("header_searchable"));
2722  }
2723  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
2724  $this->tpl->setVariable("TXT_COURSE_EXPORT", $lng->txt("course_export"));
2725 
2726  $this->tpl->setVariable('TXT_VISIB_REG', $this->lng->txt('visible_registration'));
2727 
2728  $this->tpl->setVariable("NAME",$definition['field_name']);
2729 
2730  if ($_POST["cmd"]["updateFields"] != "")
2731  {
2732  $definition['visible'] = isset($_POST['def'][$field_id]['visible']) ? 1 : 0;
2733  $definition['changeable'] = isset($_POST['def'][$field_id]['changeable']) ? 1 : 0;
2734  $definition['required'] = isset($_POST['def'][$field_id]['required']) ? 1 : 0;
2735  $definition['searchable'] = isset($_POST['def'][$field_id]['searchable']) ? 1 : 0;
2736  $definition['export'] = isset($_POST['def'][$field_id]['export']) ? 1 : 0;
2737  $definition['course_export'] = isset($_POST['def'][$field_id]['course_export']) ? 1 : 0;
2738  }
2739 
2740  $this->tpl->setVariable("VISIBLE",ilUtil::formCheckbox($definition['visible'],"def[$field_id][visible]",1));
2741  $this->tpl->setVariable("CHANGE",ilUtil::formCheckbox($definition['changeable'],"def[$field_id][changeable]",1));
2742  $this->tpl->setVariable("REQUIRED",ilUtil::formCheckbox($definition['required'],"def[$field_id][required]",1));
2743  if ($definition["field_type"] != UDF_TYPE_WYSIWYG)
2744  {
2745  $this->tpl->setVariable("SEARCHABLE",ilUtil::formCheckbox($definition['searchable'],"def[$field_id][searchable]",1));
2746  }
2747  $this->tpl->setVariable("EXPORT",ilUtil::formCheckbox($definition['export'],"def[$field_id][export]",1));
2748  $this->tpl->setVariable("COURSE_EXPORT",ilUtil::formCheckbox($definition['course_export'],"def[$field_id][course_export]",1));
2749 
2750  $this->tpl->setVariable('VISIB_REG',
2751  ilUtil::formCheckbox($definition['visib_reg'], 'def['.$field_id.'][visib_reg]', 1));
2752 
2753  $this->ctrl->setParameter($this,'field_id',$field_id);
2754 
2755  // Show edit link (depends on type)
2756  switch($definition['field_type'])
2757  {
2758  case UDF_TYPE_TEXT:
2759  $this->tpl->setVariable("EDIT_LINK",$this->ctrl->getLinkTarget($this,'editTextField'));
2760  break;
2761 
2762  case UDF_TYPE_WYSIWYG:
2763  $this->tpl->setVariable("EDIT_LINK",$this->ctrl->getLinkTarget($this,'editWysiwygField'));
2764  break;
2765 
2766  case UDF_TYPE_SELECT:
2767  $this->tpl->setVariable("EDIT_LINK",$this->ctrl->getLinkTarget($this,'editSelectField'));
2768  break;
2769  }
2770  $this->tpl->setVariable("EDIT",$this->lng->txt('edit'));
2771 
2772  $this->tpl->setVariable("DELETE_LINK",$this->ctrl->getLinkTarget($this,'askDeleteField'));
2773  $this->tpl->setVariable("DELETE",$this->lng->txt('delete'));
2774  $this->tpl->parseCurrentBlock();
2775  }
2776 }
2777  }
2778 
2780  {
2781  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2783  $definition = $udf->getDefinition((int) $_GET['field_id']);
2784 
2785  // Save paremeter
2786  $this->ctrl->setParameter($this,'field_id',(int) $_GET['field_id']);
2787 
2788  $this->setSubTabs('settings');
2789  $this->tabs_gui->setTabActive('settings');
2790  $this->tabs_gui->setSubTabActive('user_defined_fields');
2791 
2792  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_update_text_field.html');
2793 
2794  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2795  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('udf_update_text_field'));
2796  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
2797 
2798  $this->tpl->setVariable("FIELD_NAME",$definition['field_name']);
2799 
2800  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('cancel'));
2801  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('update'));
2802 
2803  return true;
2804  }
2805 
2807  {
2808  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2809 
2811  $definition = $udf->getDefinition((int) $_GET['field_id']);
2812 
2813  $udf->setFieldName(ilUtil::stripslashes($_POST['field_name']));
2814  $udf->setFieldType($definition['field_type']);
2815  $udf->setFieldValues($definition['field_values']);
2816  $udf->enableVisible($definition['visible']);
2817  $udf->enableChangeable($definition['changeable']);
2818  $udf->enableRequired($definition['required']);
2819  $udf->enableSearchable($definition['searchable']);
2820  $udf->enableExport($definition['export']);
2821  $udf->enableCourseExport($definition['course_export']);
2822 
2823  $udf->enableVisibleRegistration($definition['visib_reg']);
2824 
2825  $udf->update($definition['field_id']);
2826 
2827  ilUtil::sendSuccess($this->lng->txt('udf_update_success'));
2828 
2829  $this->listUserDefinedFieldsObject();
2830  }
2831 
2833  {
2834  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2836  $definition = $udf->getDefinition((int) $_GET['field_id']);
2837 
2838  // Save paremeter
2839  $this->ctrl->setParameter($this,'field_id',(int) $_GET['field_id']);
2840 
2841  $this->setSubTabs('settings');
2842  $this->tabs_gui->setTabActive('settings');
2843  $this->tabs_gui->setSubTabActive('user_defined_fields');
2844 
2845  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_update_text_field.html');
2846 
2847  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2848  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('udf_update_wysiwyg_field'));
2849  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
2850 
2851  $this->tpl->setVariable("FIELD_NAME",$definition['field_name']);
2852 
2853  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('cancel'));
2854  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('update'));
2855 
2856  return true;
2857  }
2858 
2860  {
2861  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2862 
2864  $definition = $udf->getDefinition((int) $_GET['field_id']);
2865 
2866  $udf->setFieldName(ilUtil::stripslashes($_POST['field_name']));
2867  $udf->setFieldType($definition['field_type']);
2868  $udf->setFieldValues($definition['field_values']);
2869  $udf->enableVisible($definition['visible']);
2870  $udf->enableChangeable($definition['changeable']);
2871  $udf->enableRequired($definition['required']);
2872  $udf->enableSearchable($definition['searchable']);
2873  $udf->enableExport($definition['export']);
2874  $udf->enableCourseExport($definition['course_export']);
2875 
2876  $udf->enableVisibleRegistration($definition['visib_reg']);
2877 
2878  $udf->update($definition['field_id']);
2879 
2880  ilUtil::sendSuccess($this->lng->txt('udf_update_success'));
2881 
2882  $this->listUserDefinedFieldsObject();
2883  }
2884 
2886  {
2887  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2888 
2889  $_SESSION['select_num_values'] = $_SESSION['select_num_values'] ? $_SESSION['select_num_values'] : 0;
2890 
2892  $definition = $udf->getDefinition((int) $_GET['field_id']);
2893 
2894  // Save paremeter
2895  $this->ctrl->setParameter($this,'field_id',(int) $_GET['field_id']);
2896 
2897  $this->setSubTabs('settings');
2898  $this->tabs_gui->setTabActive('settings');
2899  $this->tabs_gui->setSubTabActive('user_defined_fields');
2900 
2901  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_update_select_field.html');
2902 
2903  //$this->tpl->setVariable("TXT_WARNING",$this->lng->txt('udf_warn_delete'));
2904  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2905  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('udf_update_select_field'));
2906  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
2907 
2908  $this->tpl->setVariable("FIELD_NAME_VALUE",$definition['field_name']);
2909 
2910  // OLD VALUES
2911  $counter = 0;
2912  foreach($definition['field_values'] as $value)
2913  {
2914  $this->tpl->setCurrentBlock("values");
2915  $this->tpl->setVariable("COUNTER",$counter++);
2916  $this->tpl->setVariable("TXT_VALUES",$this->lng->txt('udf_value').' '.($counter));
2917  $this->tpl->setVariable("FIELD_NAME",$value);
2918 
2919  $this->ctrl->setParameter($this,'value_id',$counter-1);
2920  $this->tpl->setVariable("DELETE_LINK",$this->ctrl->getLinkTarget($this,'deleteValue'));
2921  $this->tpl->setVariable("DELETE",$this->lng->txt('delete'));
2922  $this->tpl->parseCurrentBlock();
2923  }
2924 
2925  // new values
2926  for($i = 0; $i < $_SESSION['select_num_values'];$i++)
2927  {
2928  $this->tpl->setCurrentBlock("new_values");
2929  $this->tpl->setVariable("NEW_COUNTER",$counter++);
2930  $this->tpl->setVariable("TXT_NEW_VALUES",$this->lng->txt('udf_value').' '.($counter));
2931  $this->tpl->setVariable("NEW_FIELD_NAME",$_POST['field_values'][$counter-1]);
2932  $this->tpl->parseCurrentBlock();
2933  }
2934  $this->tpl->setVariable("BTN_NEW_VALUE",$this->lng->txt('btn_new_value'));
2935  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('cancel'));
2936  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('save'));
2937 
2938  return true;
2939  }
2940 
2942  {
2943  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2944 
2945 
2946  $_POST['field_values'] = is_array($_POST['field_values']) ? $_POST['field_values'] : array();
2947 
2949  $definition = $udf->getDefinition((int) $_GET['field_id']);
2950 
2951 
2952  $udf->setFieldName(ilUtil::stripslashes($_POST['field_name']));
2953  $udf->setFieldValues(array_merge($definition['field_values'],$_POST['field_values']));
2954  $udf->setFieldType($definition['field_type']);
2955  $udf->enableVisible($definition['visible']);
2956  $udf->enableChangeable($definition['changeable']);
2957  $udf->enableRequired($definition['required']);
2958  $udf->enableSearchable($definition['searchable']);
2959  $udf->enableExport($definition['export']);
2960  $udf->enableCourseExport($definition['course_export']);
2961 
2962  $udf->enableVisibleRegistration($definition['visib_reg']);
2963 
2964  if($error = $udf->validateValues())
2965  {
2966  switch($error)
2967  {
2968  case UDF_DUPLICATE_VALUES:
2969  ilUtil::sendFailure($this->lng->txt('udf_duplicate_entries'));
2970  $this->editSelectFieldObject();
2971  return false;
2972 
2973  case UDF_NO_VALUES:
2974  ilUtil::sendFailure($this->lng->txt('udf_no_entries'));
2975  $this->editSelectFieldObject();
2976  return false;
2977  }
2978  }
2979 
2980  $udf->update($definition['field_id']);
2981  ilUtil::sendSuccess($this->lng->txt('udf_update_success'));
2982 
2983  unset($_SESSION['select_num_values']);
2984  $this->editSelectFieldObject();
2985  }
2986 
2987 
2989  {
2990  include_once './Services/User/classes/class.ilUserDefinedFields.php';
2991 
2993  $udf->deleteValue((int) $_GET['field_id'],(int) $_GET['value_id']);
2994 
2995  ilUtil::sendSuccess($this->lng->txt('udf_value_deleted'));
2996  $this->editSelectFieldObject();
2997 
2998  return true;
2999  }
3000 
3002  {
3003  $_SESSION['select_num_values'] += 1;
3004  $this->editSelectFieldObject();
3005  return true;
3006  }
3007 
3009  {
3010  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3011 
3012  ilUtil::sendQuestion($this->lng->txt('udf_delete_sure'));
3013 
3014  $this->setSubTabs('settings');
3015  $this->tabs_gui->setTabActive('settings');
3016  $this->tabs_gui->setSubTabActive('user_defined_fields');
3017 
3018  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_ask_delete.html');
3019 
3020  $this->ctrl->setParameter($this,'field_id',(int) $_GET['field_id']);
3021  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3022  $this->tpl->setVariable("TXT_DELETE_FIELD",$this->lng->txt('udf_delete_header'));
3023  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
3024 
3025  $user_field_definitions =& ilUserDefinedFields::_getInstance();
3026  $definition = $user_field_definitions->getDefinition((int) $_GET['field_id']);
3027 
3028  $this->tpl->setVariable("FIELD_NAME",$definition['field_name']);
3029  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
3030  $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
3031 
3032  return true;
3033  }
3034 
3036  {
3037  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3038  $user_field_definitions =& ilUserDefinedFields::_getInstance();
3039 
3040  $user_field_definitions->delete((int) $_GET['field_id']);
3041 
3042  ilUtil::sendSuccess($this->lng->txt('udf_field_deleted'));
3043  $this->listUserDefinedFieldsObject();
3044 
3045  return true;
3046  }
3047 
3049  {
3050  $this->updateFieldsObject("save");
3051  }
3052 
3056  function updateFieldsObject($action = "")
3057  {
3058  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3059 
3060  $user_field_definitions =& ilUserDefinedFields::_getInstance();
3061  $a_fields = $user_field_definitions->getDefinitions();
3062 
3063  foreach($a_fields as $field_id => $definition)
3064  {
3065  if( isset($_POST['chb']['required_'.$field_id]) && (int)$_POST['chb']['required_'.$field_id] &&
3066  (!isset($_POST['chb']['visib_reg_'.$field_id]) || !(int)$_POST['chb']['visib_reg_'.$field_id]))
3067  {
3068  $this->confirm_change = 1;
3069  global $lng;
3070  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
3071  $this->listUserDefinedFieldsObject();
3072  return false;
3073  }
3074  }
3075 
3076  // check if a course export state of any user defined field has been added
3077  if ($action != 'save')
3078  {
3079  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
3080  $privacy = ilPrivacySettings::_getInstance();
3081  if ($privacy->enabledExport() == true && $privacy->confirmationRequired() == true)
3082  {
3083  foreach($a_fields as $field_id => $definition)
3084  {
3085  if ($definition['course_export'] == 0 && (int) $_POST['chb']['course_export_'.$field_id] == 1)
3086  {
3087  $this->confirm_change = 1;
3088  $this->listUserDefinedFieldsObject();
3089  return true;
3090  }
3091  }
3092  }
3093  }
3094 
3095  // Reset user confirmation
3096  if ($action == 'save')
3097  {
3098  include_once('Modules/Course/classes/class.ilCourseAgreement.php');
3100  }
3101 
3102  foreach($a_fields as $field_id => $definition)
3103  {
3104  $user_field_definitions->setFieldName($definition['field_name']);
3105  $user_field_definitions->setFieldType($definition['field_type']);
3106  $user_field_definitions->setFieldValues($definition['field_values']);
3107  $user_field_definitions->enableVisible((int) $_POST['chb']['visible_'.$field_id]);
3108  $user_field_definitions->enableChangeable((int) $_POST['chb']['changeable_'.$field_id]);
3109  $user_field_definitions->enableRequired((int) $_POST['chb']['required_'.$field_id]);
3110  $user_field_definitions->enableSearchable((int) $_POST['chb']['searchable_'.$field_id]);
3111  $user_field_definitions->enableExport((int) $_POST['chb']['export_'.$field_id]);
3112  $user_field_definitions->enableCourseExport((int) $_POST['chb']['course_export_'.$field_id]);
3113 
3114  $user_field_definitions->enableVisibleRegistration((int)$_POST['chb']['visib_reg_'.$field_id]);
3115 
3116  $user_field_definitions->update($field_id);
3117  }
3118 
3119  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
3120  $this->listUserDefinedFieldsObject();
3121 
3122  return true;
3123  }
3124 
3126  {
3127  global $lng, $tpl;
3128 
3129  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3130 
3131  // number of values defaults to 3
3132  $_SESSION['num_values'] = 3;
3133 
3134  $this->setSubTabs('settings');
3135  $this->tabs_gui->setTabActive('settings');
3136  $this->tabs_gui->setSubTabActive('user_defined_fields');
3137 
3138  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3139  $this->form = new ilPropertyFormGUI();
3140  $this->form->setFormAction($this->ctrl->getFormAction($this,'chooseDefinitions'));
3141  $this->form->setTitle($this->lng->txt('add_new_user_defined_field'));
3142 
3143  $radg = new ilRadioGroupInputGUI($this->lng->txt('field_type'), "field_type");
3144  $radg->setValue(UDF_TYPE_TEXT);
3145  $op1 = new ilRadioOption($lng->txt("udf_type_text"), UDF_TYPE_TEXT);
3146  $radg->addOption($op1);
3147  $op2 = new ilRadioOption($lng->txt("udf_type_select"), UDF_TYPE_SELECT);
3148  $radg->addOption($op2);
3149  $op3 = new ilRadioOption($lng->txt("udf_type_wysiwyg"), UDF_TYPE_WYSIWYG);
3150  $radg->addOption($op3);
3151  $this->form->addItem($radg);
3152  $this->form->addCommandButton("chooseDefinitions", $lng->txt("btn_next"));
3153  $this->form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
3154  $this->tpl->setContent($this->form->getHTML());
3155  return true;
3156  }
3157 
3162  {
3163  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3164 
3165  $this->setSubTabs('settings');
3166  $this->tabs_gui->setTabActive('settings');
3167  $this->tabs_gui->setSubTabActive('user_defined_fields');
3168 
3169  switch($field_type = (int) $_REQUEST['field_type'])
3170  {
3171  case UDF_TYPE_TEXT:
3172  $this->__showTextTable();
3173  break;
3174 
3175  case UDF_TYPE_SELECT:
3176  $this->__showSelectTable();
3177  break;
3178 
3179  case UDF_TYPE_WYSIWYG:
3180  $this->__showWysiwygTable();
3181  break;
3182  }
3183  }
3184 
3189  function __showTextTable()
3190  {
3191  global $lng;
3192 
3193  $lng->loadLanguageModule("administration");
3194  $lng->loadLanguageModule("ps");
3195 
3196  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_edit_text_field.html');
3197 
3198  include_once("Modules/Course/classes/class.ilCourseAgreement.php");
3200  {
3201  $this->tpl->setCurrentBlock('warning_modify');
3202  $this->tpl->setVariable('TXT_WARNING', $lng->txt('ps_warning_modify'));
3203  $this->tpl->parseCurrentBlock();
3204  }
3205 
3206  // Save field_type
3207  $this->ctrl->setParameter($this,'field_type',(int) $_REQUEST['field_type']);
3208  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3209 
3210  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('udf_add_field'));
3211  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('btn_previous'));
3212  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('add_new_user_defined_text_field'));
3213  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
3214  $this->tpl->setVariable("FIELD_NAME",$_POST['field_name']);
3215 
3216  $this->tpl->setVariable("TXT_VISIBLE", $this->lng->txt("visible"));
3217  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("changeable"));
3218  $this->tpl->setVariable("TXT_REQUIRED", $this->lng->txt("required_field"));
3219  $this->tpl->setVariable("TXT_SEARCHABLE", $this->lng->txt("header_searchable"));
3220  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
3221  $this->tpl->setVariable("TXT_COURSE_EXPORT", $lng->txt("course_export"));
3222 
3223  $this->tpl->setVariable('TXT_VISIB_REG', $this->lng->txt('visible_registration'));
3224 
3225  $this->tpl->setVariable("VISIBLE",ilUtil::formCheckbox($_POST['def']['visible'],"def[visible]",1));
3226  $this->tpl->setVariable("CHANGE",ilUtil::formCheckbox($_POST['def']['changeable'],"def[changeable]",1));
3227  $this->tpl->setVariable("REQUIRED",ilUtil::formCheckbox($_POST['def']['required'],"def[required]",1));
3228  $this->tpl->setVariable("SEARCHABLE",ilUtil::formCheckbox($_POST['def']['searchable'],"def[searchable]",1));
3229  $this->tpl->setVariable("EXPORT",ilUtil::formCheckbox($_POST['def']['export'],"def[export]",1));
3230  $this->tpl->setVariable("COURSE_EXPORT",ilUtil::formCheckbox($_POST['def']['course_export'],"def[course_export]",1));
3231 
3232  $this->tpl->setVariable('VISIB_REG',
3233  ilUtil::formCheckbox($_POST['def']['visib_reg'], 'def[visib_reg]', 1));
3234 
3235  return true;
3236  }
3237 
3239  {
3240  global $lng;
3241 
3242  $lng->loadLanguageModule("administration");
3243  $lng->loadLanguageModule("ps");
3244 
3245  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_edit_select_field.html');
3246 
3247  include_once("Modules/Course/classes/class.ilCourseAgreement.php");
3249  {
3250  $this->tpl->setCurrentBlock('warning_modify');
3251  $this->tpl->setVariable('TXT_WARNING', $lng->txt('ps_warning_modify'));
3252  $this->tpl->parseCurrentBlock();
3253  }
3254 
3255  // Save field_type
3256  $this->ctrl->setParameter($this,'field_type',(int) $_REQUEST['field_type']);
3257  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3258  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('udf_add_field'));
3259  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('btn_previous'));
3260  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('add_new_user_defined_select_field'));
3261  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
3262  $this->tpl->setVariable("FIELD_NAME_VALUE",$_POST['field_name']);
3263  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
3264  $this->tpl->setVariable("TXT_COURSE_EXPORT", $lng->txt("course_export"));
3265 
3266  $this->tpl->setVariable("TXT_VISIBLE", $this->lng->txt("visible"));
3267  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("changeable"));
3268  $this->tpl->setVariable("TXT_REQUIRED", $this->lng->txt("required_field"));
3269  $this->tpl->setVariable("TXT_SEARCHABLE", $this->lng->txt("header_searchable"));
3270 
3271  $this->tpl->setVariable('TXT_VISIB_REG', $this->lng->txt('visible_registration'));
3272 
3273  $this->tpl->setVariable("VISIBLE",ilUtil::formCheckbox($_POST['def']['visible'],"def[visible]",1));
3274  $this->tpl->setVariable("CHANGE",ilUtil::formCheckbox($_POST['def']['changeable'],"def[changeable]",1));
3275  $this->tpl->setVariable("REQUIRED",ilUtil::formCheckbox($_POST['def']['required'],"def[required]",1));
3276  $this->tpl->setVariable("SEARCHABLE",ilUtil::formCheckbox($_POST['def']['searchable'],"def[searchable]",1));
3277  $this->tpl->setVariable("EXPORT",ilUtil::formCheckbox($_POST['def']['export'],"def[export]",1));
3278  $this->tpl->setVariable("COURSE_EXPORT",ilUtil::formCheckbox($_POST['def']['course_export'],"def[course_export]",1));
3279 
3280  $this->tpl->setVariable('VISIB_REG',
3281  ilUtil::formCheckbox($_POST['def']['visib_reg'], 'def[visib_reg]', 1));
3282 
3283  $this->tpl->setVariable("BTN_NEW_VALUE",$this->lng->txt('btn_new_value'));
3284 
3285  for($i = 0; $i < $_SESSION['num_values']; $i++)
3286  {
3287  $this->tpl->setCurrentBlock("values");
3288  $this->tpl->setVariable("TXT_VALUES",$this->lng->txt('udf_value').' '.($i+1));
3289  $this->tpl->setVariable("COUNTER",$i);
3290  $this->tpl->setVariable("FIELD_NAME",$_POST['field_values'][$i]);
3291  $this->tpl->parseCurrentBlock();
3292  }
3293  }
3294 
3300  {
3301  global $lng;
3302 
3303  $lng->loadLanguageModule("administration");
3304  $lng->loadLanguageModule("ps");
3305 
3306  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_edit_wysiwyg_field.html');
3307 
3308  include_once("Modules/Course/classes/class.ilCourseAgreement.php");
3310  {
3311  $this->tpl->setCurrentBlock('warning_modify');
3312  $this->tpl->setVariable('TXT_WARNING', $lng->txt('ps_warning_modify'));
3313  $this->tpl->parseCurrentBlock();
3314  }
3315 
3316  // Save field_type
3317  $this->ctrl->setParameter($this,'field_type',(int) $_REQUEST['field_type']);
3318  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3319 
3320  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('udf_add_field'));
3321  $this->tpl->setVariable("BTN_PREVIOUS",$this->lng->txt('btn_previous'));
3322  $this->tpl->setVariable("TXT_SELECT_TYPE",$this->lng->txt('add_new_user_defined_wysiwyg_field'));
3323  $this->tpl->setVariable("TXT_FIELD_NAME",$this->lng->txt('field_name'));
3324  $this->tpl->setVariable("FIELD_NAME",$_POST['field_name']);
3325 
3326  $this->tpl->setVariable("TXT_VISIBLE", $this->lng->txt("visible"));
3327  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("changeable"));
3328  $this->tpl->setVariable("TXT_REQUIRED", $this->lng->txt("required_field"));
3329  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
3330  $this->tpl->setVariable("TXT_COURSE_EXPORT", $lng->txt("course_export"));
3331 
3332  $this->tpl->setVariable('TXT_VISIB_REG', $this->lng->txt('visible_registration'));
3333 
3334  $this->tpl->setVariable("VISIBLE",ilUtil::formCheckbox($_POST['def']['visible'],"def[visible]",1));
3335  $this->tpl->setVariable("CHANGE",ilUtil::formCheckbox($_POST['def']['changeable'],"def[changeable]",1));
3336  $this->tpl->setVariable("REQUIRED",ilUtil::formCheckbox($_POST['def']['required'],"def[required]",1));
3337  $this->tpl->setVariable("EXPORT",ilUtil::formCheckbox($_POST['def']['export'],"def[export]",1));
3338  $this->tpl->setVariable("COURSE_EXPORT",ilUtil::formCheckbox($_POST['def']['course_export'],"def[course_export]",1));
3339 
3340  $this->tpl->setVariable('VISIB_REG',
3341  ilUtil::formCheckbox($_POST['def']['visib_reg'], 'def[visib_reg]', 1));
3342 
3343  return true;
3344  }
3345 
3346 
3347  function addValueObject()
3348  {
3349  $_SESSION['num_values'] += 1;
3350  $this->chooseDefinitionsObject();
3351  return true;
3352  }
3353 
3354  function saveFieldObject()
3355  {
3356  include_once './Services/User/classes/class.ilUserDefinedFields.php';
3357  $user_field_definitions =& ilUserDefinedFields::_getInstance();
3358 
3359  if( isset($_POST['def']['required']) && (int)$_POST['def']['required'] &&
3360  (!isset($_POST['def']['visib_reg']) || !(int)$_POST['def']['visib_reg'])
3361  ){
3362  $this->confirm_change = 1;
3363  ilUtil::sendFailure($this->lng->txt('udf_required_requires_visib_reg'));
3364  $this->chooseDefinitionsObject();
3365  return false;
3366  }
3367 
3368  if (!strlen($_POST['field_name']))
3369  {
3370  ilUtil::sendFailure($this->lng->txt('udf_no_name_given'));
3371  $this->chooseDefinitionsObject();
3372  return false;
3373  }
3374 
3375  if($user_field_definitions->nameExists($_POST['field_name']))
3376  {
3377  ilUtil::sendFailure($this->lng->txt('udf_name_already_exists'));
3378  $this->chooseDefinitionsObject();
3379  return false;
3380  }
3381 
3382  // Text fields
3383  $user_field_definitions->setFieldType($_REQUEST['field_type']);
3384  if($_REQUEST['field_type'] == UDF_TYPE_SELECT)
3385  {
3386  $user_field_definitions->setFieldValues($_POST['field_values']);
3387  if($error = $user_field_definitions->validateValues())
3388  {
3389  switch($error)
3390  {
3391  case UDF_DUPLICATE_VALUES:
3392  ilUtil::sendFailure($this->lng->txt('udf_duplicate_entries'));
3393  $this->chooseDefinitionsObject();
3394  return false;
3395 
3396  case UDF_NO_VALUES:
3397  ilUtil::sendFailure($this->lng->txt('udf_no_entries'));
3398  $this->chooseDefinitionsObject();
3399  return false;
3400  }
3401  }
3402  }
3403 
3404  $user_field_definitions->setFieldName($_POST['field_name']);
3405  $user_field_definitions->enableVisible($_POST['def']['visible']);
3406  $user_field_definitions->enableChangeable($_POST['def']['changeable']);
3407  $user_field_definitions->enableRequired($_POST['def']['required']);
3408  $user_field_definitions->enableSearchable($_POST['def']['searchable']);
3409  $user_field_definitions->enableExport($_POST['def']['export']);
3410  $user_field_definitions->enableCourseExport($_POST['def']['course_export']);
3411 
3412  $user_field_definitions->enableVisibleRegistration((int)$_POST['def']['visib_reg']);
3413 
3414  $user_field_definitions->add();
3415 
3416  if ((int) $_POST['def']['course_export'] == 1)
3417  {
3418  include_once('Modules/Course/classes/class.ilCourseAgreement.php');
3420  }
3421 
3422  ilUtil::sendSuccess($this->lng->txt('udf_added_field'));
3423  $this->listUserDefinedFieldsObject();
3424 
3425  return true;
3426  }
3427 
3438  function settingsObject()
3439  {
3440  global $tpl, $lng, $ilias;
3441 
3442  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
3443  $lng->loadLanguageModule("administration");
3444  $lng->loadLanguageModule("mail");
3445  $this->setSubTabs('settings');
3446 if (true)
3447 {
3448  include_once("./Services/User/classes/class.ilUserFieldSettingsTableGUI.php");
3449  $tab = new ilUserFieldSettingsTableGUI($this, "settings");
3450  if($this->confirm_change) $tab->setConfirmChange();
3451  $tpl->setContent($tab->getHTML());
3452 }
3453 else
3454 {
3455  $this->getTemplateFile("settings","usr");
3456 
3457  $profile_fields =& $this->object->getProfileFields();
3458 
3459  $profile_fields [] = "preferences";
3460  // For the following fields, the required state can not be changed.
3461  // key = field, value = 1 (field is required), 0 (field is not required)
3462  $fixed_required_fields = array(
3463  "firstname" => 1,
3464  "lastname" => 1,
3465  "upload" => 0,
3466  "password" => 0,
3467  "language" => 0,
3468  "skin_style" => 0,
3469  "hits_per_page" => 0,
3470  "show_users_online" => 0,
3471  "instant_messengers" => 0,
3472  "hide_own_online_status" => 0,
3473  "preferences" => 0,
3474  );
3475 
3476  $no_export_fields = array(
3477  "hits_per_page",
3478  "show_users_online",
3479  "hide_own_online_status"
3480  );
3481 
3482  // fields which won't be changeable
3483  $no_changeable_fields = array(
3484  #"preferences",
3485  );
3486 
3487  // fields which won't be visible
3488  $no_visible_fields = array(
3489  #"preferences",
3490  );
3491 
3492  // disable visible checkbox
3493  $disabled_visible_fields= array(
3494  "preferences",
3495  );
3496 
3497  //disable changeable checkbox
3498  $disabled_changeable_fields= array(
3499  "preferences",
3500  );
3501 
3502  // Settings for the course export state
3503  // key = field, value = 2 (field is disabled but checked), value = 1 (field is changeable), 0 (checkbox is not shown)
3504  $course_export_fields = array(
3505  "gender" => 1, "firstname" => 2,
3506  "lastname" => 2, "title" => 1,
3507  "upload" => 0, "password" => 0,
3508  "institution" => 1, "department" => 1,
3509  "street" => 1, "zipcode" => 1,
3510  "city" => 1, "country" => 1,
3511  "phone_office" => 1, "phone_home" => 1,
3512  "phone_mobile" => 1, "fax" => 1,
3513  "email" => 1, "hobby" => 1,
3514  "referral_comment" => 0, "matriculation" => 1,
3515  "language" => 0, "skin_style" => 0,
3516  "hits_per_page" => 0, "show_users_online" => 0,
3517  "instant_messengers" => 0,
3518  "preferences" => 0,
3519  );
3520  foreach ($profile_fields as $field)
3521  {
3522  $this->tpl->setCurrentBlock("profile_settings");
3523 
3524  $txt = strcasecmp($field,"upload") == 0 ? "personal_picture" : $field;
3525  $this->tpl->setVariable("TXT_PROFILE_DATA", $this->lng->txt($txt));
3526 
3527  $this->tpl->setVariable("PROFILE_OPTION_ENABLED", "enabled_" . $field);
3528  $this->tpl->setVariable("PROFILE_OPTION_VISIBLE", "visible_" . $field);
3529  $this->tpl->setVariable("PROFILE_OPTION_REQUIRED", "required_" . $field);
3530 
3531  // Headers which are always displayed in a row
3532  $this->tpl->setVariable("HEADER_PROFILE_DATA", $this->lng->txt("usr_settings_header_profile_profile"));
3533  $this->tpl->setVariable("HEADER_ENABLED", $this->lng->txt("changeable"));
3534  $this->tpl->setVariable("HEADER_VISIBLE", $this->lng->txt("visible"));
3535  $this->tpl->setVariable("HEADER_REQUIRED", $this->lng->txt("required_field"));
3536  $this->tpl->setVariable("HEADER_EXPORT", $this->lng->txt("export"));
3537 
3538  // Check searchable
3540  {
3541  $this->tpl->setVariable("HEADER_SEARCH",$this->lng->txt('header_searchable'));
3542  $checked = ($_POST["cmd"]["saveGlobalUserSettings"] && $this->confirm_change == 1) ?
3543  $_POST["cbh"][$field]["searchable"] : ilUserSearchOptions::_isEnabled($field);
3544  $this->tpl->setVariable("CHECK_SEARCH",ilUtil::formCheckbox($checked,
3545  "cbh[$field][searchable]",
3546  1));
3547  }
3548 
3549  if(!in_array($field,
3550  array('password', 'upload', 'language', 'skin_style', 'hits_per_page', 'show_users_online', 'hide_own_online_status', 'instant_messengers')))
3551  {
3552  // Registration fields
3553  $this->tpl->setVariable('HEADER_VISIB_REG', $this->lng->txt('header_visible_registration'));
3554  $this->tpl->setVariable('PROFILE_OPTION_REGISTRATION', 'visib_reg_'.$field);
3555  if((int)$ilias->getSetting('usr_settings_visib_reg'.$field) ||
3556  ($this->confirm_change == 1 && (int)$_POST['chb']['visib_reg'.$field]))
3557  {
3558  $this->tpl->setVariable('CHECKED_REGISTRATION', ' checked="checked"');
3559  }
3560 
3561  }
3562 
3563  // BEGIN Enable field in Personal Profile
3564  if (!in_array($field, $no_changeable_fields) &&
3565  ($ilias->getSetting("usr_settings_disable_".$field) != "1" ||
3566  ($this->confirm_change == 1 && ! $_POST["chb"]["enabled_" . $field])))
3567  {
3568  $this->tpl->setVariable("CHECKED_ENABLED", " checked=\"checked\"");
3569  }
3570 
3571  if (in_array($field, $disabled_changeable_fields))
3572  {
3573  $this->tpl->setVariable("DISABLE_ENABLED", " disabled=\"disabled\"");
3574  }
3575 
3576  // END Enable field in Personal Profile
3577  // BEGIN Show field in Personal Profile
3578  if (!in_array($field, $no_visible_fields) &&
3579  ($ilias->getSetting("usr_settings_hide_".$field) != "1" ||
3580  ($this->confirm_change == 1 && ! $_POST["chb"]["visible_" . $field])))
3581  {
3582  $this->tpl->setVariable("CHECKED_VISIBLE", " checked=\"checked\"");
3583  }
3584 
3585  if (in_array($field, $disabled_visible_fields))
3586  {
3587  $this->tpl->setVariable("DISABLE_VISIBLE", " disabled=\"disabled\"");
3588  }
3589 
3590  // END Show field in Personal Profile
3591  if (!in_array($field, $no_export_fields))
3592  {
3593  $this->tpl->setVariable("PROFILE_OPTION_EXPORT", "export_" . $field);
3594  // BEGIN Export field of Personal Profile
3595  if ($ilias->getSetting("usr_settings_export_".$field) == "1" ||
3596  ($this->confirm_change == 1 && $_POST["chb"]["export_" . $field] == "1"))
3597  {
3598  $this->tpl->setVariable("CHECKED_EXPORT", " checked=\"checked\"");
3599  }
3600  // END Export field of Personal Profile
3601  }
3602  // BEGIN Require field in Personal Profile
3603  $is_fixed = array_key_exists($field, $fixed_required_fields);
3604  if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed &&
3605  ($ilias->getSetting("require_".$field) == "1" ||
3606  ($this->confirm_change == 1 && $_POST["chb"]["required_" . $field] == "1")))
3607  {
3608  $this->tpl->setVariable("CHECKED_REQUIRED", " checked=\"checked\"");
3609  }
3610  if ($is_fixed)
3611  {
3612  $this->tpl->setVariable("DISABLE_REQUIRED", " disabled=\"disabled\"");
3613  }
3614  // END Require field in Personal Profile
3615 
3616  // BEGIN Course Export field in Personal Profile
3617  if (is_array($course_export_fields))
3618  {
3619  if (in_array($field, $course_export_fields) && $course_export_fields[$field] != 0)
3620  {
3621  $this->tpl->setVariable("HEADER_COURSE_EXPORT", $lng->txt("course_export"));
3622  $this->tpl->setVariable("PROFILE_OPTION_COURSE_EXPORT", "course_export_" . $field);
3623 
3624  if ($course_export_fields[$field] == 2)
3625  {
3626  $this->tpl->setVariable("CHECKED_COURSE_EXPORT", " checked=\"checked\"");
3627  $this->tpl->setVariable("DISABLE_COURSE_EXPORT", " disabled=\"disabled\"");
3628  }
3629  else
3630  {
3631  if ($ilias->getSetting("usr_settings_course_export_".$field) == "1" ||
3632  ($this->confirm_change == 1 && $_POST["chb"]["course_export_" . $field] == "1"))
3633  {
3634  $this->tpl->setVariable("CHECKED_COURSE_EXPORT", " checked=\"checked\"");
3635  }
3636  }
3637  }
3638  }
3639  // END Course Export field in Personal Profile
3640 
3641  // BEGIN Default value for hits per pages field in Personal Profile
3642  if ($field == "hits_per_page")
3643  {
3644  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
3645  $options = array(2,10,15,20,30,40,50,100,9999);
3646  $selected_option = $ilias->getSetting("hits_per_page");
3647  if ($selected_option == null) $selected_option = 10;
3648  $this->tpl->setCurrentBlock("default_value_option");
3649  foreach ($options as $option)
3650  {
3651  if ($option == $selected_option)
3652  {
3653  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
3654  }
3655 
3656  $this->tpl->setVariable("OPTION_VALUE", $option);
3657  $this->tpl->setVariable("OPTION_TEXT", ($option == 9999) ? $this->lng->txt("no_limit") : $option);
3658  $this->tpl->parseCurrentBlock();
3659  }
3660  $this->tpl->setCurrentBlock("profile_settings");
3661  $this->tpl->setVariable("HEADER_DEFAULT_VALUE", $this->lng->txt("default_value"));
3662  }
3663  // END Default value for language field in Personal Profile
3664 
3665  // BEGIN Show Users Online
3666  else if ($field == "show_users_online")
3667  {
3668  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
3669  $options = array('y','associated','n');
3670  $selected_option = $ilias->getSetting("show_users_online");
3671  if ($selected_option == "") $selected_option = "y";
3672  $this->tpl->setCurrentBlock("default_value_option");
3673  foreach ($options as $option)
3674  {
3675  if ($option == $selected_option)
3676  {
3677  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
3678  }
3679 
3680  $this->tpl->setVariable("OPTION_VALUE", $option);
3681  $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt("users_online_show_short_".$option));
3682  $this->tpl->parseCurrentBlock();
3683  }
3684  $this->tpl->setCurrentBlock("profile_settings");
3685  $this->tpl->setVariable("HEADER_DEFAULT_VALUE", $this->lng->txt("default_value"));
3686  }
3687  // END Show Users Online
3688 
3689  $this->tpl->parseCurrentBlock();
3690  }
3691  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3692  $this->tpl->setVariable("TXT_HEADER_PROFILE", $this->lng->txt("usr_settings_header_profile"));
3693  $this->tpl->setVariable("TXT_EXPLANATION_PROFILE", $this->lng->txt("usr_settings_explanation_profile"));
3694  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3695 
3696  if ($this->confirm_change == 1)
3697  {
3698  $this->tpl->setVariable("CONFIRM_MESSAGE", $this->lng->txt("confirm_message_course_export"));
3699  $this->tpl->setVariable("BUTTON_CONFIRM", $this->lng->txt("confirm"));
3700  $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
3701  }
3702 }
3703  }
3704 
3706  {
3707  $this->saveGlobalUserSettingsObject("save");
3708  }
3709 
3710  function saveGlobalUserSettingsObject($action = "")
3711  {
3712  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
3713  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
3714 
3715  global $ilias,$ilSetting;
3716 
3717  $profile_fields =& $this->object->getProfileFields();
3718 
3719  $valid = true;
3720  foreach ($profile_fields as $field)
3721  {
3722  if ( $_POST["chb"]["required_".$field] &&
3723  !(int)$_POST['chb']['visib_reg_' . $field]
3724  ){
3725  $valid = false;
3726  break;
3727  }
3728  }
3729 
3730  if(!$valid)
3731  {
3732  global $lng;
3733  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
3734  $this->confirm_change = 1;
3735  $this->settingsObject();
3736  return;
3737  }
3738 
3739  // For the following fields, the required state can not be changed
3740  $fixed_required_fields = array(
3741  "firstname" => 1,
3742  "lastname" => 1,
3743  "upload" => 0,
3744  "password" => 0,
3745  "language" => 0,
3746  "skin_style" => 0,
3747  "hits_per_page" => 0,
3748  "show_users_online" => 0,
3749  "hide_own_online_status" => 0
3750  );
3751 
3752  // check if a course export state of any field has been added
3753  $privacy = ilPrivacySettings::_getInstance();
3754  if ($privacy->enabledExport() == true &&
3755  $privacy->confirmationRequired() == true &&
3756  $action != "save")
3757  {
3758  foreach ($profile_fields as $field)
3759  {
3760  if (! $ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1")
3761  {
3762  #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
3763  #$this->confirm_change = 1;
3764  #$this->settingsObject();
3765  #return;
3766  }
3767  }
3768  }
3769  // Reset user confirmation
3770  if($action == 'save')
3771  {
3772  include_once('Modules/Course/classes/class.ilCourseAgreement.php');
3774  }
3775 
3776  foreach ($profile_fields as $field)
3777  {
3778  // Enable disable searchable
3780  {
3781  ilUserSearchOptions::_saveStatus($field,(bool) $_POST['chb']['searchable_'.$field]);
3782  }
3783 
3784  if (! $_POST["chb"]["visible_".$field])
3785  {
3786  $ilias->setSetting("usr_settings_hide_".$field, "1");
3787  }
3788  else
3789  {
3790  $ilias->deleteSetting("usr_settings_hide_".$field);
3791  }
3792 
3793  if (! $_POST["chb"]["changeable_" . $field])
3794  {
3795  $ilias->setSetting("usr_settings_disable_".$field, "1");
3796  }
3797  else
3798  {
3799  $ilias->deleteSetting("usr_settings_disable_".$field);
3800  }
3801 
3802  // registration visible
3803  if ((int)$_POST['chb']['visib_reg_' . $field])
3804  {
3805  $ilSetting->set('usr_settings_visib_reg_'.$field, '1');
3806  }
3807  else
3808  {
3809  $ilSetting->set('usr_settings_visib_reg_'.$field, '0');
3810  }
3811 
3812  if ($_POST["chb"]["export_" . $field])
3813  {
3814  $ilias->setSetting("usr_settings_export_".$field, "1");
3815  }
3816  else
3817  {
3818  $ilias->deleteSetting("usr_settings_export_".$field);
3819  }
3820 
3821  if ($_POST["chb"]["course_export_" . $field])
3822  {
3823  $ilias->setSetting("usr_settings_course_export_".$field, "1");
3824  }
3825  else
3826  {
3827  $ilias->deleteSetting("usr_settings_course_export_".$field);
3828  }
3829 
3830  $is_fixed = array_key_exists($field, $fixed_required_fields);
3831  if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed && $_POST["chb"]["required_".$field])
3832  {
3833  $ilias->setSetting("require_".$field, "1");
3834  }
3835  else
3836  {
3837  $ilias->deleteSetting("require_" . $field);
3838  }
3839  }
3840 
3841  if ($_POST["select"]["default_hits_per_page"])
3842  {
3843  $ilias->setSetting("hits_per_page",$_POST["select"]["default_hits_per_page"]);
3844  }
3845 
3846  if ($_POST["select"]["default_show_users_online"])
3847  {
3848  $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
3849  }
3850 
3851  if ($_POST["chb"]["export_preferences"])
3852  {
3853  $ilias->setSetting("usr_settings_export_preferences",$_POST["chb"]["export_preferences"]);
3854  } else {
3855  $ilias->deleteSetting("usr_settings_export_preferences");
3856  }
3857 
3858  $ilias->setSetting('mail_incoming_mail', (int)$_POST['select']['default_mail_incoming_mail']);
3859 
3860  ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
3861  $this->settingsObject();
3862  }
3863 
3864 
3869  {
3870  $action[-1] = $this->lng->txt('all_users');
3871  $action[1] = $this->lng->txt('usr_active_only');
3872  $action[0] = $this->lng->txt('usr_inactive_only');
3873  $action[2] = $this->lng->txt('usr_limited_access_only');
3874  $action[3] = $this->lng->txt('usr_without_courses');
3875  $action[4] = $this->lng->txt('usr_filter_lastlogin');
3876  $action[5] = $this->lng->txt("usr_filter_coursemember");
3877  $action[6] = $this->lng->txt("usr_filter_groupmember");
3878  $action[7] = $this->lng->txt("usr_filter_role");
3879 
3880  return ilUtil::formSelect($_SESSION['user_filter'],"user_filter",$action,false,true);
3881  }
3882 
3890  {
3891  if(!isset($_POST["file"]))
3892  {
3893  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3894  }
3895 
3896  if (count($_POST["file"]) > 1)
3897  {
3898  $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3899  }
3900 
3901 
3902  $export_dir = $this->object->getExportDirectory();
3903  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
3904  $_POST["file"][0]);
3905  }
3906 
3911  {
3912  if(!isset($_POST["file"]))
3913  {
3914  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3915  }
3916 
3917  // SAVE POST VALUES
3918  $_SESSION["ilExportFiles"] = $_POST["file"];
3919 
3920  $this->getTemplateFile("confirm_delete_export","usr");
3921 
3922  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
3923 
3924  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3925 
3926  // BEGIN TABLE HEADER
3927  $this->tpl->setCurrentBlock("table_header");
3928  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
3929  $this->tpl->parseCurrentBlock();
3930 
3931  // BEGIN TABLE DATA
3932  $counter = 0;
3933  foreach($_POST["file"] as $file)
3934  {
3935  $this->tpl->setCurrentBlock("table_row");
3936  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
3937  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_usrf.gif"));
3938  $this->tpl->setVariable("TEXT_CONTENT", $file);
3939  $this->tpl->parseCurrentBlock();
3940  }
3941 
3942  // cancel/confirm button
3943  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3944  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
3945  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
3946  "deleteExportFile" => $this->lng->txt("confirm"));
3947  foreach ($buttons as $name => $value)
3948  {
3949  $this->tpl->setCurrentBlock("operation_btn");
3950  $this->tpl->setVariable("BTN_NAME",$name);
3951  $this->tpl->setVariable("BTN_VALUE",$value);
3952  $this->tpl->parseCurrentBlock();
3953  }
3954  }
3955 
3956 
3961  {
3962  session_unregister("ilExportFiles");
3963  ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
3964  }
3965 
3966 
3971  {
3972  $export_dir = $this->object->getExportDirectory();
3973  foreach($_SESSION["ilExportFiles"] as $file)
3974  {
3975  $exp_file = $export_dir."/".$file;
3976  if (@is_file($exp_file))
3977  {
3978  unlink($exp_file);
3979  }
3980  }
3981  ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
3982  }
3983 
3994  function exportObject()
3995  {
3996  global $ilias, $ilCtrl;
3997 
3998  if ($_POST["cmd"]["export"])
3999  {
4000  $this->object->buildExportFile($_POST["export_type"]);
4001  ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "export"));
4002  exit;
4003  }
4004 
4005  $this->getTemplateFile("export","usr");
4006 
4007  $export_types = array(
4008  "userfolder_export_excel_x86",
4009  "userfolder_export_csv",
4010  "userfolder_export_xml"
4011  );
4012 
4013  // create table
4014  include_once("./Services/Table/classes/class.ilTableGUI.php");
4015  $tbl = new ilTableGUI();
4016 
4017  // load files templates
4018  $this->tpl->addBlockfile("EXPORT_FILES", "export_files", "tpl.table.html");
4019 
4020  // load template for table content data
4021  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_export_file_row.html");
4022 
4023  $num = 0;
4024 
4025  $tbl->setTitle($this->lng->txt("userfolder_export_files"));
4026 
4027  $tbl->setHeaderNames(array("", $this->lng->txt("userfolder_export_file"),
4028  $this->lng->txt("userfolder_export_file_size"), $this->lng->txt("date") ));
4029  $tbl->setHeaderVars(array(), $ilCtrl->getParameterArray($this, "export"));
4030 
4031  $tbl->enabled["sort"] = false;
4032  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
4033 
4034  // control
4035  $tbl->setOrderColumn($_GET["sort_by"]);
4036  $tbl->setOrderDirection($_GET["sort_order"]);
4037  $tbl->setLimit($_GET["limit"]);
4038  $tbl->setOffset($_GET["offset"]);
4039  $tbl->setMaxCount($this->maxcount); // ???
4040 
4041 
4042  $this->tpl->setVariable("COLUMN_COUNTS", 4);
4043 
4044  // delete button
4045  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
4046  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
4047  $this->tpl->setCurrentBlock("tbl_action_btn");
4048  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
4049  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
4050  $this->tpl->parseCurrentBlock();
4051 
4052  $this->tpl->setCurrentBlock("tbl_action_btn");
4053  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
4054  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
4055  $this->tpl->parseCurrentBlock();
4056 
4057  // footer
4058  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
4059  //$tbl->disable("footer");
4060 
4061  $export_files = $this->object->getExportFiles();
4062 
4063  $tbl->setMaxCount(count($export_files));
4064  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
4065 
4066  $tbl->render();
4067 
4068  if(count($export_files) > 0)
4069  {
4070  $i=0;
4071  foreach($export_files as $exp_file)
4072  {
4073  $this->tpl->setCurrentBlock("tbl_content");
4074  $this->tpl->setVariable("TXT_FILENAME", $exp_file["filename"]);
4075 
4076  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
4077  $this->tpl->setVariable("CSS_ROW", $css_row);
4078 
4079  $this->tpl->setVariable("TXT_SIZE", $exp_file["filesize"]);
4080  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["filename"]);
4081 
4082  $file_arr = explode("__", $exp_file["filename"]);
4083  $this->tpl->setVariable('TXT_DATE',ilDatePresentation::formatDate(new ilDateTime($file_arr[0],IL_CAL_UNIX)));
4084 
4085  $this->tpl->parseCurrentBlock();
4086  }
4087 
4088  $this->tpl->setCurrentBlock("selectall");
4089  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
4090  $this->tpl->setVariable("CSS_ROW", $css_row);
4091  $this->tpl->parseCurrentBlock();
4092  } //if is_array
4093  else
4094  {
4095  $this->tpl->setCurrentBlock("notfound");
4096  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
4097  $this->tpl->setVariable("NUM_COLS", 3);
4098  $this->tpl->parseCurrentBlock();
4099  }
4100 
4101  $this->tpl->parseCurrentBlock();
4102 
4103 
4104  foreach ($export_types as $export_type)
4105  {
4106  $this->tpl->setCurrentBlock("option");
4107  $this->tpl->setVariable("OPTION_VALUE", $export_type);
4108  $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt($export_type));
4109  $this->tpl->parseCurrentBlock();
4110  }
4111 
4112  $this->tpl->setVariable("EXPORT_BUTTON", $this->lng->txt("create_export_file"));
4113  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
4114  }
4115 
4120  {
4121  global $lng;
4122 
4123  $this->setSubTabs('settings');
4124  $this->tabs_gui->setTabActive('settings');
4125  $this->tabs_gui->setSubTabActive('user_new_account_mail');
4126 
4127  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_new_account_mail.html');
4128  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
4129  $this->tpl->setVariable("IMG_MAIL", ilUtil::getImagePath("icon_mail.gif"));
4130 
4131  $lng->loadLanguageModule("meta");
4132  $lng->loadLanguageModule("mail");
4133  $this->tpl->setVariable("TXT_NEW_USER_ACCOUNT_MAIL", $lng->txt("user_new_account_mail"));
4134  $this->tpl->setVariable("TXT_NEW_USER_ACCOUNT_MAIL_DESC", $lng->txt("user_new_account_mail_desc"));
4135 
4136  // placeholder help text
4137  $this->tpl->setVariable("TXT_USE_PLACEHOLDERS", $lng->txt("mail_nacc_use_placeholder"));
4138  $this->tpl->setVariable("TXT_MAIL_SALUTATION", $lng->txt("mail_nacc_salutation"));
4139  $this->tpl->setVariable("TXT_FIRST_NAME", $lng->txt("firstname"));
4140  $this->tpl->setVariable("TXT_LAST_NAME", $lng->txt("lastname"));
4141  $this->tpl->setVariable("TXT_EMAIL", $lng->txt("email"));
4142  $this->tpl->setVariable("TXT_LOGIN", $lng->txt("mail_nacc_login"));
4143  $this->tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
4144  $this->tpl->setVariable("TXT_PASSWORD_BLOCK", $lng->txt("mail_nacc_pw_block"));
4145  $this->tpl->setVariable("TXT_NOPASSWORD_BLOCK", $lng->txt("mail_nacc_no_pw_block"));
4146  $this->tpl->setVariable("TXT_ADMIN_MAIL", $lng->txt("mail_nacc_admin_mail"));
4147  $this->tpl->setVariable("TXT_ILIAS_URL", $lng->txt("mail_nacc_ilias_url"));
4148  $this->tpl->setVariable("TXT_CLIENT_NAME", $lng->txt("mail_nacc_client_name"));
4149  $this->tpl->setVariable("TXT_TARGET", $lng->txt("mail_nacc_target"));
4150  $this->tpl->setVariable("TXT_TARGET_TITLE", $lng->txt("mail_nacc_target_title"));
4151  $this->tpl->setVariable("TXT_TARGET_TYPE", $lng->txt("mail_nacc_target_type"));
4152  $this->tpl->setVariable("TXT_TARGET_BLOCK", $lng->txt("mail_nacc_target_block"));
4153 
4154  $langs = $lng->getInstalledLanguages();
4155  foreach($langs as $lang_key)
4156  {
4157  $amail = $this->object->_lookupNewAccountMail($lang_key);
4158  $this->tpl->setCurrentBlock("mail_block");
4159  $add = "";
4160  if ($lang_key == $lng->getDefaultLanguage())
4161  {
4162  $add = " (".$lng->txt("default").")";
4163  }
4164  $this->tpl->setVariable("TXT_LANGUAGE",
4165  $lng->txt("meta_l_".$lang_key).$add);
4166  $this->tpl->setVariable("TXT_BODY", $lng->txt("message_content"));
4167  $this->tpl->setVariable("TA_BODY", "body_".$lang_key);
4168  $this->tpl->setVariable("VAL_BODY",
4169  ilUtil::prepareFormOutput($amail["body"]));
4170  $this->tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
4171  $this->tpl->setVariable("INPUT_SUBJECT", "subject_".$lang_key);
4172  $this->tpl->setVariable("VAL_SUBJECT",
4173  ilUtil::prepareFormOutput($amail["subject"]));
4174  $this->tpl->setVariable("TXT_SAL_G", $lng->txt("mail_salutation_general"));
4175  $this->tpl->setVariable("INPUT_SAL_G", "sal_g_".$lang_key);
4176  $this->tpl->setVariable("VAL_SAL_G",
4177  ilUtil::prepareFormOutput($amail["sal_g"]));
4178  $this->tpl->setVariable("TXT_SAL_M", $lng->txt("mail_salutation_male"));
4179  $this->tpl->setVariable("INPUT_SAL_M", "sal_m_".$lang_key);
4180  $this->tpl->setVariable("VAL_SAL_M",
4181  ilUtil::prepareFormOutput($amail["sal_m"]));
4182  $this->tpl->setVariable("TXT_SAL_F", $lng->txt("mail_salutation_female"));
4183  $this->tpl->setVariable("INPUT_SAL_F", "sal_f_".$lang_key);
4184  $this->tpl->setVariable("VAL_SAL_F",
4185  ilUtil::prepareFormOutput($amail["sal_f"]));
4186  $this->tpl->parseCurrentBlock();
4187  }
4188  $this->tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
4189  $this->tpl->setVariable("TXT_SAVE", $lng->txt("save"));
4190  }
4191 
4193  {
4194  $this->ctrl->redirect($this, "settings");
4195  }
4196 
4198  {
4199  global $lng;
4200 
4201  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
4202  $langs = $lng->getInstalledLanguages();
4203  foreach($langs as $lang_key)
4204  {
4205  $this->object->_writeNewAccountMail($lang_key,
4206  ilUtil::stripSlashes($_POST["subject_".$lang_key]),
4207  ilUtil::stripSlashes($_POST["sal_g_".$lang_key]),
4208  ilUtil::stripSlashes($_POST["sal_f_".$lang_key]),
4209  ilUtil::stripSlashes($_POST["sal_m_".$lang_key]),
4210  ilUtil::stripSlashes($_POST["body_".$lang_key]));
4211  }
4212  $this->ctrl->redirect($this, "newAccountMail");
4213  }
4214 
4215  function getAdminTabs(&$tabs_gui)
4216  {
4217  $this->getTabs($tabs_gui);
4218  }
4219 
4225  function getTabs(&$tabs_gui)
4226  {
4227  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
4228 
4229  global $rbacsystem;
4230 
4231  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
4232  {
4233  $tabs_gui->addTarget("obj_usrf",
4234  $this->ctrl->getLinkTarget($this, "view"), array("view","delete","resetFilter", "userAction", ""), "", "");
4235 
4236  $tabs_gui->addTarget("search_user_extended",
4237  $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','startExtended'),
4238  array(""), "iladminusersearchgui", "");
4239  }
4240 
4241  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
4242  {
4243  $tabs_gui->addTarget("settings",
4244  $this->ctrl->getLinkTarget($this, "settings"), array("settings", "saveGlobalUserSettings"), "", "");
4245 
4246  $tabs_gui->addTarget("export",
4247  $this->ctrl->getLinkTarget($this, "export"), "export", "", "");
4248 
4252  {
4253  $tabs_gui->addTarget("learning_progress",
4254  $this->ctrl->getLinkTarget($this, "learningProgress"), "learningProgress", "", "");
4255  }
4256  }
4257 
4258  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
4259  {
4260  $tabs_gui->addTarget("perm_settings",
4261  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
4262  array("perm","info","owner"), 'ilpermissiongui');
4263  }
4264  }
4265 
4266 
4270  function setSubTabs($a_tab)
4271  {
4272  global $rbacsystem,$ilUser;
4273 
4274  switch($a_tab)
4275  {
4276  case "settings":
4277  $this->tabs_gui->addSubTabTarget("standard_fields",
4278  $this->ctrl->getLinkTarget($this,'settings'),
4279  array("settings", "saveGlobalUserSettings"), get_class($this));
4280  $this->tabs_gui->addSubTabTarget("user_defined_fields",
4281  $this->ctrl->getLinkTarget($this,'listUserDefinedFields'),
4282  "listUserDefinedFields",get_class($this));
4283  $this->tabs_gui->addSubTabTarget("user_new_account_mail",
4284  $this->ctrl->getLinkTarget($this,'newAccountMail'),
4285  "newAccountMail",get_class($this));
4286  $this->tabs_gui->addSubTabTarget('loginname_settings',
4287  $this->ctrl->getLinkTarget($this, 'showLoginnameSettings'), 'showLoginnameSettings', get_class($this));
4288 
4289  break;
4290  }
4291  }
4292 
4294  {
4295  global $ilSetting;
4296 
4297  $this->initLoginSettingsForm();
4298  $this->loginSettingsForm->setValuesByArray(array(
4299  'allow_change_loginname' => (bool)$ilSetting->get('allow_change_loginname'),
4300  'create_history_loginname' => (bool)$ilSetting->get('create_history_loginname'),
4301  'prevent_reuse_of_loginnames' => (bool)$ilSetting->get('prevent_reuse_of_loginnames'),
4302  'loginname_change_blocking_time' => (int)$ilSetting->get('loginname_change_blocking_time')
4303  ));
4304 
4305  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
4306  }
4307 
4308  private function initLoginSettingsForm()
4309  {
4310  $this->setSubTabs('settings');
4311  $this->tabs_gui->setTabActive('settings');
4312  $this->tabs_gui->setSubTabActive('loginname_settings');
4313 
4314  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4315  $this->loginSettingsForm = new ilPropertyFormGUI;
4316  $this->loginSettingsForm->setFormAction($this->ctrl->getFormAction($this, 'saveLoginnameSettings'));
4317  $this->loginSettingsForm->setTitle($this->lng->txt('loginname_settings'));
4318 
4319  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
4320  $chbChangeLogin->setValue(1);
4321  $this->loginSettingsForm->addItem($chbChangeLogin);
4322  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
4323  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
4324  $chbCreateHistory->setValue(1);
4325  $chbChangeLogin->addSubItem($chbCreateHistory);
4326  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'prevent_reuse_of_loginnames');
4327  $chbReuseLoginnames->setValue(1);
4328  $chbReuseLoginnames->setInfo($this->lng->txt('prevent_reuse_of_loginnames_contained_in_history_info'));
4329  $chbChangeLogin->addSubItem($chbReuseLoginnames);
4330  $chbChangeBlockingTime = new ilTextInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
4331  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
4332  $chbChangeBlockingTime->setSize(10);
4333  $chbChangeBlockingTime->setMaxLength(10);
4334  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
4335 
4336  $this->loginSettingsForm->addCommandButton('saveLoginnameSettings', $this->lng->txt('save'));
4337  }
4338 
4340  {
4341  global $ilUser, $ilSetting;
4342 
4343  $this->initLoginSettingsForm();
4344  if($this->loginSettingsForm->checkInput())
4345  {
4346  $valid = true;
4347 
4348  if(strlen($this->loginSettingsForm->getInput('loginname_change_blocking_time')) &&
4349  !preg_match('/^[0-9]*$/',
4350  $this->loginSettingsForm->getInput('loginname_change_blocking_time')))
4351  {
4352  $valid = false;
4353  $this->loginSettingsForm->getItemByPostVar('loginname_change_blocking_time')
4354  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
4355  }
4356 
4357  if($valid)
4358  {
4359  $ilSetting->set('allow_change_loginname', (int)$this->loginSettingsForm->getInput('allow_change_loginname'));
4360  $ilSetting->set('create_history_loginname', (int)$this->loginSettingsForm->getInput('create_history_loginname'));
4361  $ilSetting->set('prevent_reuse_of_loginnames', (int)$this->loginSettingsForm->getInput('prevent_reuse_of_loginnames'));
4362  $ilSetting->set('loginname_change_blocking_time', (int)$this->loginSettingsForm->getInput('loginname_change_blocking_time'));
4363 
4364  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4365  }
4366  else
4367  {
4368  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
4369  }
4370  }
4371  else
4372  {
4373  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
4374  }
4375  $this->loginSettingsForm->setValuesByPost();
4376 
4377  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
4378  }
4379 
4380  /*
4381  function showUpperIcon()
4382  {
4383  var_dump($this->ctrl->getCmd());
4384  }*/
4385 } // END class.ilObjUserFolderGUI
4386 ?>