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