ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjectOwnershipManagementGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
5
15{
19 protected $user;
20
24 protected $ctrl;
25
29 protected $tpl;
30
34 protected $toolbar;
35
39 protected $lng;
40
44 protected $obj_definition;
45
49 protected $tree;
50
51 protected $user_id; // [int]
52
53 public function __construct($a_user_id = null)
54 {
55 global $DIC;
56
57 $this->user = $DIC->user();
58 $this->ctrl = $DIC->ctrl();
59 $this->tpl = $DIC["tpl"];
60 $this->toolbar = $DIC->toolbar();
61 $this->lng = $DIC->language();
62 $this->obj_definition = $DIC["objDefinition"];
63 $this->tree = $DIC->repositoryTree();
64 $ilUser = $DIC->user();
65
66 if ($a_user_id === null) {
67 $a_user_id = $ilUser->getId();
68 }
69 $this->user_id = (int) $a_user_id;
70 }
71
72 public function executeCommand()
73 {
75
76 $next_class = $ilCtrl->getNextClass($this);
77 $cmd = $ilCtrl->getCmd();
78
79 switch ($next_class) {
80 default:
81 if (!$cmd) {
82 $cmd = "listObjects";
83 }
84 $this->$cmd();
85 break;
86 }
87
88 return true;
89 }
90
91 public function listObjects()
92 {
94 $ilToolbar = $this->toolbar;
97 $objDefinition = $this->obj_definition;
98
99 $sel_type = '';
100
101 $objects = ilObject::getAllOwnedRepositoryObjects($this->user_id);
102
103 if (sizeof($objects)) {
104 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "listObjects"));
105
106 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
107 $sel = new ilSelectInputGUI($lng->txt("type"), "type");
108 $ilToolbar->addStickyItem($sel, true);
109
110 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
111 $button = ilSubmitButton::getInstance();
112 $button->setCaption("ok");
113 $button->setCommand("listObjects");
114 $ilToolbar->addStickyItem($button);
115
116 $options = array();
117 foreach (array_keys($objects) as $type) {
118 // #11050
119 if (!$objDefinition->isPlugin($type)) {
120 $options[$type] = $lng->txt("obj_" . $type);
121 } else {
122 include_once("./Services/Component/classes/class.ilPlugin.php");
124 }
125 }
126 asort($options);
127 $sel->setOptions($options);
128
129 $sel_type = (string) $_REQUEST["type"];
130 if ($sel_type) {
131 $sel->setValue($sel_type);
132 } else {
133 $sel_type = array_keys($options);
134 $sel_type = array_shift($sel_type);
135 }
136 $ilCtrl->setParameter($this, "type", $sel_type);
137 }
138
139 // #17751
140 if (is_array($objects[$sel_type]) && sizeof($objects[$sel_type])) {
141 ilObject::fixMissingTitles($sel_type, $objects[$sel_type]);
142 }
143
144 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
145 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id, $objects[$sel_type]);
146 $tpl->setContent($tbl->getHTML());
147 }
148
149 public function applyFilter()
150 {
151 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
152 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id);
153 $tbl->resetOffset();
154 $tbl->writeFilterToSession();
155 $this->listObjects();
156 }
157
158 public function resetFilter()
159 {
160 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
161 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id);
162 $tbl->resetOffset();
163 $tbl->resetFilter();
164 $this->listObjects();
165 }
166
167 protected function redirectParentCmd($a_ref_id, $a_cmd)
168 {
171
172 $parent = $tree->getParentId($a_ref_id);
173 $ilCtrl->setParameterByClass("ilRepositoryGUI", "ref_id", $parent);
174 $ilCtrl->setParameterByClass("ilRepositoryGUI", "item_ref_id", $a_ref_id);
175 $ilCtrl->setParameterByClass("ilRepositoryGUI", "cmd", $a_cmd);
176 $ilCtrl->redirectByClass("ilRepositoryGUI");
177 }
178
179 protected function redirectCmd($a_ref_id, $a_class, $a_cmd = null)
180 {
183 $objDefinition = $this->obj_definition;
184
185 $node = $tree->getNodeData($a_ref_id);
186 $gui_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
187 $path = array("ilRepositoryGUI", $gui_class, $a_class);
188
189 // #10495 - check if object type supports ilexportgui "directly"
190 if ($a_class == "ilExportGUI") {
191 try {
192 $ilCtrl->getLinkTargetByClass($path);
193 } catch (Exception $e) {
194 switch ($node["type"]) {
195 case "glo":
196 $cmd = "exportList";
197 $path = array("ilRepositoryGUI", "ilGlossaryEditorGUI", $gui_class);
198 break;
199
200 default:
201 $cmd = "export";
202 $path = array("ilRepositoryGUI", $gui_class);
203 break;
204 }
205 $ilCtrl->setParameterByClass($gui_class, "ref_id", $a_ref_id);
206 $ilCtrl->setParameterByClass($gui_class, "cmd", $cmd);
207 $ilCtrl->redirectByClass($path);
208 }
209 }
210
211 $ilCtrl->setParameterByClass($a_class, "ref_id", $a_ref_id);
212 $ilCtrl->setParameterByClass($a_class, "cmd", $a_cmd);
213 $ilCtrl->redirectByClass($path);
214 }
215
216 public function delete()
217 {
218 $ref_id = (int) $_REQUEST["ownid"];
219 $this->redirectParentCmd($ref_id, "delete");
220 }
221
222 public function move()
223 {
224 $ref_id = (int) $_REQUEST["ownid"];
225 $this->redirectParentCmd($ref_id, "cut");
226 }
227
228 public function export()
229 {
230 $ref_id = (int) $_REQUEST["ownid"];
231 $this->redirectCmd($ref_id, "ilExportGUI");
232 }
233
234 public function changeOwner()
235 {
236 $ref_id = (int) $_REQUEST["ownid"];
237 $this->redirectCmd($ref_id, "ilPermissionGUI", "owner");
238 }
239}
user()
Definition: user.php:4
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
Class ilObjectOwnershipManagementGUI.
static lookupTxtById($plugin_id, $lang_var)
static getAllOwnedRepositoryObjects($a_user_id)
Get all ids of objects user owns.
static fixMissingTitles($a_type, array &$a_obj_title_map)
Try to fix missing object titles.
This class represents a selection list property in a property form.
static getInstance()
Factory.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
$type
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18