Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • Hooks
  • ManageBlock
  • Model
  • Module
  • PermissionsOperation
  • Role
  • SaveOperation
 1 <?php
 2 
 3 /*
 4  * This file is part of the Icybee package.
 5  *
 6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
 7  *
 8  * For the full copyright and license information, please view the LICENSE
 9  * file that was distributed with this source code.
10  */
11 
12 namespace Icybee\Modules\Users\Roles;
13 
14 class PermissionsOperation extends \ICanBoogie\Operation
15 {
16     protected function get_controls()
17     {
18         return array
19         (
20             self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER
21         )
22 
23         + parent::get_controls();
24     }
25 
26     protected function validate(\ICanboogie\Errors $errors)
27     {
28         return true;
29     }
30 
31     protected function process()
32     {
33         global $core;
34 
35         $request = $this->request;
36         $model = $this->module->model;
37 
38         foreach ($request['roles'] as $rid => $perms)
39         {
40             $role = $model[$rid];
41 
42             $p = array();
43 
44             foreach ($perms as $perm => $name)
45             {
46                 if ($name === 'inherit')
47                 {
48                     continue;
49                 }
50 
51                 if ($name === 'on')
52                 {
53                     if (isset($core->modules->descriptors[$perm]))
54                     {
55                         #
56                         # the module defines his permission level
57                         #
58 
59                         $p[$perm] = $core->modules->descriptors[$perm][Module::T_PERMISSION];
60 
61                         continue;
62                     }
63                     else
64                     {
65                         #
66                         # this is a special permission
67                         #
68 
69                         $p[$perm] = true;
70 
71                         continue;
72                     }
73                 }
74 
75                 $p[$perm] = is_numeric($name) ? $name : Role::$permission_levels[$name];
76             }
77 
78             $role->perms = $p;
79             $role->save();
80         }
81 
82         $this->response->message = 'Permissions have been saved.';
83 
84         return true;
85     }
86 }
Autodoc API documentation generated by ApiGen 2.8.0