ILIAS  Release_4_2_x_branch Revision 61807
 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 
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 'iladminusersearchgui':
77  include_once('./Services/Search/classes/class.ilAdminUserSearchGUI.php');
78  $user_search =& new ilAdminUserSearchGUI();
79  $user_search->enableSearchableCheck(false);
80  $user_search->setCallback(
81  $this,
82  'searchResultHandler',
83  array(
84  'delete' => $this->lng->txt('delete'),
85  'activate' => $this->lng->txt('activate'),
86  'deactivate' => $this->lng->txt('deactivate'),
87  'accessRestrict'=> $this->lng->txt('accessRestrict'),
88  'accessFree' => $this->lng->txt('accessFree'),
89  'export' => $this->lng->txt('export')
90  )
91  );
92  $this->tabs_gui->setTabActive('search_user_extended');
93  $this->ctrl->setReturn($this,'view');
94  $ret =& $this->ctrl->forwardCommand($user_search);
95  break;
96 
97  case 'ilaccountcodesgui':
98  $this->tabs_gui->setTabActive('settings');
99  $this->setSubTabs("settings");
100  $ilTabs->activateSubTab("account_codes");
101  include_once("./Services/User/classes/class.ilAccountCodesGUI.php");
102  $acc = new ilAccountCodesGUI($this->ref_id);
103  $this->ctrl->forwardCommand($acc);
104  break;
105 
106  case 'ilcustomuserfieldsgui':
107  $this->tabs_gui->setTabActive('settings');
108  $this->setSubTabs("settings");
109  $ilTabs->activateSubTab("user_defined_fields");
110  include_once("./Services/User/classes/class.ilCustomUserFieldsGUI.php");
111  $cf = new ilCustomUserFieldsGUI();
112  $this->ctrl->forwardCommand($cf);
113  break;
114 
115  default:
116  if(!$cmd)
117  {
118  $cmd = "view";
119  }
120  $cmd .= "Object";
121 
122  $this->$cmd();
123 
124  break;
125  }
126  return true;
127  }
128 
130  {
131  global $rbacsystem, $tpl;
132 
133  if (!$rbacsystem->checkAccess("read",$this->object->getRefId()))
134  {
135  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
136  }
137 
138  include_once "Services/User/classes/class.ilUserLPTableGUI.php";
139  $tbl = new ilUserLPTableGUI($this, "learningProgress", $this->object->getRefId());
140 
141  $tpl->setContent($tbl->getHTML());
142  }
143 
148  function resetFilterObject()
149  {
150  include_once("./Services/User/classes/class.ilUserTableGUI.php");
151  $utab = new ilUserTableGUI($this, "view");
152  $utab->resetOffset();
153  $utab->resetFilter();
154 
155  // from "old" implementation
156  $this->viewObject(TRUE);
157  }
158 
162  function addUserObject()
163  {
164  global $ilCtrl;
165 
166  $ilCtrl->setParameterByClass("ilobjusergui", "new_type", "usr");
167  $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjusergui"), "create");
168  }
169 
170 
174  function applyFilterObject()
175  {
176  global $ilTabs;
177 
178  include_once("./Services/User/classes/class.ilUserTableGUI.php");
179  $utab = new ilUserTableGUI($this, "view");
180  $utab->resetOffset();
181  $utab->writeFilterToSession();
182  $this->viewObject();
183  $ilTabs->activateTab("obj_usrf");
184  }
185 
191  function viewObject($reset_filter = FALSE)
192  {
193  global $rbacsystem, $ilUser, $ilToolbar, $tpl, $ilSetting, $lng;
194 
195  $ilToolbar->addButton($this->lng->txt("usr_add"),
196  $this->ctrl->getLinkTarget($this, "addUser"));
197  $ilToolbar->addButton($this->lng->txt("import_users"),
198  $this->ctrl->getLinkTarget($this, "importUserForm"));
199 
200  // alphabetical navigation
201  include_once './Services/User/classes/class.ilUserAccountSettings.php';
203  if ((int) $ilSetting->get('user_adm_alpha_nav'))
204  {
205  $ilToolbar->addSeparator();
206 
207  // alphabetical navigation
208  include_once("./Services/Form/classes/class.ilAlphabetInputGUI.php");
209  $ai = new ilAlphabetInputGUI("", "first");
210  include_once("./Services/User/classes/class.ilObjUser.php");
211  $ai->setLetters(ilObjUser::getFirstLettersOfLastnames());
212  /*$ai->setLetters(array("A","B","C","D","E","F","G","H","I","J",
213  "K","L","M","N","O","P","Q","R","S","T",
214  "U","V","W","X","Y","Z","1","2","3","4","_",
215  "Ä","Ü","Ö",":",";","+","*","#","§","%","&"));*/
216  $ai->setParentCommand($this, "chooseLetter");
217  $ai->setHighlighted($_GET["letter"]);
218  $ilToolbar->addInputItem($ai, true);
219 
220  }
221 
222  include_once("./Services/User/classes/class.ilUserTableGUI.php");
223  $utab = new ilUserTableGUI($this, "view");
224  $tpl->setContent($utab->getHTML());
225  }
226 
230  protected function addUserAutoCompleteObject()
231  {
232  include_once './Services/User/classes/class.ilUserAutoComplete.php';
233  $auto = new ilUserAutoComplete();
234  $auto->setSearchFields(array('login','firstname','lastname','email'));
235  $auto->enableFieldSearchableCheck(false);
236  echo $auto->getList($_REQUEST['query']);
237  exit();
238  }
239 
247  {
248  global $ilCtrl;
249 
250  $ilCtrl->redirect($this, "view");
251  }
252 
253 
260  function showActions($with_subobjects = false)
261  {
262  global $rbacsystem;
263 
264  $operations = array();
265 //var_dump($this->actions);
266  if ($this->actions == "")
267  {
268  $d = array(
269  "delete" => array("name" => "delete", "lng" => "delete"),
270  "activate" => array("name" => "activate", "lng" => "activate"),
271  "deactivate" => array("name" => "deactivate", "lng" => "deactivate"),
272  "accessRestrict" => array("name" => "accessRestrict", "lng" => "accessRestrict"),
273  "accessFree" => array("name" => "accessFree", "lng" => "accessFree"),
274  "export" => array("name" => "export", "lng" => "export")
275  );
276  }
277  else
278  {
279  $d = $this->actions;
280  }
281  foreach ($d as $row)
282  {
283  if ($rbacsystem->checkAccess($row["name"],$this->object->getRefId()))
284  {
285  $operations[] = $row;
286  }
287  }
288 
289  if (count($operations) > 0)
290  {
291  $select = "<select name=\"selectedAction\">\n";
292  foreach ($operations as $val)
293  {
294  $select .= "<option value=\"" . $val["name"] . "\"";
295  if (strcmp($_POST["selectedAction"], $val["name"]) == 0)
296  {
297  $select .= " selected=\"selected\"";
298  }
299  $select .= ">";
300  $select .= $this->lng->txt($val["lng"]);
301  $select .= "</option>";
302  }
303  $select .= "</select>";
304  $this->tpl->setCurrentBlock("tbl_action_select");
305  $this->tpl->setVariable("SELECT_ACTION", $select);
306  $this->tpl->setVariable("BTN_NAME", "userAction");
307  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("submit"));
308  $this->tpl->parseCurrentBlock();
309  }
310 
311  if ($with_subobjects === true)
312  {
313  $subobjs = $this->showPossibleSubObjects();
314  }
315 
316  if ((count($operations) > 0) or $subobjs === true)
317  {
318  $this->tpl->setCurrentBlock("tbl_action_row");
319  $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
320  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
321  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
322  $this->tpl->parseCurrentBlock();
323  }
324  }
325 
333  {
334  global $rbacsystem;
335 
336  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
337 
338  if (!$rbacsystem->checkAccess('create_usr',$this->object->getRefId()))
339  {
340  unset($d["usr"]);
341  }
342 
343  if (count($d) > 0)
344  {
345  foreach ($d as $row)
346  {
347  $count = 0;
348  if ($row["max"] > 0)
349  {
350  //how many elements are present?
351  for ($i=0; $i<count($this->data["ctrl"]); $i++)
352  {
353  if ($this->data["ctrl"][$i]["type"] == $row["name"])
354  {
355  $count++;
356  }
357  }
358  }
359  if ($row["max"] == "" || $count < $row["max"])
360  {
361  $subobj[] = $row["name"];
362  }
363  }
364  }
365 
366  if (is_array($subobj))
367  {
368  //build form
369  $opts = ilUtil::formSelect(12,"new_type",$subobj);
370  $this->tpl->setCurrentBlock("add_object");
371  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
372  $this->tpl->setVariable("BTN_NAME", "create");
373  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
374  $this->tpl->parseCurrentBlock();
375 
376  return true;
377  }
378 
379  return false;
380  }
381 
383  {
384  $this->ctrl->redirectByClass('iladminusersearchgui','showSearchResults');
385 
386  #session_unregister("saved_post");
387  #$this->ctrl->returnToParent($this);
388  }
389 
396  {
397  $this->cancelUserFolderAction();
398  }
399 
406  {
407  global $rbacsystem, $ilUser;
408 
409  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
410  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
411  {
412  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
413  }
414 
415  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
416 
417  // FOR ALL SELECTED OBJECTS
418  foreach ($_SESSION["saved_post"] as $id)
419  {
420  // instatiate correct object class (usr)
421  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
422  $obj->setActive(TRUE, $ilUser->getId());
423  $obj->update();
424  }
425 
426  ilUtil::sendSuccess($this->lng->txt("user_activated"),true);
427 
428  if ($_SESSION['user_activate_search'] == true)
429  {
430  session_unregister("user_activate_search");
431  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show','',false,false);
432  ilUtil::redirect($script);
433  }
434  else
435  {
436  $this->ctrl->redirect($this, "view");
437  }
438  }
439 
446  {
447  $this->cancelUserFolderAction();
448  }
449 
456  {
457  global $rbacsystem, $ilUser;
458 
459  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
460  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
461  {
462  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
463  }
464 
465  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
466 
467  // FOR ALL SELECTED OBJECTS
468  foreach ($_SESSION["saved_post"] as $id)
469  {
470  // instatiate correct object class (usr)
471  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
472  $obj->setActive(FALSE, $ilUser->getId());
473  $obj->update();
474  }
475 
476  // Feedback
477  ilUtil::sendSuccess($this->lng->txt("user_deactivated"),true);
478 
479  if ($_SESSION['user_deactivate_search'] == true)
480  {
481  session_unregister("user_deactivate_search");
482  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show','',false,false);
483  ilUtil::redirect($script);
484  }
485  else
486  {
487  $this->ctrl->redirect($this, "view");
488  }
489  }
490 
492  {
493  $this->cancelUserFolderAction();
494  }
495 
497  {
498  global $rbacsystem, $ilUser;
499 
500  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
501  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
502  {
503  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
504  }
505 
506  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
507 
508  // FOR ALL SELECTED OBJECTS
509  foreach ($_SESSION["saved_post"] as $id)
510  {
511  // instatiate correct object class (usr)
512  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
513  $obj->setTimeLimitOwner($ilUser->getId());
514  $obj->setTimeLimitUnlimited(1);
515  $obj->setTimeLimitFrom("");
516  $obj->setTimeLimitUntil("");
517  $obj->setTimeLimitMessage(0);
518  $obj->update();
519  }
520 
521  // Feedback
522  ilUtil::sendSuccess($this->lng->txt("access_free_granted"),true);
523 
524  if ($_SESSION['user_accessFree_search'] == true)
525  {
526  session_unregister("user_accessFree_search");
527  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show','',false,false);
528  ilUtil::redirect($script);
529  }
530  else
531  {
532  $this->ctrl->redirect($this, "view");
533  }
534  }
535 
536  function setAccessRestrictionObject($a_form = null)
537  {
538  if(!$a_form)
539  {
540  $a_form = $this->initAccessRestrictionForm();
541  }
542  $this->tpl->setContent($a_form->getHTML());
543  }
544 
545  protected function initAccessRestrictionForm()
546  {
547  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
548  $form = new ilPropertyFormGUI();
549  $form->setTitle($this->lng->txt("time_limit_add_time_limit_for_selected"));
550  $form->setFormAction($this->ctrl->getFormAction($this, "confirmaccessRestrict"));
551 
552  $from = new ilDateTimeInputGUI($this->lng->txt("access_from"), "from");
553  $from->setShowTime(true);
554  $from->setRequired(true);
555  $form->addItem($from);
556 
557  $to = new ilDateTimeInputGUI($this->lng->txt("access_until"), "to");
558  $to->setRequired(true);
559  $to->setShowTime(true);
560  $form->addItem($to);
561 
562  $form->addCommandButton("confirmaccessRestrict", $this->lng->txt("confirm"));
563  $form->addCommandButton("cancelaccessRestrict", $this->lng->txt("cancel"));
564 
565  return $form;
566  }
567 
569  {
570  $this->cancelUserFolderAction();
571  }
572 
574  {
575  $form = $this->initAccessRestrictionForm();
576  if(!$form->checkInput())
577  {
578  return $this->setAccessRestrictionObject($form);
579  }
580 
581  $timefrom = $form->getItemByPostVar("from")->getDate()->get(IL_CAL_UNIX);
582  $timeuntil = $form->getItemByPostVar("to")->getDate()->get(IL_CAL_UNIX);
583  if ($timeuntil <= $timefrom)
584  {
585  ilUtil::sendFailure($this->lng->txt("time_limit_not_valid"));
586  return $this->setAccessRestrictionObject($form);
587  }
588 
589  global $rbacsystem, $ilUser;
590 
591  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
592  if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
593  {
594  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
595  }
596 
597  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
598 
599  // FOR ALL SELECTED OBJECTS
600  foreach ($_SESSION["saved_post"] as $id)
601  {
602  // instatiate correct object class (usr)
603  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
604  $obj->setTimeLimitOwner($ilUser->getId());
605  $obj->setTimeLimitUnlimited(0);
606  $obj->setTimeLimitFrom($timefrom);
607  $obj->setTimeLimitUntil($timeuntil);
608  $obj->setTimeLimitMessage(0);
609  $obj->update();
610  }
611 
612  // Feedback
613  ilUtil::sendSuccess($this->lng->txt("access_restricted"),true);
614 
615  if ($_SESSION['user_accessRestrict_search'] == true)
616  {
617  session_unregister("user_accessRestrict_search");
618  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show','',false,false);
619  ilUtil::redirect($script);
620  }
621  else
622  {
623  $this->ctrl->redirect($this, "view");
624  }
625  }
626 
633  {
634  $this->cancelUserFolderAction();
635  }
636 
643  {
644  global $rbacsystem, $ilCtrl;
645 
646  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
647  if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
648  {
649  ilUtil::sendFailure($this->lng->txt("msg_no_perm_delete"), true);
650  $ilCtrl->redirect($this, "view");
651  }
652 
653  $_SESSION['saved_post'] = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
654 
655  if (in_array($_SESSION["AccountId"],$_SESSION["saved_post"]))
656  {
657  $this->ilias->raiseError($this->lng->txt("msg_no_delete_yourself"),$this->ilias->error_obj->WARNING);
658  }
659 
660  // FOR ALL SELECTED OBJECTS
661  foreach ($_SESSION["saved_post"] as $id)
662  {
663  // instatiate correct object class (usr)
664  $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
665  $obj->delete();
666  }
667 
668  // Feedback
669  ilUtil::sendSuccess($this->lng->txt("user_deleted"),true);
670 
671  // now unset the delete users in session
672  #unset($_SESSION['saved_post']);
673 
674  if ($_SESSION['user_delete_search'] == true)
675  {
676  session_unregister("user_delete_search");
677  $script = $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI','show','',false,false);
678  ilUtil::redirect($script);
679  }
680  else
681  {
682  $this->ctrl->redirect($this, "view");
683  }
684  }
685 
692  {
693  $this->cancelUserFolderAction();
694  }
695 
702  {
703  $user_data_filter = $_SESSION['saved_post'] ? $_SESSION['saved_post'] : array();
704  session_unregister("saved_post");
705  $this->object->buildExportFile($_POST["export_type"], $user_data_filter);
706  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
707  }
708 
712  function deleteObject()
713  {
714  if(!isset($_POST["id"]))
715  {
716  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
717  }
718  // SAVE POST VALUES
719  $_SESSION["saved_post"] = $_POST["id"];
720 
721  unset($this->data);
722  $this->data["cols"] = array("type", "title", "description", "last_change");
723 
724  foreach($_POST["id"] as $id)
725  {
726  $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
727 
728  $this->data["data"]["$id"] = array(
729  "type" => $obj_data->getType(),
730  "title" => $obj_data->getTitle(),
731  "desc" => $obj_data->getDescription(),
732  "last_update" => $obj_data->getLastUpdateDate());
733  }
734 
735  $this->data["buttons"] = array(
736  "confirmedDelete" => $this->lng->txt("confirm"),
737  "cancelDelete" => $this->lng->txt("cancel")
738  );
739 
740  $this->getTemplateFile("confirm");
741 
742  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
743 
744  $this->tpl->setVariable("FORMACTION",
745  $this->ctrl->getFormAction($this));
746 
747  // BEGIN TABLE HEADER
748  foreach ($this->data["cols"] as $key)
749  {
750  $this->tpl->setCurrentBlock("table_header");
751  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
752  $this->tpl->parseCurrentBlock();
753  }
754  // END TABLE HEADER
755 
756  // BEGIN TABLE DATA
757  $counter = 0;
758 
759  foreach($this->data["data"] as $key => $value)
760  {
761  // BEGIN TABLE CELL
762  foreach($value as $key => $cell_data)
763  {
764  $this->tpl->setCurrentBlock("table_cell");
765 
766  // CREATE TEXT STRING
767  if($key == "type")
768  {
769  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
770  }
771  else
772  {
773  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
774  }
775  $this->tpl->parseCurrentBlock();
776  }
777 
778  $this->tpl->setCurrentBlock("table_row");
779  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
780  $this->tpl->parseCurrentBlock();
781  // END TABLE CELL
782  }
783  // END TABLE DATA
784 
785  // BEGIN OPERATION_BTN
786  foreach($this->data["buttons"] as $name => $value)
787  {
788  $this->tpl->setCurrentBlock("operation_btn");
789  $this->tpl->setVariable("BTN_NAME",$name);
790  $this->tpl->setVariable("BTN_VALUE",$value);
791  $this->tpl->parseCurrentBlock();
792  }
793 
794  return true;
795  }
796 
798  {
799  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
800  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
801  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("export_format_selection"));
802  $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
803  $options = array();
804  foreach ($export_types as $type)
805  {
806  $options[$type] = $this->lng->txt($type);
807  }
808  $select = ilUtil::formSelect("userfolder_export_xml", "export_type" ,$options, false, true);
809  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("export_format") . ": " . $select);
810  $this->tpl->setVariable("CMD_CANCEL", "cancelexport");
811  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
812  $this->tpl->setVariable("CMD_OK", "confirmexport");
813  $this->tpl->setVariable("TXT_OK", $this->lng->txt("confirm"));
814  $this->tpl->parseCurrentBlock();
815  }
816 
820  function showActionConfirmation($action)
821  {
822  if(!isset($_POST["id"]))
823  {
824  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
825  }
826  // SAVE POST VALUES
827  $_SESSION["saved_post"] = $_POST["id"];
828 
829  if (strcmp($action, "export") == 0) return $this->selectExportFormat();
830  if (strcmp($action, "accessRestrict") == 0) return $this->setAccessRestrictionObject();
831 
832  unset($this->data);
833 
834  // display confirmation message
835  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
836  $cgui = new ilConfirmationGUI();
837  $cgui->setFormAction($this->ctrl->getFormAction($this));
838  $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
839  $cgui->setCancel($this->lng->txt("cancel"), "cancel" . $action);
840  $cgui->setConfirm($this->lng->txt("confirm"), "confirm" . $action);
841 
842  foreach($_POST["id"] as $id)
843  {
844  $user = new ilObjUser($id);
845 
846  $login = $user->getLastLogin();
847  if(!$login)
848  {
849  $login = $this->lng->txt("never");
850  }
851  else
852  {
854  }
855 
856  $caption = $user->getFullname()." (".$user->getLogin().")".", ".
857  $user->getEmail()." - ".$this->lng->txt("last_login").": ".$login;
858 
859  // the post data is actually not used, see saved_post
860  $cgui->addItem("user_id[]", $i, $caption);
861  }
862 
863  $this->tpl->setContent($cgui->getHTML());
864 
865  return true;
866  }
867 
871  function deleteUsersObject()
872  {
873  $_POST["selectedAction"] = "delete";
874  $this->showActionConfirmation($_POST["selectedAction"]);
875  }
876 
881  {
882  $_POST["selectedAction"] = "activate";
883  $this->showActionConfirmation($_POST["selectedAction"]);
884  }
885 
890  {
891  $_POST["selectedAction"] = "deactivate";
892  $this->showActionConfirmation($_POST["selectedAction"]);
893  }
894 
899  {
900  $_POST["selectedAction"] = "accessRestrict";
901  $this->showActionConfirmation($_POST["selectedAction"]);
902  }
903 
907  function freeAccessObject()
908  {
909  $_POST["selectedAction"] = "accessFree";
910  $this->showActionConfirmation($_POST["selectedAction"]);
911  }
912 
916  function exportUsersObject()
917  {
918  $_POST["selectedAction"] = "export";
919  $this->showActionConfirmation($_POST["selectedAction"]);
920  }
921 
922  function userActionObject()
923  {
924  $this->showActionConfirmation($_POST["selectedAction"]);
925  }
926 
932  // presumably deprecated
933  // functionality moved to search/classes/iladminusersearch
934  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
936  {
937  $this->tabs_gui->setTabActive('obj_usrf');
938 
939  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_search_form.html");
940 
941  $this->tpl->setVariable("FORMACTION",
942  $this->ctrl->getFormAction($this));
943  $this->tpl->setVariable("USERNAME_CHECKED", " checked=\"checked\"");
944  $this->tpl->setVariable("FIRSTNAME_CHECKED", " checked=\"checked\"");
945  $this->tpl->setVariable("LASTNAME_CHECKED", " checked=\"checked\"");
946  $this->tpl->setVariable("EMAIL_CHECKED", " checked=\"checked\"");
947  $this->tpl->setVariable("ACTIVE_CHECKED", " checked=\"checked\"");
948  $this->tpl->setVariable("TXT_SEARCH_USER",$this->lng->txt("search_user"));
949  $this->tpl->setVariable("TXT_SEARCH_IN",$this->lng->txt("search_in"));
950  $this->tpl->setVariable("TXT_SEARCH_USERNAME",$this->lng->txt("username"));
951  $this->tpl->setVariable("TXT_SEARCH_FIRSTNAME",$this->lng->txt("firstname"));
952  $this->tpl->setVariable("TXT_SEARCH_LASTNAME",$this->lng->txt("lastname"));
953  $this->tpl->setVariable("TXT_SEARCH_EMAIL",$this->lng->txt("email"));
954  $this->tpl->setVariable("TXT_SEARCH_ACTIVE",$this->lng->txt("search_active"));
955  $this->tpl->setVariable("TXT_SEARCH_INACTIVE",$this->lng->txt("search_inactive"));
956  $this->tpl->setVariable("BUTTON_SEARCH",$this->lng->txt("search"));
957  $this->tpl->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
958  $this->tpl->setVariable("TXT_SEARCH_NOTE",$this->lng->txt("search_note"));
959  $this->tpl->setVariable("ACTIVE_CHECKED","checked=\"checked\"");
960  }
961 
962  // presumably deprecated
963  // functionality moved to search/classes/iladminusersearch
964  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
966  {
967  $this->ctrl->redirect($this, "view");
968  }
969 
970  // presumably deprecated
971  // functionality moved to search/classes/iladminusersearch
972  // dont't if this method is used elsewhere too - saschahofmann@gmx.de 6.6.07
973  function searchUserObject()
974  {
975  global $rbacreview;
976 
977  $obj_str = "&obj_id=".$this->obj_id;
978 
979  $_POST["search_string"] = trim($_POST["search_string"]) ? trim($_POST["search_string"]) : trim(urldecode($_GET["search_string"]));
980  //$_POST["search_fields"] = $_POST["search_fields"] ? $_POST["search_fields"] : explode(",",urldecode($_GET["search_fields"]));
981  $_SESSION['us_active'] = isset($_POST['active']) ? $_POST['active'] : $_SESSION['us_active'];
982 
983  $_POST["search_fields"] = array ("username","firstname","lastname","email");
984 
985  if (empty($_POST["search_string"]))
986  {
987  $_POST["search_string"] = "%";
988  }
989 
990  if (empty($_POST["search_fields"]))
991  {
992  $_POST["search_fields"] = array();
993  }
994  if (count($search_result = ilObjUser::searchUsers($_POST["search_string"],$_SESSION['us_active'])) == 0)
995  {
996  if ($_POST["search_string"] == "%")
997  {
998  $_POST["search_string"] = "";
999  }
1000  $msg = $this->lng->txt("msg_no_search_result");
1001  if ($_POST["search_string"] != "")
1002  {
1003  $msg .= " ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'";
1004  }
1005  ilUtil::sendInfo($msg, true);
1006  $this->ctrl->redirect($this, "searchUserForm");
1007  }
1008  //add template for buttons
1009  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1010 
1011  // display button
1012  $this->tpl->setCurrentBlock("btn_cell");
1013  $this->tpl->setVariable("BTN_LINK",
1014  $this->ctrl->getLinkTarget($this, "searchUserForm"));
1015  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("search_new"));
1016  $this->tpl->parseCurrentBlock();
1017 
1018  $this->data["cols"] = array("", "login", "firstname", "lastname", "email", "active");
1019 
1020  if($_SESSION['us_active'] == 1)
1021  {
1022  $searchActive = true;
1023  }
1024  else
1025  {
1026  $searchInactive = true;
1027  }
1028 
1029  foreach ($search_result as $key => $val)
1030  {
1031  $val["active_text"] = $this->lng->txt("inactive");
1032  if ($val["active"])
1033  {
1034  $val["active_text"] = $this->lng->txt("active");
1035  }
1036 
1037  // check if the fields are set
1038  $searchStringToLower = strtolower($_POST["search_string"]);
1039  $displaySearchResult = false;
1040  if (in_array("username", $_POST["search_fields"]))
1041  if (strpos(strtolower($val["login"]), strtolower($_POST["search_string"])) !== false)
1042  $displaySearchResult = true;
1043  if (in_array("firstname", $_POST["search_fields"]))
1044  if (strpos(strtolower($val["firstname"]), strtolower($_POST["search_string"])) !== false)
1045  $displaySearchResult = true;
1046  if (in_array("lastname", $_POST["search_fields"]))
1047  if (strpos(strtolower($val["lastname"]), strtolower($_POST["search_string"])) !== false)
1048  $displaySearchResult = true;
1049  if (in_array("email", $_POST["search_fields"]))
1050  if (strpos(strtolower($val["email"]), strtolower($_POST["search_string"])) !== false)
1051  $displaySearchResult = true;
1052  if (($val["active"] == 1) && ($searchActive == true) ||
1053  ($val["active"] == 0) && ($searchInactive == true))
1054  {
1055  if ((strcmp($_POST["search_string"], "%") == 0) || $displaySearchResult)
1056  {
1057  //visible data part
1058  $this->data["data"][] = array(
1059  "login" => $val["login"],
1060  "firstname" => $val["firstname"],
1061  "lastname" => $val["lastname"],
1062  "email" => $val["email"],
1063  "active" => $val["active_text"],
1064  "obj_id" => $val["usr_id"]
1065  );
1066  }
1067  }
1068  }
1069  if (count($this->data["data"]) == 0)
1070  {
1071  ilUtil::sendInfo($this->lng->txt("msg_no_search_result")." ".$this->lng->txt("with")." '".htmlspecialchars($_POST["search_string"])."'",true);
1072 
1073  $this->ctrl->redirect($this, "searchUserForm");
1074  }
1075 
1076  $this->maxcount = count($this->data["data"]);
1077 
1078  // TODO: correct this in objectGUI
1079  if ($_GET["sort_by"] == "name")
1080  {
1081  $_GET["sort_by"] = "login";
1082  }
1083 
1084  // sorting array
1085  $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
1086  $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
1087 
1088  // now compute control information
1089  foreach ($this->data["data"] as $key => $val)
1090  {
1091  $this->data["ctrl"][$key] = array(
1092  "ref_id" => $this->id,
1093  "obj_id" => $val["obj_id"]
1094  );
1095  $tmp[] = $val["obj_id"];
1096  unset($this->data["data"][$key]["obj_id"]);
1097  }
1098 
1099  // remember filtered users
1100  $_SESSION["user_list"] = $tmp;
1101 
1102  // load template for table
1103  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1104  // load template for table content data
1105  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1106 
1107  $num = 0;
1108 
1109  $this->ctrl->setParameter($this, "sort_by", "name");
1110  $this->ctrl->setParameter($this, "sort_order", $_GET["sort_order"]);
1111  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
1112  $this->tpl->setVariable("FORMACTION",
1113  $this->ctrl->getFormAction($this));
1114 
1115  // create table
1116  include_once "./Services/Table/classes/class.ilTableGUI.php";
1117  $tbl = new ilTableGUI();
1118 
1119  // title & header columns
1120  $tbl->setTitle($this->lng->txt("search_result"),"icon_".$this->object->getType().".gif",$this->lng->txt("obj_".$this->object->getType()));
1121  $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
1122 
1123  foreach ($this->data["cols"] as $val)
1124  {
1125  $header_names[] = $this->lng->txt($val);
1126  }
1127 
1128  $tbl->setHeaderNames($header_names);
1129 
1130  $header_params = $this->ctrl->getParameterArray($this, "searchUser");
1131  $header_params["search_string"] = urlencode($_POST["search_string"]);
1132  $header_params["search_fields"] = urlencode(implode(",",$_POST["search_fields"]));
1133 
1134  $tbl->setHeaderVars($this->data["cols"],$header_params);
1135  $tbl->setColumnWidth(array("","25%","25$%","25%","25%"));
1136 
1137  // control
1138  $tbl->enable("hits");
1139  $tbl->setOrderColumn($_GET["sort_by"]);
1140  $tbl->setOrderDirection($_GET["sort_order"]);
1141  $tbl->setLimit($_GET["limit"]);
1142  $tbl->setOffset($_GET["offset"]);
1143  $tbl->setMaxCount($this->maxcount);
1144 
1145  $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1146 
1147  // footer
1148  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1149 
1150  // render table
1151  $tbl->render();
1152 
1153  if (is_array($this->data["data"][0]))
1154  {
1155  //table cell
1156  for ($i=0; $i < count($this->data["data"]); $i++)
1157  {
1158  $data = $this->data["data"][$i];
1159  $ctrl = $this->data["ctrl"][$i];
1160 
1161  // dirty workaround to have ids for function showActions (checkbox toggle option)
1162  $this->ids[] = $ctrl["obj_id"];
1163 
1164  // color changing
1165  $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
1166 
1167  $this->tpl->setCurrentBlock("checkbox");
1168  $this->tpl->setVariable("CHECKBOX_ID", $ctrl["obj_id"]);
1169  //$this->tpl->setVariable("CHECKED", $checked);
1170  $this->tpl->setVariable("CSS_ROW", $css_row);
1171  $this->tpl->parseCurrentBlock();
1172 
1173  $this->tpl->setCurrentBlock("table_cell");
1174  $this->tpl->setVariable("CELLSTYLE", "tblrow1");
1175  $this->tpl->parseCurrentBlock();
1176 
1177  foreach ($data as $key => $val)
1178  {
1179  //build link
1180  $this->ctrl->setParameterByClass("ilobjusergui", "ref_id", "7");
1181  $this->ctrl->setParameterByClass("ilobjusergui", "obj_id", $ctrl["obj_id"]);
1182  $link = $this->ctrl->getLinkTargetByClass("ilobjusergui", "view");
1183 
1184  if ($key == "login")
1185  {
1186  $this->tpl->setCurrentBlock("begin_link");
1187  $this->tpl->setVariable("LINK_TARGET", $link);
1188  $this->tpl->parseCurrentBlock();
1189  $this->tpl->touchBlock("end_link");
1190  }
1191 
1192  $this->tpl->setCurrentBlock("text");
1193  $this->tpl->setVariable("TEXT_CONTENT", $val);
1194  $this->tpl->parseCurrentBlock();
1195  $this->tpl->setCurrentBlock("table_cell");
1196  $this->tpl->parseCurrentBlock();
1197  } //foreach
1198 
1199  $this->tpl->setCurrentBlock("tbl_content");
1200  $this->tpl->setVariable("CSS_ROW", $css_row);
1201  $this->tpl->parseCurrentBlock();
1202  } //for
1203 
1204  $this->showActions(true);
1205  }
1206  }
1207 
1208 
1213  {
1214  global $tpl, $rbacsystem;
1215 
1216  // Blind out tabs for local user import
1217  if($this->ctrl->getTargetScript() == 'repository.php')
1218  {
1219  $this->tabs_gui->clearTargets();
1220  }
1221 
1222  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1223  {
1224  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1225  }
1226 
1227  $this->initUserImportForm();
1228  $tpl->setContent($this->form->getHTML());
1229 
1230  //$this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_form.html");
1231  }
1232 
1238  public function initUserImportForm()
1239  {
1240  global $lng, $ilCtrl;
1241 
1242  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1243  $this->form = new ilPropertyFormGUI();
1244 
1245  // Import File
1246  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1247  $fi = new ilFileInputGUI($lng->txt("import_file"), "importFile");
1248  $fi->setSuffixes(array("xml", "zip"));
1249  //$fi->enableFileNameSelection();
1250  //$fi->setInfo($lng->txt(""));
1251  $this->form->addItem($fi);
1252 
1253  $this->form->addCommandButton("importUserRoleAssignment", $lng->txt("import"));
1254  $this->form->addCommandButton("importCancelled", $lng->txt("cancel"));
1255 
1256  $this->form->setTitle($lng->txt("import_users"));
1257  $this->form->setFormAction($ilCtrl->getFormAction($this));
1258 
1259  }
1260 
1261 
1268  {
1269  // purge user import directory
1270  $import_dir = $this->getImportDir();
1271  if (@is_dir($import_dir))
1272  {
1273  ilUtil::delDir($import_dir);
1274  }
1275 
1276  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
1277  {
1278  $this->ctrl->redirect($this, "view");
1279  //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
1280  }
1281  else
1282  {
1283  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
1284  }
1285  }
1286 
1290  function getImportDir()
1291  {
1292  // For each user session a different directory must be used to prevent
1293  // that one user session overwrites the import data that another session
1294  // is currently importing.
1295  global $ilUser;
1296  $importDir = ilUtil::getDataDir().'/user_import/usr_'.$ilUser->getId().'_'.session_id();
1297  ilUtil::makeDirParents($importDir);
1298  return $importDir;
1299  }
1300 
1305  {
1306  global $ilUser,$rbacreview, $tpl, $lng, $ilCtrl;;
1307 
1308  // Blind out tabs for local user import
1309  if($this->ctrl->getTargetScript() == 'repository.php')
1310  {
1311  $this->tabs_gui->clearTargets();
1312  }
1313 
1314  $this->initUserImportForm();
1315  if ($this->form->checkInput())
1316  {
1317  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1318  include_once './Services/User/classes/class.ilUserImportParser.php';
1319 
1320  global $rbacreview, $rbacsystem, $tree, $lng;
1321 
1322 
1323  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html");
1324 
1325  $import_dir = $this->getImportDir();
1326 
1327  // recreate user import directory
1328  if (@is_dir($import_dir))
1329  {
1330  ilUtil::delDir($import_dir);
1331  }
1332  ilUtil::makeDir($import_dir);
1333 
1334  // move uploaded file to user import directory
1335  $file_name = $_FILES["importFile"]["name"];
1336  $parts = pathinfo($file_name);
1337  $full_path = $import_dir."/".$file_name;
1338 
1339  // check if import file exists
1340  if (!is_file($_FILES["importFile"]["tmp_name"]))
1341  {
1342  ilUtil::delDir($import_dir);
1343  $this->ilias->raiseError($this->lng->txt("no_import_file_found")
1344  , $this->ilias->error_obj->MESSAGE);
1345  }
1346  ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"],
1347  $_FILES["importFile"]["name"], $full_path);
1348 
1349  // handle zip file
1350  if (strtolower($parts["extension"]) == "zip")
1351  {
1352  // unzip file
1353  ilUtil::unzip($full_path);
1354 
1355  $xml_file = null;
1356  $file_list = ilUtil::getDir($import_dir);
1357  foreach ($file_list as $a_file)
1358  {
1359  if (substr($a_file['entry'],-4) == '.xml')
1360  {
1361  $xml_file = $import_dir."/".$a_file['entry'];
1362  break;
1363  }
1364  }
1365  if (is_null($xml_file))
1366  {
1367  $subdir = basename($parts["basename"],".".$parts["extension"]);
1368  $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
1369  }
1370  }
1371  // handle xml file
1372  else
1373  {
1374  $xml_file = $full_path;
1375  }
1376 
1377  // check xml file
1378  if (!is_file($xml_file))
1379  {
1380  ilUtil::delDir($import_dir);
1381  $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip")
1382  ." ".$subdir."/".$subdir.".xml", $this->ilias->error_obj->MESSAGE);
1383  }
1384 
1385  require_once("./Services/User/classes/class.ilUserImportParser.php");
1386 
1387  // Verify the data
1388  // ---------------
1389  $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
1390  $importParser->startParsing();
1391  switch ($importParser->getErrorLevel())
1392  {
1393  case IL_IMPORT_SUCCESS :
1394  break;
1395  case IL_IMPORT_WARNING :
1396  $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
1397  break;
1398  case IL_IMPORT_FAILURE :
1399  ilUtil::delDir($import_dir);
1400  $this->ilias->raiseError(
1401  $lng->txt("verification_failed").$importParser->getProtocolAsHTML($lng->txt("verification_failure_log")),
1402  $this->ilias->error_obj->MESSAGE
1403  );
1404  return;
1405  }
1406 
1407  // Create the role selection form
1408  // ------------------------------
1409  $this->tpl->setCurrentBlock("role_selection_form");
1410  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1411  $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
1412  $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
1413  $this->tpl->setVariable("IMPORT_FILE", $file_name);
1414  $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
1415  $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
1416  $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
1417  $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
1418  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1419  $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
1420 
1421  // Extract the roles
1422  $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
1423  $importParser->startParsing();
1424  $roles = $importParser->getCollectedRoles();
1425 
1426  // get global roles
1427  $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
1428  $gl_roles = array();
1429  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1430  foreach ($all_gl_roles as $obj_data)
1431  {
1432  // check assignment permission if called from local admin
1433  if($this->object->getRefId() != USER_FOLDER_ID)
1434  {
1435  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
1436  {
1437  continue;
1438  }
1439  }
1440  // exclude anonymous role from list
1441  if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
1442  {
1443  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
1444  if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$roles_of_user))
1445  {
1446  $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
1447  }
1448  }
1449  }
1450 
1451  // global roles
1452  $got_globals = false;
1453  foreach($roles as $role_id => $role)
1454  {
1455  if ($role["type"] == "Global")
1456  {
1457  if (! $got_globals)
1458  {
1459  $got_globals = true;
1460 
1461  $this->tpl->setCurrentBlock("global_role_section");
1462  $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
1463  $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
1464  }
1465 
1466  // pre selection for role
1467  $pre_select = array_search($role[name], $gl_roles);
1468  if (! $pre_select)
1469  {
1470  switch($role["name"])
1471  {
1472  case "Administrator": // ILIAS 2/3 Administrator
1473  $pre_select = array_search("Administrator", $gl_roles);
1474  break;
1475 
1476  case "Autor": // ILIAS 2 Author
1477  $pre_select = array_search("User", $gl_roles);
1478  break;
1479 
1480  case "Lerner": // ILIAS 2 Learner
1481  $pre_select = array_search("User", $gl_roles);
1482  break;
1483 
1484  case "Gast": // ILIAS 2 Guest
1485  $pre_select = array_search("Guest", $gl_roles);
1486  break;
1487 
1488  default:
1489  $pre_select = array_search("User", $gl_roles);
1490  break;
1491  }
1492  }
1493  $this->tpl->setCurrentBlock("global_role");
1494  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $gl_roles, false, true);
1495  $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"]." [".$role_id."]");
1496  $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
1497  $this->tpl->parseCurrentBlock();
1498  }
1499  }
1500 
1501  // Check if local roles need to be assigned
1502  $got_locals = false;
1503  foreach($roles as $role_id => $role)
1504  {
1505  if ($role["type"] == "Local")
1506  {
1507  $got_locals = true;
1508  break;
1509  }
1510  }
1511 
1512  if ($got_locals)
1513  {
1514  $this->tpl->setCurrentBlock("local_role_section");
1515  $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
1516  $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
1517 
1518 
1519  // get local roles
1520  if ($this->object->getRefId() == USER_FOLDER_ID)
1521  {
1522  // The import function has been invoked from the user folder
1523  // object. In this case, we show only matching roles,
1524  // because the user folder object is considered the parent of all
1525  // local roles and may contains thousands of roles on large ILIAS
1526  // installations.
1527  $loc_roles = array();
1528  foreach($roles as $role_id => $role)
1529  {
1530  if ($role["type"] == "Local")
1531  {
1532  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
1533  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
1534  foreach ($matching_role_ids as $mid) {
1535  if (! in_array($mid, $loc_roles)) {
1536  $loc_roles[] = array('obj_id'=>$mid);
1537  }
1538  }
1539  }
1540  }
1541  } else {
1542  // The import function has been invoked from a locally
1543  // administrated category. In this case, we show all roles
1544  // contained in the subtree of the category.
1545  $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
1546  }
1547  $l_roles = array();
1548 
1549  // create a search array with .
1550  $l_roles_mailbox_searcharray = array();
1551  foreach ($loc_roles as $key => $loc_role)
1552  {
1553  // fetch context path of role
1554  $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"],true);
1555 
1556  // only process role folders that are not set to status "deleted"
1557  // and for which the user has write permissions.
1558  // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
1559  // (The ROLE_FOLDER_ID folder contains the global roles).
1560  if (!$rbacreview->isDeleted($rolf[0])
1561  && $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0]))
1562  && $rolf[0] != ROLE_FOLDER_ID
1563  )
1564  {
1565  // A local role is only displayed, if it is contained in the subtree of
1566  // the localy administrated category. If the import function has been
1567  // invoked from the user folder object, we show all local roles, because
1568  // the user folder object is considered the parent of all local roles.
1569  // Thus, if we start from the user folder object, we initialize the
1570  // isInSubtree variable with true. In all other cases it is initialized
1571  // with false, and only set to true if we find the object id of the
1572  // locally administrated category in the tree path to the local role.
1573  $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
1574 
1575  $path = "";
1576  if ($this->tree->isInTree($rolf[0]))
1577  {
1578  // Create path. Paths which have more than 4 segments
1579  // are truncated in the middle.
1580  $tmpPath = $this->tree->getPathFull($rolf[0]);
1581  for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++)
1582  {
1583  if ($i > 1)
1584  {
1585  $path = $path.' > ';
1586  }
1587  if ($i < 3 || $i > $n - 3)
1588  {
1589  $path = $path.$tmpPath[$i]['title'];
1590  }
1591  else if ($i == 3 || $i == $n - 3)
1592  {
1593  $path = $path.'...';
1594  }
1595 
1596  $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
1597  }
1598  }
1599  else
1600  {
1601  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$loc_role["obj_id"].")</b>";
1602  }
1603  $roleMailboxAddress = $rbacreview->getRoleMailboxAddress($loc_role['obj_id']);
1604  $l_roles[$loc_role['obj_id']] = $roleMailboxAddress.', '.$path;
1605  }
1606  } //foreach role
1607 
1608  $l_roles[""] = "";
1609  natcasesort($l_roles);
1610  $l_roles[""] = $this->lng->txt("usrimport_ignore_role");
1611  foreach($roles as $role_id => $role)
1612  {
1613  if ($role["type"] == "Local")
1614  {
1615  $this->tpl->setCurrentBlock("local_role");
1616  $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);
1617  $searchName = (substr($role['name'],0,1) == '#') ? $role['name'] : '#'.$role['name'];
1618  $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName);
1619  $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : "";
1620  if ($this->object->getRefId() == USER_FOLDER_ID) {
1621  // There are too many roles in a large ILIAS installation
1622  // that's why whe show only a choice with the the option "ignore",
1623  // and the matching roles.
1624  $selectable_roles = array();
1625  $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role");
1626  foreach ($matching_role_ids as $id)
1627  {
1628  $selectable_roles[$id] = $l_roles[$id];
1629  }
1630  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $selectable_roles, false, true);
1631  } else {
1632  $role_select = ilUtil::formSelect($pre_select, "role_assign[".$role_id."]", $l_roles, false, true);
1633  }
1634  $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
1635  $this->tpl->parseCurrentBlock();
1636  }
1637  }
1638  }
1639  //
1640 
1641  $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
1642  $handlers = array(
1643  IL_IGNORE_ON_CONFLICT => "ignore_on_conflict",
1644  IL_UPDATE_ON_CONFLICT => "update_on_conflict"
1645  );
1646  $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\n','<br>',$this->lng->txt("usrimport_conflict_handling_info")));
1647  $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
1648  $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
1649 
1650  // new account mail
1651  $this->lng->loadLanguageModule("mail");
1652  include_once './Services/User/classes/class.ilObjUserFolder.php';
1653  $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
1654  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
1655  {
1656  $this->tpl->setCurrentBlock("inform_user");
1657  $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail"));
1658  if (true)
1659  {
1660  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
1661  }
1662  $this->tpl->setVariable("TXT_INFORM_USER_MAIL",
1663  $this->lng->txt("user_send_new_account_mail"));
1664  $this->tpl->parseCurrentBlock();
1665  }
1666  }
1667  else
1668  {
1669  $this->form->setValuesByPost();
1670  $tpl->setContent($this->form->getHtml());
1671  }
1672  }
1673 
1678  {
1679  global $rbacreview,$ilUser;
1680 
1681  // Blind out tabs for local user import
1682  if($this->ctrl->getTargetScript() == 'repository.php')
1683  {
1684  $this->tabs_gui->clearTargets();
1685  }
1686 
1687  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1688  include_once './Services/User/classes/class.ilUserImportParser.php';
1689 
1690  global $rbacreview, $rbacsystem, $tree, $lng;
1691 
1692  switch ($_POST["conflict_handling_choice"])
1693  {
1694  case "update_on_conflict" :
1695  $rule = IL_UPDATE_ON_CONFLICT;
1696  break;
1697  case "ignore_on_conflict" :
1698  default :
1699  $rule = IL_IGNORE_ON_CONFLICT;
1700  break;
1701  }
1702  $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
1703  $importParser->setFolderId($this->getUserOwnerId());
1704  $import_dir = $this->getImportDir();
1705 
1706  // Catch hack attempts
1707  // We check here again, if the role folders are in the tree, and if the
1708  // user has permission on the roles.
1709  if ($_POST["role_assign"])
1710  {
1711  $global_roles = $rbacreview->getGlobalRoles();
1712  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1713  foreach ($_POST["role_assign"] as $role_id)
1714  {
1715  if ($role_id != "")
1716  {
1717  if (in_array($role_id, $global_roles))
1718  {
1719  if(!in_array(SYSTEM_ROLE_ID,$roles_of_user))
1720  {
1721  if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$roles_of_user)
1722  || ($this->object->getRefId() != USER_FOLDER_ID
1723  && ! ilObjRole::_getAssignUsersStatus($role_id))
1724  )
1725  {
1726  ilUtil::delDir($import_dir);
1727  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
1728  $this->ilias->error_obj->MESSAGE);
1729  }
1730  }
1731  }
1732  else
1733  {
1734  $rolf = $rbacreview->getFoldersAssignedToRole($role_id,true);
1735  if ($rbacreview->isDeleted($rolf[0])
1736  || ! $rbacsystem->checkAccess('write',$tree->getParentId($rolf[0])))
1737  {
1738  ilUtil::delDir($import_dir);
1739  $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"),
1740  $this->ilias->error_obj->MESSAGE);
1741  return;
1742  }
1743  }
1744  }
1745  }
1746  }
1747 
1748  $importParser->setRoleAssignment($_POST["role_assign"]);
1749  $importParser->startParsing();
1750 
1751  // purge user import directory
1752  ilUtil::delDir($import_dir);
1753 
1754  switch ($importParser->getErrorLevel())
1755  {
1756  case IL_IMPORT_SUCCESS :
1757  ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
1758  break;
1759  case IL_IMPORT_WARNING :
1760  ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings").$importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
1761  break;
1762  case IL_IMPORT_FAILURE :
1763  $this->ilias->raiseError(
1764  $this->lng->txt("user_import_failed")
1765  .$importParser->getProtocolAsHTML($lng->txt("import_failure_log")),
1766  $this->ilias->error_obj->MESSAGE
1767  );
1768  break;
1769  }
1770 
1771  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1772  {
1773  $this->ctrl->redirect($this, "view");
1774  //ilUtil::redirect($this->ctrl->getLinkTarget($this));
1775  }
1776  else
1777  {
1778  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
1779  }
1780  }
1781 
1782 
1784  {
1785  global $rbacsystem,$ilias;
1786 
1787  unset($_SESSION['applied_users']);
1788 
1789  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
1790  {
1791  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1792  }
1793 
1794  if(!count($app_users =& $ilias->account->getAppliedUsers()))
1795  {
1796  ilUtil::sendFailure($this->lng->txt('no_users_applied'));
1797 
1798  return false;
1799  }
1800 
1801  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_applied_users.html");
1802  $this->lng->loadLanguageModule('crs');
1803 
1804  $counter = 0;
1805  foreach($app_users as $usr_id)
1806  {
1807  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1808 
1809  $f_result[$counter][] = ilUtil::formCheckbox(0,"users[]",$usr_id);
1810  $f_result[$counter][] = $tmp_user->getLogin();
1811  $f_result[$counter][] = $tmp_user->getFirstname();
1812  $f_result[$counter][] = $tmp_user->getLastname();
1813 
1814  if($tmp_user->getTimeLimitUnlimited())
1815  {
1816  $f_result[$counter][] = "<b>".$this->lng->txt('crs_unlimited')."</b>";
1817  }
1818  else
1819  {
1820  $limit = "<b>".$this->lng->txt('crs_from').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitFrom()).'<br />';
1821  $limit .= "<b>".$this->lng->txt('crs_to').'</b> '.strftime("%Y-%m-%d %R",$tmp_user->getTimeLimitUntil());
1822 
1823  $f_result[$counter][] = $limit;
1824  }
1825  ++$counter;
1826  }
1827 
1828  $this->__showAppliedUsersTable($f_result);
1829 
1830  return true;
1831  }
1832 
1834  {
1835  global $rbacsystem;
1836 
1837  if(!$rbacsystem->checkAccess("write", $this->ref_id))
1838  {
1839  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1840  }
1841 
1842  $this->lng->loadLanguageModule('crs');
1843 
1844  $_POST['users'] = $_SESSION['applied_users'] = ($_SESSION['applied_users'] ? $_SESSION['applied_users'] : $_POST['users']);
1845 
1846  if(!isset($_SESSION['error_post_vars']))
1847  {
1848  ilUtil::sendInfo($this->lng->txt('time_limit_add_time_limit_for_selected'));
1849  }
1850 
1851  if(!count($_POST["users"]))
1852  {
1853  ilUtil::sendFailure($this->lng->txt("time_limit_no_users_selected"));
1854  $this->appliedUsersObject();
1855 
1856  return false;
1857  }
1858 
1859  $counter = 0;
1860  foreach($_POST['users'] as $usr_id)
1861  {
1862  if($counter)
1863  {
1864  $title .= ', ';
1865  }
1866  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1867  $title .= $tmp_user->getLogin();
1868  ++$counter;
1869  }
1870  if(strlen($title) > 79)
1871  {
1872  $title = substr($title,0,80);
1873  $title .= '...';
1874  }
1875 
1876 
1877  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.usr_edit_applied_users.html");
1878  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1879 
1880  // LOAD SAVED DATA IN CASE OF ERROR
1881  $time_limit_unlimited = $_SESSION["error_post_vars"]["au"]["time_limit_unlimited"] ?
1882  1 : 0;
1883 
1884  $time_limit_start = $_SESSION["error_post_vars"]["au"]["time_limit_start"] ?
1885  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_start"]) :
1886  time();
1887  $time_limit_end = $_SESSION["error_post_vars"]["au"]["time_limit_end"] ?
1888  $this->__toUnix($_SESSION["error_post_vars"]["au"]["time_limit_end"]) :
1889  time();
1890 
1891 
1892  // SET TEXT VARIABLES
1893  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_usr"));
1894  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_usr_b.gif"));
1895  $this->tpl->setVariable("TITLE",$title);
1896  $this->tpl->setVariable("TXT_TIME_LIMIT",$this->lng->txt("time_limit"));
1897  $this->tpl->setVariable("TXT_TIME_LIMIT_START",$this->lng->txt("crs_start"));
1898  $this->tpl->setVariable("TXT_TIME_LIMIT_END",$this->lng->txt("crs_end"));
1899  $this->tpl->setVariable("CMD_SUBMIT","updateAppliedUsers");
1900  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
1901  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
1902 
1903 
1904 
1905  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_DAY",$this->__getDateSelect("day","au[time_limit_start][day]",
1906  date("d",$time_limit_start)));
1907  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MONTH",$this->__getDateSelect("month","au[time_limit_start][month]",
1908  date("m",$time_limit_start)));
1909  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_YEAR",$this->__getDateSelect("year","au[time_limit_start][year]",
1910  date("Y",$time_limit_start)));
1911  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_HOUR",$this->__getDateSelect("hour","au[time_limit_start][hour]",
1912  date("G",$time_limit_start)));
1913  $this->tpl->setVariable("SELECT_TIME_LIMIT_START_MINUTE",$this->__getDateSelect("minute","au[time_limit_start][minute]",
1914  date("i",$time_limit_start)));
1915  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_DAY",$this->__getDateSelect("day","au[time_limit_end][day]",
1916  date("d",$time_limit_end)));
1917  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MONTH",$this->__getDateSelect("month","au[time_limit_end][month]",
1918  date("m",$time_limit_end)));
1919  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_YEAR",$this->__getDateSelect("year","au[time_limit_end][year]",
1920  date("Y",$time_limit_end)));
1921  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_HOUR",$this->__getDateSelect("hour","au[time_limit_end][hour]",
1922  date("G",$time_limit_end)));
1923  $this->tpl->setVariable("SELECT_TIME_LIMIT_END_MINUTE",$this->__getDateSelect("minute","au[time_limit_end][minute]",
1924  date("i",$time_limit_end)));
1925  if($this->ilias->account->getTimeLimitUnlimited())
1926  {
1927  $this->tpl->setVariable("ROWSPAN",3);
1928  $this->tpl->setCurrentBlock("unlimited");
1929  $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED",$this->lng->txt("crs_unlimited"));
1930  $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"au[time_limit_unlimited]",1));
1931  $this->tpl->parseCurrentBlock();
1932  }
1933  else
1934  {
1935  $this->tpl->setVariable("ROWSPAN",2);
1936  }
1937  }
1938 
1940  {
1941  global $rbacsystem;
1942 
1943  if(!$rbacsystem->checkAccess("write", $this->ref_id))
1944  {
1945  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1946  }
1947 
1948  $start = $this->__toUnix($_POST['au']['time_limit_start']);
1949  $end = $this->__toUnix($_POST['au']['time_limit_end']);
1950 
1951  if(!$_POST['au']['time_limit_unlimited'])
1952  {
1953  if($start > $end)
1954  {
1955  $_SESSION['error_post_vars'] = $_POST;
1956  ilUtil::sendFailure($this->lng->txt('time_limit_not_valid'));
1957  $this->editAppliedUsersObject();
1958 
1959  return false;
1960  }
1961  }
1962  #if(!$this->ilias->account->getTimeLimitUnlimited())
1963  #{
1964  # if($start < $this->ilias->account->getTimeLimitFrom() or
1965  # $end > $this->ilias->account->getTimeLimitUntil())
1966  # {
1967  # $_SESSION['error_post_vars'] = $_POST;
1968  # ilUtil::sendInfo($this->lng->txt('time_limit_not_within_owners'));
1969  # $this->editAppliedUsersObject();
1970 
1971  # return false;
1972  # }
1973  #}
1974 
1975  foreach($_SESSION['applied_users'] as $usr_id)
1976  {
1977  $tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id);
1978 
1979  $tmp_user->setTimeLimitUnlimited((int) $_POST['au']['time_limit_unlimited']);
1980  $tmp_user->setTimeLimitFrom($start);
1981  $tmp_user->setTimeLimitUntil($end);
1982  $tmp_user->setTimeLimitMessage(0);
1983  $tmp_user->update();
1984 
1985  unset($tmp_user);
1986  }
1987 
1988  unset($_SESSION['applied_users']);
1989  ilUtil::sendSuccess($this->lng->txt('time_limit_users_updated'));
1990  $this->appliedUsersObject();
1991 
1992  return true;
1993  }
1994 
1995  function __showAppliedUsersTable($a_result_set)
1996  {
1997  $tbl =& $this->__initTableGUI();
1998  $tpl =& $tbl->getTemplateObject();
1999 
2000  // SET FORMAACTION
2001  $tpl->setCurrentBlock("tbl_form_header");
2002 
2003  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2004  $tpl->parseCurrentBlock();
2005 
2006  $tpl->setCurrentBlock("tbl_action_btn");
2007  $tpl->setVariable("BTN_NAME",'editAppliedUsers');
2008  $tpl->setVariable("BTN_VALUE",$this->lng->txt('edit'));
2009  $tpl->parseCurrentBlock();
2010 
2011  $tpl->setCurrentBlock("tbl_action_row");
2012  $tpl->setVariable("COLUMN_COUNTS",5);
2013  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2014  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2015  $tpl->parseCurrentBlock();
2016 
2017 
2018 
2019  $tbl->setTitle($this->lng->txt("time_limit_applied_users"),"icon_usr_b.gif",$this->lng->txt("users"));
2020  $tbl->setHeaderNames(array('',
2021  $this->lng->txt("login"),
2022  $this->lng->txt("firstname"),
2023  $this->lng->txt("lastname"),
2024  $this->lng->txt("time_limits")));
2025  $header_params = $this->ctrl->getParameterArray($this, "appliedUsers");
2026  $tbl->setHeaderVars(array("",
2027  "login",
2028  "firstname",
2029  "lastname",
2030  "time_limit"),
2031  array($header_params));
2032  $tbl->setColumnWidth(array("3%","19%","19%","19%","40%"));
2033 
2034 
2035  $this->__setTableGUIBasicData($tbl,$a_result_set);
2036  $tbl->render();
2037 
2038  $this->tpl->setVariable("APPLIED_USERS",$tbl->tpl->get());
2039 
2040  return true;
2041  }
2042 
2043  function &__initTableGUI()
2044  {
2045  include_once "./Services/Table/classes/class.ilTableGUI.php";
2046 
2047  return new ilTableGUI(0,false);
2048  }
2049 
2050  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
2051  {
2052  $offset = $_GET["offset"];
2053  $order = $_GET["sort_by"];
2054  $direction = $_GET["sort_order"];
2055 
2056  //$tbl->enable("hits");
2057  $tbl->setOrderColumn($order);
2058  $tbl->setOrderDirection($direction);
2059  $tbl->setOffset($offset);
2060  $tbl->setLimit($_GET["limit"]);
2061  $tbl->setMaxCount(count($result_set));
2062  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2063  $tbl->setData($result_set);
2064  }
2065 
2066  function __getDateSelect($a_type,$a_varname,$a_selected)
2067  {
2068  switch($a_type)
2069  {
2070  case "minute":
2071  for($i=0;$i<=60;$i++)
2072  {
2073  $days[$i] = $i < 10 ? "0".$i : $i;
2074  }
2075  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2076 
2077  case "hour":
2078  for($i=0;$i<24;$i++)
2079  {
2080  $days[$i] = $i < 10 ? "0".$i : $i;
2081  }
2082  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2083 
2084  case "day":
2085  for($i=1;$i<32;$i++)
2086  {
2087  $days[$i] = $i < 10 ? "0".$i : $i;
2088  }
2089  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2090 
2091  case "month":
2092  for($i=1;$i<13;$i++)
2093  {
2094  $month[$i] = $i < 10 ? "0".$i : $i;
2095  }
2096  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
2097 
2098  case "year":
2099  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
2100  {
2101  $year[$i] = $i;
2102  }
2103  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
2104  }
2105  }
2106  function __toUnix($a_time_arr)
2107  {
2108  return mktime($a_time_arr["hour"],
2109  $a_time_arr["minute"],
2110  $a_time_arr["second"],
2111  $a_time_arr["month"],
2112  $a_time_arr["day"],
2113  $a_time_arr["year"]);
2114  }
2115 
2117  {
2119  $this->viewObject();
2120  }
2121 
2126  protected function generalSettingsObject()
2127  {
2128  global $ilSetting;
2129 
2130  $this->initFormGeneralSettings();
2131 
2132  include_once './Services/User/classes/class.ilUserAccountSettings.php';
2134  $this->form->setValuesByArray(
2135  array(
2136  'lua' => $aset->isLocalUserAdministrationEnabled(),
2137  'lrua' => $aset->isUserAccessRestricted(),
2138  'allow_change_loginname' => (bool)$ilSetting->get('allow_change_loginname'),
2139  'create_history_loginname' => (bool)$ilSetting->get('create_history_loginname'),
2140  'prevent_reuse_of_loginnames' => (bool)$ilSetting->get('prevent_reuse_of_loginnames'),
2141  'loginname_change_blocking_time' => (int)$ilSetting->get('loginname_change_blocking_time'),
2142  'user_adm_alpha_nav' => (int)$ilSetting->get('user_adm_alpha_nav'),
2143  // 'user_ext_profiles' => (int)$ilSetting->get('user_ext_profiles')
2144  'user_reactivate_code' => (int)$ilSetting->get('user_reactivate_code')
2145  )
2146  );
2147 
2148  $this->tpl->setContent($this->form->getHTML());
2149  }
2150 
2151 
2156  public function saveGeneralSettingsObject()
2157  {
2158  global $ilUser, $ilSetting;
2159 
2160  $this->initFormGeneralSettings();
2161  if($this->form->checkInput())
2162  {
2163  $valid = true;
2164 
2165  if(strlen($this->form->getInput('loginname_change_blocking_time')) &&
2166  !preg_match('/^[0-9]*$/',
2167  $this->form->getInput('loginname_change_blocking_time')))
2168  {
2169  $valid = false;
2170  $this->form->getItemByPostVar('loginname_change_blocking_time')
2171  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
2172  }
2173 
2174  if($valid)
2175  {
2176  include_once './Services/User/classes/class.ilUserAccountSettings.php';
2177  ilUserAccountSettings::getInstance()->enableLocalUserAdministration($this->form->getInput('lua'));
2178  ilUserAccountSettings::getInstance()->restrictUserAccess($this->form->getInput('lrua'));
2180 
2181  // TODO: move to user account settings
2182  $ilSetting->set('allow_change_loginname', (int)$this->form->getInput('allow_change_loginname'));
2183  $ilSetting->set('create_history_loginname', (int)$this->form->getInput('create_history_loginname'));
2184  $ilSetting->set('prevent_reuse_of_loginnames', (int)$this->form->getInput('prevent_reuse_of_loginnames'));
2185  $ilSetting->set('loginname_change_blocking_time', (int)$this->form->getInput('loginname_change_blocking_time'));
2186  $ilSetting->set('user_adm_alpha_nav', (int)$this->form->getInput('user_adm_alpha_nav'));
2187  // $ilSetting->set('user_ext_profiles', (int)$this->form->getInput('user_ext_profiles'));
2188  $ilSetting->set('user_portfolios', (int)$this->form->getInput('user_portfolios'));
2189  $ilSetting->set('user_reactivate_code', (int)$this->form->getInput('user_reactivate_code'));
2190 
2191  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
2192  }
2193  else
2194  {
2195  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2196  }
2197  }
2198  else
2199  {
2200  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2201  }
2202  $this->form->setValuesByPost();
2203  $this->tpl->setContent($this->form->getHTML());
2204  }
2205 
2206 
2211  protected function initFormGeneralSettings()
2212  {
2213  $this->setSubTabs('settings');
2214  $this->tabs_gui->setTabActive('settings');
2215  $this->tabs_gui->setSubTabActive('general_settings');
2216 
2217  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2218  $this->form = new ilPropertyFormGUI();
2219  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
2220 
2221  $this->form->setTitle($this->lng->txt('general_settings'));
2222 
2223  $lua = new ilCheckboxInputGUI($this->lng->txt('enable_local_user_administration'),'lua');
2224  $lua->setInfo($this->lng->txt('enable_local_user_administration_info'));
2225  $lua->setValue(1);
2226  $this->form->addItem($lua);
2227 
2228  $lrua = new ilCheckboxInputGUI($this->lng->txt('restrict_user_access'),'lrua');
2229  $lrua->setInfo($this->lng->txt('restrict_user_access_info'));
2230  $lrua->setValue(1);
2231  $this->form->addItem($lrua);
2232 
2233  // enable alphabetical navigation in user administration
2234  $alph = new ilCheckboxInputGUI($this->lng->txt('user_adm_enable_alpha_nav'), 'user_adm_alpha_nav');
2235  //$alph->setInfo($this->lng->txt('restrict_user_access_info'));
2236  $alph->setValue(1);
2237  $this->form->addItem($alph);
2238 
2239  /* extended user profiles
2240  $cb = new ilCheckboxInputGUI($this->lng->txt("user_ext_profiles"), "user_ext_profiles");
2241  $cb->setInfo($this->lng->txt('user_ext_profiles_desc'));
2242  $this->form->addItem($cb);
2243  */
2244 
2245  // account codes
2246  $code = new ilCheckboxInputGUI($this->lng->txt("user_account_code_setting"), "user_reactivate_code");
2247  $code->setInfo($this->lng->txt('user_account_code_setting_info'));
2248  $this->form->addItem($code);
2249 
2250  $log = new ilFormSectionHeaderGUI();
2251  $log->setTitle($this->lng->txt('loginname_settings'));
2252  $this->form->addItem($log);
2253 
2254  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
2255  $chbChangeLogin->setValue(1);
2256  $this->form->addItem($chbChangeLogin);
2257  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
2258  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
2259  $chbCreateHistory->setValue(1);
2260 
2261  $chbChangeLogin->addSubItem($chbCreateHistory);
2262  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'prevent_reuse_of_loginnames');
2263  $chbReuseLoginnames->setValue(1);
2264  $chbReuseLoginnames->setInfo($this->lng->txt('prevent_reuse_of_loginnames_contained_in_history_info'));
2265 
2266  $chbChangeLogin->addSubItem($chbReuseLoginnames);
2267  $chbChangeBlockingTime = new ilTextInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
2268  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
2269  $chbChangeBlockingTime->setSize(10);
2270  $chbChangeBlockingTime->setMaxLength(10);
2271  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
2272 
2273  $this->form->addCommandButton('saveGeneralSettings', $this->lng->txt('save'));
2274  }
2275 
2276 
2277 
2278 
2289  function settingsObject()
2290  {
2291  global $tpl, $lng, $ilias;
2292 
2293  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
2294  $lng->loadLanguageModule("administration");
2295  $lng->loadLanguageModule("mail");
2296  $this->setSubTabs('settings');
2297 
2298  include_once("./Services/User/classes/class.ilUserFieldSettingsTableGUI.php");
2299  $tab = new ilUserFieldSettingsTableGUI($this, "settings");
2300  if($this->confirm_change) $tab->setConfirmChange();
2301  $tpl->setContent($tab->getHTML());
2302  }
2303 
2305  {
2306  $this->saveGlobalUserSettingsObject("save");
2307  }
2308 
2309  function saveGlobalUserSettingsObject($action = "")
2310  {
2311  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
2312  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
2313 
2314  global $ilias,$ilSetting;
2315 
2316  // see ilUserFieldSettingsTableGUI
2317  include_once("./Services/User/classes/class.ilUserProfile.php");
2318  $up = new ilUserProfile();
2319  $up->skipField("username");
2320  $field_properties = $up->getStandardFields();
2321  $profile_fields = array_keys($field_properties);
2322 
2323  $valid = true;
2324  foreach ($profile_fields as $field)
2325  {
2326  if ( $_POST["chb"]["required_".$field] &&
2327  !(int)$_POST['chb']['visib_reg_' . $field]
2328  ){
2329  $valid = false;
2330  break;
2331  }
2332  }
2333 
2334  if(!$valid)
2335  {
2336  global $lng;
2337  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
2338  $this->confirm_change = 1;
2339  $this->settingsObject();
2340  return;
2341  }
2342 
2343  // For the following fields, the required state can not be changed
2344  $fixed_required_fields = array(
2345  "firstname" => 1,
2346  "lastname" => 1,
2347  "upload" => 0,
2348  "password" => 0,
2349  "language" => 0,
2350  "skin_style" => 0,
2351  "hits_per_page" => 0,
2352  "show_users_online" => 0,
2353  "hide_own_online_status" => 0
2354  );
2355 
2356  // check if a course export state of any field has been added
2357  $privacy = ilPrivacySettings::_getInstance();
2358  if ($privacy->enabledCourseExport() == true &&
2359  $privacy->courseConfirmationRequired() == true &&
2360  $action != "save")
2361  {
2362  foreach ($profile_fields as $field)
2363  {
2364  if (! $ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1")
2365  {
2366  #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
2367  #$this->confirm_change = 1;
2368  #$this->settingsObject();
2369  #return;
2370  }
2371  }
2372  }
2373  // Reset user confirmation
2374  if($action == 'save')
2375  {
2376  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
2378  }
2379 
2380  foreach ($profile_fields as $field)
2381  {
2382  // Enable disable searchable
2384  {
2385  ilUserSearchOptions::_saveStatus($field,(bool) $_POST['chb']['searchable_'.$field]);
2386  }
2387 
2388  if (!$_POST["chb"]["visible_".$field] && !$field_properties[$field]["visible_hide"])
2389  {
2390  $ilias->setSetting("usr_settings_hide_".$field, "1");
2391  }
2392  else
2393  {
2394  $ilias->deleteSetting("usr_settings_hide_".$field);
2395  }
2396 
2397  if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"])
2398  {
2399  $ilias->setSetting("usr_settings_disable_".$field, "1");
2400  }
2401  else
2402  {
2403  $ilias->deleteSetting("usr_settings_disable_".$field);
2404  }
2405 
2406  // registration visible
2407  if ((int)$_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"])
2408  {
2409  $ilSetting->set('usr_settings_visib_reg_'.$field, '1');
2410  }
2411  else
2412  {
2413  $ilSetting->set('usr_settings_visib_reg_'.$field, '0');
2414  }
2415 
2416  if ((int)$_POST['chb']['visib_lua_' . $field])
2417  {
2418 
2419  $ilSetting->set('usr_settings_visib_lua_'.$field, '1');
2420  }
2421  else
2422  {
2423  $ilSetting->set('usr_settings_visib_lua_'.$field, '0');
2424  }
2425 
2426  if ((int)$_POST['chb']['changeable_lua_' . $field])
2427  {
2428 
2429  $ilSetting->set('usr_settings_changeable_lua_'.$field, '1');
2430  }
2431  else
2432  {
2433  $ilSetting->set('usr_settings_changeable_lua_'.$field, '0');
2434  }
2435 
2436  if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"])
2437  {
2438  $ilias->setSetting("usr_settings_export_".$field, "1");
2439  }
2440  else
2441  {
2442  $ilias->deleteSetting("usr_settings_export_".$field);
2443  }
2444 
2445  // Course export/visibility
2446  if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"])
2447  {
2448  $ilias->setSetting("usr_settings_course_export_".$field, "1");
2449  }
2450  else
2451  {
2452  $ilias->deleteSetting("usr_settings_course_export_".$field);
2453  }
2454 
2455  // Group export/visibility
2456  if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"])
2457  {
2458  $ilias->setSetting("usr_settings_group_export_".$field, "1");
2459  }
2460  else
2461  {
2462  $ilias->deleteSetting("usr_settings_group_export_".$field);
2463  }
2464 
2465  $is_fixed = array_key_exists($field, $fixed_required_fields);
2466  if ($is_fixed && $fixed_required_fields[$field] || ! $is_fixed && $_POST["chb"]["required_".$field])
2467  {
2468  $ilias->setSetting("require_".$field, "1");
2469  }
2470  else
2471  {
2472  $ilias->deleteSetting("require_" . $field);
2473  }
2474  }
2475 
2476  if ($_POST["select"]["default_hits_per_page"])
2477  {
2478  $ilias->setSetting("hits_per_page",$_POST["select"]["default_hits_per_page"]);
2479  }
2480 
2481  if ($_POST["select"]["default_show_users_online"])
2482  {
2483  $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
2484  }
2485 
2486  if ($_POST["chb"]["export_preferences"])
2487  {
2488  $ilias->setSetting("usr_settings_export_preferences",$_POST["chb"]["export_preferences"]);
2489  } else {
2490  $ilias->deleteSetting("usr_settings_export_preferences");
2491  }
2492 
2493  $ilias->setSetting('mail_incoming_mail', (int)$_POST['select']['default_mail_incoming_mail']);
2494 
2495  ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
2496  $this->settingsObject();
2497  }
2498 
2499 
2504  {
2505  $action[-1] = $this->lng->txt('all_users');
2506  $action[1] = $this->lng->txt('usr_active_only');
2507  $action[0] = $this->lng->txt('usr_inactive_only');
2508  $action[2] = $this->lng->txt('usr_limited_access_only');
2509  $action[3] = $this->lng->txt('usr_without_courses');
2510  $action[4] = $this->lng->txt('usr_filter_lastlogin');
2511  $action[5] = $this->lng->txt("usr_filter_coursemember");
2512  $action[6] = $this->lng->txt("usr_filter_groupmember");
2513  $action[7] = $this->lng->txt("usr_filter_role");
2514 
2515  return ilUtil::formSelect($_SESSION['user_filter'],"user_filter",$action,false,true);
2516  }
2517 
2525  {
2526  if(!isset($_POST["file"]))
2527  {
2528  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2529  }
2530 
2531  if (count($_POST["file"]) > 1)
2532  {
2533  $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2534  }
2535 
2536  $file = basename($_POST["file"][0]);
2537 
2538  $export_dir = $this->object->getExportDirectory();
2539  ilUtil::deliverFile($export_dir."/".$file, $file);
2540  }
2541 
2546  {
2547  if(!isset($_POST["file"]))
2548  {
2549  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2550  }
2551 
2552  // SAVE POST VALUES
2553  $_SESSION["ilExportFiles"] = $_POST["file"];
2554 
2555  $this->getTemplateFile("confirm_delete_export","usr");
2556 
2557  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
2558 
2559  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2560 
2561  // BEGIN TABLE HEADER
2562  $this->tpl->setCurrentBlock("table_header");
2563  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
2564  $this->tpl->parseCurrentBlock();
2565 
2566  // BEGIN TABLE DATA
2567  $counter = 0;
2568  foreach($_POST["file"] as $file)
2569  {
2570  $this->tpl->setCurrentBlock("table_row");
2571  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
2572  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_usrf.gif"));
2573  $this->tpl->setVariable("TEXT_CONTENT", $file);
2574  $this->tpl->parseCurrentBlock();
2575  }
2576 
2577  // cancel/confirm button
2578  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
2579  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2580  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
2581  "deleteExportFile" => $this->lng->txt("confirm"));
2582  foreach ($buttons as $name => $value)
2583  {
2584  $this->tpl->setCurrentBlock("operation_btn");
2585  $this->tpl->setVariable("BTN_NAME",$name);
2586  $this->tpl->setVariable("BTN_VALUE",$value);
2587  $this->tpl->parseCurrentBlock();
2588  }
2589  }
2590 
2591 
2596  {
2597  session_unregister("ilExportFiles");
2598  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2599  }
2600 
2601 
2606  {
2607  $export_dir = $this->object->getExportDirectory();
2608  foreach($_SESSION["ilExportFiles"] as $file)
2609  {
2610  $file = basename($file);
2611 
2612  $exp_file = $export_dir."/".$file;
2613  if (@is_file($exp_file))
2614  {
2615  unlink($exp_file);
2616  }
2617  }
2618  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2619  }
2620 
2631  function exportObject()
2632  {
2633  global $ilias, $ilCtrl;
2634 
2635  if ($_POST["cmd"]["export"])
2636  {
2637  $this->object->buildExportFile($_POST["export_type"]);
2638  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2639  exit;
2640  }
2641 
2642  $this->getTemplateFile("export","usr");
2643 
2644  $export_types = array(
2645  "userfolder_export_excel_x86",
2646  "userfolder_export_csv",
2647  "userfolder_export_xml"
2648  );
2649 
2650  // create table
2651  include_once("./Services/Table/classes/class.ilTableGUI.php");
2652  $tbl = new ilTableGUI();
2653 
2654  // load files templates
2655  $this->tpl->addBlockfile("EXPORT_FILES", "export_files", "tpl.table.html");
2656 
2657  // load template for table content data
2658  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_export_file_row.html");
2659 
2660  $num = 0;
2661 
2662  $tbl->setTitle($this->lng->txt("userfolder_export_files"));
2663 
2664  $tbl->setHeaderNames(array("", $this->lng->txt("userfolder_export_file"),
2665  $this->lng->txt("userfolder_export_file_size"), $this->lng->txt("date") ));
2666  $tbl->setHeaderVars(array(), $ilCtrl->getParameterArray($this, "export"));
2667 
2668  $tbl->enabled["sort"] = false;
2669  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
2670 
2671  // control
2672  $tbl->setOrderColumn($_GET["sort_by"]);
2673  $tbl->setOrderDirection($_GET["sort_order"]);
2674  $tbl->setLimit($_GET["limit"]);
2675  $tbl->setOffset($_GET["offset"]);
2676  $tbl->setMaxCount($this->maxcount); // ???
2677 
2678 
2679  $this->tpl->setVariable("COLUMN_COUNTS", 4);
2680 
2681  // delete button
2682  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2683  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2684  $this->tpl->setCurrentBlock("tbl_action_btn");
2685  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
2686  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
2687  $this->tpl->parseCurrentBlock();
2688 
2689  $this->tpl->setCurrentBlock("tbl_action_btn");
2690  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
2691  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
2692  $this->tpl->parseCurrentBlock();
2693 
2694  // footer
2695  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2696  //$tbl->disable("footer");
2697 
2698  $export_files = $this->object->getExportFiles();
2699 
2700  $tbl->setMaxCount(count($export_files));
2701  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
2702 
2703  $tbl->render();
2704 
2705  if(count($export_files) > 0)
2706  {
2707  $i=0;
2708  foreach($export_files as $exp_file)
2709  {
2710  $this->tpl->setCurrentBlock("tbl_content");
2711  $this->tpl->setVariable("TXT_FILENAME", $exp_file["filename"]);
2712 
2713  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
2714  $this->tpl->setVariable("CSS_ROW", $css_row);
2715 
2716  $this->tpl->setVariable("TXT_SIZE", $exp_file["filesize"]);
2717  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["filename"]);
2718 
2719  $file_arr = explode("__", $exp_file["filename"]);
2720  $this->tpl->setVariable('TXT_DATE',ilDatePresentation::formatDate(new ilDateTime($file_arr[0],IL_CAL_UNIX)));
2721 
2722  $this->tpl->parseCurrentBlock();
2723  }
2724 
2725  $this->tpl->setCurrentBlock("selectall");
2726  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2727  $this->tpl->setVariable("CSS_ROW", $css_row);
2728  $this->tpl->parseCurrentBlock();
2729  } //if is_array
2730  /*
2731  else
2732 
2733  {
2734  $this->tpl->setCurrentBlock("notfound");
2735  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
2736  $this->tpl->setVariable("NUM_COLS", 3);
2737  $this->tpl->parseCurrentBlock();
2738  }
2739  */
2740 
2741  $this->tpl->parseCurrentBlock();
2742 
2743 
2744  foreach ($export_types as $export_type)
2745  {
2746  $this->tpl->setCurrentBlock("option");
2747  $this->tpl->setVariable("OPTION_VALUE", $export_type);
2748  $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt($export_type));
2749  $this->tpl->parseCurrentBlock();
2750  }
2751 
2752  $this->tpl->setVariable("EXPORT_BUTTON", $this->lng->txt("create_export_file"));
2753  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2754  }
2755 
2756  protected function initNewAccountMailForm()
2757  {
2758  global $lng, $ilCtrl;
2759 
2760  $lng->loadLanguageModule("meta");
2761  $lng->loadLanguageModule("mail");
2762 
2763  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2764  $form = new ilPropertyFormGUI();
2765  $form->setFormAction($ilCtrl->getFormAction($this));
2766 
2767  $form->setTitleIcon(ilUtil::getImagePath("icon_mail.gif"));
2768  $form->setTitle($lng->txt("user_new_account_mail"));
2769  $form->setDescription($lng->txt("user_new_account_mail_desc"));
2770 
2771  $langs = $lng->getInstalledLanguages();
2772  foreach($langs as $lang_key)
2773  {
2774  $amail = $this->object->_lookupNewAccountMail($lang_key);
2775 
2776  $title = $lng->txt("meta_l_".$lang_key);
2777  if ($lang_key == $lng->getDefaultLanguage())
2778  {
2779  $title .= " (".$lng->txt("default").")";
2780  }
2781 
2782  $header = new ilFormSectionHeaderGUI();
2783  $header->setTitle($title);
2784  $form->addItem($header);
2785 
2786  $subj = new ilTextInputGUI($lng->txt("subject"), "subject_".$lang_key);
2787  // $subj->setRequired(true);
2788  $subj->setValue($amail["subject"]);
2789  $form->addItem($subj);
2790 
2791  $salg = new ilTextInputGUI($lng->txt("mail_salutation_general"), "sal_g_".$lang_key);
2792  // $salg->setRequired(true);
2793  $salg->setValue($amail["sal_g"]);
2794  $form->addItem($salg);
2795 
2796  $salf = new ilTextInputGUI($lng->txt("mail_salutation_female"), "sal_f_".$lang_key);
2797  // $salf->setRequired(true);
2798  $salf->setValue($amail["sal_f"]);
2799  $form->addItem($salf);
2800 
2801  $salm = new ilTextInputGUI($lng->txt("mail_salutation_male"), "sal_m_".$lang_key);
2802  // $salm->setRequired(true);
2803  $salm->setValue($amail["sal_m"]);
2804  $form->addItem($salm);
2805 
2806  $body = new ilTextAreaInputGUI($lng->txt("message_content"), "body_".$lang_key);
2807  // $body->setRequired(true);
2808  $body->setValue($amail["body"]);
2809  $body->setRows(10);
2810  $body->setCols(100);
2811  $form->addItem($body);
2812  }
2813 
2814  $form->addCommandButton("saveNewAccountMail", $lng->txt("save"));
2815  $form->addCommandButton("cancelNewAccountMail", $lng->txt("cancel"));
2816 
2817  return $form;
2818  }
2819 
2824  {
2825  global $lng;
2826 
2827  $this->setSubTabs('settings');
2828  $this->tabs_gui->setTabActive('settings');
2829  $this->tabs_gui->setSubTabActive('user_new_account_mail');
2830 
2831  $form = $this->initNewAccountMailForm();
2832 
2833  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.usrf_new_account_mail.html');
2834  $this->tpl->setVariable("FORM", $form->getHTML());
2835 
2836  // placeholder help text
2837  $this->tpl->setVariable("TXT_USE_PLACEHOLDERS", $lng->txt("mail_nacc_use_placeholder"));
2838  $this->tpl->setVariable("TXT_MAIL_SALUTATION", $lng->txt("mail_nacc_salutation"));
2839  $this->tpl->setVariable("TXT_FIRST_NAME", $lng->txt("firstname"));
2840  $this->tpl->setVariable("TXT_LAST_NAME", $lng->txt("lastname"));
2841  $this->tpl->setVariable("TXT_EMAIL", $lng->txt("email"));
2842  $this->tpl->setVariable("TXT_LOGIN", $lng->txt("mail_nacc_login"));
2843  $this->tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
2844  $this->tpl->setVariable("TXT_PASSWORD_BLOCK", $lng->txt("mail_nacc_pw_block"));
2845  $this->tpl->setVariable("TXT_NOPASSWORD_BLOCK", $lng->txt("mail_nacc_no_pw_block"));
2846  $this->tpl->setVariable("TXT_ADMIN_MAIL", $lng->txt("mail_nacc_admin_mail"));
2847  $this->tpl->setVariable("TXT_ILIAS_URL", $lng->txt("mail_nacc_ilias_url"));
2848  $this->tpl->setVariable("TXT_CLIENT_NAME", $lng->txt("mail_nacc_client_name"));
2849  $this->tpl->setVariable("TXT_TARGET", $lng->txt("mail_nacc_target"));
2850  $this->tpl->setVariable("TXT_TARGET_TITLE", $lng->txt("mail_nacc_target_title"));
2851  $this->tpl->setVariable("TXT_TARGET_TYPE", $lng->txt("mail_nacc_target_type"));
2852  $this->tpl->setVariable("TXT_TARGET_BLOCK", $lng->txt("mail_nacc_target_block"));
2853  }
2854 
2856  {
2857  $this->ctrl->redirect($this, "settings");
2858  }
2859 
2861  {
2862  global $lng;
2863 
2864  $langs = $lng->getInstalledLanguages();
2865  foreach($langs as $lang_key)
2866  {
2867  $this->object->_writeNewAccountMail($lang_key,
2868  ilUtil::stripSlashes($_POST["subject_".$lang_key]),
2869  ilUtil::stripSlashes($_POST["sal_g_".$lang_key]),
2870  ilUtil::stripSlashes($_POST["sal_f_".$lang_key]),
2871  ilUtil::stripSlashes($_POST["sal_m_".$lang_key]),
2872  ilUtil::stripSlashes($_POST["body_".$lang_key]));
2873  }
2874 
2875  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2876  $this->ctrl->redirect($this, "newAccountMail");
2877  }
2878 
2879  function getAdminTabs(&$tabs_gui)
2880  {
2881  $this->getTabs($tabs_gui);
2882  }
2883 
2889  function getTabs(&$tabs_gui)
2890  {
2891  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
2892 
2893  global $rbacsystem;
2894 
2895  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
2896  {
2897  $tabs_gui->addTarget("obj_usrf",
2898  $this->ctrl->getLinkTarget($this, "view"), array("view","delete","resetFilter", "userAction", ""), "", "");
2899 
2900  $tabs_gui->addTarget(
2901  "search_user_extended",
2902  $this->ctrl->getLinkTargetByClass('ilAdminUserSearchGUI',''),
2903  array(),
2904  "iladminusersearchgui",
2905  ""
2906  );
2907  }
2908 
2909  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
2910  {
2911  $tabs_gui->addTarget("settings",
2912  $this->ctrl->getLinkTarget($this, "generalSettings"),array('settings','generalSettings','listUserDefinedField','newAccountMail'));
2913 
2914  $tabs_gui->addTarget("export",
2915  $this->ctrl->getLinkTarget($this, "export"), "export", "", "");
2916 
2920  {
2921  $tabs_gui->addTarget("learning_progress",
2922  $this->ctrl->getLinkTarget($this, "learningProgress"), "learningProgress", "", "");
2923  }
2924  }
2925 
2926  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2927  {
2928  $tabs_gui->addTarget("perm_settings",
2929  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
2930  array("perm","info","owner"), 'ilpermissiongui');
2931  }
2932  }
2933 
2934 
2938  function setSubTabs($a_tab)
2939  {
2940  global $rbacsystem,$ilUser;
2941 
2942  switch($a_tab)
2943  {
2944  case "settings":
2945  $this->tabs_gui->addSubTabTarget(
2946  'general_settings',
2947  $this->ctrl->getLinkTarget($this, 'generalSettings'), 'generalSettings', get_class($this));
2948  $this->tabs_gui->addSubTabTarget("standard_fields",
2949  $this->ctrl->getLinkTarget($this,'settings'),
2950  array("settings", "saveGlobalUserSettings"), get_class($this));
2951  $this->tabs_gui->addSubTabTarget("user_defined_fields",
2952  $this->ctrl->getLinkTargetByClass("ilcustomuserfieldsgui", "listUserDefinedFields"),
2953  "listUserDefinedFields",get_class($this));
2954  $this->tabs_gui->addSubTabTarget("user_new_account_mail",
2955  $this->ctrl->getLinkTarget($this,'newAccountMail'),
2956  "newAccountMail",get_class($this));
2957  $this->tabs_gui->addSubTab("account_codes", $this->lng->txt("user_account_codes"),
2958  $this->ctrl->getLinkTargetByClass("ilaccountcodesgui"));
2959  break;
2960  }
2961  }
2962 
2964  {
2965  global $ilSetting;
2966 
2967  $this->initLoginSettingsForm();
2968  $this->loginSettingsForm->setValuesByArray(array(
2969  'allow_change_loginname' => (bool)$ilSetting->get('allow_change_loginname'),
2970  'create_history_loginname' => (bool)$ilSetting->get('create_history_loginname'),
2971  'prevent_reuse_of_loginnames' => (bool)$ilSetting->get('prevent_reuse_of_loginnames'),
2972  'loginname_change_blocking_time' => (int)$ilSetting->get('loginname_change_blocking_time')
2973  ));
2974 
2975  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
2976  }
2977 
2978  private function initLoginSettingsForm()
2979  {
2980  $this->setSubTabs('settings');
2981  $this->tabs_gui->setTabActive('settings');
2982  $this->tabs_gui->setSubTabActive('loginname_settings');
2983 
2984  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2985  $this->loginSettingsForm = new ilPropertyFormGUI;
2986  $this->loginSettingsForm->setFormAction($this->ctrl->getFormAction($this, 'saveLoginnameSettings'));
2987  $this->loginSettingsForm->setTitle($this->lng->txt('loginname_settings'));
2988 
2989  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
2990  $chbChangeLogin->setValue(1);
2991  $this->loginSettingsForm->addItem($chbChangeLogin);
2992  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
2993  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
2994  $chbCreateHistory->setValue(1);
2995  $chbChangeLogin->addSubItem($chbCreateHistory);
2996  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'prevent_reuse_of_loginnames');
2997  $chbReuseLoginnames->setValue(1);
2998  $chbReuseLoginnames->setInfo($this->lng->txt('prevent_reuse_of_loginnames_contained_in_history_info'));
2999  $chbChangeLogin->addSubItem($chbReuseLoginnames);
3000  $chbChangeBlockingTime = new ilTextInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
3001  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
3002  $chbChangeBlockingTime->setSize(10);
3003  $chbChangeBlockingTime->setMaxLength(10);
3004  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
3005 
3006  $this->loginSettingsForm->addCommandButton('saveLoginnameSettings', $this->lng->txt('save'));
3007  }
3008 
3010  {
3011  global $ilUser, $ilSetting;
3012 
3013  $this->initLoginSettingsForm();
3014  if($this->loginSettingsForm->checkInput())
3015  {
3016  $valid = true;
3017 
3018  if(strlen($this->loginSettingsForm->getInput('loginname_change_blocking_time')) &&
3019  !preg_match('/^[0-9]*$/',
3020  $this->loginSettingsForm->getInput('loginname_change_blocking_time')))
3021  {
3022  $valid = false;
3023  $this->loginSettingsForm->getItemByPostVar('loginname_change_blocking_time')
3024  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
3025  }
3026 
3027  if($valid)
3028  {
3029  $ilSetting->set('allow_change_loginname', (int)$this->loginSettingsForm->getInput('allow_change_loginname'));
3030  $ilSetting->set('create_history_loginname', (int)$this->loginSettingsForm->getInput('create_history_loginname'));
3031  $ilSetting->set('prevent_reuse_of_loginnames', (int)$this->loginSettingsForm->getInput('prevent_reuse_of_loginnames'));
3032  $ilSetting->set('loginname_change_blocking_time', (int)$this->loginSettingsForm->getInput('loginname_change_blocking_time'));
3033 
3034  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
3035  }
3036  else
3037  {
3038  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
3039  }
3040  }
3041  else
3042  {
3043  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
3044  }
3045  $this->loginSettingsForm->setValuesByPost();
3046 
3047  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
3048  }
3049 
3053  function _goto($a_user)
3054  {
3055  global $ilAccess, $ilErr, $lng;
3056 
3057  $a_target = USER_FOLDER_ID;
3058 
3059  if ($ilAccess->checkAccess("read", "", $a_target))
3060  {
3061  ilUtil::redirect("ilias.php?baseClass=ilAdministrationGUI&ref_id=".$a_target."&jmpToUser=".$a_user);
3062  exit;
3063  }
3064  else
3065  {
3066  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3067  {
3068  $_GET["cmd"] = "frameset";
3069  $_GET["target"] = "";
3070  $_GET["ref_id"] = ROOT_FOLDER_ID;
3071  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3072  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3073  include("repository.php");
3074  exit;
3075  }
3076  }
3077  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
3078  }
3079 
3083  function jumpToUserObject()
3084  {
3085  global $ilCtrl;
3086 
3087  if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int)$_GET["jmpToUser"]) == "usr")
3088  {
3089  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", (int) $_GET["jmpToUser"]);
3090  $ilCtrl->redirectByClass("ilobjusergui", "view");
3091  }
3092  }
3093 
3097  public function searchResultHandler($a_cmd,$a_usr_ids)
3098  {
3099 
3100 
3101  if(!count((array) $a_usr_ids))
3102  {
3103  ilUtil::sendFailure($this->lng->txt('select_one'));
3104  return false;
3105  }
3106 
3107  $_POST['id'] = $a_usr_ids;
3108 
3109  switch($a_cmd)
3110  {
3111  /*
3112  case 'delete':
3113  return $this->deleteObject();
3114  */
3115 
3116  default:
3117  $_POST['selectedAction'] = $a_cmd;
3118  return $this->showActionConfirmation($a_cmd);
3119  }
3120 
3121  }
3122 
3123 
3124 } // END class.ilObjUserFolderGUI
3125 ?>