ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPortfolioTemplateAccess.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObjectAccess.php");
5 
14 {
18  protected $user;
19 
23  protected $lng;
24 
28  protected $rbacsystem;
29 
33  protected $access;
34 
35 
39  public function __construct()
40  {
41  global $DIC;
42 
43  $this->user = $DIC->user();
44  $this->lng = $DIC->language();
45  $this->rbacsystem = $DIC->rbac()->system();
46  $this->access = $DIC->access();
47  }
48 
49  public static function _getCommands()
50  {
51  $commands = array(
52  array("permission" => "read", "cmd" => "preview", "lang_var" => "preview", "default" => true),
53  array("permission" => "write", "cmd" => "view", "lang_var" => "edit"),
54  array("permission" => "read", "cmd" => "createfromtemplate", "lang_var" => "prtf_create_portfolio_from_template"),
55  // array("permission" => "write", "cmd" => "export", "lang_var" => "export_html")
56  );
57 
58  return $commands;
59  }
60 
61  public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
62  {
64  $lng = $this->lng;
66  $ilAccess = $this->access;
67 
68  if ($a_user_id == "") {
69  $a_user_id = $ilUser->getId();
70  }
71 
72  switch ($a_cmd) {
73  case "view":
74  if (!self::_lookupOnline($a_obj_id)
75  && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
76  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
77  return false;
78  }
79  break;
80 
81  // for permission query feature
82  case "infoScreen":
83  if (!self::_lookupOnline($a_obj_id)) {
84  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
85  } else {
86  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
87  }
88  break;
89 
90  }
91 
92  switch ($a_permission) {
93  case "read":
94  case "visible":
95  if (!self::_lookupOnline($a_obj_id) &&
96  (!$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id))) {
97  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
98  return false;
99  }
100  break;
101  }
102 
103  return true;
104  }
105 
106  public static function _lookupOnline($a_id)
107  {
108  include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
110  }
111 
115  public static function _checkGoto($a_target)
116  {
117  global $DIC;
118 
119  $ilAccess = $DIC->access();
120 
121  $t_arr = explode("_", $a_target);
122 
123  if ($t_arr[0] != "prtt" || ((int) $t_arr[1]) <= 0) {
124  return false;
125  }
126 
127  if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
128  return true;
129  }
130  return false;
131  }
132 }
global $DIC
Definition: saml.php:7
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
Class ilObjectAccess.
Class ilObjPortfolioTemplateAccess.
static _checkGoto($a_target)
check whether goto script will succeed