ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 // check "global" online switch
75 if (!self::_lookupOnline($a_obj_id) &&
76 !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
77 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
78 return false;
79 }
80
81 return true;
82 }
83
87 public static function _lookupOnline($a_obj_id)
88 {
89 global $DIC;
90
91 $ilDB = $DIC->database();
92
93 $result = $ilDB->query("SELECT * FROM il_poll" .
94 " WHERE id = " . $ilDB->quote($a_obj_id, "integer"));
95 $row = $ilDB->fetchAssoc($result);
96 return $row["online_status"];
97 }
98
106 public static function _isActivated($a_ref_id)
107 {
108 include_once './Services/Object/classes/class.ilObjectActivation.php';
109 $item = ilObjectActivation::getItem($a_ref_id);
110 switch ($item['timing_type']) {
112 if (time() < $item['timing_start'] or
113 time() > $item['timing_end']) {
114 return false;
115 }
116 // fallthrough
117
118 // no break
119 default:
120 return true;
121 }
122 }
123
136 public static function _getCommands()
137 {
138 $commands = array(
139 array("permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true),
140 array("permission" => "write", "cmd" => "render", "lang_var" => "edit"),
141 // array("permission" => "write", "cmd" => "export", "lang_var" => "export")
142 );
143
144 return $commands;
145 }
146
150 public static function _checkGoto($a_target)
151 {
152 global $DIC;
153
154 $ilAccess = $DIC->access();
155
156 $t_arr = explode("_", $a_target);
157
158 if ($t_arr[0] != "poll" || ((int) $t_arr[1]) <= 0) {
159 return false;
160 }
161
162 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
163 return true;
164 }
165 return false;
166 }
167
168
174 public function canBeDelivered(ilWACPath $ilWACPath)
175 {
176 $ilAccess = $this->access;
177 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
178
179 foreach (ilObject2::_getAllReferences($results[1]) as $ref_id) {
180 if ($ilAccess->checkAccess('read', '', $ref_id)) {
181 return true;
182 }
183 }
184
185 return false;
186 }
187}
$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.
global $DIC
Definition: saml.php:7
global $ilDB
$results
Definition: svg-scanner.php:47
$ilUser
Definition: imgupload.php:18