ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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;
56  $lng = $this->lng;
57  $rbacsystem = $this->rbacsystem;
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  switch ($permission) {
84  case "read":
85  case "visible":
86  if (!self::_lookupOnline($obj_id) &&
87  (!$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_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  {
100  }
101 
105  public static function _lookupOnlineStatus(array $a_ids): array
106  {
107  global $DIC;
108 
109  $ilDB = $DIC->database();
110 
111  $q = "SELECT id, is_online FROM usr_portfolio WHERE " .
112  $ilDB->in("id", $a_ids, false, "integer");
113  $lm_set = $ilDB->query($q);
114  $status = [];
115  while ($r = $ilDB->fetchAssoc($lm_set)) {
116  $status[$r["id"]] = $r["is_online"];
117  }
118  return $status;
119  }
120 
121 
125  public static function _checkGoto(string $target): bool
126  {
127  global $DIC;
128 
129  $ilAccess = $DIC->access();
130 
131  $t_arr = explode("_", $target);
132 
133  if ($t_arr[0] !== "prtt" || ((int) $t_arr[1]) <= 0) {
134  return false;
135  }
136 
137  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
138  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
139  return true;
140  }
141  return false;
142  }
143 }
addInfoItem(string $a_type, string $a_text, string $a_data="")
add an info item to current info object
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...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static lookupOnline(int $a_id)
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
$lm_set
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$q
Definition: shib_logout.php:21
$r
static _checkGoto(string $target)
check whether goto script will succeed