ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 */
11 {
12 
14  private $recursive = false;
15 
17  private $staff = "employee";
18 
19  public function __construct($parent_obj, $parent_cmd, $staff = "employee", $recursive = false, $template_context = "")
20  {
21  global $DIC;
22  $lng = $DIC['lng'];
23  $ilCtrl = $DIC['ilCtrl'];
24  $ilTabs = $DIC['ilTabs'];
29  $this->ctrl = $ilCtrl;
30  $this->tabs = $ilTabs;
31  $this->lng = $lng;
32 
33  $this->setPrefix("il_orgu_" . $staff);
34  $this->setFormName('il_orgu_' . $staff);
35  $this->setId("il_orgu_" . $staff);
36 
37  parent::__construct($parent_obj, $parent_cmd, $template_context);
38 
39  $this->setFormAction($this->ctrl->getFormAction($parent_obj));
40  $this->setStaff($staff);
41  $this->recursive = $recursive;
42  $this->setTableHeaders();
43  $this->setTopCommands(true);
44  $this->setEnableHeader(true);
45  $this->setShowRowsSelector(true);
46  $this->setShowTemplates(false);
47  $this->setEnableHeader(true);
48  $this->setDefaultOrderField("role");
49  $this->setEnableTitle(true);
50  $this->setTitle($this->lng->txt("Staff"));
51  $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
52  }
53 
54 
55  protected function setTableHeaders()
56  {
57  $this->addColumn($this->lng->txt("firstname"), "first_name");
58  $this->addColumn($this->lng->txt("lastname"), "last_name");
59  if ($this->recursive) {
60  $this->addColumn($this->lng->txt('obj_orgu'), 'org_units');
61  }
62  $this->addColumn($this->lng->txt("action"));
63  }
64 
65  public function parseData()
66  {
67  if ($this->staff == "employee") {
68  $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getEmployees($_GET["ref_id"], $this->recursive));
69  } elseif ($this->staff == "superior") {
70  $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getSuperiors($_GET["ref_id"], $this->recursive));
71  } else {
72  throw new Exception("The ilOrgUnitStaffTableGUI's staff variable has to be either 'employee' or 'superior'");
73  }
74 
75  $this->setData($data);
76  }
77 
78  protected function parseRows($user_ids)
79  {
80  $data = array();
81  foreach ($user_ids as $user_id) {
82  $set = array();
83  $this->setRowForUser($set, $user_id);
84  $data[] = $set;
85  }
86  return $data;
87  }
88 
92  public function setStaff($staff)
93  {
94  $this->staff = $staff;
95  }
96 
100  public function getStaff()
101  {
102  return $this->staff;
103  }
104 
105  protected function setRowForUser(&$set, $user_id)
106  {
107  $user = new ilObjUser($user_id);
108  $set["first_name"] = $user->getFirstname();
109  $set["last_name"] = $user->getLastname();
110  $set["user_object"] = $user;
111  $set["user_id"] = $user_id;
112  if ($this->recursive) {
113  $set["org_units"] = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id, (int) $_GET['ref_id']);
114  }
115  }
116 
117  public function fillRow($set)
118  {
119  global $DIC;
120  $ilUser = $DIC['ilUser'];
121  $ilAccess = $DIC['ilAccess'];
122  $lng = $DIC['lng'];
123  $ilAccess = $DIC['ilAccess'];
124  $this->tpl->setVariable("FIRST_NAME", $set["first_name"]);
125  $this->tpl->setVariable("LAST_NAME", $set["last_name"]);
126  if ($this->recursive) {
127  $orgUnitsTitles = array_values(ilObjOrgUnitTree::_getInstance()->getTitles($set['org_units']));
128  $this->tpl->setVariable("ORG_UNITS", implode(', ', $orgUnitsTitles));
129  }
130  $this->ctrl->setParameterByClass("illearningprogressgui", "obj_id", $set["user_id"]);
131  $this->ctrl->setParameterByClass("ilobjorgunitgui", "obj_id", $set["user_id"]);
132  $selection = new ilAdvancedSelectionListGUI();
133  $selection->setListTitle($lng->txt("Actions"));
134  $selection->setId("selection_list_user_lp_" . $set["user_id"]);
135 
136  if ($ilAccess->checkAccess("view_learning_progress", "", $_GET["ref_id"]) and ilObjUserTracking::_enabledLearningProgress() and
138  $selection->addItem($lng->txt("show_learning_progress"), "show_learning_progress", $this->ctrl->getLinkTargetByClass(array("ilAdministrationGUI", "ilObjOrgUnitGUI", "ilLearningProgressGUI"), ""));
139  }
140  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->recursive) {
141  if ($this->staff == "employee") {
142  $this->addEmployeeActions($selection);
143  }
144  if ($this->staff == "superior") {
145  $this->addSuperiorActions($selection);
146  }
147  }
148  $this->tpl->setVariable("ACTIONS", $selection->getHTML());
149  }
150 
154  protected function addEmployeeActions(&$selection)
155  {
156  $selection->addItem($this->lng->txt("remove"), "delete_from_employees", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromEmployees"));
157  $selection->addItem($this->lng->txt("change_to_superior"), "change_to_superior", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromEmployeeToSuperior"));
158  }
159 
163  protected function addSuperiorActions(&$selection)
164  {
165  $selection->addItem($this->lng->txt("remove"), "delete_from_superiors", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromSuperiors"));
166  $selection->addItem($this->lng->txt("change_to_employee"), "change_to_employee", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromSuperiorToEmployee"));
167  }
168 
172  public function setRecursive($recursive)
173  {
174  $this->recursive = $recursive;
175  }
176 }
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
setShowTemplates($a_value)
Toggle templates.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
Class ilOrgUnitStaffTableGUI.
setPrefix($a_prefix)
$ilUser
Definition: imgupload.php:18
$user
Definition: migrateto20.php:57
setRowTemplate($a_template, $a_template_dir="")
Set row template.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFormName($a_formname="")
Set Form name.
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.
setEnableHeader($a_enableheader)
Set Enable Header.
setEnableTitle($a_enabletitle)
Set Enable Title.