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