ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl, $lng, $rbacsystem;
25
26 $this->log = ilLoggerFactory::getLogger("user");
27
28 $this->parent_obj = $a_parent_obj;
29
30 $this->setId("usrrolesp");
31
32 parent::__construct($a_parent_obj);
33
34 $this->getItems();
35
36 $this->setLimit(9999);
37 $this->setTitle($lng->txt("user_role_starting_point"));
38
39 $this->addColumn($lng->txt("user_order"));
40 $this->addColumn($lng->txt("criteria"));
41 $this->addColumn($lng->txt("starting_page"));
42 $this->addColumn($lng->txt("actions"));
43 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
44 $this->setRowTemplate("tpl.user_role_starting_point_row.html", "Services/User");
45 $this->addCommandButton("saveOrder", $lng->txt("save_order"));
46
47 $this->setExternalSorting(true);
48
49 //require_once "./Services/AccessControl/classes/class.ilObjRole.php";
50 //$roles_without_point = ilObjRole::getGlobalRolesWithoutStartingPoint();
51 }
52
56 public function getItems()
57 {
58 global $lng;
59
60 include_once "Services/User/classes/class.ilUserUtil.php";
61 require_once "Services/Object/classes/class.ilObjectDataCache.php";
62 require_once "Services/AccessControl/classes/class.ilObjRole.php";
63 require_once "Services/AccessControl/classes/class.ilStartingPoint.php";
64 $dc = new ilObjectDataCache();
65
67
68 $status = (ilUserUtil::hasPersonalStartingPoint()? $lng->txt("yes") : $lng->txt("no"));
69
70 $result = array();
71 $result[] = array(
72 "id" => "user",
73 "criteria" => $lng->txt("user_chooses_starting_page"),
74 "starting_page" => $status,
75 "starting_position" => self::TABLE_POSITION_USER_CHOOSES
76 );
77
79
80 foreach ($points as $point) {
81 $starting_point = $point['starting_point'];
82 $position = $point['position'];
83 $sp_text = $valid_points[$starting_point];
84
85 if ($starting_point == ilUserUtil::START_REPOSITORY_OBJ && $point['starting_object']) {
86 $object_id = ilObject::_lookupObjId($point['starting_object']);
87 $type = $dc->lookupType($object_id);
88 $title = $dc->lookupTitle($object_id);
89 $sp_text = $this->lng->txt("obj_" . $type) . " <i>\"" . $title . "\"</i> [" . $point['starting_object'] . "]";
90 }
91
92 if ($point['rule_type'] == ilStartingPoint::ROLE_BASED) {
93 $options = unserialize($point['rule_options']);
94
95 $role_obj = new ilObjRole($options['role_id']);
96
97 $result[] = array(
98 "id" => $point['id'],
99 "criteria" => $role_obj->getTitle(),
100 "starting_page" => $sp_text,
101 "starting_position" => (int) $position,
102 "role_id" => $role_obj->getId()
103 );
104 }
105 }
106
107 $default_sp = ilUserUtil::getStartingPoint();
108 $starting_point = $valid_points[$default_sp];
109 if ($default_sp == ilUserUtil::START_REPOSITORY_OBJ) {
110 $reference_id = ilUserUtil::getStartingObject();
111
112 $object_id = ilObject::_lookupObjId($reference_id);
113 $type = $dc->lookupType($object_id);
114 $title = $dc->lookupTitle($object_id);
115 $starting_point = $this->lng->txt("obj_" . $type) . " " . "<i>\"" . $title . "\" ($reference_id)</i>";
116 }
117
118 $result[] = array(
119 "id" => "default",
120 "criteria" => $lng->txt("default"),
121 "starting_page" => $starting_point,
122 "starting_position" => self::TABLE_POSITION_DEFAULT
123 );
124
125 $result = ilUtil::sortArray($result, "starting_position", "asc", true);
126
128
129 $this->setData($result);
130 }
131
135 protected function fillRow($a_set)
136 {
137 global $lng, $ilCtrl;
138
139 include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
140
142 $list->setListTitle($lng->txt("actions"));
143
144 $ilCtrl->setParameter($this->getParentObject(), "spid", $a_set['id']);
145
146
147 if ($a_set['id'] > 0 && $a_set['id'] != 'default' && $a_set['id'] != 'user') {
149 $ilCtrl->setParameter($this->getParentObject(), "rolid", $a_set["role_id"]);
150 }
151
152 $list->setId($a_set["id"]);
153
154 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initRoleStartingPointForm");
155 $list->addItem($lng->txt("edit"), "", $edit_url);
156 $delete_url = $ilCtrl->getLinkTarget($this->getParentObject(), "confirmDeleteStartingPoint");
157 $list->addItem($lng->txt("delete"), "", $delete_url);
158 $this->tpl->setVariable("VAL_ID", "position[" . $a_set['id'] . "]");
159 $this->tpl->setVariable("VAL_POS", $a_set["starting_position"]);
160
161 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("has_role") . ": " . $a_set["criteria"]);
162 } else {
163 if ($a_set['id'] == "default") {
164 $ilCtrl->setParameter($this->getParentObject(), "rolid", "default");
165 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initRoleStartingPointForm");
166 } else {
167 $ilCtrl->setParameter($this->getParentObject(), "rolid", "user");
168 $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "initUserStartingPointForm");
169 }
170
171 $list->addItem($lng->txt("edit"), "", $edit_url);
172
173 $this->tpl->setVariable("HIDDEN", "hidden");
174
175 $this->tpl->setVariable("TXT_TITLE", $a_set["criteria"]);
176 }
177
178 $this->tpl->setVariable("TXT_PAGE", $a_set["starting_page"]);
179
180 $this->tpl->setVariable("ACTION", $list->getHTML());
181 }
182}
$result
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
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 _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 $ilCtrl
Definition: ilias.php:18
$type
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41