Skip to content

Commit 451db4b

Browse files
committed
refs #244, correctly throw access denied exceptions
1 parent 1409921 commit 451db4b

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

blocks/Section/Section.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Mooc\UI\Block;
66
use Mooc\UI\Errors\BadRequest;
7+
use Mooc\UI\Errors\AccessDenied;
78
use Mooc\UI\Courseware\Courseware;
89

910
/**
@@ -95,7 +96,7 @@ function (Block $child) use ($context) {
9596
$json = $child->toJSON();
9697
$json['block_content'] = $child->render('student', $context);
9798
$json['view_name'] = 'student';
98-
99+
99100
if (!$child->getModel()->isVisible()) {
100101
$json['invisible'] = true;
101102
} else {
@@ -118,15 +119,15 @@ function (Block $child) use ($context) {
118119
$content_block_types_favorite = $block_types['favorite_blocks'];
119120

120121
return compact(
121-
'blocks',
122+
'blocks',
122123
'content_block_types_function',
123124
'content_block_types_interaction',
124125
'content_block_types_layout',
125126
'content_block_types_multimedia',
126127
'content_block_types_all',
127128
'content_block_types_favorite',
128129
'icon',
129-
'title',
130+
'title',
130131
'visited',
131132
'can_update'
132133
);
@@ -135,7 +136,7 @@ function (Block $child) use ($context) {
135136
public function add_content_block_handler($data)
136137
{
137138
if (!$this->container['current_user']->canCreate($this)) {
138-
throw new Errors\AccessDenied(_cw('Sie sind nicht berechtigt Blöcke anzulegen.'));
139+
throw new AccessDenied(_cw('Sie sind nicht berechtigt Blöcke anzulegen.'));
139140
}
140141

141142
if (!isset($data['type'])) {
@@ -180,7 +181,7 @@ public function add_content_block_handler($data)
180181
public function remove_content_block_handler($data)
181182
{
182183
if (!$this->container['current_user']->canUpdate($this)) {
183-
throw new Errors\AccessDenied(_cw('Sie sind nicht berechtigt Blöcke zu löschen.'));
184+
throw new AccessDenied(_cw('Sie sind nicht berechtigt Blöcke zu löschen.'));
184185
}
185186

186187
if (!isset($data['child_id'])) {
@@ -204,7 +205,7 @@ public function remove_content_block_handler($data)
204205
public function add_favorites_handler($data)
205206
{
206207
if (!$this->container['current_user']->canUpdate($this)) {
207-
throw new Errors\AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
208+
throw new AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
208209
}
209210
if (!isset($data['favorites'])) {
210211
throw new BadRequest('Type required.');
@@ -219,7 +220,7 @@ public function add_favorites_handler($data)
219220
public function set_icon_handler($data)
220221
{
221222
if (!$this->container['current_user']->canUpdate($this)) {
222-
throw new Errors\AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
223+
throw new AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
223224
}
224225
$this->custom_icon = true;
225226
if (in_array($data['icon'], $this->allowed_icons())) {
@@ -239,7 +240,7 @@ public function allowed_icons()
239240
public function visibility_handler($data)
240241
{
241242
if (!$this->container['current_user']->canUpdate($this)) {
242-
throw new Errors\AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
243+
throw new AccessDenied(_cw('Sie sind nicht berechtigt diese Änderung vorzunehmen.'));
243244
}
244245
$child = $this->_model->children->findOneBy('id', (int) $data['block_id']); //Mooc\DB\Block
245246

@@ -343,7 +344,7 @@ private function getBlockTypes()
343344
if (!class_exists($className)) {
344345
continue;
345346
}
346-
347+
347348
if ($type == 'EvaluationBlock') {
348349
continue;
349350
}

0 commit comments

Comments
 (0)