ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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"),
51  array("permission" => "read", "cmd" => "createfromtemplate", "lang_var" => "prtf_create_portfolio_from_template"),
52  // array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
53  );
54 
55  return $commands;
56  }
57 
58  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
59  {
61  $lng = $this->lng;
63  $ilAccess = $this->access;
64 
65  if ($a_user_id == "") {
66  $a_user_id = $ilUser->getId();
67  }
68 
69  switch ($a_cmd) {
70  case "view":
71  if (!self::_lookupOnline($a_obj_id)
72  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
73  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
74  return false;
75  }
76  break;
77 
78  // for permission query feature
79  case "infoScreen":
80  if (!self::_lookupOnline($a_obj_id)) {
81  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
82  } else {
83  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
84  }
85  break;
86 
87  }
88 
89  switch ($a_permission) {
90  case "read":
91  case "visible":
92  if (!self::_lookupOnline($a_obj_id) &&
93  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
94  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
95  return false;
96  }
97  break;
98  }
99 
100  return true;
101  }
102 
103  public static function _lookupOnline($a_id)
104  {
106  }
107 
113  public static function _lookupOnlineStatus($a_ids)
114  {
115  global $DIC;
116 
117  $ilDB = $DIC->database();
118 
119  $q = "SELECT id, is_online FROM usr_portfolio WHERE " .
120  $ilDB->in("id", $a_ids, false, "integer");
121  $lm_set = $ilDB->query($q);
122  $status = [];
123  while ($r = $ilDB->fetchAssoc($lm_set)) {
124  $status[$r["id"]] = $r["is_online"];
125  }
126  return $status;
127  }
128 
129 
133  public static function _checkGoto($a_target)
134  {
135  global $DIC;
136 
137  $ilAccess = $DIC->access();
138 
139  $t_arr = explode("_", $a_target);
140 
141  if ($t_arr[0] != "prtt" || ((int) $t_arr[1]) <= 0) {
142  return false;
143  }
144 
145  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
146  $ilAccess->checkAccess("visible", "", $t_arr[1])) {
147  return true;
148  }
149  return false;
150  }
151 }
const IL_NO_OBJECT_ACCESS
user()
Definition: user.php:4
static lookupOnline($a_id)
Is online?
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
const IL_STATUS_MESSAGE
$ilUser
Definition: imgupload.php:18
static _lookupOnlineStatus($a_ids)
Check wether booking pool is online (legacy version)
$lm_set
global $ilDB
Class ilObjPortfolioTemplateAccess.
$DIC
Definition: xapitoken.php:46
static _checkGoto($a_target)
check whether goto script will succeed