ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 {
55 $ilUser = $this->user;
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)
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 switch ($permission) {
84 case "read":
85 case "visible":
86 if (!self::_lookupOnline($obj_id) &&
88 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
89 return false;
90 }
91 break;
92 }
93
94 return true;
95 }
96
97 public static function _lookupOnline(int $a_id): bool
98 {
99 return !self::_isOffline($a_id);
100 }
101
105 public static function _lookupOnlineStatus(array $a_ids): array
106 {
107 $status = [];
108 foreach ($a_ids as $id) {
109 $status[$id] = !self::_isOffline($id);
110 }
111 return $status;
112 }
113
114
118 public static function _checkGoto(string $target): bool
119 {
120 global $DIC;
121
122 $ilAccess = $DIC->access();
123
124 $t_arr = explode("_", $target);
125
126 if ($t_arr[0] !== "prtt" || ((int) $t_arr[1]) <= 0) {
127 return false;
128 }
129
130 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
131 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
132 return true;
133 }
134 return false;
135 }
136}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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...
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.
Class ilObjectAccess.
static _isOffline(int $obj_id)
Type-specific implementation of general status, has to be overwritten if object type does not support...
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="")
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26