ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjCloudAccess.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.ilObjectPluginAccess.php");
5include_once("class.ilCloudConnector.php");
6include_once("class.ilObjCloud.php");
7
17{
18 protected static $access_cache = array();
19
20
21 public static function _getCommands()
22 {
23 $commands = array(
24 array("permission" => "read", "cmd" => "render", "lang_var" => "show", "default" => true),
25 array("permission" => "write", "cmd" => "editSettings", "lang_var" => "settings"),
26 );
27
28 return $commands;
29 }
30
31
41 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
42 {
43 global $DIC;
44 $ilUser = $DIC['ilUser'];
45 $rbacsystem = $DIC['rbacsystem'];
46 $rbacreview = $DIC['rbacreview'];
47
48 $object = new ilObjCloud($a_ref_id);
49
53 try {
54 ilCloudConnector::checkServiceActive($object->getServiceName());
55 } catch (Exception $e) {
56 return false;
57 }
58
59 if ($a_user_id == "") {
60 $a_user_id = $ilUser->getId();
61 }
62
67 if (!ilObjCloudAccess::checkAuthStatus($a_obj_id) && $a_user_id != $object->getOwnerId() && !$rbacreview->isAssigned($a_user_id, 2)) {
68 return false;
69 }
70
71 switch ($a_permission) {
72 case "visible":
73 case "read":
74 if (!ilObjCloudAccess::checkOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, "write", $a_ref_id)) {
75 return false;
76 }
77 break;
78 }
79
80 return true;
81 }
82
83
89 public static function _checkGoto($a_target)
90 {
91 global $DIC;
92 $ilAccess = $DIC['ilAccess'];
93
94 $t_arr = explode("_", $a_target);
95
96 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
97 return true;
98 }
99
100 return false;
101 }
102
103
109 public static function checkOnline($a_id)
110 {
111 global $DIC;
112 $ilDB = $DIC['ilDB'];
113
114 if (!isset(self::$access_cache[$a_id]["online"])) {
115 $set = $ilDB->query("SELECT is_online FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
116 $rec = $ilDB->fetchAssoc($set);
117 self::$access_cache[$a_id]["online"] = (boolean) ($rec["is_online"]);
118 }
119
120 return self::$access_cache[$a_id]["online"];
121 }
122
123
129 public static function checkAuthStatus($a_id)
130 {
131 global $DIC;
132 $ilDB = $DIC['ilDB'];
133
134 if (!isset(self::$access_cache[$a_id]["auth_status"])) {
135 $set = $ilDB->query("SELECT auth_complete FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
136 $rec = $ilDB->fetchAssoc($set);
137 self::$access_cache[$a_id]["auth_status"] = (boolean) $rec["auth_complete"];
138 }
139
140 return self::$access_cache[$a_id]["auth_status"];
141 }
142}
An exception for terminatinating execution or to throw for unit testing.
static checkServiceActive($name)
Class ilObjCloudAccess.
static _checkGoto($a_target)
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
static _getCommands()
get commands
Class ilObjCloud.
Class ilObjectAccess.
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46