[2055] | 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 | |
---|
[3730] | 13 | class dcPagesActionsPage extends dcPostsActionsPage |
---|
| 14 | { |
---|
| 15 | public function __construct($core, $uri, $redirect_args = array()) |
---|
| 16 | { |
---|
| 17 | parent::__construct($core, $uri, $redirect_args); |
---|
| 18 | $this->redirect_fields = array(); |
---|
| 19 | $this->caller_title = __('Pages'); |
---|
[2055] | 20 | |
---|
[3730] | 21 | } |
---|
[2055] | 22 | |
---|
[3730] | 23 | public function error(Exception $e) |
---|
| 24 | { |
---|
| 25 | $this->core->error->add($e->getMessage()); |
---|
| 26 | $this->beginPage(dcPage::breadcrumb( |
---|
| 27 | array( |
---|
| 28 | html::escapeHTML($this->core->blog->name) => '', |
---|
| 29 | __('Pages') => $this->getRedirection(true), |
---|
| 30 | __('Pages actions') => '' |
---|
| 31 | )) |
---|
| 32 | ); |
---|
| 33 | $this->endPage(); |
---|
| 34 | } |
---|
[2055] | 35 | |
---|
[3730] | 36 | public function beginPage($breadcrumb = '', $head = '') |
---|
| 37 | { |
---|
| 38 | echo '<html><head><title>' . __('Pages') . '</title>' . |
---|
| 39 | dcPage::jsLoad('js/_posts_actions.js') . |
---|
| 40 | $head . |
---|
| 41 | '</script></head><body>' . |
---|
| 42 | $breadcrumb; |
---|
| 43 | echo '<p><a class="back" href="' . $this->getRedirection(true) . '">' . __('Back to pages list') . '</a></p>'; |
---|
[2055] | 44 | |
---|
[3730] | 45 | } |
---|
[2566] | 46 | |
---|
[3730] | 47 | public function endPage() |
---|
| 48 | { |
---|
| 49 | echo '</body></html>'; |
---|
| 50 | } |
---|
[2055] | 51 | |
---|
[3730] | 52 | public function loadDefaults() |
---|
| 53 | { |
---|
| 54 | DefaultPagesActions::adminPagesActionsPage($this->core, $this); |
---|
| 55 | $this->actions['reorder'] = array('dcPagesActionsPage', 'doReorderPages'); |
---|
| 56 | $this->core->callBehavior('adminPagesActionsPage', $this->core, $this); |
---|
[2566] | 57 | |
---|
[3730] | 58 | } |
---|
| 59 | public function process() |
---|
| 60 | { |
---|
| 61 | // fake action for pages reordering |
---|
| 62 | if (!empty($this->from['reorder'])) { |
---|
| 63 | $this->from['action'] = 'reorder'; |
---|
| 64 | } |
---|
| 65 | $this->from['post_type'] = 'page'; |
---|
| 66 | return parent::process(); |
---|
| 67 | } |
---|
[2566] | 68 | |
---|
[3730] | 69 | public static function doReorderPages($core, dcPostsActionsPage $ap, $post) |
---|
| 70 | { |
---|
| 71 | foreach ($post['order'] as $post_id => $value) { |
---|
| 72 | if (!$core->auth->check('publish,contentadmin', $core->blog->id)) { |
---|
| 73 | throw new Exception(__('You are not allowed to change this entry status')); |
---|
| 74 | } |
---|
[2566] | 75 | |
---|
[3730] | 76 | $strReq = "WHERE blog_id = '" . $core->con->escape($core->blog->id) . "' " . |
---|
| 77 | "AND post_id " . $core->con->in($post_id); |
---|
[2566] | 78 | |
---|
[3730] | 79 | #If user can only publish, we need to check the post's owner |
---|
| 80 | if (!$core->auth->check('contentadmin', $core->blog->id)) { |
---|
| 81 | $strReq .= "AND user_id = '" . $core->con->escape($core->auth->userID()) . "' "; |
---|
| 82 | } |
---|
[2566] | 83 | |
---|
[3730] | 84 | $cur = $core->con->openCursor($core->prefix . 'post'); |
---|
[2566] | 85 | |
---|
[3730] | 86 | $cur->post_position = (integer) $value - 1; |
---|
| 87 | $cur->post_upddt = date('Y-m-d H:i:s'); |
---|
[2566] | 88 | |
---|
[3730] | 89 | $cur->update($strReq); |
---|
| 90 | $core->blog->triggerBlog(); |
---|
[2566] | 91 | |
---|
[3730] | 92 | } |
---|
| 93 | |
---|
| 94 | dcPage::addSuccessNotice(__('Selected pages have been successfully reordered.')); |
---|
| 95 | $ap->redirect(false); |
---|
| 96 | } |
---|
[2055] | 97 | } |
---|
| 98 | |
---|
[2566] | 99 | class DefaultPagesActions |
---|
[2055] | 100 | { |
---|
[3730] | 101 | public static function adminPagesActionsPage($core, $ap) |
---|
| 102 | { |
---|
| 103 | if ($core->auth->check('publish,contentadmin', $core->blog->id)) { |
---|
| 104 | $ap->addAction( |
---|
| 105 | array(__('Status') => array( |
---|
| 106 | __('Publish') => 'publish', |
---|
| 107 | __('Unpublish') => 'unpublish', |
---|
| 108 | __('Schedule') => 'schedule', |
---|
| 109 | __('Mark as pending') => 'pending' |
---|
| 110 | )), |
---|
| 111 | array('dcDefaultPostActions', 'doChangePostStatus') |
---|
| 112 | ); |
---|
| 113 | } |
---|
| 114 | if ($core->auth->check('admin', $core->blog->id)) { |
---|
| 115 | $ap->addAction( |
---|
| 116 | array(__('Change') => array( |
---|
| 117 | __('Change author') => 'author')), |
---|
| 118 | array('dcDefaultPostActions', 'doChangePostAuthor') |
---|
| 119 | ); |
---|
| 120 | } |
---|
| 121 | if ($core->auth->check('delete,contentadmin', $core->blog->id)) { |
---|
| 122 | $ap->addAction( |
---|
| 123 | array(__('Delete') => array( |
---|
| 124 | __('Delete') => 'delete')), |
---|
| 125 | array('dcDefaultPostActions', 'doDeletePost') |
---|
| 126 | ); |
---|
| 127 | } |
---|
| 128 | } |
---|
[2566] | 129 | } |
---|