ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPollAccess.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Object/classes/class.ilObjectAccess.php");
6require_once('./Services/WebAccessChecker/interfaces/interface.ilWACCheckingClass.php');
7
16{
20 protected $user;
21
25 protected $lng;
26
30 protected $rbacsystem;
31
35 protected $access;
36
37
41 public function __construct()
42 {
43 global $DIC;
44
45 $this->user = $DIC->user();
46 $this->lng = $DIC->language();
47 $this->rbacsystem = $DIC->rbac()->system();
48 $this->access = $DIC->access();
49 }
50
63 public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
64 {
68 $ilAccess = $this->access;
69
70 if ($a_user_id == "") {
71 $a_user_id = $ilUser->getId();
72 }
73
74 if (
75 $a_cmd == 'preview' &&
76 $a_permission == 'read'
77 ) {
78 return false;
79 }
80
81 // check "global" online switch
82 if (!self::_lookupOnline($a_obj_id) &&
83 !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
84 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
85 return false;
86 }
87
88 return true;
89 }
90
94 public static function _lookupOnline($a_obj_id)
95 {
96 global $DIC;
97
98 $ilDB = $DIC->database();
99
100 $result = $ilDB->query("SELECT * FROM il_poll" .
101 " WHERE id = " . $ilDB->quote($a_obj_id, "integer"));
102 $row = $ilDB->fetchAssoc($result);
103 return $row["online_status"];
104 }
105
113 public static function _isActivated($a_ref_id)
114 {
115 include_once './Services/Object/classes/class.ilObjectActivation.php';
116 $item = ilObjectActivation::getItem($a_ref_id);
117 switch ($item['timing_type']) {
119 if (time() < $item['timing_start'] or
120 time() > $item['timing_end']) {
121 return false;
122 }
123 // fallthrough
124
125 // no break
126 default:
127 return true;
128 }
129 }
130
143 public static function _getCommands()
144 {
145 $commands = array(
146 array("permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true),
147 array("permission" => "write", "cmd" => "render", "lang_var" => "edit"),
148 // array("permission" => "write", "cmd" => "export", "lang_var" => "export")
149 );
150
151 return $commands;
152 }
153
157 public static function _checkGoto($a_target)
158 {
159 global $DIC;
160
161 $ilAccess = $DIC->access();
162
163 $t_arr = explode("_", $a_target);
164
165 if ($t_arr[0] != "poll" || ((int) $t_arr[1]) <= 0) {
166 return false;
167 }
168
169 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
170 return true;
171 }
172 return false;
173 }
174
175
181 public function canBeDelivered(ilWACPath $ilWACPath)
182 {
183 $ilAccess = $this->access;
184 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
185
186 foreach (ilObject2::_getAllReferences($results[1]) as $ref_id) {
187 if ($ilAccess->checkAccess('read', '', $ref_id)) {
188 return true;
189 }
190 }
191
192 return false;
193 }
194}
$result
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_NO_OBJECT_ACCESS
Class ilObjPollAccess.
__construct()
Constructor.
static _isActivated($a_ref_id)
Is activated?
static _getCommands()
get commands
static _lookupOnline($a_obj_id)
get status
_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...
static _checkGoto($a_target)
check whether goto script will succeed
canBeDelivered(ilWACPath $ilWACPath)
static _getAllReferences($a_id)
get all reference ids of object
Class ilObjectAccess.
static getItem($a_ref_id)
Get item data.
Class ilWACPath.
Class ilWACCheckingClass.
$row
global $DIC
Definition: saml.php:7
global $ilDB
$results
Definition: svg-scanner.php:47
$ilUser
Definition: imgupload.php:18