ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjectOwnershipManagementGUI Class Reference

Class ilObjectOwnershipManagementGUI. More...

+ Collaboration diagram for ilObjectOwnershipManagementGUI:

Public Member Functions

 __construct (?int $user_id=null, bool $read_only=false)
 
 executeCommand ()
 
 listObjects ()
 
 applyFilter ()
 
 resetFilter ()
 
 delete ()
 
 move ()
 
 export ()
 
 changeOwner ()
 
 isReadOnly ()
 

Data Fields

const P_OWNID = 'ownid'
 

Protected Member Functions

 redirectParentCmd (int $ref_id, string $cmd)
 
 redirectCmd (int $ref_id, string $class, ?string $cmd=null)
 
 checkReadOnly ()
 

Protected Attributes

ilObjUser $user
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
UIFactory $ui_factory
 
ilToolbarGUI $toolbar
 
ilLanguage $lng
 
ilObjectDefinition $obj_definition
 
ilTree $tree
 
int $user_id
 
int $own_id = 0
 
bool $read_only
 

Private Member Functions

 getLabelForObjectType (string $type)
 

Private Attributes

ilObjectRequestRetriever $retriever
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjectOwnershipManagementGUI::__construct ( ?int  $user_id = null,
bool  $read_only = false 
)

Definition at line 46 of file class.ilObjectOwnershipManagementGUI.php.

References $DIC, $read_only, $user_id, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

47  {
48  global $DIC;
49 
50  $this->user = $DIC['ilUser'];
51  $this->ctrl = $DIC['ilCtrl'];
52  $this->tpl = $DIC['tpl'];
53  $this->ui_factory = $DIC['ui.factory'];
54  $this->toolbar = $DIC['ilToolbar'];
55  $this->lng = $DIC['lng'];
56  $this->obj_definition = $DIC['objDefinition'];
57  $this->tree = $DIC['tree'];
58  $this->retriever = new ilObjectRequestRetriever($DIC->http()->wrapper(), $DIC['refinery']);
59 
60  $this->lng->loadLanguageModule('obj');
61 
62  $this->user_id = $this->user->getId();
63  if (!is_null($user_id)) {
64  $this->user_id = $user_id;
65  }
66  $this->read_only = $read_only;
67  $this->own_id = $this->retriever->getMaybeInt(self::P_OWNID, 0);
68  }
global $DIC
Definition: shib_login.php:22
Base class for all sub item list gui's.
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilObjectOwnershipManagementGUI::applyFilter ( )

Definition at line 134 of file class.ilObjectOwnershipManagementGUI.php.

References listObjects().

134  : void
135  {
136  $tbl = new ilObjectOwnershipManagementTableGUI($this, 'listObjects', $this->user_id);
137  $tbl->resetOffset();
138  $tbl->writeFilterToSession();
139  $this->listObjects();
140  }
+ Here is the call graph for this function:

◆ changeOwner()

ilObjectOwnershipManagementGUI::changeOwner ( )

Definition at line 221 of file class.ilObjectOwnershipManagementGUI.php.

References checkReadOnly(), and redirectCmd().

221  : void
222  {
223  $this->checkReadOnly();
224 
225  $this->redirectCmd(
226  $this->own_id,
227  ilPermissionGUI::class,
228  'owner'
229  );
230  }
redirectCmd(int $ref_id, string $class, ?string $cmd=null)
+ Here is the call graph for this function:

◆ checkReadOnly()

ilObjectOwnershipManagementGUI::checkReadOnly ( )
protected

Definition at line 237 of file class.ilObjectOwnershipManagementGUI.php.

Referenced by changeOwner(), delete(), export(), and move().

237  : void
238  {
239  if ($this->read_only) {
240  throw new ilObjectException(
241  'Cannot perform actions when in read only mode'
242  );
243  }
244  }
Base exception class for object service.
+ Here is the caller graph for this function:

◆ delete()

ilObjectOwnershipManagementGUI::delete ( )

Definition at line 191 of file class.ilObjectOwnershipManagementGUI.php.

References checkReadOnly(), and redirectParentCmd().

191  : void
192  {
193  $this->checkReadOnly();
194 
195  $this->redirectParentCmd(
196  $this->own_id,
197  'delete'
198  );
199  }
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectOwnershipManagementGUI::executeCommand ( )

Definition at line 70 of file class.ilObjectOwnershipManagementGUI.php.

References ILIAS\Repository\ctrl().

70  : void
71  {
72  $this->ctrl->getNextClass($this);
73  $cmd = $this->ctrl->getCmd();
74 
75  if (!$cmd) {
76  $cmd = 'listObjects';
77  }
78  $this->$cmd();
79  }
+ Here is the call graph for this function:

