ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjPortfolioTemplateAccess.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
15 protected $user;
16
20 protected $lng;
21
25 protected $rbacsystem;
26
30 protected $access;
31
32
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->user = $DIC->user();
41 $this->lng = $DIC->language();
42 $this->rbacsystem = $DIC->rbac()->system();
43 $this->access = $DIC->access();
44 }
45
46 public static function _getCommands()
47 {
48 $commands = array(
49 array("permission" => "read", "cmd" => "preview", "lang_var" => "preview", "default" => true),
50 array("permission" => "write", "cmd" => "view", "lang_var" => "edit_content"),
51 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
52 array("permission" => "read", "cmd" => "createfromtemplate", "lang_var" => "prtf_create_portfolio_from_template"),
53 // array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
54 );
55
56 return $commands;
57 }
58
59 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
60 {
64 $ilAccess = $this->access;
65
66 if ($a_user_id == "") {
67 $a_user_id = $ilUser->getId();
68 }
69
70 switch ($a_cmd) {
71 case "view":
72 if (!self::_lookupOnline($a_obj_id)
73 && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
74 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
75 return false;
76 }
77 break;
78
79 // for permission query feature
80 case "infoScreen":
81 if (!self::_lookupOnline($a_obj_id)) {
82 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
83 } else {
84 $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
85 }
86 break;
87
88 }
89
90 switch ($a_permission) {
91 case "read":
92 case "visible":
93 if (!self::_lookupOnline($a_obj_id) &&
94 (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
95 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
96 return false;
97 }
98 break;
99 }
100
101 return true;
102 }
103
104 public static function _lookupOnline($a_id)
105 {
107 }
108
114 public static function _lookupOnlineStatus($a_ids)
115 {
116 global $DIC;
117
118 $ilDB = $DIC->database();
119
120 $q = "SELECT id, is_online FROM usr_portfolio WHERE " .
121 $ilDB->in("id", $a_ids, false, "integer");
122 $lm_set = $ilDB->query($q);
123 $status = [];
124 while ($r = $ilDB->fetchAssoc($lm_set)) {
125 $status[$r["id"]] = $r["is_online"];
126 }
127 return $status;
128 }
129
130
134 public static function _checkGoto($a_target)
135 {
136 global $DIC;
137
138 $ilAccess = $DIC->access();
139
140 $t_arr = explode("_", $a_target);
141
142 if ($t_arr[0] != "prtt" || ((int) $t_arr[1]) <= 0) {
143 return false;
144 }
145
146 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
147 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
148 return true;
149 }
150 return false;
151 }
152}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_STATUS_MESSAGE
const IL_NO_OBJECT_ACCESS
static lookupOnline($a_id)
Is online?
Class ilObjPortfolioTemplateAccess.
static _checkGoto($a_target)
check whether goto script will succeed
static _lookupOnlineStatus($a_ids)
Check wether booking pool is online (legacy version)
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
Class ilObjectAccess.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
global $ilDB
$lm_set