ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $lng, $ilCtrl, $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 $this->addColumn($this->lng->txt("firstname"), "first_name");
57 $this->addColumn($this->lng->txt("lastname"), "last_name");
58 if ($this->recursive) {
59 $this->addColumn($this->lng->txt('obj_orgu'), 'org_units');
60 }
61 $this->addColumn($this->lng->txt("action"));
62 }
63
64 public function parseData(){
65 if($this->staff == "employee")
66 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getEmployees($_GET["ref_id"], $this->recursive));
67 elseif($this->staff == "superior")
68 $data = $this->parseRows(ilObjOrgUnitTree::_getInstance()->getSuperiors($_GET["ref_id"], $this->recursive));
69 else
70 throw new Exception("The ilOrgUnitStaffTableGUI's staff variable has to be either 'employee' or 'superior'");
71
72 $this->setData($data);
73 }
74
75 protected function parseRows($user_ids){
76 $data = array();
77 foreach($user_ids as $user_id){
78 $set = array();
79 $this->setRowForUser($set, $user_id);
80 $data[] = $set;
81 }
82 return $data;
83 }
84
88 public function setStaff($staff)
89 {
90 $this->staff = $staff;
91 }
92
96 public function getStaff()
97 {
98 return $this->staff;
99 }
100
101 protected function setRowForUser(&$set, $user_id){
102 $user = new ilObjUser($user_id);
103 $set["first_name"] = $user->getFirstname();
104 $set["last_name"] = $user->getLastname();
105 $set["user_object"] = $user;
106 $set["user_id"] = $user_id;
107 if ($this->recursive) $set["org_units"] = ilObjOrgUnitTree::_getInstance()->getOrgUnitOfUser($user_id, (int)$_GET['ref_id']);
108 }
109
110 function fillRow($set){
111 global $ilUser, $Access, $lng, $ilAccess;
112 $this->tpl->setVariable("FIRST_NAME", $set["first_name"]);
113 $this->tpl->setVariable("LAST_NAME", $set["last_name"]);
114 if ($this->recursive) {
115 $orgUnitsTitles = array_values(ilObjOrgUnitTree::_getInstance()->getTitles($set['org_units']));
116 $this->tpl->setVariable("ORG_UNITS", implode(', ', $orgUnitsTitles));
117 }
118 $this->ctrl->setParameterByClass("illearningprogressgui", "obj_id", $set["user_id"]);
119 $this->ctrl->setParameterByClass("ilobjorgunitgui", "obj_id", $set["user_id"]);
120 $selection = new ilAdvancedSelectionListGUI();
121 $selection->setListTitle($lng->txt("Actions"));
122 $selection->setId("selection_list_user_lp_".$set["user_id"]);
123
124 if($ilAccess->checkAccess("view_learning_progress", "", $_GET["ref_id"]) AND ilObjUserTracking::_enabledLearningProgress() and
126 $selection->addItem($lng->txt("show_learning_progress"), "show_learning_progress", $this->ctrl->getLinkTargetByClass(array("ilAdministrationGUI", "ilObjOrgUnitGUI", "ilLearningProgressGUI"), ""));
127 }
128 if($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->recursive){
129 if($this->staff == "employee")
130 $this->addEmployeeActions($selection);
131 if($this->staff == "superior")
132 $this->addSuperiorActions($selection);
133 }
134 $this->tpl->setVariable("ACTIONS", $selection->getHTML());
135
136 }
137
141 protected function addEmployeeActions(&$selection){
142 $selection->addItem($this->lng->txt("remove"), "delete_from_employees", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromEmployees"));
143 $selection->addItem($this->lng->txt("change_to_superior"), "change_to_superior", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromEmployeeToSuperior"));
144 }
145
149 protected function addSuperiorActions(&$selection){
150 $selection->addItem($this->lng->txt("remove"), "delete_from_superiors", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "confirmRemoveFromSuperiors"));
151 $selection->addItem($this->lng->txt("change_to_employee"), "change_to_employee", $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "fromSuperiorToEmployee"));
152 }
153
157 public function setRecursive($recursive){
158 $this->recursive = $recursive;
159 }
160
161
162}
163?>
$_GET["client_id"]
User interface class for advanced drop-down selection lists.
static _getInstance()
singleton access.
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.
setFormName($a_formname)
Set Form name.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
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:40
global $ilUser
Definition: imgupload.php:15