ILIAS  release_7 Revision v7.30-3-g800a261c036
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 */
3
12{
13
15 private $recursive = false;
17 private $staff = "employee";
18
19
20 public function __construct($parent_obj, $parent_cmd, $staff = "employee", $recursive = false, $template_context = "")
21 {
22 global $DIC;
23 $lng = $DIC['lng'];
24 $ilCtrl = $DIC['ilCtrl'];
25 $ilTabs = $DIC['ilTabs'];
30 $this->ctrl = $ilCtrl;
31 $this->tabs = $ilTabs;
32 $this->lng = $lng;
33
34 $this->setPrefix("il_orgu_" . $staff);
35 $this->setFormName('il_orgu_' . $staff);
36 $this->setId("il_orgu_" . $staff);
37
38 parent::__construct($parent_obj, $parent_cmd, $template_context);
39
40 $this->setFormAction($this->ctrl->getFormAction($parent_obj));
41 $this->setStaff($staff);
42 $this->recursive = $recursive;
43 $this->setTableHeaders();
44 $this->setTopCommands(true);
45 $this->setEnableHeader(true);
46 $this->setShowRowsSelector(true);
47 $this->setShowTemplates(false);
48 $this->setEnableHeader(true);
49 $this->setDefaultOrderField("role");
50 $this->setEnableTitle(true);
51 $this->setTitle($this->lng->txt("Staff"));
52 $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
53 }
54
55
56 protected function setTableHeaders()
57 {
58 $this->addColumn($this->lng->txt("firstname"), "first_name");
59 $this->addColumn($this->lng->txt("lastname"), "last_name");
60 if ($this->recursive) {
61 $this->addColumn($this->lng->txt('obj_orgu'), 'org_units');
62 }
63 $this->addColumn($this->lng->txt("action"));
64 }
65
66
67 public function parseData()
68 {
69 if ($this->staff == "employee") {
70 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getEmployees($_GET["ref_id"], $this->recursive));
71 } elseif ($this->staff == "superior") {
72 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getSuperiors($_GET["ref_id"], $this->recursive));
73 } else {
74 throw new Exception("The ilOrgUnitStaffTableGUI's staff variable has to be either 'employee' or 'superior'");
75 }
76
77 $this->setData($data);
78 }
79
80
81 protected function parseRows($user_ids)
82 {
83 $data = array();
84 foreach ($user_ids as $user_id) {
85 $set = array();
86 $this->setRowForUser($set, $user_id);
87 $data[] = $set;
88 }
89
90 return $data;
91 }
92
93
97 public function setStaff($staff)
98 {
99 $this->staff = $staff;
100 }
101
102
106 public function getStaff()
107 {
108 return $this->staff;
109 }
110
111
112 protected function setRowForUser(&$set, $user_id)
113 {
114 $user = new ilObjUser($user_id);
115 $set["first_name"] = $user->getFirstname();
116 $set["last_name"] = $user->getLastname();
117 $set["user_object"] = $user;
118 $set["user_id"] = $user_id;
119 if ($this->recursive) {
120 $set["org_units"] = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id);
121 }
122 }
123
124
125 public function fillRow($set)
126 {
127 global $DIC;
128 $ilUser = $DIC['ilUser'];
129 $ilAccess = $DIC['ilAccess'];
130 $lng = $DIC['lng'];
131 $ilAccess = $DIC['ilAccess'];
132 $this->tpl->setVariable("FIRST_NAME", $set["first_name"]);
133 $this->tpl->setVariable("LAST_NAME", $set["last_name"]);
134 if ($this->recursive) {
135 $orgUnitsTitles = array_values(ilObjOrgUnitTree::_getInstance()->getTitles($set['org_units']));
136 $this->tpl->setVariable("ORG_UNITS", implode(', ', $orgUnitsTitles));
137 }
138 $this->ctrl->setParameterByClass("illearningprogressgui", "obj_id", $set["user_id"]);
139 $this->ctrl->setParameterByClass("ilobjorgunitgui", "obj_id", $set["user_id"]);
140 $selection = new ilAdvancedSelectionListGUI();
141 $selection->setListTitle($lng->txt("Actions"));
142 $selection->setId("selection_list_user_lp_" . $set["user_id"]);
143
144 if ($ilAccess->checkAccess("view_learning_progress", "", $_GET["ref_id"]) and ilObjUserTracking::_enabledLearningProgress() and
146 ) {
147 $selection->addItem(
148 $lng->txt("show_learning_progress"),
149 "show_learning_progress",
150 $this->ctrl->getLinkTargetByClass(array("ilAdministrationGUI", "ilObjOrgUnitGUI", "ilLearningProgressGUI"), "")
151 );
152 }
153 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->recursive) {
154 if ($this->staff == "employee") {
155 $this->addEmployeeActions($selection);
156 }
157 if ($this->staff == "superior") {
158 $this->addSuperiorActions($selection);
159 }
160 }
161 $this->tpl->setVariable("ACTIONS", $selection->getHTML());
162 }
163
164
168 protected function addEmployeeActions(&$selection)
169 {
170 $selection->addItem($this->lng->txt("remove"), "delete_from_employees", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromEmployees"));
171 $selection->addItem($this->lng->txt("change_to_superior"), "change_to_superior", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromEmployeeToSuperior"));
172 }
173
174
178 protected function addSuperiorActions(&$selection)
179 {
180 $selection->addItem($this->lng->txt("remove"), "delete_from_superiors", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromSuperiors"));
181 $selection->addItem($this->lng->txt("change_to_employee"), "change_to_employee", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromSuperiorToEmployee"));
182 }
183
184
188 public function setRecursive($recursive)
189 {
190 $this->recursive = $recursive;
191 }
192}
$_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.
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="")
ilTable2GUI constructor.
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
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 $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc