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