Dotclear

source: plugins/pages/class.actionpage.php @ 2566:9bf417837888

Revision 2566:9bf417837888, 3.4 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Add some people in CREDITS, remove trailing spaces and tabs.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13class dcPagesActionsPage extends dcPostsActionsPage {
14
15     public function __construct($core,$uri,$redirect_args=array()) {
16          parent::__construct($core,$uri,$redirect_args);
17          $this->redirect_fields = array();
18          $this->caller_title = __('Pages');
19
20     }
21
22     public function error(Exception $e) {
23          $this->core->error->add($e->getMessage());
24          $this->beginPage(dcPage::breadcrumb(
25               array(
26                    html::escapeHTML($this->core->blog->name) => '',
27                    __('Pages') => $this->getRedirection(true),
28                    __('Pages actions') => ''
29               ))
30          );
31          $this->endPage();
32     }
33     public function beginPage($breadcrumb='',$head='') {
34          echo '<html><head><title>'.__('Pages').'</title>'.
35               dcPage::jsLoad('js/_posts_actions.js').
36               $head.
37               '</script></head><body>'.
38               $breadcrumb;
39          echo '<p><a class="back" href="'.$this->getRedirection(true).'">'.__('Back to pages list').'</a></p>';
40
41     }
42
43     public function endPage() {
44          echo '</body></html>';
45     }
46     public function loadDefaults() {
47          DefaultPagesActions::adminPagesActionsPage($this->core,$this);
48          $this->actions['reorder']=array('dcPagesActionsPage','doReorderPages');
49          $this->core->callBehavior('adminPagesActionsPage',$this->core,$this);
50
51     }
52     public function process() {
53          // fake action for pages reordering
54          if (!empty($this->from['reorder'])) {
55               $this->from['action']='reorder';
56          }
57          $this->from['post_type']='page';
58          return parent::process();
59     }
60
61     public static function doReorderPages($core, dcPostsActionsPage $ap, $post) {
62          foreach($post['order'] as $post_id => $value) {
63               if (!$core->auth->check('publish,contentadmin',$core->blog->id))
64                    throw new Exception(__('You are not allowed to change this entry status'));
65
66               $strReq = "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ".
67                         "AND post_id ".$core->con->in($post_id);
68
69               #If user can only publish, we need to check the post's owner
70               if (!$core->auth->check('contentadmin',$core->blog->id))
71                    $strReq .= "AND user_id = '".$core->con->escape($core->auth->userID())."' ";
72
73               $cur = $core->con->openCursor($core->prefix.'post');
74
75               $cur->post_position = (integer) $value-1;
76               $cur->post_upddt = date('Y-m-d H:i:s');
77
78               $cur->update($strReq);
79               $core->blog->triggerBlog();
80
81          }
82
83          dcPage::addSuccessNotice(__('Selected pages have been successfully reordered.'));
84          $ap->redirect(false);
85     }
86}
87
88class DefaultPagesActions
89{
90     public static function adminPagesActionsPage($core, $ap) {
91          if ($core->auth->check('publish,contentadmin',$core->blog->id)) {
92               $ap->addAction(
93                    array(__('Status') => array(
94                         __('Publish') => 'publish',
95                         __('Unpublish') => 'unpublish',
96                         __('Schedule') => 'schedule',
97                         __('Mark as pending') => 'pending'
98                    )),
99                    array('dcDefaultPostActions','doChangePostStatus')
100               );
101          }
102          if ($core->auth->check('admin',$core->blog->id))
103          {
104               $ap->addAction(
105                    array(__('Change') => array(
106                         __('Change author') => 'author')),
107                    array('dcDefaultPostActions','doChangePostAuthor')
108               );
109          }
110          if ($core->auth->check('delete,contentadmin',$core->blog->id)) {
111               $ap->addAction(
112                    array(__('Delete') => array(
113                         __('Delete') => 'delete')),
114                    array('dcDefaultPostActions','doDeletePost')
115               );
116          }
117     }
118}
Note: See TracBrowser for help on using the repository browser.

Sites map