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

  • Blueprint
  • BlueprintNode
  • BreadcrumbElement
  • Content
  • ContentModel
  • CopyOperation
  • DeleteOperation
  • EditBlock
  • ExportBlock
  • ExportOperation
  • Hooks
  • ImportOperation
  • LanguagesElement
  • ListView
  • ManageBlock
  • Model
  • Module
  • NavigationBranchElement
  • NavigationElement
  • NavigationExcludeOperation
  • NavigationIncludeOperation
  • Page
  • PageController
  • PopPage
  • PopTemplate
  • QueryOperationOperation
  • SaveOperation
  • TemplateEditorsOperation
  • UpdateTreeOperation
 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\Pages;
13 
14 use ICanBoogie\I18n\FormattedString;
15 
16 class CopyOperation extends \ICanBoogie\Operation
17 {
18     protected function get_controls()
19     {
20         return array
21         (
22             self::CONTROL_PERMISSION => Module::PERMISSION_CREATE,
23             self::CONTROL_RECORD => true
24         )
25 
26         + parent::get_controls();
27     }
28 
29     protected function process()
30     {
31         global $core;
32 
33         $record = $this->record;
34         $key = $this->key;
35         $title = $record->title;
36 
37         unset($record->nid);
38         unset($record->is_online);
39         unset($record->created_at);
40         unset($record->updated_at);
41 
42         $record->uid = $core->user_id;
43         $record->title .= ' (copie)';
44         $record->slug .= '-copie';
45 
46         $contentsModel = $this->module->model('contents');
47         $contents = $contentsModel->where(array('pageid' => $key))->all;
48 
49         $nid = $this->module->model->save((array) $record);
50 
51         if (!$nid)
52         {
53             \ICanBoogie\log_error('Unable to copy page %title (#:nid)', array('title' => $title, 'nid' => $key));
54 
55             return;
56         }
57 
58         $this->response->message = new FormattedString('Page %title was copied to %copy', array('title' => $title, 'copy' => $record->title));
59 
60         foreach ($contents as $record)
61         {
62             $record->pageid = $nid;
63             $record = (array) $record;
64 
65             $contentsModel->insert
66             (
67                 $record,
68 
69                 array
70                 (
71                     'on duplicate' => $record
72                 )
73             );
74         }
75 
76         return array($key, $nid);
77     }
78 }
Autodoc API documentation generated by ApiGen 2.8.0