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

  • Comment
  • ConfigBlock
  • ConfigOperation
  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • Hooks
  • ManageBlock
  • Model
  • Module
  • PatchOperation
  • PreviewOperation
  • SaveOperation
  • SubmitForm
  • Update20131208
  • ViewProvider
 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\Comments;
13 
14 use ICanBoogie\Errors;
15 
16 class PatchOperation extends \ICanBoogie\Operation
17 {
18     protected function get_controls()
19     {
20         return array
21         (
22             self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER
23         )
24 
25         + parent::get_controls();
26     }
27 
28     protected function validate(Errors $errors)
29     {
30         $status = $this->request['status'];
31 
32         if ($status !== null && !in_array($status, array(Comment::STATUS_APPROVED, Comment::STATUS_PENDING, Comment::STATUS_SPAM)))
33         {
34             throw new \InvalidArgumentException('Invalid status value: ' . $status);
35         }
36 
37         return $errors;
38     }
39 
40     protected function process()
41     {
42         $record = $this->record;
43 
44         #
45 
46         $status = $this->request['status'];
47 
48         if ($status)
49         {
50             static $status_names = array
51             (
52                 Comment::STATUS_APPROVED => 'Approved',
53                 Comment::STATUS_PENDING => 'Pending',
54                 Comment::STATUS_SPAM => 'Spam'
55             );
56 
57             $record->status = $status;
58         }
59 
60         #
61 
62         $record->save();
63 
64         return true;
65     }
66 }
Autodoc API documentation generated by ApiGen 2.8.0