ILIAS  release_8 Revision v8.24
class.ilObjPortfolioTemplateAccess.php
Go to the documentation of this file.
1<?php
2
24{
25 protected ilObjUser $user;
26 protected ilLanguage $lng;
29
30 public function __construct()
31 {
32 global $DIC;
33
34 $this->user = $DIC->user();
35 $this->lng = $DIC->language();
36 $this->rbacsystem = $DIC->rbac()->system();
37 $this->access = $DIC->access();
38 }
39
40 public static function _getCommands(): array
41 {
42 $commands = array(
43 array("permission" => "read", "cmd" => "preview", "lang_var" => "preview", "default" => true),
44 array("permission" => "write", "cmd" => "view", "lang_var" => "edit_content"),
45 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings"),
46 array("permission" => "read", "cmd" => "createfromtemplate", "lang_var" => "prtf_create_portfolio_from_template"),
47 // array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
48 );
49
50 return $commands;
51 }
52
53 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
54 {
58 $ilAccess = $this->access;
59
60 if (is_null($user_id)) {
61 $user_id = $ilUser->getId();
62 }
63
64 switch ($cmd) {
65 case "view":
66 if (!self::_lookupOnline($obj_id)
67 && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
68 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
69 return false;
70 }
71 break;
72
73 // for permission query feature
74 case "infoScreen":
75 if (!self::_lookupOnline($obj_id)) {
76 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
77 } else {
78 $ilAccess->addInfoItem(ilAccessInfo::IL_STATUS_MESSAGE, $lng->txt("online"));
79 }
80 break;
81
82 }
83
84 switch ($permission) {
85 case "read":
86 case "visible":
87 if (!self::_lookupOnline($obj_id) &&
88 (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id))) {
89 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
90 return false;
91 }
92 break;
93 }
94
95 return true;
96 }
97
98 public static function _lookupOnline(int $a_id): bool
99 {
101 }
102
106 public static function _lookupOnlineStatus(array $a_ids): array
107 {
108 global $DIC;
109
110 $ilDB = $DIC->database();
111
112 $q = "SELECT id, is_online FROM usr_portfolio WHERE " .
113 $ilDB->in("id", $a_ids, false, "integer");
114 $lm_set = $ilDB->query($q);
115 $status = [];
116 while ($r = $ilDB->fetchAssoc($lm_set)) {
117 $status[$r["id"]] = $r["is_online"];
118 }
119 return $status;
120 }
121
122
126 public static function _checkGoto(string $target): bool
127 {
128 global $DIC;
129
130 $ilAccess = $DIC->access();
131
132 $t_arr = explode("_", $target);
133
134 if ($t_arr[0] !== "prtt" || ((int) $t_arr[1]) <= 0) {
135 return false;
136 }
137
138 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
139 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
140 return true;
141 }
142 return false;
143 }
144}
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static lookupOnline(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _checkGoto(string $target)
check whether goto script will succeed
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$lm_set