ILIAS  release_7 Revision v7.30-3-g800a261c036
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(
90 "alert" => true,
91 "property" => $lng->txt("status"),
92 "value" => $lng->txt("cld_not_authenticated_offline"),
93 );
94 } else {
95 if (!ilObjCloudAccess::checkOnline($this->obj_id)) {
96 $props[] = array(
97 "alert" => true,
98 "property" => $lng->txt("status"),
99 "value" => $lng->txt("offline"),
100 );
101 }
102 }
103
104 return $props;
105 }
106
107
115 private function neutralizeCommands(array &$commands, array $custom_list_actions)
116 {
117 foreach ($custom_list_actions as $custom_list_action) {
118 for ($i = 0; $i < count($commands); $i++) {
119 if ($commands[$i]["lang_var"] == $custom_list_action["lang_var"]) {
120 unset($commands[$i]);
121 }
122 }
123 }
124 }
125
126
133 private function injectCustomUrlsInCommands($custom_urls, &$ref_commands)
134 {
135 foreach ($custom_urls as $custom_url) {
136 foreach ($ref_commands as &$ref_command) {
137 if ($custom_url["id"] === $ref_command["lang_var"]) {
138 $ref_command["link"] = $custom_url["link"];
139 }
140 }
141 }
142 }
143
144
151 private function fetchCustomUrlsFromCustomActions(array $custom_list_actions, &$custom_urls)
152 {
153 foreach ($custom_list_actions as $custom_list_action) {
154 if (array_key_exists("custom_url", $custom_list_action)) {
155 array_push(
156 $custom_urls,
157 [
158 "id" => $custom_list_action["lang_var"],
159 "link" => $custom_list_action["custom_url"],
160 ]
161 );
162 }
163 }
164 }
165}
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.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24