ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjCloudListGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Repository/classes/class.ilObjectPluginListGUI.php";
5
15{
16
20 public function init()
21 {
22 global $DIC;
23 $lng = $DIC['lng'];
24
25 $this->copy_enabled = false;
26 $this->delete_enabled = true;
27 $this->cut_enabled = false;
28 $this->subscribe_enabled = true;
29 $this->link_enabled = false;
30 $this->info_screen_enabled = true;
31 $this->timings_enabled = true;
32 $this->type = "cld";
33 $this->gui_class_name = "ilobjcloudgui";
34
35 // general commands array
36 include_once('./Modules/Cloud/classes/class.ilObjCloudAccess.php');
37 $this->commands = ilObjCloudAccess::_getCommands();
38 $lng->loadLanguageModule("cld");
39 }
40
41
42 public function getCommands()
43 {
44 $object = ilObjectFactory::getInstanceByRefId($this->ref_id);
45 $header_action_gui = ilCloudConnector::getHeaderActionGUIClass(ilCloudConnector::getServiceClass($object->getServiceName(), $object->getId(), false));
46 $custom_urls = [];
47
48 if (method_exists($header_action_gui, "getCustomListActions")) {
49 // Fetch custom actions
50 $custom_list_actions = $header_action_gui->getCustomListActions();
51
52 if (is_array($custom_list_actions)) {
53 // Fetch custom URLs from the custom actions, if available
54 $this->fetchCustomUrlsFromCustomActions($custom_list_actions, $custom_urls);
55 // Adjust commands of this object by adding the new custom ones
56 $this->commands = array_merge($this->commands, $custom_list_actions);
57 }
58 }
59
60 // Generate ilias link, check permissions, etc...
61 $ref_commands = parent::getCommands();
62
63 // Remove recently added custom actions from dynamic field "commands" as
64 // it may pass onto other ListGUIs and mess them up
65 if (method_exists($header_action_gui, "getCustomListActions")) {
66 $this->neutralizeCommands($this->commands, $custom_list_actions);
67 }
68
69 // Inject custom urls, if avilable
70 if (!empty($custom_urls)) {
71 $this->injectCustomUrlsInCommands($custom_urls, $ref_commands);
72 }
73
74 return $ref_commands;
75 }
76
77
81 public function getProperties()
82 {
83 global $DIC;
84 $lng = $DIC['lng'];
85
86 $props = array();
87 include_once('./Modules/Cloud/classes/class.ilObjCloudAccess.php');
88 if (!ilObjCloudAccess::checkAuthStatus($this->obj_id)) {
89 $props[] = array("alert" => true, "property" => $lng->txt("status"),
90 "value" => $lng->txt("cld_not_authenticated_offline"));
91 } elseif (!ilObjCloudAccess::checkOnline($this->obj_id)) {
92 $props[] = array("alert" => true, "property" => $lng->txt("status"),
93 "value" => $lng->txt("offline"));
94 }
95
96 return $props;
97 }
98
99
107 private function neutralizeCommands(array &$commands, array $custom_list_actions)
108 {
109 foreach ($custom_list_actions as $custom_list_action) {
110 for ($i = 0; $i < count($commands); $i++) {
111 if ($commands[$i]["lang_var"] == $custom_list_action["lang_var"]) {
112 unset($commands[$i]);
113 }
114 }
115 }
116 }
117
118
125 private function injectCustomUrlsInCommands($custom_urls, &$ref_commands)
126 {
127 foreach ($custom_urls as $custom_url) {
128 foreach ($ref_commands as &$ref_command) {
129 if ($custom_url["id"] === $ref_command["lang_var"]) {
130 $ref_command["link"] = $custom_url["link"];
131 }
132 }
133 }
134 }
135
136
143 private function fetchCustomUrlsFromCustomActions(array $custom_list_actions, &$custom_urls)
144 {
145 foreach ($custom_list_actions as $custom_list_action) {
146 if (array_key_exists("custom_url", $custom_list_action)) {
147 array_push(
148 $custom_urls,
149 [
150 "id" => $custom_list_action["lang_var"],
151 "link" => $custom_list_action["custom_url"],
152 ]
153 );
154 }
155 }
156 }
157}
An exception for terminatinating execution or to throw for unit testing.
static getHeaderActionGUIClass(ilCloudPluginService $plugin_service_class)
static getServiceClass($service_name, $obj_id, $connect=true)
static _getCommands()
get commands
Class ilObjCloudListGUI.
fetchCustomUrlsFromCustomActions(array $custom_list_actions, &$custom_urls)
Fetches custom URLs from predefined actions and structures them appropriately.
neutralizeCommands(array &$commands, array $custom_list_actions)
Remove recently added custom actions from dynamic field "commands" as it may pass onto other ListGUIs...
getCommands()
get all current commands for a specific ref id (in the permission context of the current user)
injectCustomUrlsInCommands($custom_urls, &$ref_commands)
Inject predefined custom URLs into ref_commands and change its destination.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectListGUI.
$i
Definition: disco.tpl.php:19
global $DIC
Definition: saml.php:7