◆ export()

ilObjectOwnershipManagementGUI::export ( )

Definition at line 211 of file class.ilObjectOwnershipManagementGUI.php.

References checkReadOnly(), and redirectCmd().

211  : void
212  {
213  $this->checkReadOnly();
214 
215  $this->redirectCmd(
216  $this->own_id,
217  ilExportGUI::class
218  );
219  }
redirectCmd(int $ref_id, string $class, ?string $cmd=null)
+ Here is the call graph for this function:

◆ getLabelForObjectType()

ilObjectOwnershipManagementGUI::getLabelForObjectType ( string  $type)
private

Definition at line 124 of file class.ilObjectOwnershipManagementGUI.php.

References ilObjectPlugin\getPluginObjectByType(), and ILIAS\Repository\lng().

Referenced by listObjects().

124  : string
125  {
126  if ($this->obj_definition->isPlugin($type)) {
128  ->txt('obj_' . $type);
129  }
130 
131  return $this->lng->txt('objs_' . $type);
132  }
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReadOnly()

ilObjectOwnershipManagementGUI::isReadOnly ( )

Definition at line 232 of file class.ilObjectOwnershipManagementGUI.php.

References $read_only.

232  : bool
233  {
234  return $this->read_only;
235  }

◆ listObjects()

ilObjectOwnershipManagementGUI::listObjects ( )

Definition at line 81 of file class.ilObjectOwnershipManagementGUI.php.

