ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_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 {
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}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_STATUS_MESSAGE
const IL_NO_OBJECT_ACCESS
static lookupOnline($a_id)
Is online?
Class ilObjPortfolioTemplateAccess.
static _checkGoto($a_target)
check whether goto script will succeed
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
Class ilObjectAccess.
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18