ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $commands = array(
23 array( "permission" => "read", "cmd" => "render", "lang_var" => "show", "default" => true ),
24 array( "permission" => "write", "cmd" => "editSettings", "lang_var" => "settings" ),
25 );
26
27 return $commands;
28 }
29
30
39 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "") {
40 global $DIC;
41 $ilUser = $DIC['ilUser'];
42 $rbacsystem = $DIC['rbacsystem'];
43 $rbacreview = $DIC['rbacreview'];
44
45 $object = new ilObjCloud($a_ref_id);
46
50 try {
51 ilCloudConnector::checkServiceActive($object->getServiceName());
52 } catch (Exception $e) {
53 return false;
54 }
55
56 if ($a_user_id == "") {
57 $a_user_id = $ilUser->getId();
58 }
59
64 if (!ilObjCloudAccess::checkAuthStatus($a_obj_id) && $a_user_id != $object->getOwnerId() && !$rbacreview->isAssigned($a_user_id, 2)) {
65 return false;
66 }
67
68 switch ($a_permission) {
69 case "visible":
70 case "read":
71 if (!ilObjCloudAccess::checkOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, "write", $a_ref_id)) {
72 return false;
73 }
74 break;
75 }
76
77 return true;
78 }
79
80
85 public static function _checkGoto($a_target) {
86
87 global $DIC;
88 $ilAccess = $DIC['ilAccess'];
89
90 $t_arr = explode("_", $a_target);
91
92 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
93 return true;
94 }
95
96 return false;
97 }
98
99
104 static function checkOnline($a_id) {
105 global $DIC;
106 $ilDB = $DIC['ilDB'];
107
108 if (!isset(self::$access_cache[$a_id]["online"])) {
109 $set = $ilDB->query("SELECT is_online FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
110 $rec = $ilDB->fetchAssoc($set);
111 self::$access_cache[$a_id]["online"] = (boolean)($rec["is_online"]);
112 }
113
114 return self::$access_cache[$a_id]["online"];
115 }
116
117
122 static function checkAuthStatus($a_id) {
123 global $DIC;
124 $ilDB = $DIC['ilDB'];
125
126 if (!isset(self::$access_cache[$a_id]["auth_status"])) {
127 $set = $ilDB->query("SELECT auth_complete FROM il_cld_data " . " WHERE id = " . $ilDB->quote($a_id, "integer"));
128 $rec = $ilDB->fetchAssoc($set);
129 self::$access_cache[$a_id]["auth_status"] = (boolean)$rec["auth_complete"];
130 }
131
132 return self::$access_cache[$a_id]["auth_status"];
133 }
134}
135
136?>
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
global $DIC
$ilUser
Definition: imgupload.php:18