ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
40 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
41 {
42 global $DIC;
43 $ilUser = $DIC['ilUser'];
44 $rbacsystem = $DIC['rbacsystem'];
45 $rbacreview = $DIC['rbacreview'];
46
47 $object = new ilObjCloud($a_ref_id);
48
52 try {
53 ilCloudConnector::checkServiceActive($object->getServiceName());
54 } catch (Exception $e) {
55 return false;
56 }
57
58 if ($a_user_id == "") {
59 $a_user_id = $ilUser->getId();
60 }
61
66 if (!ilObjCloudAccess::checkAuthStatus($a_obj_id) && $a_user_id != $object->getOwnerId() && !$rbacreview->isAssigned($a_user_id, 2)) {
67 return false;
68 }
69
70 switch ($a_permission) {
71 case "visible":
72 case "read":
73 if (!ilObjCloudAccess::checkOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, "write", $a_ref_id)) {
74 return false;
75 }
76 break;
77 }
78
79 return true;
80 }
81
82
87 public static function _checkGoto($a_target)
88 {
89 global $DIC;
90 $ilAccess = $DIC['ilAccess'];
91
92 $t_arr = explode("_", $a_target);
93
94 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
95 return true;
96 }
97
98 return false;
99 }
100
101
106 public static function checkOnline($a_id)
107 {
108 global $DIC;
109 $ilDB = $DIC['ilDB'];
110
111 if (!isset(self::$access_cache[$a_id]["online"])) {
112 $set = $ilDB->query("SELECT is_online FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
113 $rec = $ilDB->fetchAssoc($set);
114 self::$access_cache[$a_id]["online"] = (boolean) ($rec["is_online"]);
115 }
116
117 return self::$access_cache[$a_id]["online"];
118 }
119
120
125 public static function checkAuthStatus($a_id)
126 {
127 global $DIC;
128 $ilDB = $DIC['ilDB'];
129
130 if (!isset(self::$access_cache[$a_id]["auth_status"])) {
131 $set = $ilDB->query("SELECT auth_complete FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
132 $rec = $ilDB->fetchAssoc($set);
133 self::$access_cache[$a_id]["auth_status"] = (boolean) $rec["auth_complete"];
134 }
135
136 return self::$access_cache[$a_id]["auth_status"];
137 }
138}
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 $DIC
Definition: saml.php:7
global $ilDB
$ilUser
Definition: imgupload.php:18