/
permissions.php
41 lines (36 loc) · 1.33 KB
/
permissions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Concrete\Controller\SinglePage\Dashboard\Blocks;
use Concrete\Core\Page\Controller\DashboardPageController;
use Concrete\Core\Permission\Access\Access;
use Concrete\Core\Permission\Checker;
use Concrete\Core\Permission\Key\Key as PermissionKey;
class Permissions extends DashboardPageController
{
public function save()
{
if ($this->token->validate('save_permissions')) {
$tp = new Checker();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('block_type');
foreach ($permissions as $pk) {
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = Access::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
return $this->buildRedirect($this->action('updated'));
}
} else {
$this->error->add($this->token->getErrorMessage());
}
}
public function updated()
{
$this->set('success', t('Permissions updated successfully.'));
}
}