ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilUserRoleStartingPointTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-20016 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("Services/Table/classes/class.ilTable2GUI.php");
5
15{
16 protected $log;
17 protected $parent_obj;
18
21
22 public function __construct($a_parent_obj)
23 {
24 global $DIC;
25
26 $ilCtrl = $DIC['ilCtrl'];
27 $lng = $DIC['lng'];
28 $rbacsystem = $DIC['rbacsystem'];
29
30 $this->log = ilLoggerFactory::getLogger("user");
31
32 $this->parent_obj = $a_parent_obj;
33
34 $this->setId("usrrolesp");
35
36 parent::__construct($a_parent_obj);
37
38 $this->getItems();
39
40 $this->setLimit(9999);
41 $this->setTitle($lng->txt("user_role_starting_point"));
42
43 $this->addColumn($lng->txt("user_order"));
44 $this->addColumn($lng->txt("criteria"));
45 $this->addColumn($lng->txt("starting_page"));
46 $this->addColumn($lng->txt("actions"));
47 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
48 $this->setRowTemplate("tpl.user_role_starting_point_row.html", "Services/User");
49 $this->addCommandButton("saveOrder", $lng->txt("save_order"));
50
51 $this->setExternalSorting(true);
52
53 //require_once "./Services/AccessControl/classes/class.ilObjRole.php";
54 //$roles_without_point = ilObjRole::getGlobalRolesWithoutStartingPoint();
55 }
56
60 public function getItems()
61 {
62 global $DIC;
63
64 $lng = $DIC['lng'];
65
66 include_once "Services/User/classes/class.ilUserUtil.php";
67 require_once "Services/Object/classes/class.ilObjectDataCache.php";
68 require_once "Services/AccessControl/classes/class.ilObjRole.php";
69 require_once "Services/AccessControl/classes/class.ilStartingPoint.php";
70 $dc = new ilObjectDataCache();
71
73
74 $status = (ilUserUtil::hasPersonalStartingPoint()? $lng->txt("yes") : $lng->txt("no"));
75
76 $result = array();
77 $result[] = array(
78 "id" => "user",
79 "criteria" => $lng->txt("user_chooses_starting_page"),
80 "starting_page" => $status,
81 "starting_position" => self::TABLE_POSITION_USER_CHOOSES
82 );
83
85
86 foreach ($points as $point) {
87 $starting_point = $point['starting_point'];
88 $position = $point['position'];
89 $sp_text = $valid_points[$starting_point];
90
91 if ($starting_point == ilUserUtil::START_REPOSITORY_OBJ && $point['starting_object']) {
92 $object_id = ilObject::_lookupObjId($point['starting_object']);
93 $type = $dc->lookupType($object_id);
94 $title = $dc->lookupTitle($object_id);
95 $sp_text = $this->lng->txt("obj_" . $type) . " <i>\"" . $title . "\"</i> [" . $point['starting_object'] . "]";
96 }
97
98 if ($point['rule_type'] == ilStartingPoint::ROLE_BASED) {
99 $options = unserialize($point['rule_options']);
100
101 $role_obj = ilObjectFactory::getInstanceByObjId($options['role_id'], false);
102 if (!$role_obj || !($role_obj instanceof \ilObjRole)) {
103 continue;
104 }
105
106 $result[] = array(
107 "id" => $point['id'],
108 "criteria" => $role_obj->getTitle(),
109 "starting_page" => $sp_text,
110 "starting_position" => (int) $position,
111 "role_id" => $role_obj->getId()
112 );
113 }
114 }
115
116 $default_sp = ilUserUtil::getStartingPoint();
117 $starting_point = $valid_points[$default_sp];
118 if ($default_sp == ilUserUtil::START_REPOSITORY_OBJ) {
119 $reference_id = ilUserUtil::getStartingObject();
120
121 $object_id = ilObject::_lookupObjId($reference_id);
122 $type = $dc->lookupType($object_id);
123 $title = $dc->lookupTitle($object_id);
124 $starting_point = $this->lng->txt("obj_" . $type) . " " . "<i>\"" . $title . "\" ($reference_id)</i>";
125 }
126
127 $result[] = array(
128 "id" => "default",
129 "criteria" => $lng->txt("default"),
130 "starting_page" => $starting_point,
131 "starting_position" => self::TABLE_POSITION_DEFAULT
132 );
133
134 $result = ilUtil::sortArray($result, "starting_position", "asc", true);
135
137
138 $this->setData($result);
139 }
140
144 protected function fillRow($a_set)
145 {
146 global $DIC;
147
148 $lng = $DIC['lng'];
149 $ilCtrl = $DIC['ilCtrl'];
150
151 include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
152
153 $list = new ilAdvancedSelectionListGUI();
154 $list->setListTitle($lng->txt("actions"));
155
156 $ilCtrl->setParameter($this->getParentObject(), "spid", $a_set['id']);
157
158
159 if ($a_set['id'] > 0 && $a_set['id'] != 'default' && $a_set['id'] != 'user') {
161 $ilCtrl->setParameter($this->getParentObject(), "rolid", $a_set["role_id"]);
162 }
163
164 $list->setId($a_set["id"]);
165
166 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initRoleStartingPointForm");
167 $list->addItem($lng->txt("edit"), "", $edit_url);
168 $delete_url = $ilCtrl->getLinkTarget($this->getParentObject(), "confirmDeleteStartingPoint");
169 $list->addItem($lng->txt("delete"), "", $delete_url);
170 $this->tpl->setVariable("VAL_ID", "position[" . $a_set['id'] . "]");
171 $this->tpl->setVariable("VAL_POS", $a_set["starting_position"]);
172
173 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("has_role") . ": " . $a_set["criteria"]);
174 } else {
175 if ($a_set['id'] == "default") {
176 $ilCtrl->setParameter($this->getParentObject(), "rolid", "default");
177 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initRoleStartingPointForm");
178 } else {
179 $ilCtrl->setParameter($this->getParentObject(), "rolid", "user");
180 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initUserStartingPointForm");
181 }
182
183 $list->addItem($lng->txt("edit"), "", $edit_url);
184
185 $this->tpl->setVariable("HIDDEN", "hidden");
186
187 $this->tpl->setVariable("TXT_TITLE", $a_set["criteria"]);
188 }
189
190 $this->tpl->setVariable("TXT_PAGE", $a_set["starting_page"]);
191
192 $this->tpl->setVariable("ACTION", $list->getHTML());
193 }
194}
$result
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static getLogger($a_component_id)
Get component logger.
Class ilObjRole.
class ilObjectDataCache
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
static getStartingPoints()
Get all the starting points in database.
static reArrangePositions($a_items)
Class ilTable2GUI.
setExternalSorting($a_val)
Set external sorting.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
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.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
TableGUI class for LTI consumer listing.
static getPossibleStartingPoints($a_force_all=false)
Get all valid starting points.
static hasPersonalStartingPoint()
Can starting point be personalized?
static getStartingPoint()
Get current starting point setting.
static getStartingObject()
Get ref id of starting object.
const START_REPOSITORY_OBJ
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type