References ILIAS\Repository\ctrl(), ilObject\fixMissingTitles(), ilObject\getAllOwnedRepositoryObjects(), getLabelForObjectType(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by applyFilter(), and resetFilter().

81  : void
82  {
83  $objects = ilObject::getAllOwnedRepositoryObjects($this->user_id);
84 
85  $tbl = new ilObjectOwnershipManagementTableGUI($this, 'listObjects', $this->user_id);
86 
87  if ($objects === []) {
88  $tbl->setTitle($this->lng->txt('user_owns_no_objects'));
89  $this->tpl->setContent($tbl->getHTML());
90  return;
91  }
92 
93  $object_types = array_keys($objects);
94 
95  $options = [];
96  foreach ($object_types as $type) {
97  $this->ctrl->setParameterByClass(self::class, 'type', $type);
98  $target = $this->ctrl->getLinkTargetByClass(self::class, 'listObjects');
99  $label = $this->getLabelForObjectType($type);
100  $options[$type] = $this->ui_factory->button()->shy($label, $target);
101  }
102  asort($options);
103 
104  $selected_type = $this->retriever->getMaybeString('type') ?? array_keys($options)[0];
105  unset($options[$selected_type]);
106 
107  $dropdown = $this->ui_factory->dropdown()->standard($options)->withLabel(
108  $this->lng->txt('select_object_type')
109  );
110 
111  $this->toolbar->addStickyItem($dropdown);
112 
113  if (is_array($objects[$selected_type])
114  && $objects[$selected_type] !== []) {
115  ilObject::fixMissingTitles($selected_type, $objects[$selected_type]);
116  }
117 
118  $tbl->setTitle($this->getLabelForObjectType($selected_type));
119  $tbl->initItems($objects[$selected_type]);
120  $this->ctrl->setParameterByClass(self::class, 'type', $selected_type);
121  $this->tpl->setContent($tbl->getHTML());
122  }
static getAllOwnedRepositoryObjects(int $user_id)
static fixMissingTitles($type, array &$obj_title_map)
Try to fix missing object titles.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move()

ilObjectOwnershipManagementGUI::move ( )

Definition at line 201 of file class.ilObjectOwnershipManagementGUI.php.

References checkReadOnly(), and redirectParentCmd().

201  : void
202  {
203  $this->checkReadOnly();
204 
205  $this->redirectParentCmd(
206  $this->own_id,
207  'cut'
208  );
209  }
+ Here is the call graph for this function:

◆ redirectCmd()

ilObjectOwnershipManagementGUI::redirectCmd ( int  $ref_id,
string  $class,
?string  $cmd = null 
)
protected

Definition at line 159 of file class.ilObjectOwnershipManagementGUI.php.

References Vendor\Package\$e, $path, and ILIAS\Repository\ctrl().

Referenced by changeOwner(), and export().

159  : void
160  {
161  $node = $this->tree->getNodeData($ref_id);
162  $gui_class = 'ilObj' . $this->obj_definition->getClassName($node['type']) . 'GUI';
163  $path = ['ilRepositoryGUI', $gui_class, $class];
164 
165  if ($class == 'ilExportGUI') {
166  try {
167  $this->ctrl->getLinkTargetByClass($path);
168  } catch (Exception $e) {
169  switch ($node['type']) {
170  case 'glo':
171  $export_cmd = 'exportList';
172  $path = ['ilRepositoryGUI', 'ilGlossaryEditorGUI', $gui_class];
173  break;
174 
175  default:
176  $export_cmd = 'export';
177  $path = ['ilRepositoryGUI', $gui_class];
178  break;
179  }
180  $this->ctrl->setParameterByClass($gui_class, 'ref_id', $ref_id);
181  $this->ctrl->setParameterByClass($gui_class, 'cmd', $export_cmd);
182  $this->ctrl->redirectByClass($path);
183  }
184  }
185 
186  $this->ctrl->setParameterByClass($class, 'ref_id', $ref_id);
187  $this->ctrl->setParameterByClass($class, 'cmd', $cmd);
188  $this->ctrl->redirectByClass($path);
189  }
$path
Definition: ltiservices.php:29
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectParentCmd()

ilObjectOwnershipManagementGUI::redirectParentCmd ( int  $ref_id,
string  $cmd 
)
protected

Definition at line 150 of file class.ilObjectOwnershipManagementGUI.php.

References ILIAS\Repository\ctrl().

Referenced by delete(), and move().

150  : void
151  {
152  $parent = $this->tree->getParentId($ref_id);
153  $this->ctrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', $parent);
154  $this->ctrl->setParameterByClass(ilRepositoryGUI::class, 'item_ref_id', $ref_id);
155  $this->ctrl->setParameterByClass(ilRepositoryGUI::class, 'cmd', $cmd);
156  $this->ctrl->redirectByClass(ilRepositoryGUI::class);
157  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilObjectOwnershipManagementGUI::resetFilter ( )

Definition at line 142 of file class.ilObjectOwnershipManagementGUI.php.

References listObjects().

142  : void
143  {
144  $tbl = new ilObjectOwnershipManagementTableGUI($this, 'listObjects', $this->user_id);
145  $tbl->resetOffset();
146  $tbl->resetFilter();
147  $this->listObjects();
148  }
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilObjectOwnershipManagementGUI::$ctrl
protected

Definition at line 34 of file class.ilObjectOwnershipManagementGUI.php.

◆ $lng

ilLanguage ilObjectOwnershipManagementGUI::$lng
protected

Definition at line 38 of file class.ilObjectOwnershipManagementGUI.php.

◆ $obj_definition

ilObjectDefinition ilObjectOwnershipManagementGUI::$obj_definition
protected

Definition at line 39 of file class.ilObjectOwnershipManagementGUI.php.

◆ $own_id

int ilObjectOwnershipManagementGUI::$own_id = 0
protected

Definition at line 42 of file class.ilObjectOwnershipManagementGUI.php.

◆ $read_only

bool ilObjectOwnershipManagementGUI::$read_only
protected

Definition at line 43 of file class.ilObjectOwnershipManagementGUI.php.

Referenced by __construct(), and isReadOnly().

◆ $retriever

ilObjectRequestRetriever ilObjectOwnershipManagementGUI::$retriever
private

Definition at line 44 of file class.ilObjectOwnershipManagementGUI.php.

◆ $toolbar

ilToolbarGUI ilObjectOwnershipManagementGUI::$toolbar
protected

Definition at line 37 of file class.ilObjectOwnershipManagementGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilObjectOwnershipManagementGUI::$tpl
protected

Definition at line 35 of file class.ilObjectOwnershipManagementGUI.php.

◆ $tree

ilTree ilObjectOwnershipManagementGUI::$tree
protected

Definition at line 40 of file class.ilObjectOwnershipManagementGUI.php.

◆ $ui_factory

UIFactory ilObjectOwnershipManagementGUI::$ui_factory
protected

Definition at line 36 of file class.ilObjectOwnershipManagementGUI.php.

◆ $user

ilObjUser ilObjectOwnershipManagementGUI::$user
protected

Definition at line 33 of file class.ilObjectOwnershipManagementGUI.php.

◆ $user_id

int ilObjectOwnershipManagementGUI::$user_id
protected

Definition at line 41 of file class.ilObjectOwnershipManagementGUI.php.

Referenced by __construct().

◆ P_OWNID

const ilObjectOwnershipManagementGUI::P_OWNID = 'ownid'

Definition at line 32 of file class.ilObjectOwnershipManagementGUI.php.


The documentation for this class was generated from the following file: