ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 */
4
14{
15 protected $user_id; // [int]
16
17 function __construct($a_user_id = null)
18 {
19 global $ilUser;
20
21 if($a_user_id === null)
22 {
23 $a_user_id = $ilUser->getId();
24 }
25 $this->user_id = (int)$a_user_id;
26 }
27
28 function &executeCommand()
29 {
30 global $ilCtrl;
31
32 $next_class =$ilCtrl->getNextClass($this);
33 $cmd = $ilCtrl->getCmd();
34
35 switch($next_class)
36 {
37 default:
38 if(!$cmd)
39 {
40 $cmd = "listObjects";
41 }
42 $this->$cmd();
43 break;
44 }
45
46 return true;
47 }
48
49 function listObjects()
50 {
51 global $tpl, $ilToolbar, $lng, $ilCtrl, $objDefinition;
52
53 $objects = ilObject::getAllOwnedRepositoryObjects($this->user_id);
54
55 if(sizeof($objects))
56 {
57 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "listObjects"));
58
59 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
60 $sel = new ilSelectInputGUI($lng->txt("type"), "type");
61 $ilToolbar->addStickyItem($sel, true);
62
63 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
65 $button->setCaption("ok");
66 $button->setCommand("listObjects");
67 $ilToolbar->addStickyItem($button);
68
69 $options = array();
70 foreach(array_keys($objects) as $type)
71 {
72 // #11050
73 if(!$objDefinition->isPlugin($type))
74 {
75 $options[$type] = $lng->txt("obj_".$type);
76 }
77 else
78 {
79 include_once("./Services/Component/classes/class.ilPlugin.php");
80 $options[$type] = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
81 }
82 }
83 asort($options);
84 $sel->setOptions($options);
85
86 $sel_type = (string)$_REQUEST["type"];
87 if($sel_type)
88 {
89 $sel->setValue($sel_type);
90 }
91 else
92 {
93 $sel_type = array_keys($options);
94 $sel_type = array_shift($sel_type);
95 }
96 $ilCtrl->setParameter($this, "type", $sel_type);
97 }
98
99 // #17751
100 if(sizeof($objects[$sel_type]))
101 {
102 ilObject::fixMissingTitles($sel_type, $objects[$sel_type]);
103 }
104
105 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
106 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id, $objects[$sel_type]);
107 $tpl->setContent($tbl->getHTML());
108 }
109
110 function applyFilter()
111 {
112 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
113 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id);
114 $tbl->resetOffset();
115 $tbl->writeFilterToSession();
116 $this->listObjects();
117 }
118
119 function resetFilter()
120 {
121 include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
122 $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id);
123 $tbl->resetOffset();
124 $tbl->resetFilter();
125 $this->listObjects();
126 }
127
128 protected function redirectParentCmd($a_ref_id, $a_cmd)
129 {
130 global $tree, $ilCtrl;
131
132 $parent = $tree->getParentId($a_ref_id);
133 $ilCtrl->setParameterByClass("ilRepositoryGUI", "ref_id", $parent);
134 $ilCtrl->setParameterByClass("ilRepositoryGUI", "item_ref_id", $a_ref_id);
135 $ilCtrl->setParameterByClass("ilRepositoryGUI", "cmd", $a_cmd);
136 $ilCtrl->redirectByClass("ilRepositoryGUI");
137 }
138
139 protected function redirectCmd($a_ref_id, $a_class, $a_cmd = null)
140 {
141 global $ilCtrl, $tree, $objDefinition;
142
143 $node = $tree->getNodeData($a_ref_id);
144 $gui_class = "ilObj".$objDefinition->getClassName($node["type"])."GUI";
145 $path = array("ilRepositoryGUI", $gui_class, $a_class);
146
147 // #10495 - check if object type supports ilexportgui "directly"
148 if($a_class == "ilExportGUI")
149 {
150 try
151 {
152 $ilCtrl->getLinkTargetByClass($path);
153 }
154 catch(Exception $e)
155 {
156 switch($node["type"])
157 {
158 case "glo":
159 $cmd = "exportList";
160 $path = array("ilRepositoryGUI", "ilGlossaryEditorGUI", $gui_class);
161 break;
162
163 default:
164 $cmd = "export";
165 $path = array("ilRepositoryGUI", $gui_class);
166 break;
167 }
168 $ilCtrl->setParameterByClass($gui_class, "ref_id", $a_ref_id);
169 $ilCtrl->setParameterByClass($gui_class, "cmd", $cmd);
170 $ilCtrl->redirectByClass($path);
171 }
172 }
173
174 $ilCtrl->setParameterByClass($a_class, "ref_id", $a_ref_id);
175 $ilCtrl->setParameterByClass($a_class, "cmd", $a_cmd);
176 $ilCtrl->redirectByClass($path);
177 }
178
179 function delete()
180 {
181 $ref_id = (int)$_REQUEST["ownid"];
182 $this->redirectParentCmd($ref_id, "delete");
183 }
184
185 function move()
186 {
187 $ref_id = (int)$_REQUEST["ownid"];
188 $this->redirectParentCmd($ref_id, "cut");
189 }
190
191 function export()
192 {
193 $ref_id = (int)$_REQUEST["ownid"];
194 $this->redirectCmd($ref_id, "ilExportGUI");
195 }
196
197 function changeOwner()
198 {
199 $ref_id = (int)$_REQUEST["ownid"];
200 $this->redirectCmd($ref_id, "ilPermissionGUI", "owner");
201 }
202}
203
204?>
global $tpl
Definition: ilias.php:8
Class ilObjectOwnershipManagementGUI.
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.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
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
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15