Changeset 3730:5c45a5df9a59 for plugins/pages/class.actionpage.php
- Timestamp:
- 03/08/18 17:58:39 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pages/class.actionpage.php
r2566 r3730 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 12 13 class dcPagesActionsPage extends dcPostsActionsPage { 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'); 14 20 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'); 21 } 19 22 20 } 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 } 21 35 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>'; 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>'; 40 44 41 45 } 42 46 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); 47 public function endPage() 48 { 49 echo '</body></html>'; 50 } 50 51 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 } 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); 60 57 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')); 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 } 65 68 66 $strReq = "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ". 67 "AND post_id ".$core->con->in($post_id); 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 } 68 75 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())."' "; 76 $strReq = "WHERE blog_id = '" . $core->con->escape($core->blog->id) . "' " . 77 "AND post_id " . $core->con->in($post_id); 72 78 73 $cur = $core->con->openCursor($core->prefix.'post'); 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 } 74 83 75 $cur->post_position = (integer) $value-1; 76 $cur->post_upddt = date('Y-m-d H:i:s'); 84 $cur = $core->con->openCursor($core->prefix . 'post'); 77 85 78 $cur->update($strReq);79 $core->blog->triggerBlog();86 $cur->post_position = (integer) $value - 1; 87 $cur->post_upddt = date('Y-m-d H:i:s'); 80 88 81 } 89 $cur->update($strReq); 90 $core->blog->triggerBlog(); 82 91 83 dcPage::addSuccessNotice(__('Selected pages have been successfully reordered.')); 84 $ap->redirect(false); 85 } 92 } 93 94 dcPage::addSuccessNotice(__('Selected pages have been successfully reordered.')); 95 $ap->redirect(false); 96 } 86 97 } 87 98 88 99 class DefaultPagesActions 89 100 { 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 105 106 107 array('dcDefaultPostActions','doChangePostAuthor')108 109 110 if ($core->auth->check('delete,contentadmin',$core->blog->id)) {111 112 113 114 array('dcDefaultPostActions','doDeletePost')115 116 117 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 } 118 129 }
Note: See TracChangeset
for help on using the changeset viewer.