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

  • ActivateOperation
  • DeactivateOperation
  • InactivesBlock
  • ManageBlock
  • ManageController
  • Module
 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\Modules;
13 
14 use ICanBoogie\I18n;
15 
16 /**
17  * Deactivates the specified modules.
18  */
19 class DeactivateOperation extends \ICanBoogie\Operation
20 {
21     protected function get_controls()
22     {
23         return array
24         (
25             self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER
26         )
27 
28         + parent::get_controls();
29     }
30 
31     /**
32      * Only modules which are not used by other modules can be disabled.
33      */
34     protected function validate(\ICanboogie\Errors $errors)
35     {
36         global $core;
37 
38         if ($this->key)
39         {
40             foreach (array_keys($this->key) as $module_id)
41             {
42                 $n = $core->modules->usage($module_id);
43 
44                 if ($n)
45                 {
46                     $errors[] = $errors->format
47                     (
48                         'The module %title cannot be disabled, :count modules are using it.', array
49                         (
50                             'title' => I18n\t($module_id, array(), array('scope' => 'module_title')),
51                             ':count' => $n
52                         )
53                     );
54                 }
55             }
56         }
57 
58         return $errors;
59     }
60 
61     protected function process()
62     {
63         global $core;
64 
65         $enabled = array_keys($core->modules->enabled_modules_descriptors);
66         $enabled = array_combine($enabled, $enabled);
67 
68         if ($this->key)
69         {
70             foreach (array_keys($this->key) as $key)
71             {
72                 unset($enabled[$key]);
73                 unset($core->modules[$key]);
74             }
75         }
76 
77         $core->vars['enabled_modules'] = array_values($enabled);
78 
79         $this->response->location = \ICanBoogie\Routing\contextualize('/admin/' . $this->module->id);
80 
81         return true;
82     }
83 }
Autodoc API documentation generated by ApiGen 2.8.0