ILIAS  release_4-3 Revision
 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 "./Services/Object/classes/class.ilObjectGUI.php";
5 
20 {
21  var $ctrl;
22 
27  function ilObjUserFolderGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
28  {
29  global $ilCtrl;
30 
31  // TODO: move this to class.ilias.php
32  define('USER_FOLDER_ID',7);
33 
34  $this->type = "usrf";
35  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
36 
37  $this->lng->loadLanguageModule('search');
38  $this->lng->loadLanguageModule("user");
39 
40  $ilCtrl->saveParameter($this, "letter");
41  }
42 
43  function setUserOwnerId($a_id)
44  {
45  $this->user_owner_id = $a_id;
46  }
47  function getUserOwnerId()
48  {
49  return $this->user_owner_id ? $this->user_owner_id : USER_FOLDER_ID;
50  }
51 
52  function &executeCommand()
53  {
54  global $ilTabs;
55 
56  $next_class = $this->ctrl->getNextClass($this);
57  $cmd = $this->ctrl->getCmd();
58  $this->prepareOutput();
59 
60  switch($next_class)
61  {
62  case 'ilusertablegui':
63  include_once("./Services/User/classes/class.ilUserTableGUI.php");
64  $u_table = new ilUserTableGUI($this, "view");
65  $u_table->initFilter();
66  $this->ctrl->setReturn($this,'view');
67  $this->ctrl->forwardCommand($u_table);
68  break;
69 
70  case 'ilpermissiongui':
71  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
72  $perm_gui =& new ilPermissionGUI($this);
73  $ret =& $this->ctrl->forwardCommand($perm_gui);
74  break;
75 
76  case 'ilrepositorysearchgui':
77  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
78  $user_search =& new ilRepositorySearchGUI();
79  $user_search->enableSearchableCheck(false);
80  $user_search->setCallback(
81  $this,
82  'searchResultHandler',
83  $this->getUserMultiCommands(true)
84  );
85  $this->tabs_gui->setTabActive('search_user_extended');
86  $this->ctrl->setReturn($this,'view');
87  $ret =& $this->ctrl->forwardCommand($user_search);
88  break;
89 
90  case 'ilaccountcodesgui':
91  $this->tabs_gui->setTabActive('settings');
92  $this->setSubTabs("settings");
93  $ilTabs->activateSubTab("account_codes");
94  include_once("./Services/User/classes/class.ilAccountCodesGUI.php");
95  $acc = new ilAccountCodesGUI($this->ref_id);
96  $this->ctrl->forwardCommand($acc);
97  break;
98 
99  case 'ilcustomuserfieldsgui':
100  $this->tabs_gui->setTabActive('settings');
101  $this->setSubTabs("settings");
102  $ilTabs->activateSubTab("user_defined_fields");
103  include_once("./Services/User/classes/class.ilCustomUserFieldsGUI.php");
104  $cf = new ilCustomUserFieldsGUI();
105  $this->ctrl->forwardCommand($cf);
106  break;
107 
108  default:
109  if(!$cmd)
110  {
111  $cmd = "view";
112  }
113  $cmd .= "Object";
114 
115  $this->$cmd();
116 
117  break;
118  }
119  return true;
120  }
121 
123  {
124  global $rbacsystem, $tpl;
125 
126  if (!$rbacsystem->checkAccess("read",$this->object->getRefId()) ||
129  {
130  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
131  }
132 
133  include_once "Services/User/classes/class.ilUserLPTableGUI.php";
134  $tbl = new ilUserLPTableGUI($this, "learningProgress", $this->object->getRefId());
135 
136  $tpl->setContent($tbl->getHTML());
137  }
138 
143  function resetFilterObject()
144  {
145  include_once("./Services/User/classes/class.ilUserTableGUI.php");
146  $utab = new ilUserTableGUI($this, "view");
147  $utab->resetOffset();
148  $utab->resetFilter();
149 
150  // from "old" implementation
151  $this->viewObject(TRUE);
152  }
153 
157  function addUserObject()
158  {
159  global $ilCtrl;
160 
161  $ilCtrl->setParameterByClass("ilobjusergui", "new_type", "usr");
162  $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjusergui"), "create");
163  }
164 
165 
169  function applyFilterObject()
170  {
171  global $ilTabs;
172 
173  include_once("./Services/User/classes/class.ilUserTableGUI.php");
174  $utab = new ilUserTableGUI($this, "view");
175  $utab->resetOffset();
176  $utab->writeFilterToSession();
177  $this->viewObject();
178  $ilTabs->activateTab("obj_usrf");
179  }
180 
186  function viewObject($reset_filter = FALSE)
187  {
188  global $rbacsystem, $ilUser, $ilToolbar, $tpl, $ilSetting, $lng;
189 
190  $ilToolbar->addButton($this->lng->txt("usr_add"),
191  $this->ctrl->getLinkTarget($this, "addUser"));
192  $ilToolbar->addButton($this->lng->txt("import_users"),
193  $this->ctrl->getLinkTarget($this, "importUserForm"));
194 
195  // alphabetical navigation
196  include_once './Services/User/classes/class.ilUserAccountSettings.php';
198  if ((int) $ilSetting->get('user_adm_alpha_nav'))
199  {
200  $ilToolbar->addSeparator();
201 
202  // alphabetical navigation
203  include_once("./Services/Form/classes/class.ilAlphabetInputGUI.php");
204  $ai = new ilAlphabetInputGUI("", "first");
205  include_once("./Services/User/classes/class.ilObjUser.php");
206  $ai->setLetters(ilObjUser::getFirstLettersOfLastnames());
207  /*$ai->setLetters(array("A","B","C","D","E","F","G","H","I","J",
208  "K","L","M","N","O","P","Q","R","S","T",
209  "U","V","W","X","Y","Z","1","2","3","4","_",
210  "Ä","Ü","Ö",":",";","+","*","#","§","%","&"));*/
211  $ai->setParentCommand($this, "chooseLetter");
212  $ai->setHighlighted($_GET["letter"]);
213  $ilToolbar->addInputItem($ai, true);
214 
215  }
216 
217  include_once("./Services/User/classes/class.ilUserTableGUI.php");
218  $utab = new ilUserTableGUI($this, "view");
219  $tpl->setContent($utab->getHTML());
220  }
221 
225  protected function addUserAutoCompleteObject()
226  {
227  include_once './Services/User/classes/class.ilUserAutoComplete.php';
228  $auto = new ilUserAutoComplete();
229  $auto->setSearchFields(array('login','firstname','lastname','email'));
230  $auto->enableFieldSearchableCheck(false);
231  echo $auto->getList($_REQUEST['term']);
232  exit();
233  }
234 
242  {
243  global $ilCtrl;
244 
245  $ilCtrl->redirect($this, "view");
246  }
247 
248 
255  function showActions($with_subobjects = false)
256  {
257  global $rbacsystem;
258 
259  $operations = array();
260 //var_dump($this->actions);
261  if ($this->actions == "")
262  {
263  $d = array(
264  "delete" => array("name" => "delete", "lng" => "delete"),
265  "activate" => array("name" => "activate", "lng" => "activate"),
266  "deactivate" => array("name" => "deactivate", "lng" => "deactivate"),
267  "accessRestrict" => array("name" => "accessRestrict", "lng" => "accessRestrict"),
268  "accessFree" => array("name" => "accessFree", "lng" => "accessFree"),
269  "export" => array("name" => "export", "lng" => "export")
270  );
271  }
272  else
273  {
274  $d = $this->actions;
275  }
276  foreach ($d as $row)
277  {
278  if ($rbacsystem->checkAccess($row["name"],$this->object->getRefId()))
279  {
280  $operations[] = $row;
281  }
282  }
283 
284  if (count($operations) > 0)
285  {
286  $select = "<select name=\"selectedAction\">\n";
287  foreach ($operations as $val)
288  {
289  $select .= "<option value=\"" . $val["name"] . "\"";
290  if (strcmp($_POST["selectedAction"], $val["name"]) == 0)
291  {
292  $select .= " selected=\"selected\"";
293  }
294  $select .= ">";
295  $select .= $this->lng->txt($val["lng"]);
296  $select .= "</option>";
297  }
298  $select .= "</select>";
299  $this->tpl->setCurrentBlock("tbl_action_select");
300  $this->tpl->setVariable("SELECT_ACTION", $select);
301  $this->tpl->setVariable("BTN_NAME", "userAction");
302  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("submit"));
303  $this->tpl->parseCurrentBlock();
304  }
305 
306  if ($with_subobjects === true)
307  {
308  $subobjs = $this->showPossibleSubObjects();
309  }
310 
311  if ((count($operations) > 0) or $subobjs === true)
312  {
313  $this->tpl->setCurrentBlock("tbl_action_row");
314  $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
315  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
316  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
317  $this->tpl->parseCurrentBlock();
318  }
319  }
320 
328  {
329  global $rbacsystem;
330 
331  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
332 
333  if (!$rbacsystem->checkAccess('create_usr',$this->object->getRefId()))
334  {
335  unset($d["usr"]);
336  }
337 
338  if (count($d) > 0)
339  {
340  foreach ($d as $row)
341  {
342  $count = 0;
343  if ($row["max"] > 0)
344  {
345  //how many elements are present?
346  for ($i=0; $i<count($this->data["ctrl"]); $i++)
347  {
348  if ($this->data["ctrl"][$i]["type"] == $row["name"])
349  {
350  $count++;
351  }
352  }
353  }
354  if ($row["max"] == "" || $count < $row["max"])
355  {
356  $subobj[] = $row["name"];
357  }
358  }
359  }
360 
361  if (is_array($subobj))
362  {
363  //build form
364  $opts = ilUtil::formSelect(12,"new_type",$subobj);
365  $this->tpl->setCurrentBlock("add_object");
366  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
367  $this->tpl->setVariable("BTN_NAME", "create");
368  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
369  $this->tpl->parseCurrentBlock();
370 
371  return true;
372  }
373 
374  return false;
375  }
376 
378  {
379  $this->ctrl->redirect($this, 'view');
380  }
381 
383  {
384  $this->ctrl->redirectByClass('ilrepositorysearchgui', 'showSearchResults');
385  }
386 
393  {
394  global $rbacsystem, $ilUser;
395 
396  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
397  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
398  {
399  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
400  }
401 
402  // FOR ALL SELECTED OBJECTS
403  foreach ($_POST["id"] as $id)
404  {
405  // instatiate correct object class (usr)
406  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
407  $obj->setActive(TRUE, $ilUser->getId());
408  $obj->update();
409  }
410 
411  ilUtil::sendSuccess($this->lng->txt("user_activated"),true);
412 
413  if ($_POST["frsrch"])
414  {
415  $this->ctrl->redirectByClass('ilRepositorySearchGUI','show');
416  }
417  else
418  {
419  $this->ctrl->redirect($this, "view");
420  }
421  }
422 
429  {
430  global $rbacsystem, $ilUser;
431 
432  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
433  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
434  {
435  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
436  }
437 
438  // FOR ALL SELECTED OBJECTS
439  foreach ($_POST["id"] as $id)
440  {
441  // instatiate correct object class (usr)
442  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
443  $obj->setActive(FALSE, $ilUser->getId());
444  $obj->update();
445  }
446 
447  // Feedback
448  ilUtil::sendSuccess($this->lng->txt("user_deactivated"),true);
449 
450  if ($_POST["frsrch"])
451  {
452  $this->ctrl->redirectByClass('ilRepositorySearchGUI','show');
453  }
454  else
455  {
456  $this->ctrl->redirect($this, "view");
457  }
458  }
459 
461  {
462  global $rbacsystem, $ilUser;
463 
464  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
465  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
466  {
467  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
468  }
469 
470  // FOR ALL SELECTED OBJECTS
471  foreach ($_POST["id"] as $id)
472  {
473  // instatiate correct object class (usr)
474  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
475  $obj->setTimeLimitOwner($ilUser->getId());
476  $obj->setTimeLimitUnlimited(1);
477  $obj->setTimeLimitFrom("");
478  $obj->setTimeLimitUntil("");
479  $obj->setTimeLimitMessage(0);
480  $obj->update();
481  }
482 
483  // Feedback
484  ilUtil::sendSuccess($this->lng->txt("access_free_granted"),true);
485 
486  if ($_POST["frsrch"])
487  {
488  $this->ctrl->redirectByClass('ilRepositorySearchGUI','show');
489  }
490  else
491  {
492  $this->ctrl->redirect($this, "view");
493  }
494  }
495 
496  function setAccessRestrictionObject($a_form = null, $a_from_search = false)
497  {
498  if(!$a_form)
499  {
500  $a_form = $this->initAccessRestrictionForm($a_from_search);
501  }
502  $this->tpl->setContent($a_form->getHTML());
503 
504  // #10963
505  return true;
506  }
507 
508  protected function initAccessRestrictionForm($a_from_search = false)
509  {
510  $user_ids = $this->getActionUserIds();
511  if(!$user_ids)
512  {
513  ilUtil::sendFailure($this->lng->txt('select_one'));
514  return $this->viewObject();
515  }
516 
517  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
518  $form = new ilPropertyFormGUI();
519  $form->setTitle($this->lng->txt("time_limit_add_time_limit_for_selected"));
520  $form->setFormAction($this->ctrl->getFormAction($this, "confirmaccessRestrict"));
521 
522  $from = new ilDateTimeInputGUI($this->lng->txt("access_from"), "from");
523  $from->setShowTime(true);
524  $from->setRequired(true);
525  $form->addItem($from);
526 
527  $to = new ilDateTimeInputGUI($this->lng->txt("access_until"), "to");
528  $to->setRequired(true);
529  $to->setShowTime(true);
530  $form->addItem($to);
531 
532  $form->addCommandButton("confirmaccessRestrict", $this->lng->txt("confirm"));
533  $form->addCommandButton("view", $this->lng->txt("cancel"));
534 
535  foreach($user_ids as $user_id)
536  {
537  $ufield = new ilHiddenInputGUI("id[]");
538  $ufield->setValue($user_id);
539  $form->addItem($ufield);
540  }
541 
542  // return to search?
543  if($a_from_search || $_POST["frsrch"])
544  {
545  $field = new ilHiddenInputGUI("frsrch");
546  $field->setValue(1);
547  $form->addItem($field);
548  }
549 
550  return $form;
551  }
552 
554  {
555  $form = $this->initAccessRestrictionForm();
556  if(!$form->checkInput())
557  {
558  return $this->setAccessRestrictionObject($form);
559  }
560 
561  $timefrom = $form->getItemByPostVar("from")->getDate()->get(IL_CAL_UNIX);
562  $timeuntil = $form->getItemByPostVar("to")->getDate()->get(IL_CAL_UNIX);
563  if ($timeuntil <= $timefrom)
564  {
565  ilUtil::sendFailure($this->lng->txt("time_limit_not_valid"));
566  return $this->setAccessRestrictionObject($form);
567  }
568 
569  global $rbacsystem, $ilUser;
570 
571  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
572  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
573  {
574  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
575  }
576 
577  // FOR ALL SELECTED OBJECTS
578  foreach ($_POST["id"] as $id)
579  {
580  // instatiate correct object class (usr)
581  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
582  $obj->setTimeLimitOwner($ilUser->getId());
583  $obj->setTimeLimitUnlimited(0);
584  $obj->setTimeLimitFrom($timefrom);
585  $obj->setTimeLimitUntil($timeuntil);
586  $obj->setTimeLimitMessage(0);
587  $obj->update();
588  }
589 
590  // Feedback
591  ilUtil::sendSuccess($this->lng->txt("access_restricted"),true);
592 
593  if ($_POST["frsrch"])
594  {
595  $this->ctrl->redirectByClass('ilRepositorySearchGUI','show');
596  }
597  else
598  {
599  $this->ctrl->redirect($this, "view");
600  }
601  }
602 
609  {
610  global $rbacsystem, $ilCtrl, $ilUser;
611 
612  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
613  if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
614  {
615  ilUtil::sendFailure($this->lng->txt("msg_no_perm_delete"), true);
616  $ilCtrl->redirect($this, "view");
617  }
618 
619  if (in_array($ilUser->getId(), $_POST["id"]))
620  {
621  $this->ilias->raiseError($this->lng->txt("msg_no_delete_yourself"),$this->ilias->error_obj->WARNING);
622  }
623 
624  // FOR ALL SELECTED OBJECTS
625  foreach ($_POST["id"] as $id)
626  {
627  // instatiate correct object class (usr)
628  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
629  $obj->delete();
630  }
631 
632  // Feedback
633  ilUtil::sendSuccess($this->lng->txt("user_deleted"),true);
634 
635  if ($_POST["frsrch"])
636  {
637  $this->ctrl->redirectByClass('ilRepositorySearchGUI','show');
638  }
639  else
640  {
641  $this->ctrl->redirect($this, "view");
642  }
643  }
644 
650  protected function getActionUserIds()
651  {
652  if($_POST["select_cmd_all"])
653  {
654  include_once("./Services/User/classes/class.ilUserTableGUI.php");
655  $utab = new ilUserTableGUI($this, "view", ilUserTableGUI::MODE_USER_FOLDER, false);
656  return $utab->getUserIdsForFilter();
657  }
658  else
659  {
660  return $_POST["id"];
661  }
662  }
663 
667  function showActionConfirmation($action, $a_from_search = false)
668  {
669  global $ilTabs;
670 
671  $user_ids = $this->getActionUserIds();
672  if(!$user_ids)
673  {
674  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
675  }
676 
677  if(!$a_from_search)
678  {
679  $ilTabs->activateTab("obj_usrf");
680  }
681  else
682  {
683  $ilTabs->activateTab("search_user_extended");
684  }
685 
686  if (strcmp($action, "accessRestrict") == 0)
687  {
688  return $this->setAccessRestrictionObject(null, $a_from_search);
689  }
690 
691  unset($this->data);
692 
693  if(!$a_from_search)
694  {
695  $cancel = "cancelUserFolderAction";
696  }
697  else
698  {
699  $cancel = "cancelSearchAction";
700  }
701 
702  // display confirmation message
703  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
704  $cgui = new ilConfirmationGUI();
705  $cgui->setFormAction($this->ctrl->getFormAction($this));
706  $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
707  $cgui->setCancel($this->lng->txt("cancel"), $cancel);
708  $cgui->setConfirm($this->lng->txt("confirm"), "confirm" . $action);
709 
710  if($a_from_search)
711  {
712  $cgui->addHiddenItem("frsrch", 1);
713  }
714 
715  foreach($user_ids as $id)
716  {
717  $user = new ilObjUser($id);
718 
719  $login = $user->getLastLogin();
720  if(!$login)
721  {
722  $login = $this->lng->txt("never");
723  }
724  else
725  {
727  }
728 
729  $caption = $user->getFullname()." (".$user->getLogin().")".", ".
730  $user->getEmail()." - ".$this->lng->txt("last_login").": ".$login;
731 
732  $cgui->addItem("id[]", $id, $caption);
733  }
734 
735  $this->tpl->setContent($cgui->getHTML());
736 
737  return true;
738  }
739 
743  function deleteUsersObject()
744  {
745  $_POST["selectedAction"] = "delete";
746  $this->showActionConfirmation($_POST["selectedAction"]);
747  }
748 
753  {
754  $_POST["selectedAction"] = "activate";
755  $this->showActionConfirmation($_POST["selectedAction"]);
756  }
757 
762  {
763  $_POST["selectedAction"] = "deactivate";
764  $this->showActionConfirmation($_POST["selectedAction"]);
765  }
766 
771  {
772  $_POST["selectedAction"] = "accessRestrict";
773  $this->showActionConfirmation($_POST["selectedAction"]);
774  }
775 
779  function freeAccessObject()
780  {
781  $_POST["selectedAction"] = "accessFree";
782  $this->showActionConfirmation($_POST["selectedAction"]);
783  }
784 
785  function userActionObject()
786  {
787  $this->showActionConfirmation($_POST["selectedAction"]);
788  }
789 
794  {
795  global $tpl, $rbacsystem;
796 
797  // Blind out tabs for local user import
798  if ($_GET["baseClass"] == 'ilRepositoryGUI')
799  {
800  $this->tabs_gui->clearTargets();
801  }
802 
803  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
804  {
805  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
806  }
807 
808  $this->initUserImportForm();
809  $tpl->setContent($this->form->getHTML());
810  }
811 
817  public function initUserImportForm()
818  {
819  global $lng, $ilCtrl;
820 
821  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
822  $this->form = new ilPropertyFormGUI();
823 
824  // Import File
825  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
826  $fi = new ilFileInputGUI($lng->txt("import_file"), "importFile");
827  $fi->setSuffixes(array("xml", "zip"));
828  //$fi->enableFileNameSelection();
829  //$fi->setInfo($lng->txt(""));
830  $this->form->addItem($fi);
831 
832  $this->form->addCommandButton("importUserRoleAssignment", $lng->txt("import"));
833  $this->form->addCommandButton("importCancelled", $lng->txt("cancel"));
834 
835  $this->form->setTitle($lng->txt("import_users"));
836  $this->form->setFormAction($ilCtrl->getFormAction($this));
837 
838  }
839 
846  {
847  // purge user import directory
848  $import_dir = $this->getImportDir();
849  if (@is_dir($import_dir))
850  {
851  ilUtil::delDir($import_dir);
852  }
853 
854  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
855  {
856  $this->ctrl->redirect($this, "view");
857  //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
858  }
859  else
860  {
861  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
862  }
863  }
864 
868  function getImportDir()
869  {
870  // For each user session a different directory must be used to prevent
871  // that one user session overwrites the import data that another session
872  // is currently importing.
873  global $ilUser;
874  $importDir = ilUtil::getDataDir().'/user_import/usr_'.$ilUser->getId().'_'.session_id();
875  ilUtil::makeDirParents($importDir);
876  return $importDir;
877  }
878 
883  {
884  global $ilUser,$rbacreview, $tpl, $lng, $ilCtrl;;
885 
886  // Blind out tabs for local user import
887  if ($_GET["baseClass"] == 'ilRepositoryGUI')
888  {
889  $this->tabs_gui->clearTargets();
890  }
891 
892  $this->initUserImportForm();
893  if ($this->form->checkInput())
894  {
895  include_once './Services/AccessControl/classes/class.ilObjRole.php';
896  include_once './Services/User/classes/class.ilUserImportParser.php';
897 
898  global $rbacreview, $rbacsystem, $tree, $lng;
899 
900 
901  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User");
902 
903  $import_dir = $this->getImportDir();
904 
905  // recreate user import directory
906  if (@is_dir($import_dir))
907  {
908  ilUtil::delDir($import_dir);
909  }
910  ilUtil::makeDir($import_dir);
911 
912  // move uploaded file to user import directory
913  $file_name = $_FILES["importFile"]["name"];
914  $parts = pathinfo($file_name);
915  $full_path = $import_dir."/".$file_name;
916 
917  // check if import file exists
918  if (!is_file($_FILES["importFile"]["tmp_name"]))
919  {
920  ilUtil::delDir($import_dir);
921  $this->ilias->raiseError($this->lng->txt("no_import_file_found")
922  , $this->ilias->error_obj->MESSAGE);
923  }
924  ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"],
925  $_FILES["importFile"]["name"], $full_path);
926 
927  // handle zip file
928  if (strtolower($parts["extension"]) == "zip")
929  {
930  // unzip file
931  ilUtil::unzip($full_path);
932 
933  $xml_file = null;
934  $file_list = ilUtil::getDir($import_dir);
935  foreach ($file_list as $a_file)
936  {
937  if (substr($a_file['entry'],-4) == '.xml')
938  {
939  $xml_file = $import_dir."/".$a_file['entry'];
940  break;
941  }
942  }
943  if (is_null($xml_file))
944  {
945  $subdir = basename($parts["basename"],".".$parts["extension"]);
946  $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
947  }
948  }
949  // handle xml file
950  else
951  {
952  $xml_file = $full_path;
953  }
954 
955  // check xml file
956  if (!is_file($xml_file))
957  {
958  ilUtil::delDir($import_dir);
959  $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip")
960  ." ".$subdir."/".$subdir.".xml", $this->ilias->error_obj->MESSAGE);
961  }
962 
963  require_once("./Services/User/classes/class.ilUserImportParser.php");
964 
965  // Verify the data
966  // ---------------
967  $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
968  $importParser->startParsing();
969  switch ($importParser->getErrorLevel())
970  {
971  case IL_IMPORT_SUCCESS :
972  break;
973  case IL_IMPORT_WARNING :
974  $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
975  break;
976  case IL_IMPORT_FAILURE :
977  ilUtil::delDir($import_dir);
978  $this->ilias->raiseError(
979  $lng->txt("verification_failed").$importParser->getProtocolAsHTML($lng->txt("verification_failure_log")),
980  $this->ilias->error_obj->MESSAGE
981  );
982  return;
983  }
984 
985  // Create the role selection form
986  // ------------------------------
987  $this->tpl->setCurrentBlock("role_selection_form");
988  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
989  $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
990  $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
991  $this->tpl->setVariable("IMPORT_FILE", $file_name);
992  $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
993  $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
994  $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
995  $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
996  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
997  $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
998 
999  // Extract the roles
1000  $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
1001  $importParser->startParsing();
1002  $roles = $importParser->getCollectedRoles();
1003 
1004  // get global roles
1005  $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
1006  $gl_roles = array();
1007  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1008  foreach ($all_gl_roles as $obj_data)
1009  {
1010  // check assignment permission if called from local admin
1011  if($this->object->getRefId() != USER_FOLDER_ID)
1012  {
1013  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
1014  {
1015  continue;
1016  }
1017  }
1018  // exclude anonymous role from list
1019  if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
1020  {
1021  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
1022  if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$roles_of_user))
1023  {
1024  $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
1025  }
1026  }
1027  }
1028 
1029  // global roles
1030  $got_globals = false;
1031  foreach($roles as $role_id => $role)
1032  {
1033  if ($role["type"] == "Global")
1034  {
1035  if (! $got_globals)
1036  {
1037  $got_globals = true;
1038 
1039  $this->tpl->setCurrentBlock("global_role_section");
1040  $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
1041  $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
1042  }
1043 
1044  // pre selection for role
1045  $pre_select = array_search($role[name], $gl_roles);
1046  if (! $pre_select)
1047  {
1048  switch($role["name"])
1049  {
1050  case "Administrator": // ILIAS 2/3 Administrator
1051  $pre_select = array_search("Administrator", $gl_roles);
1052  break;
1053 
1054  case "Autor": // ILIAS 2 Author
1055  $pre_select = array_search("User", $gl_roles);
1056  break;
1057 
1058  case "Lerner": // ILIAS 2 Learner
1059  $pre_select = array_search("User", $gl_roles);
1060  break;
1061 
1062  case "Gast": // ILIAS 2 Guest
1063  $pre_select = array_search("Guest", $gl_roles);
1064  break;
1065 
1066  default:
1067  $pre_select = array_search("User", $gl_roles);
1068  break;
1069  }
1070  }
1071  $this->tpl->setCurrentBlock("global_role");
1072  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $gl_roles, false, true);
1073  $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"]." [".$role_id."]");
1074  $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
1075  $this->tpl->parseCurrentBlock();
1076  }
1077  }
1078 
1079  // Check if local roles need to be assigned
1080  $got_locals = false;
1081  foreach($roles as $role_id => $role)
1082  {
1083  if ($role["type"] == "Local")
1084  {
1085  $got_locals = true;
1086  break;
1087  }
1088  }
1089 
1090  if ($got_locals)
1091  {
1092  $this->tpl->setCurrentBlock("local_role_section");
1093  $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
1094  $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
1095 
1096 
1097  // get local roles
1098  if ($this->object->getRefId() == USER_FOLDER_ID)
1099  {
1100  // The import function has been invoked from the user folder
1101  // object. In this case, we show only matching roles,
1102  // because the user folder object is considered the parent of all
1103  // local roles and may contains thousands of roles on large ILIAS
1104  // installations.
1105  $loc_roles = array();
1106  foreach($roles as $role_id => $role)
1107  {
1108  if ($role["type"] == "Local")
1109  {
1110  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
1111  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
1112  foreach ($matching_role_ids as $mid) {
1113  if (! in_array($mid, $loc_roles)) {
1114  $loc_roles[] = array('obj_id'=>$mid);
1115  }
1116  }
1117  }
1118  }
1119  } else {
1120  // The import function has been invoked from a locally
1121  // administrated category. In this case, we show all roles
1122  // contained in the subtree of the category.
1123  $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
1124  }
1125  $l_roles = array();
1126 
1127  // create a search array with .
1128  $l_roles_mailbox_searcharray = array();
1129  foreach ($loc_roles as $key => $loc_role)
1130  {
1131  // fetch context path of role
1132  $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"],true);
1133 
1134  // only process role folders that are not set to status "deleted"
1135  // and for which the user has write permissions.
1136  // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
1137  // (The ROLE_FOLDER_ID folder contains the global roles).
1138  if (!$rbacreview->isDeleted($rolf[0])
1139  && $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0]))
1140  && $rolf[0] != ROLE_FOLDER_ID
1141  )
1142  {
1143  // A local role is only displayed, if it is contained in the subtree of
1144  // the localy administrated category. If the import function has been
1145  // invoked from the user folder object, we show all local roles, because
1146  // the user folder object is considered the parent of all local roles.
1147  // Thus, if we start from the user folder object, we initialize the
1148  // isInSubtree variable with true. In all other cases it is initialized
1149  // with false, and only set to true if we find the object id of the
1150  // locally administrated category in the tree path to the local role.
1151  $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
1152 
1153  $path = "";
1154  if ($this->tree->isInTree($rolf[0]))
1155  {
1156  // Create path. Paths which have more than 4 segments
1157  // are truncated in the middle.
1158  $tmpPath = $this->tree->getPathFull($rolf[0]);
1159  for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++)
1160  {
1161  if ($i > 1)
1162  {
1163  $path = $path.' > ';
1164  }
1165  if ($i < 3 || $i > $n - 3)
1166  {
1167  $path = $path.$tmpPath[$i]['title'];
1168  }
1169  else if ($i == 3 || $i == $n - 3)
1170  {
1171  $path = $path.'...';
1172  }
1173 
1174  $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
1175  }
1176  }
1177  else
1178  {
1179  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$loc_role["obj_id"].")</b>";
1180  }
1181  $roleMailboxAddress = $rbacreview->getRoleMailboxAddress($loc_role['obj_id']);
1182  $l_roles[$loc_role['obj_id']] = $roleMailboxAddress.', '.$path;
1183  }
1184  } //foreach role
1185 
1186  $l_roles[""] = "";
1187  natcasesort($l_roles);
1188  $l_roles[""] = $this->lng->txt("usrimport_ignore_role");
1189  foreach($roles as $role_id => $role)
1190  {
1191  if ($role["type"] == "Local")
1192  {
1193  $this->tpl->setCurrentBlock("local_role");
1194  $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);
1195  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
1196  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
1197  $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : "";
1198  if ($this->object->getRefId() == USER_FOLDER_ID) {
1199  // There are too many roles in a large ILIAS installation
1200  // that's why whe show only a choice with the the option "ignore",
1201  // and the matching roles.
1202  $selectable_roles = array();
1203  $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role");
1204  foreach ($matching_role_ids as $id)
1205  {
1206  $selectable_roles[$id] = $l_roles[$id];
1207  }
1208  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $selectable_roles, false, true);
1209  } else {
1210  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $l_roles, false, true);
1211  }
1212  $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
1213  $this->tpl->parseCurrentBlock();
1214  }
1215  }
1216  }
1217  //
1218 
1219  $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
1220  $handlers = array(
1221  IL_IGNORE_ON_CONFLICT => "ignore_on_conflict",
1222  IL_UPDATE_ON_CONFLICT => "update_on_conflict"
1223  );
1224  $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\n','<br>',$this->lng->txt("usrimport_conflict_handling_info")));
1225  $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
1226  $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
1227 
1228  // new account mail
1229  $this->lng->loadLanguageModule("mail");
1230  include_once './Services/User/classes/class.ilObjUserFolder.php';
1231  $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
1232  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
1233  {
1234  $this->tpl->setCurrentBlock("inform_user");
1235  $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail"));
1236  if (true)
1237  {
1238  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
1239  }
1240  $this->tpl->setVariable("TXT_INFORM_USER_MAIL",
1241  $this->lng->txt("user_send_new_account_mail"));
1242  $this->tpl->parseCurrentBlock();
1243  }
1244  }
1245  else
1246  {
1247  $this->form->setValuesByPost();
1248  $tpl->setContent($this->form->getHtml());
1249  }
1250  }
1251 
1256  {
1257  global $rbacreview,$ilUser;
1258 
1259  // Blind out tabs for local user import
1260  if ($_GET["baseClass"] == 'ilRepositoryGUI')
1261  {
1262  $this->tabs_gui->clearTargets();
1263  }
1264 
1265  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1266  include_once './Services/User/classes/class.ilUserImportParser.php';
1267 
1268  global $rbacreview, $rbacsystem, $tree, $lng;
1269 
1270  switch ($_POST["conflict_handling_choice"])
1271  {
1272  case "update_on_conflict" :
1273  $rule = IL_UPDATE_ON_CONFLICT;
1274  break;
1275  case "ignore_on_conflict" :
1276  default :
1277  $rule = IL_IGNORE_ON_CONFLICT;
1278  break;
1279  }
1280  $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
1281  $importParser->setFolderId($this->getUserOwnerId());
1282  $import_dir = $this->getImportDir();
1283 
1284  // Catch hack attempts
1285  // We check here again, if the role folders are in the tree, and if the
1286  // user has permission on the roles.
1287  if ($_POST["role_assign"])
1288  {
1289  $global_roles = $rbacreview->getGlobalRoles();
1290  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1291  foreach ($_POST["role_assign"] as $role_id)
1292  {
1293  if ($role_id != "")
1294  {
1295  if (in_array($role_id, $global_roles))
1296  {
1297  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user))
1298  {
1299  if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$roles_of_user)
1300  || ($this->object->getRefId() != USER_FOLDER_ID
1301  && ! ilObjRole::_getAssignUsersStatus($role_id))
1302  )
1303  {
1304  ilUtil::delDir($import_dir);
1305  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
1306  $this->ilias->error_obj->MESSAGE);
1307  }
1308  }
1309  }
1310  else
1311  {
1312  $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
1313  if ($rbacreview->isDeleted($rolf[0])
1314  || ! $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0])))
1315  {
1316  ilUtil::delDir($import_dir);
1317  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
1318  $this->ilias->error_obj->MESSAGE);
1319  return;
1320  }
1321  }
1322  }
1323  }
1324  }
1325 
1326  $importParser->setRoleAssignment($_POST["role_assign"]);
1327  $importParser->startParsing();
1328 
1329  // purge user import directory
1330  ilUtil::delDir($import_dir);
1331 
1332  switch ($importParser->getErrorLevel())
1333  {
1334  case IL_IMPORT_SUCCESS :
1335  ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
1336  break;
1337  case IL_IMPORT_WARNING :
1338  ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings").$importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
1339  break;
1340  case IL_IMPORT_FAILURE :
1341  $this->ilias->raiseError(
1342  $this->lng->txt("user_import_failed")
1343  .$importParser->getProtocolAsHTML($lng->txt("import_failure_log")),
1344  $this->ilias->error_obj->MESSAGE
1345  );
1346  break;
1347  }
1348 
1349  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1350  {
1351  $this->ctrl->redirect($this, "view");
1352  //ilUtil::redirect($this->ctrl->getLinkTarget($this));
1353  }
1354  else
1355  {
1356  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
1357  }
1358  }
1359 
1360 
1362  {
1363  global $rbacsystem,$ilias;
1364 
1365  unset($_SESSION['applied_users']);
1366 
1367  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
1368  {
1369  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1370  }
1371 
1372  if(!count($app_users =& $ilias->account->getAppliedUsers()))
1373  {
1374  ilUtil::sendFailure($this->lng->txt('no_users_applied'));
1375 
1376  return false;
1377  }
1378 
1379  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_applied_users.html", "Services/User");
1380  $this->lng->loadLanguageModule('crs');
1381 
1382  $counter = 0;
1383  foreach($app_users as $usr_id)
1384  {
1385  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1386 
1387  $f_result[$counter][] = ilUtil::formCheckbox(0,"users[]",$usr_id);
1388  $f_result[$counter][] = $tmp_user->getLogin();
1389  $f_result[$counter][] = $tmp_user->getFirstname();
1390  $f_result[$counter][] = $tmp_user->getLastname();
1391 
1392  if($tmp_user->getTimeLimitUnlimited())
1393  {
1394  $f_result[$counter][] = "<b>".$this->lng->txt('crs_unlimited')."</b>";
1395  }
1396  else
1397  {
1398  $limit = "<b>".$this->lng->txt('crs_from').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitFrom()).'<br />';
1399  $limit .= "<b>".$this->lng->txt('crs_to').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitUntil());
1400 
1401  $f_result[$counter][] = $limit;
1402  }
1403  ++$counter;
1404  }
1405 
1406  $this->__showAppliedUsersTable($f_result);
1407 
1408  return true;
1409  }
1410 
1412  {
1413  global $rbacsystem;
1414 
1415  if(!$rbacsystem->checkAccess("write", $this->ref_id))
1416  {
1417  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1418  }
1419 
1420  $this->lng->loadLanguageModule('crs');
1421 
1422  $_POST['users'] = $_SESSION['applied_users'] = ($_SESSION['applied_users'] ? $_SESSION['applied_users'] : $_POST['users']);
1423 
1424  if(!isset($_SESSION['error_post_vars']))
1425  {
1426  ilUtil::sendInfo($this->lng->txt('time_limit_add_time_limit_for_selected'));
1427  }
1428 
1429  if(!count($_POST["users"]))
1430  {
1431  ilUtil::sendFailure($this->lng->txt("time_limit_no_users_selected"));
1432  $this->appliedUsersObject();
1433 
1434  return false;
1435  }
1436 
1437  $counter = 0;
1438  foreach($_POST['users'] as $usr_id)
1439  {
1440  if($counter)
1441  {
1442  $title .= ', ';
1443  }
1444  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1445  $title .= $tmp_user->getLogin();
1446  ++$counter;
1447  }
1448  if(strlen($title) > 79)
1449  {
1450  $title = substr($title,0,80);
1451  $title .= '...';
1452  }
1453 
1454 
1455  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_edit_applied_users.html", "Services/User");
1456  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1457 
1458  // LOAD SAVED DATA IN CASE OF ERROR
1459  $time_limit_unlimited = $_SESSION["error_post_vars"]["au"]["time_limit_unlimited"] ?
1460  1 : 0;
1461 
1462  $time_limit_start = $_SESSION["error_post_vars"]["au"]["time_limit_start"] ?
1463  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_start"]) :
1464  time();
1465  $time_limit_end = $_SESSION["error_post_vars"]["au"]["time_limit_end"] ?
1466  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_end"]) :
1467  time();
1468 
1469 
1470  // SET TEXT VARIABLES
1471  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_usr"));
1472  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_usr_b.png"));
1473  $this->tpl->setVariable("TITLE",$title);
1474  $this->tpl->setVariable("TXT_TIME_LIMIT",$this->lng->txt("time_limit"));
1475  $this->tpl->setVariable("TXT_TIME_LIMIT_START",$this->lng->txt("crs_start"));
1476  $this->tpl->setVariable("TXT_TIME_LIMIT_END",$this->lng->txt("crs_end"));
1477  $this->tpl->setVariable("CMD_SUBMIT","updateAppliedUsers");
1478  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
1479  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
1480 
1481 
1482 
1483  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_DAY",$this->__getDateSelect("day","au[time_limit_start][day]",
1484  date("d",$time_limit_start)));
1485  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MONTH",$this->__getDateSelect("month","au[time_limit_start][month]",
1486  date("m",$time_limit_start)));
1487  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_YEAR",$this->__getDateSelect("year","au[time_limit_start][year]",
1488  date("Y",$time_limit_start)));
1489  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_HOUR",$this->__getDateSelect("hour","au[time_limit_start][hour]",
1490  date("G",$time_limit_start)));
1491  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MINUTE",$this->__getDateSelect("minute","au[time_limit_start][minute]",
1492  date("i",$time_limit_start)));
1493  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_DAY",$this->__getDateSelect("day","au[time_limit_end][day]",
1494  date("d",$time_limit_end)));
1495  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MONTH",$this->__getDateSelect("month","au[time_limit_end][month]",
1496  date("m",$time_limit_end)));
1497  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_YEAR",$this->__getDateSelect("year","au[time_limit_end][year]",
1498  date("Y",$time_limit_end)));
1499  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_HOUR",$this->__getDateSelect("hour","au[time_limit_end][hour]",
1500  date("G",$time_limit_end)));
1501  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MINUTE",$this->__getDateSelect("minute","au[time_limit_end][minute]",
1502  date("i",$time_limit_end)));
1503  if($this->ilias->account->getTimeLimitUnlimited())
1504  {
1505  $this->tpl->setVariable("ROWSPAN",3);
1506  $this->tpl->setCurrentBlock("unlimited");
1507  $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED",$this->lng->txt("crs_unlimited"));
1508  $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"au[time_limit_unlimited]",1));
1509  $this->tpl->parseCurrentBlock();
1510  }
1511  else
1512  {
1513  $this->tpl->setVariable("ROWSPAN",2);
1514  }
1515  }
1516 
1518  {
1519  global $rbacsystem;
1520 
1521  if(!$rbacsystem->checkAccess("write", $this->ref_id))
1522  {
1523  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1524  }
1525 
1526  $start = $this->__toUnix($_POST['au']['time_limit_start']);
1527  $end = $this->__toUnix($_POST['au']['time_limit_end']);
1528 
1529  if(!$_POST['au']['time_limit_unlimited'])
1530  {
1531  if($start > $end)
1532  {
1533  $_SESSION['error_post_vars'] = $_POST;
1534  ilUtil::sendFailure($this->lng->txt('time_limit_not_valid'));
1535  $this->editAppliedUsersObject();
1536 
1537  return false;
1538  }
1539  }
1540  #if(!$this->ilias->account->getTimeLimitUnlimited())
1541  #{
1542  # if($start < $this->ilias->account->getTimeLimitFrom() or
1543  # $end > $this->ilias->account->getTimeLimitUntil())
1544  # {
1545  # $_SESSION['error_post_vars'] = $_POST;
1546  # ilUtil::sendInfo($this->lng->txt('time_limit_not_within_owners'));
1547  # $this->editAppliedUsersObject();
1548 
1549  # return false;
1550  # }
1551  #}
1552 
1553  foreach($_SESSION['applied_users'] as $usr_id)
1554  {
1555  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1556 
1557  $tmp_user->setTimeLimitUnlimited((int) $_POST['au']['time_limit_unlimited']);
1558  $tmp_user->setTimeLimitFrom($start);
1559  $tmp_user->setTimeLimitUntil($end);
1560  $tmp_user->setTimeLimitMessage(0);
1561  $tmp_user->update();
1562 
1563  unset($tmp_user);
1564  }
1565 
1566  unset($_SESSION['applied_users']);
1567  ilUtil::sendSuccess($this->lng->txt('time_limit_users_updated'));
1568  $this->appliedUsersObject();
1569 
1570  return true;
1571  }
1572 
1573  function __showAppliedUsersTable($a_result_set)
1574  {
1575  $tbl =& $this->__initTableGUI();
1576  $tpl =& $tbl->getTemplateObject();
1577 
1578  // SET FORMAACTION
1579  $tpl->setCurrentBlock("tbl_form_header");
1580 
1581  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1582  $tpl->parseCurrentBlock();
1583 
1584  $tpl->setCurrentBlock("tbl_action_btn");
1585  $tpl->setVariable("BTN_NAME",'editAppliedUsers');
1586  $tpl->setVariable("BTN_VALUE",$this->lng->txt('edit'));
1587  $tpl->parseCurrentBlock();
1588 
1589  $tpl->setCurrentBlock("tbl_action_row");
1590  $tpl->setVariable("COLUMN_COUNTS",5);
1591  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
1592  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
1593  $tpl->parseCurrentBlock();
1594 
1595 
1596 
1597  $tbl->setTitle($this->lng->txt("time_limit_applied_users"),"icon_usr_b.png",$this->lng->txt("users"));
1598  $tbl->setHeaderNames(array('',
1599  $this->lng->txt("login"),
1600  $this->lng->txt("firstname"),
1601  $this->lng->txt("lastname"),
1602  $this->lng->txt("time_limits")));
1603  $header_params = $this->ctrl->getParameterArray($this, "appliedUsers");
1604  $tbl->setHeaderVars(array("",
1605  "login",
1606  "firstname",
1607  "lastname",
1608  "time_limit"),
1609  array($header_params));
1610  $tbl->setColumnWidth(array("3%","19%","19%","19%","40%"));
1611 
1612 
1613  $this->__setTableGUIBasicData($tbl,$a_result_set);
1614  $tbl->render();
1615 
1616  $this->tpl->setVariable("APPLIED_USERS",$tbl->tpl->get());
1617 
1618  return true;
1619  }
1620 
1621  function &__initTableGUI()
1622  {
1623  include_once "./Services/Table/classes/class.ilTableGUI.php";
1624 
1625  return new ilTableGUI(0,false);
1626  }
1627 
1628  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
1629  {
1630  $offset = $_GET["offset"];
1631  $order = $_GET["sort_by"];
1632  $direction = $_GET["sort_order"];
1633 
1634  //$tbl->enable("hits");
1635  $tbl->setOrderColumn($order);
1636  $tbl->setOrderDirection($direction);
1637  $tbl->setOffset($offset);
1638  $tbl->setLimit($_GET["limit"]);
1639  $tbl->setMaxCount(count($result_set));
1640  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1641  $tbl->setData($result_set);
1642  }
1643 
1644  function __getDateSelect($a_type,$a_varname,$a_selected)
1645  {
1646  switch($a_type)
1647  {
1648  case "minute":
1649  for($i=0;$i<=60;$i++)
1650  {
1651  $days[$i] = $i < 10 ? "0".$i : $i;
1652  }
1653  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
1654 
1655  case "hour":
1656  for($i=0;$i<24;$i++)
1657  {
1658  $days[$i] = $i < 10 ? "0".$i : $i;
1659  }
1660  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
1661 
1662  case "day":
1663  for($i=1;$i<32;$i++)
1664  {
1665  $days[$i] = $i < 10 ? "0".$i : $i;
1666  }
1667  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
1668 
1669  case "month":
1670  for($i=1;$i<13;$i++)
1671  {
1672  $month[$i] = $i < 10 ? "0".$i : $i;
1673  }
1674  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
1675 
1676  case "year":
1677  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
1678  {
1679  $year[$i] = $i;
1680  }
1681  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
1682  }
1683  }
1684  function __toUnix($a_time_arr)
1685  {
1686  return mktime($a_time_arr["hour"],
1687  $a_time_arr["minute"],
1688  $a_time_arr["second"],
1689  $a_time_arr["month"],
1690  $a_time_arr["day"],
1691  $a_time_arr["year"]);
1692  }
1693 
1695  {
1697  $this->viewObject();
1698  }
1699 
1704  protected function generalSettingsObject()
1705  {
1706  global $ilSetting;
1707 
1708  $this->initFormGeneralSettings();
1709 
1710  include_once './Services/User/classes/class.ilUserAccountSettings.php';
1712 
1713  $show_blocking_time_in_days = $ilSetting->get('loginname_change_blocking_time') / 86400;
1714  $show_blocking_time_in_days = (float)$show_blocking_time_in_days;
1715 
1716  $this->form->setValuesByArray(
1717  array(
1718  'lua' => $aset->isLocalUserAdministrationEnabled(),
1719  'lrua' => $aset->isUserAccessRestricted(),
1720  'allow_change_loginname' => (bool)$ilSetting->get('allow_change_loginname'),
1721  'create_history_loginname' => (bool)$ilSetting->get('create_history_loginname'),
1722  'reuse_of_loginnames' => (bool)$ilSetting->get('reuse_of_loginnames'),
1723  'loginname_change_blocking_time' => (float)$show_blocking_time_in_days,
1724  'user_adm_alpha_nav' => (int)$ilSetting->get('user_adm_alpha_nav'),
1725  // 'user_ext_profiles' => (int)$ilSetting->get('user_ext_profiles')
1726  'user_reactivate_code' => (int)$ilSetting->get('user_reactivate_code'),
1727  'user_own_account' => (int)$ilSetting->get('user_delete_own_account'),
1728  'user_own_account_email' => $ilSetting->get('user_delete_own_account_email')
1729  )
1730  );
1731 
1732  $this->tpl->setContent($this->form->getHTML());
1733  }
1734 
1735 
1740  public function saveGeneralSettingsObject()
1741  {
1742  global $ilUser, $ilSetting;
1743 
1744  $this->initFormGeneralSettings();
1745  if($this->form->checkInput())
1746  {
1747  $valid = true;
1748 
1749  if(!strlen($this->form->getInput('loginname_change_blocking_time')))
1750  {
1751  $valid = false;
1752  $this->form->getItemByPostVar('loginname_change_blocking_time')
1753  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
1754  }
1755 
1756  if($valid)
1757  {
1758  include_once './Services/User/classes/class.ilUserAccountSettings.php';
1759  ilUserAccountSettings::getInstance()->enableLocalUserAdministration($this->form->getInput('lua'));
1760  ilUserAccountSettings::getInstance()->restrictUserAccess($this->form->getInput('lrua'));
1762 
1763  $ilSetting->set('allow_change_loginname', (int)$this->form->getInput('allow_change_loginname'));
1764  $ilSetting->set('create_history_loginname', (int)$this->form->getInput('create_history_loginname'));
1765  $ilSetting->set('reuse_of_loginnames', (int)$this->form->getInput('reuse_of_loginnames'));
1766  $save_blocking_time_in_seconds = (int)($this->form->getInput('loginname_change_blocking_time') * 86400);
1767  $ilSetting->set('loginname_change_blocking_time', (int)$save_blocking_time_in_seconds);
1768  $ilSetting->set('user_adm_alpha_nav', (int)$this->form->getInput('user_adm_alpha_nav'));
1769  // $ilSetting->set('user_ext_profiles', (int)$this->form->getInput('user_ext_profiles'));
1770  $ilSetting->set('user_portfolios', (int)$this->form->getInput('user_portfolios'));
1771  $ilSetting->set('user_reactivate_code', (int)$this->form->getInput('user_reactivate_code'));
1772 
1773  $ilSetting->set('user_delete_own_account', (int)$this->form->getInput('user_own_account'));
1774  $ilSetting->set('user_delete_own_account_email', $this->form->getInput('user_own_account_email'));
1775 
1776 
1777  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
1778  }
1779  else
1780  {
1781  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
1782  }
1783  }
1784  else
1785  {
1786  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
1787  }
1788  $this->form->setValuesByPost();
1789  $this->tpl->setContent($this->form->getHTML());
1790  }
1791 
1792 
1797  protected function initFormGeneralSettings()
1798  {
1799  $this->setSubTabs('settings');
1800  $this->tabs_gui->setTabActive('settings');
1801  $this->tabs_gui->setSubTabActive('general_settings');
1802 
1803  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1804  $this->form = new ilPropertyFormGUI();
1805  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
1806 
1807  $this->form->setTitle($this->lng->txt('general_settings'));
1808 
1809  $lua = new ilCheckboxInputGUI($this->lng->txt('enable_local_user_administration'),'lua');
1810  $lua->setInfo($this->lng->txt('enable_local_user_administration_info'));
1811  $lua->setValue(1);
1812  $this->form->addItem($lua);
1813 
1814  $lrua = new ilCheckboxInputGUI($this->lng->txt('restrict_user_access'),'lrua');
1815  $lrua->setInfo($this->lng->txt('restrict_user_access_info'));
1816  $lrua->setValue(1);
1817  $this->form->addItem($lrua);
1818 
1819  // enable alphabetical navigation in user administration
1820  $alph = new ilCheckboxInputGUI($this->lng->txt('user_adm_enable_alpha_nav'), 'user_adm_alpha_nav');
1821  //$alph->setInfo($this->lng->txt('restrict_user_access_info'));
1822  $alph->setValue(1);
1823  $this->form->addItem($alph);
1824 
1825  /* extended user profiles
1826  $cb = new ilCheckboxInputGUI($this->lng->txt("user_ext_profiles"), "user_ext_profiles");
1827  $cb->setInfo($this->lng->txt('user_ext_profiles_desc'));
1828  $this->form->addItem($cb);
1829  */
1830 
1831  // account codes
1832  $code = new ilCheckboxInputGUI($this->lng->txt("user_account_code_setting"), "user_reactivate_code");
1833  $code->setInfo($this->lng->txt('user_account_code_setting_info'));
1834  $this->form->addItem($code);
1835 
1836  // delete own account
1837  $own = new ilCheckboxInputGUI($this->lng->txt("user_allow_delete_own_account"), "user_own_account");
1838  $this->form->addItem($own);
1839  $own_email = new ilEMailInputGUI($this->lng->txt("user_delete_own_account_notification_email"), "user_own_account_email");
1840  $own->addSubItem($own_email);
1841 
1842  $log = new ilFormSectionHeaderGUI();
1843  $log->setTitle($this->lng->txt('loginname_settings'));
1844  $this->form->addItem($log);
1845 
1846  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
1847  $chbChangeLogin->setValue(1);
1848  $this->form->addItem($chbChangeLogin);
1849  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
1850  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
1851  $chbCreateHistory->setValue(1);
1852 
1853  $chbChangeLogin->addSubItem($chbCreateHistory);
1854  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'reuse_of_loginnames');
1855  $chbReuseLoginnames->setValue(1);
1856  $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
1857 
1858  $chbChangeLogin->addSubItem($chbReuseLoginnames);
1859  $chbChangeBlockingTime = new ilNumberInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
1860  $chbChangeBlockingTime->allowDecimals(true);
1861  $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
1862  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
1863  $chbChangeBlockingTime->setSize(10);
1864  $chbChangeBlockingTime->setMaxLength(10);
1865  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
1866 
1867  $this->form->addCommandButton('saveGeneralSettings', $this->lng->txt('save'));
1868  }
1869 
1870 
1871 
1872 
1883  function settingsObject()
1884  {
1885  global $tpl, $lng, $ilias, $ilTabs;
1886 
1887  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
1888  $lng->loadLanguageModule("administration");
1889  $lng->loadLanguageModule("mail");
1890  $this->setSubTabs('settings');
1891  $ilTabs->activateTab('settings');
1892  $ilTabs->activateSubTab('standard_fields');
1893 
1894  include_once("./Services/User/classes/class.ilUserFieldSettingsTableGUI.php");
1895  $tab = new ilUserFieldSettingsTableGUI($this, "settings");
1896  if($this->confirm_change) $tab->setConfirmChange();
1897  $tpl->setContent($tab->getHTML());
1898  }
1899 
1901  {
1902  $this->saveGlobalUserSettingsObject("save");
1903  }
1904 
1905  function saveGlobalUserSettingsObject($action = "")
1906  {
1907  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
1908  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
1909 
1910  global $ilias,$ilSetting;
1911 
1912  // see ilUserFieldSettingsTableGUI
1913  include_once("./Services/User/classes/class.ilUserProfile.php");
1914  $up = new ilUserProfile();
1915  $up->skipField("username");
1916  $field_properties = $up->getStandardFields();
1917  $profile_fields = array_keys($field_properties);
1918 
1919  $valid = true;
1920  foreach ($profile_fields as $field)
1921  {
1922  if ( $_POST["chb"]["required_".$field] &&
1923  !(int)$_POST['chb']['visib_reg_' . $field]
1924  ){
1925  $valid = false;
1926  break;
1927  }
1928  }
1929 
1930  if(!$valid)
1931  {
1932  global $lng;
1933  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
1934  $this->confirm_change = 1;
1935  $this->settingsObject();
1936  return;
1937  }
1938 
1939  // For the following fields, the required state can not be changed
1940  $fixed_required_fields = array(
1941  "firstname" => 1,
1942  "lastname" => 1,
1943  "upload" => 0,
1944  "password" => 0,
1945  "language" => 0,
1946  "skin_style" => 0,
1947  "hits_per_page" => 0,
1948  "show_users_online" => 0,
1949  "hide_own_online_status" => 0
1950  );
1951 
1952  // check if a course export state of any field has been added
1953  $privacy = ilPrivacySettings::_getInstance();
1954  if ($privacy->enabledCourseExport() == true &&
1955  $privacy->courseConfirmationRequired() == true &&
1956  $action != "save")
1957  {
1958  foreach ($profile_fields as $field)
1959  {
1960  if (! $ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1")
1961  {
1962  #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
1963  #$this->confirm_change = 1;
1964  #$this->settingsObject();
1965  #return;
1966  }
1967  }
1968  }
1969  // Reset user confirmation
1970  if($action == 'save')
1971  {
1972  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
1974  }
1975 
1976  foreach ($profile_fields as $field)
1977  {
1978  // Enable disable searchable
1980  {
1981  ilUserSearchOptions::_saveStatus($field,(bool) $_POST['chb']['searchable_'.$field]);
1982  }
1983 
1984  if (!$_POST["chb"]["visible_".$field] && !$field_properties[$field]["visible_hide"])
1985  {
1986  $ilias->setSetting("usr_settings_hide_".$field, "1");
1987  }
1988  else
1989  {
1990  $ilias->deleteSetting("usr_settings_hide_".$field);
1991  }
1992 
1993  if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"])
1994  {
1995  $ilias->setSetting("usr_settings_disable_".$field, "1");
1996  }
1997  else
1998  {
1999  $ilias->deleteSetting("usr_settings_disable_".$field);
2000  }
2001 
2002  // registration visible
2003  if ((int)$_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"])
2004  {
2005  $ilSetting->set('usr_settings_visib_reg_'.$field, '1');
2006  }
2007  else
2008  {
2009  $ilSetting->set('usr_settings_visib_reg_'.$field, '0');
2010  }
2011 
2012  if ((int)$_POST['chb']['visib_lua_' . $field])
2013  {
2014 
2015  $ilSetting->set('usr_settings_visib_lua_'.$field, '1');
2016  }
2017  else
2018  {
2019  $ilSetting->set('usr_settings_visib_lua_'.$field, '0');
2020  }
2021 
2022  if ((int)$_POST['chb']['changeable_lua_' . $field])
2023  {
2024 
2025  $ilSetting->set('usr_settings_changeable_lua_'.$field, '1');
2026  }
2027  else
2028  {
2029  $ilSetting->set('usr_settings_changeable_lua_'.$field, '0');
2030  }
2031 
2032  if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"])
2033  {
2034  $ilias->setSetting("usr_settings_export_".$field, "1");
2035  }
2036  else
2037  {
2038  $ilias->deleteSetting("usr_settings_export_".$field);
2039  }
2040 
2041  // Course export/visibility
2042  if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"])
2043  {
2044  $ilias->setSetting("usr_settings_course_export_".$field, "1");
2045  }
2046  else
2047  {
2048  $ilias->deleteSetting("usr_settings_course_export_".$field);
2049  }
2050 
2051  // Group export/visibility
2052  if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"])
2053  {
2054  $ilias->setSetting("usr_settings_group_export_".$field, "1");
2055  }
2056  else
2057  {
2058  $ilias->deleteSetting("usr_settings_group_export_".$field);
2059  }
2060 
2061  $is_fixed = array_key_exists($field, $fixed_required_fields);
2062  if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed && $_POST["chb"]["required_".$field])
2063  {
2064  $ilias->setSetting("require_".$field, "1");
2065  }
2066  else
2067  {
2068  $ilias->deleteSetting("require_" . $field);
2069  }
2070  }
2071 
2072  if ($_POST["select"]["default_hits_per_page"])
2073  {
2074  $ilias->setSetting("hits_per_page",$_POST["select"]["default_hits_per_page"]);
2075  }
2076 
2077  if ($_POST["select"]["default_show_users_online"])
2078  {
2079  $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
2080  }
2081 
2082  if ($_POST["chb"]["export_preferences"])
2083  {
2084  $ilias->setSetting("usr_settings_export_preferences",$_POST["chb"]["export_preferences"]);
2085  } else {
2086  $ilias->deleteSetting("usr_settings_export_preferences");
2087  }
2088 
2089  $ilias->setSetting('mail_incoming_mail', (int)$_POST['select']['default_mail_incoming_mail']);
2090 
2091  ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
2092  $this->settingsObject();
2093  }
2094 
2095 
2100  {
2101  $action[-1] = $this->lng->txt('all_users');
2102  $action[1] = $this->lng->txt('usr_active_only');
2103  $action[0] = $this->lng->txt('usr_inactive_only');
2104  $action[2] = $this->lng->txt('usr_limited_access_only');
2105  $action[3] = $this->lng->txt('usr_without_courses');
2106  $action[4] = $this->lng->txt('usr_filter_lastlogin');
2107  $action[5] = $this->lng->txt("usr_filter_coursemember");
2108  $action[6] = $this->lng->txt("usr_filter_groupmember");
2109  $action[7] = $this->lng->txt("usr_filter_role");
2110 
2111  return ilUtil::formSelect($_SESSION['user_filter'],"user_filter",$action,false,true);
2112  }
2113 
2121  {
2122  if(!isset($_POST["file"]))
2123  {
2124  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2125  }
2126 
2127  if (count($_POST["file"]) > 1)
2128  {
2129  $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2130  }
2131 
2132  $file = basename($_POST["file"][0]);
2133 
2134  $export_dir = $this->object->getExportDirectory();
2135  ilUtil::deliverFile($export_dir."/".$file, $file);
2136  }
2137 
2142  {
2143  if(!isset($_POST["file"]))
2144  {
2145  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2146  }
2147 
2148  // display confirmation message
2149  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2150  $cgui = new ilConfirmationGUI();
2151  $cgui->setFormAction($this->ctrl->getFormAction($this));
2152  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
2153  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteExportFile");
2154  $cgui->setConfirm($this->lng->txt("confirm"), "deleteExportFile");
2155 
2156  // BEGIN TABLE DATA
2157  $counter = 0;
2158  foreach($_POST["file"] as $file)
2159  {
2160  $caption = ilUtil::getImageTagByType("usrf", $this->tpl->tplPath).
2161  " ".$file;
2162  $cgui->addItem("file[]", $file, $caption);
2163  }
2164 
2165  $this->tpl->setContent($cgui->getHTML());
2166  }
2167 
2168 
2173  {
2174  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2175  }
2176 
2177 
2182  {
2183  $export_dir = $this->object->getExportDirectory();
2184  foreach($_POST["file"] as $file)
2185  {
2186  $file = basename($file);
2187 
2188  $exp_file = $export_dir."/".$file;
2189  if (@is_file($exp_file))
2190  {
2191  unlink($exp_file);
2192  }
2193  }
2194  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2195  }
2196 
2207  function exportObject()
2208  {
2209  global $ilias, $ilCtrl;
2210 
2211  if ($_POST["cmd"]["export"])
2212  {
2213  $this->object->buildExportFile($_POST["export_type"]);
2214  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2215  exit;
2216  }
2217 
2218  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_export.html','Services/User');
2219 
2220  $export_types = array(
2221  "userfolder_export_excel_x86",
2222  "userfolder_export_csv",
2223  "userfolder_export_xml"
2224  );
2225 
2226  // create table
2227  include_once("./Services/Table/classes/class.ilTableGUI.php");
2228  $tbl = new ilTableGUI();
2229 
2230  // load files templates
2231  $this->tpl->addBlockfile("EXPORT_FILES", "export_files", "tpl.table.html");
2232 
2233  // load template for table content data
2234  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_export_file_row.html", "Services/User");
2235 
2236  $num = 0;
2237 
2238  $tbl->setTitle($this->lng->txt("userfolder_export_files"));
2239 
2240  $tbl->setHeaderNames(array("", $this->lng->txt("userfolder_export_file"),
2241  $this->lng->txt("userfolder_export_file_size"), $this->lng->txt("date") ));
2242  $tbl->setHeaderVars(array(), $ilCtrl->getParameterArray($this, "export"));
2243 
2244  $tbl->enabled["sort"] = false;
2245  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
2246 
2247  // control
2248  $tbl->setOrderColumn($_GET["sort_by"]);
2249  $tbl->setOrderDirection($_GET["sort_order"]);
2250  $tbl->setLimit($_GET["limit"]);
2251  $tbl->setOffset($_GET["offset"]);
2252  $tbl->setMaxCount($this->maxcount); // ???
2253 
2254 
2255  $this->tpl->setVariable("COLUMN_COUNTS", 4);
2256 
2257  // delete button
2258  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
2259  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2260  $this->tpl->setCurrentBlock("tbl_action_btn");
2261  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
2262  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
2263  $this->tpl->parseCurrentBlock();
2264 
2265  $this->tpl->setCurrentBlock("tbl_action_btn");
2266  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
2267  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
2268  $this->tpl->parseCurrentBlock();
2269 
2270  // footer
2271  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2272  //$tbl->disable("footer");
2273 
2274  $export_files = $this->object->getExportFiles();
2275 
2276  $tbl->setMaxCount(count($export_files));
2277  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
2278 
2279  $tbl->render();
2280 
2281  if(count($export_files) > 0)
2282  {
2283  $i=0;
2284  foreach($export_files as $exp_file)
2285  {
2286  $this->tpl->setCurrentBlock("tbl_content");
2287  $this->tpl->setVariable("TXT_FILENAME", $exp_file["filename"]);
2288 
2289  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
2290  $this->tpl->setVariable("CSS_ROW", $css_row);
2291 
2292  $this->tpl->setVariable("TXT_SIZE", $exp_file["filesize"]);
2293  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["filename"]);
2294 
2295  $file_arr = explode("__", $exp_file["filename"]);
2296  $this->tpl->setVariable('TXT_DATE',ilDatePresentation::formatDate(new ilDateTime($file_arr[0],IL_CAL_UNIX)));
2297 
2298  $this->tpl->parseCurrentBlock();
2299  }
2300 
2301  $this->tpl->setCurrentBlock("selectall");
2302  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2303  $this->tpl->setVariable("CSS_ROW", $css_row);
2304  $this->tpl->parseCurrentBlock();
2305  } //if is_array
2306  /*
2307  else
2308 
2309  {
2310  $this->tpl->setCurrentBlock("notfound");
2311  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
2312  $this->tpl->setVariable("NUM_COLS", 3);
2313  $this->tpl->parseCurrentBlock();
2314  }
2315  */
2316 
2317  $this->tpl->parseCurrentBlock();
2318 
2319 
2320  foreach ($export_types as $export_type)
2321  {
2322  $this->tpl->setCurrentBlock("option");
2323  $this->tpl->setVariable("OPTION_VALUE", $export_type);
2324  $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt($export_type));
2325  $this->tpl->parseCurrentBlock();
2326  }
2327 
2328  $this->tpl->setVariable("EXPORT_BUTTON", $this->lng->txt("create_export_file"));
2329  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2330  }
2331 
2332  protected function initNewAccountMailForm()
2333  {
2334  global $lng, $ilCtrl;
2335 
2336  $lng->loadLanguageModule("meta");
2337  $lng->loadLanguageModule("mail");
2338 
2339  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2340  $form = new ilPropertyFormGUI();
2341  $form->setFormAction($ilCtrl->getFormAction($this));
2342 
2343  $form->setTitleIcon(ilUtil::getImagePath("icon_mail.png"));
2344  $form->setTitle($lng->txt("user_new_account_mail"));
2345  $form->setDescription($lng->txt("user_new_account_mail_desc"));
2346 
2347  $langs = $lng->getInstalledLanguages();
2348  foreach($langs as $lang_key)
2349  {
2350  $amail = $this->object->_lookupNewAccountMail($lang_key);
2351 
2352  $title = $lng->txt("meta_l_".$lang_key);
2353  if ($lang_key == $lng->getDefaultLanguage())
2354  {
2355  $title .= " (".$lng->txt("default").")";
2356  }
2357 
2358  $header = new ilFormSectionHeaderGUI();
2359  $header->setTitle($title);
2360  $form->addItem($header);
2361 
2362  $subj = new ilTextInputGUI($lng->txt("subject"), "subject_".$lang_key);
2363  // $subj->setRequired(true);
2364  $subj->setValue($amail["subject"]);
2365  $form->addItem($subj);
2366 
2367  $salg = new ilTextInputGUI($lng->txt("mail_salutation_general"), "sal_g_".$lang_key);
2368  // $salg->setRequired(true);
2369  $salg->setValue($amail["sal_g"]);
2370  $form->addItem($salg);
2371 
2372  $salf = new ilTextInputGUI($lng->txt("mail_salutation_female"), "sal_f_".$lang_key);
2373  // $salf->setRequired(true);
2374  $salf->setValue($amail["sal_f"]);
2375  $form->addItem($salf);
2376 
2377  $salm = new ilTextInputGUI($lng->txt("mail_salutation_male"), "sal_m_".$lang_key);
2378  // $salm->setRequired(true);
2379  $salm->setValue($amail["sal_m"]);
2380  $form->addItem($salm);
2381 
2382  $body = new ilTextAreaInputGUI($lng->txt("message_content"), "body_".$lang_key);
2383  // $body->setRequired(true);
2384  $body->setValue($amail["body"]);
2385  $body->setRows(10);
2386  $body->setCols(100);
2387  $form->addItem($body);
2388 
2389  $att = new ilFileInputGUI($lng->txt("attachment"), "att_".$lang_key);
2390  $att->setAllowDeletion(true);
2391  if($amail["att_file"])
2392  {
2393  $att->setValue($amail["att_file"]);
2394  }
2395  $form->addItem($att);
2396  }
2397 
2398  $form->addCommandButton("saveNewAccountMail", $lng->txt("save"));
2399  $form->addCommandButton("cancelNewAccountMail", $lng->txt("cancel"));
2400 
2401  return $form;
2402  }
2403 
2408  {
2409  global $lng;
2410 
2411  $this->setSubTabs('settings');
2412  $this->tabs_gui->setTabActive('settings');
2413  $this->tabs_gui->setSubTabActive('user_new_account_mail');
2414 
2415  $form = $this->initNewAccountMailForm();
2416 
2417  $ftpl = new ilTemplate('tpl.usrf_new_account_mail.html', true, true, 'Services/User');
2418  $ftpl->setVariable("FORM", $form->getHTML());
2419  unset($form);
2420 
2421  // placeholder help text
2422  $ftpl->setVariable("TXT_USE_PLACEHOLDERS", $lng->txt("mail_nacc_use_placeholder"));
2423  $ftpl->setVariable("TXT_MAIL_SALUTATION", $lng->txt("mail_nacc_salutation"));
2424  $ftpl->setVariable("TXT_FIRST_NAME", $lng->txt("firstname"));
2425  $ftpl->setVariable("TXT_LAST_NAME", $lng->txt("lastname"));
2426  $ftpl->setVariable("TXT_EMAIL", $lng->txt("email"));
2427  $ftpl->setVariable("TXT_LOGIN", $lng->txt("mail_nacc_login"));
2428  $ftpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
2429  $ftpl->setVariable("TXT_PASSWORD_BLOCK", $lng->txt("mail_nacc_pw_block"));
2430  $ftpl->setVariable("TXT_NOPASSWORD_BLOCK", $lng->txt("mail_nacc_no_pw_block"));
2431  $ftpl->setVariable("TXT_ADMIN_MAIL", $lng->txt("mail_nacc_admin_mail"));
2432  $ftpl->setVariable("TXT_ILIAS_URL", $lng->txt("mail_nacc_ilias_url"));
2433  $ftpl->setVariable("TXT_CLIENT_NAME", $lng->txt("mail_nacc_client_name"));
2434  $ftpl->setVariable("TXT_TARGET", $lng->txt("mail_nacc_target"));
2435  $ftpl->setVariable("TXT_TARGET_TITLE", $lng->txt("mail_nacc_target_title"));
2436  $ftpl->setVariable("TXT_TARGET_TYPE", $lng->txt("mail_nacc_target_type"));
2437  $ftpl->setVariable("TXT_TARGET_BLOCK", $lng->txt("mail_nacc_target_block"));
2438 
2439  $this->tpl->setContent($ftpl->get());
2440  }
2441 
2443  {
2444  $this->ctrl->redirect($this, "settings");
2445  }
2446 
2448  {
2449  global $lng;
2450 
2451  $langs = $lng->getInstalledLanguages();
2452  foreach($langs as $lang_key)
2453  {
2454  $this->object->_writeNewAccountMail($lang_key,
2455  ilUtil::stripSlashes($_POST["subject_".$lang_key]),
2456  ilUtil::stripSlashes($_POST["sal_g_".$lang_key]),
2457  ilUtil::stripSlashes($_POST["sal_f_".$lang_key]),
2458  ilUtil::stripSlashes($_POST["sal_m_".$lang_key]),
2459  ilUtil::stripSlashes($_POST["body_".$lang_key]));
2460 
2461  if($_FILES["att_".$lang_key]["tmp_name"])
2462  {
2463  $this->object->_updateAccountMailAttachment($lang_key,
2464  $_FILES["att_".$lang_key]["tmp_name"],
2465  $_FILES["att_".$lang_key]["name"]);
2466  }
2467 
2468  if ($_POST["att_".$lang_key."_delete"])
2469  {
2470  $this->object->_deleteAccountMailAttachment($lang_key);
2471  }
2472  }
2473 
2474  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2475  $this->ctrl->redirect($this, "newAccountMail");
2476  }
2477 
2478  function getAdminTabs(&$tabs_gui)
2479  {
2480  $this->getTabs($tabs_gui);
2481  }
2482 
2488  function getTabs(&$tabs_gui)
2489  {
2490  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
2491 
2492  global $rbacsystem;
2493 
2494  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
2495  {
2496  $tabs_gui->addTarget("obj_usrf",
2497  $this->ctrl->getLinkTarget($this, "view"), array("view","delete","resetFilter", "userAction", ""), "", "");
2498 
2499  $tabs_gui->addTarget(
2500  "search_user_extended",
2501  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI',''),
2502  array(),
2503  "ilrepositorysearchgui",
2504  ""
2505  );
2506  }
2507 
2508  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
2509  {
2510  $tabs_gui->addTarget("settings",
2511  $this->ctrl->getLinkTarget($this, "generalSettings"),array('settings','generalSettings','listUserDefinedField','newAccountMail'));
2512 
2513  $tabs_gui->addTarget("export",
2514  $this->ctrl->getLinkTarget($this, "export"), "export", "", "");
2515 
2518  {
2519  $tabs_gui->addTarget("learning_progress",
2520  $this->ctrl->getLinkTarget($this, "learningProgress"), "learningProgress", "", "");
2521  }
2522  }
2523 
2524  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2525  {
2526  $tabs_gui->addTarget("perm_settings",
2527  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
2528  array("perm","info","owner"), 'ilpermissiongui');
2529  }
2530  }
2531 
2532 
2536  function setSubTabs($a_tab)
2537  {
2538  global $rbacsystem,$ilUser;
2539 
2540  switch($a_tab)
2541  {
2542  case "settings":
2543  $this->tabs_gui->addSubTabTarget(
2544  'general_settings',
2545  $this->ctrl->getLinkTarget($this, 'generalSettings'), 'generalSettings', get_class($this));
2546  $this->tabs_gui->addSubTabTarget("standard_fields",
2547  $this->ctrl->getLinkTarget($this,'settings'),
2548  array("settings", "saveGlobalUserSettings"), get_class($this));
2549  $this->tabs_gui->addSubTabTarget("user_defined_fields",
2550  $this->ctrl->getLinkTargetByClass("ilcustomuserfieldsgui", "listUserDefinedFields"),
2551  "listUserDefinedFields",get_class($this));
2552  $this->tabs_gui->addSubTabTarget("user_new_account_mail",
2553  $this->ctrl->getLinkTarget($this,'newAccountMail'),
2554  "newAccountMail",get_class($this));
2555  $this->tabs_gui->addSubTab("account_codes", $this->lng->txt("user_account_codes"),
2556  $this->ctrl->getLinkTargetByClass("ilaccountcodesgui"));
2557  break;
2558  }
2559  }
2560 
2562  {
2563  global $ilSetting;
2564 
2565  $show_blocking_time_in_days = (int)$ilSetting->get('loginname_change_blocking_time') / 86400;
2566 
2567  $this->initLoginSettingsForm();
2568  $this->loginSettingsForm->setValuesByArray(array(
2569  'allow_change_loginname' => (bool)$ilSetting->get('allow_change_loginname'),
2570  'create_history_loginname' => (bool)$ilSetting->get('create_history_loginname'),
2571  'reuse_of_loginnames' => (bool)$ilSetting->get('reuse_of_loginnames'),
2572  'loginname_change_blocking_time' => (float)$show_blocking_time_in_days
2573  ));
2574 
2575  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
2576  }
2577 
2578  private function initLoginSettingsForm()
2579  {
2580  $this->setSubTabs('settings');
2581  $this->tabs_gui->setTabActive('settings');
2582  $this->tabs_gui->setSubTabActive('loginname_settings');
2583 
2584  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2585  $this->loginSettingsForm = new ilPropertyFormGUI;
2586  $this->loginSettingsForm->setFormAction($this->ctrl->getFormAction($this, 'saveLoginnameSettings'));
2587  $this->loginSettingsForm->setTitle($this->lng->txt('loginname_settings'));
2588 
2589  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
2590  $chbChangeLogin->setValue(1);
2591  $this->loginSettingsForm->addItem($chbChangeLogin);
2592  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
2593  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
2594  $chbCreateHistory->setValue(1);
2595  $chbChangeLogin->addSubItem($chbCreateHistory);
2596  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'reuse_of_loginnames');
2597  $chbReuseLoginnames->setValue(1);
2598  $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
2599  $chbChangeLogin->addSubItem($chbReuseLoginnames);
2600  $chbChangeBlockingTime = new ilNumberInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
2601  $chbChangeBlockingTime->allowDecimals(true);
2602  $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
2603  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
2604  $chbChangeBlockingTime->setSize(10);
2605  $chbChangeBlockingTime->setMaxLength(10);
2606  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
2607 
2608  $this->loginSettingsForm->addCommandButton('saveLoginnameSettings', $this->lng->txt('save'));
2609  }
2610 
2612  {
2613  global $ilUser, $ilSetting;
2614 
2615  $this->initLoginSettingsForm();
2616  if($this->loginSettingsForm->checkInput())
2617  {
2618  $valid = true;
2619 
2620  if(!strlen($this->loginSettingsForm->getInput('loginname_change_blocking_time')))
2621  {
2622  $valid = false;
2623  $this->loginSettingsForm->getItemByPostVar('loginname_change_blocking_time')
2624  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
2625  }
2626 
2627  if($valid)
2628  {
2629  $save_blocking_time_in_seconds = (int)$this->loginSettingsForm->getInput('loginname_change_blocking_time') * 86400;
2630 
2631  $ilSetting->set('allow_change_loginname', (int)$this->loginSettingsForm->getInput('allow_change_loginname'));
2632  $ilSetting->set('create_history_loginname', (int)$this->loginSettingsForm->getInput('create_history_loginname'));
2633  $ilSetting->set('reuse_of_loginnames', (int)$this->loginSettingsForm->getInput('reuse_of_loginnames'));
2634  $ilSetting->set('loginname_change_blocking_time', (int)$save_blocking_time_in_seconds);
2635 
2636  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
2637  }
2638  else
2639  {
2640  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2641  }
2642  }
2643  else
2644  {
2645  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2646  }
2647  $this->loginSettingsForm->setValuesByPost();
2648 
2649  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
2650  }
2651 
2655  function _goto($a_user)
2656  {
2657  global $ilAccess, $ilErr, $lng;
2658 
2659  $a_target = USER_FOLDER_ID;
2660 
2661  if ($ilAccess->checkAccess("read", "", $a_target))
2662  {
2663  ilUtil::redirect("ilias.php?baseClass=ilAdministrationGUI&ref_id=".$a_target."&jmpToUser=".$a_user);
2664  exit;
2665  }
2666  else
2667  {
2668  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2669  {
2670  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2671  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2673  }
2674  }
2675  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2676  }
2677 
2681  function jumpToUserObject()
2682  {
2683  global $ilCtrl;
2684 
2685  if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int)$_GET["jmpToUser"]) == "usr")
2686  {
2687  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", (int) $_GET["jmpToUser"]);
2688  $ilCtrl->redirectByClass("ilobjusergui", "view");
2689  }
2690  }
2691 
2695  public function searchResultHandler($a_usr_ids,$a_cmd)
2696  {
2697  if(!count((array) $a_usr_ids))
2698  {
2699  ilUtil::sendFailure($this->lng->txt('select_one'));
2700  return false;
2701  }
2702 
2703  $_POST['id'] = $a_usr_ids;
2704 
2705  // no real confirmation here
2706  if(stristr($a_cmd, "export"))
2707  {
2708  $cmd = $a_cmd."Object";
2709  return $this->$cmd();
2710  }
2711 
2712  $_POST['selectedAction'] = $a_cmd;
2713  return $this->showActionConfirmation($a_cmd, true);
2714  }
2715 
2716  public function getUserMultiCommands($a_search_form = false)
2717  {
2718  global $rbacsystem;
2719 
2720  // see searchResultHandler()
2721  if($a_search_form)
2722  {
2723  $cmds = array(
2724  'activate' => $this->lng->txt('activate'),
2725  'deactivate' => $this->lng->txt('deactivate'),
2726  'accessRestrict' => $this->lng->txt('accessRestrict'),
2727  'accessFree' => $this->lng->txt('accessFree')
2728  );
2729 
2730  if ($rbacsystem->checkAccess('delete', $this->object->getRefId()))
2731  {
2732  $cmds["delete"] = $this->lng->txt("delete");
2733  }
2734  }
2735  // show confirmation
2736  else
2737  {
2738  $cmds = array(
2739  'activateUsers' => $this->lng->txt('activate'),
2740  'deactivateUsers' => $this->lng->txt('deactivate'),
2741  'restrictAccess' => $this->lng->txt('accessRestrict'),
2742  'freeAccess' => $this->lng->txt('accessFree')
2743  );
2744 
2745  if ($rbacsystem->checkAccess('delete', $this->object->getRefId()))
2746  {
2747  $cmds["deleteUsers"] = $this->lng->txt("delete");
2748  }
2749  }
2750 
2751  // no confirmation needed
2752  $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
2753  foreach ($export_types as $type)
2754  {
2755  $cmd = explode("_", $type);
2756  $cmd = array_pop($cmd);
2757  $cmds['usrExport'.ucfirst($cmd)] = $this->lng->txt('export').' - '.
2758  $this->lng->txt($type);
2759  }
2760 
2761  return $cmds;
2762  }
2763 
2765  {
2766  $user_ids = $this->getActionUserIds();
2767  if(!$user_ids)
2768  {
2769  ilUtil::sendFailure($this->lng->txt('select_one'));
2770  return $this->viewObject();
2771  }
2772  $this->object->buildExportFile("userfolder_export_excel_x86", $user_ids);
2773  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2774  }
2775 
2777  {
2778  $user_ids = $this->getActionUserIds();
2779  if(!$user_ids)
2780  {
2781  ilUtil::sendFailure($this->lng->txt('select_one'));
2782  return $this->viewObject();
2783  }
2784  $this->object->buildExportFile("userfolder_export_csv", $user_ids);
2785  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2786  }
2787 
2789  {
2790  $user_ids = $this->getActionUserIds();
2791  if(!$user_ids)
2792  {
2793  ilUtil::sendFailure($this->lng->txt('select_one'));
2794  return $this->viewObject();
2795  }
2796  $this->object->buildExportFile("userfolder_export_xml", $user_ids);
2797  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2798  }
2799 } // END class.ilObjUserFolderGUI
2800 ?>