ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilOrgUnitStaffTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3require_once("./Services/Table/classes/class.ilTable2GUI.php");
4require_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
5require_once("./Services/Tracking/classes/class.ilObjUserTracking.php");
14
16 private $recursive = false;
17
19 private $staff = "employee";
20
21 public function __construct($parent_obj, $parent_cmd, $staff = "employee", $recursive = false, $template_context = ""){
22
23
24 global $DIC;
25 $lng = $DIC['lng'];
26 $ilCtrl = $DIC['ilCtrl'];
27 $ilTabs = $DIC['ilTabs'];
32 $this->ctrl = $ilCtrl;
33 $this->tabs = $ilTabs;
34 $this->lng = $lng;
35
36 $this->setPrefix("il_orgu_".$staff);
37 $this->setFormName('il_orgu_'.$staff);
38 $this->setId("il_orgu_".$staff);
39
40 parent::__construct($parent_obj, $parent_cmd, $template_context);
41
42 $this->setFormAction($this->ctrl->getFormAction($parent_obj));
43 $this->setStaff($staff);
44 $this->recursive = $recursive;
45 $this->setTableHeaders();
46 $this->setTopCommands(true);
47 $this->setEnableHeader(true);
48 $this->setShowRowsSelector(true);
49 $this->setShowTemplates(false);
50 $this->setEnableHeader(true);
51 $this->setDefaultOrderField("role");
52 $this->setEnableTitle(true);
53 $this->setTitle($this->lng->txt("Staff"));
54 $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
55 }
56
57
58 protected function setTableHeaders(){
59 $this->addColumn($this->lng->txt("firstname"), "first_name");
60 $this->addColumn($this->lng->txt("lastname"), "last_name");
61 if ($this->recursive) {
62 $this->addColumn($this->lng->txt('obj_orgu'), 'org_units');
63 }
64 $this->addColumn($this->lng->txt("action"));
65 }
66
67 public function parseData(){
68 if($this->staff == "employee")
69 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getEmployees($_GET["ref_id"], $this->recursive));
70 elseif($this->staff == "superior")
71 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getSuperiors($_GET["ref_id"], $this->recursive));
72 else
73 throw new Exception("The ilOrgUnitStaffTableGUI's staff variable has to be either 'employee' or 'superior'");
74
75 $this->setData($data);
76 }
77
78 protected function parseRows($user_ids){
79 $data = array();
80 foreach($user_ids as $user_id){
81 $set = array();
82 $this->setRowForUser($set, $user_id);
83 $data[] = $set;
84 }
85 return $data;
86 }
87
91 public function setStaff($staff)
92 {
93 $this->staff = $staff;
94 }
95
99 public function getStaff()
100 {
101 return $this->staff;
102 }
103
104 protected function setRowForUser(&$set, $user_id){
105 $user = new ilObjUser($user_id);
106 $set["first_name"] = $user->getFirstname();
107 $set["last_name"] = $user->getLastname();
108 $set["user_object"] = $user;
109 $set["user_id"] = $user_id;
110 if ($this->recursive) $set["org_units"] = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id, (int)$_GET['ref_id']);
111 }
112
113 function fillRow($set){
114 global $DIC;
115 $ilUser = $DIC['ilUser'];
116 $ilAccess = $DIC['ilAccess'];
117 $lng = $DIC['lng'];
118 $ilAccess = $DIC['ilAccess'];
119 $this->tpl->setVariable("FIRST_NAME", $set["first_name"]);
120 $this->tpl->setVariable("LAST_NAME", $set["last_name"]);
121 if ($this->recursive) {
122 $orgUnitsTitles = array_values(ilObjOrgUnitTree::_getInstance()->getTitles($set['org_units']));
123 $this->tpl->setVariable("ORG_UNITS", implode(', ', $orgUnitsTitles));
124 }
125 $this->ctrl->setParameterByClass("illearningprogressgui", "obj_id", $set["user_id"]);
126 $this->ctrl->setParameterByClass("ilobjorgunitgui", "obj_id", $set["user_id"]);
127 $selection = new ilAdvancedSelectionListGUI();
128 $selection->setListTitle($lng->txt("Actions"));
129 $selection->setId("selection_list_user_lp_".$set["user_id"]);
130
131 if($ilAccess->checkAccess("view_learning_progress", "", $_GET["ref_id"]) AND ilObjUserTracking::_enabledLearningProgress() and
133 $selection->addItem($lng->txt("show_learning_progress"), "show_learning_progress", $this->ctrl->getLinkTargetByClass(array("ilAdministrationGUI", "ilObjOrgUnitGUI", "ilLearningProgressGUI"), ""));
134 }
135 if($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->recursive){
136 if($this->staff == "employee")
137 $this->addEmployeeActions($selection);
138 if($this->staff == "superior")
139 $this->addSuperiorActions($selection);
140 }
141 $this->tpl->setVariable("ACTIONS", $selection->getHTML());
142
143 }
144
148 protected function addEmployeeActions(&$selection){
149 $selection->addItem($this->lng->txt("remove"), "delete_from_employees", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromEmployees"));
150 $selection->addItem($this->lng->txt("change_to_superior"), "change_to_superior", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromEmployeeToSuperior"));
151 }
152
156 protected function addSuperiorActions(&$selection){
157 $selection->addItem($this->lng->txt("remove"), "delete_from_superiors", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromSuperiors"));
158 $selection->addItem($this->lng->txt("change_to_employee"), "change_to_employee", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromSuperiorToEmployee"));
159 }
160
164 public function setRecursive($recursive){
165 $this->recursive = $recursive;
166 }
167
168
169}
170?>
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
Class ilOrgUnitStaffTableGUI.
fillRow($set)
Standard Version of Fill Row.
Class ilTable2GUI.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
Constructor.
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setShowTemplates($a_value)
Toggle templates.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $DIC
$ilUser
Definition: imgupload.php:18