[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 require dirname(__FILE__).'/../inc/admin/prepend.php'; 24 25 dcPage::check('usage,contentadmin'); 26 27 $params = array(); 28 29 /* Actions 30 -------------------------------------------------------- */ 31 if (!empty($_POST['action']) && !empty($_POST['entries'])) 32 { 33 $entries = $_POST['entries']; 34 $action = $_POST['action']; 35 36 if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) 37 { 38 $redir = $_POST['redir']; 39 } 40 else 41 { 42 $redir = 43 'posts.php?user_id='.$_POST['user_id']. 44 '&cat_id='.$_POST['cat_id']. 45 '&status='.$_POST['status']. 46 '&selected='.$_POST['selected']. 47 '&month='.$_POST['month']. 48 '&lang='.$_POST['lang']. 49 '&sortby='.$_POST['sortby']. 50 '&order='.$_POST['order']. 51 '&page='.$_POST['page']. 52 '&nb='.$_POST['nb']; 53 } 54 55 foreach ($entries as $k => $v) { 56 $entries[$k] = (integer) $v; 57 } 58 59 $params['sql'] = 'AND P.post_id IN('.implode(',',$entries).') '; 60 $params['no_content'] = true; 61 62 $posts = $core->blog->getPosts($params); 63 64 # --BEHAVIOR-- adminPostsActions 65 $core->callBehavior('adminPostsActions',$core,$posts,$action,$redir); 66 67 if (preg_match('/^(publish|unpublish|schedule|pending)$/',$action)) 68 { 69 switch ($action) { 70 case 'unpublish' : $status = 0; break; 71 case 'schedule' : $status = -1; break; 72 case 'pending' : $status = -2; break; 73 default : $status = 1; break; 74 } 75 76 try 77 { 78 while ($posts->fetch()) { 79 $core->blog->updPostStatus($posts->post_id,$status); 80 } 81 82 http::redirect($redir); 83 } 84 catch (Exception $e) 85 { 86 $core->error->add($e->getMessage()); 87 } 88 } 89 elseif ($action == 'delete') 90 { 91 try 92 { 93 while ($posts->fetch()) { 94 $core->blog->delPost($posts->post_id); 95 } 96 97 http::redirect($redir); 98 } 99 catch (Exception $e) 100 { 101 $core->error->add($e->getMessage()); 102 } 103 104 } 105 elseif ($action == 'category' && isset($_POST['new_cat_id'])) 106 { 107 try 108 { 109 while ($posts->fetch()) 110 { 111 $new_cat_id = (integer) $_POST['new_cat_id']; 112 $core->blog->updPostCategory($posts->post_id,$new_cat_id); 113 } 114 http::redirect($redir); 115 } 116 catch (Exception $e) 117 { 118 $core->error->add($e->getMessage()); 119 } 120 } 121 elseif ($action == 'author' && isset($_POST['new_auth_id']) 122 && $core->auth->check('admin',$core->blog->id)) 123 { 124 $new_user_id = $_POST['new_auth_id']; 125 126 try 127 { 128 if ($core->getUser($new_user_id)->isEmpty()) { 129 throw new Exception(__('This user does not exists')); 130 } 131 132 while ($posts->fetch()) 133 { 134 $cur = $core->con->openCursor($core->prefix.'post'); 135 $cur->user_id = $new_user_id; 136 $cur->update('WHERE post_id = '.(integer) $posts->post_id); 137 } 138 139 http::redirect($redir); 140 } 141 catch (Exception $e) 142 { 143 $core->error->add($e->getMessage()); 144 } 145 } 146 } 147 148 /* DISPLAY 149 -------------------------------------------------------- */ 150 dcPage::open(__('Entries')); 151 152 if (!isset($action)) { 153 dcPage::close(); 154 exit; 155 } 156 157 $hidden_fields = ''; 158 while ($posts->fetch()) { 159 $hidden_fields .= form::hidden(array('entries[]'),$posts->post_id); 160 } 161 162 if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) 163 { 164 $hidden_fields .= form::hidden(array('redir'),$_POST['redir']); 165 } 166 else 167 { 168 $hidden_fields .= 169 form::hidden(array('user_id'),$_POST['user_id']). 170 form::hidden(array('cat_id'),$_POST['cat_id']). 171 form::hidden(array('status'),$_POST['status']). 172 form::hidden(array('selected'),$_POST['selected']). 173 form::hidden(array('month'),$_POST['month']). 174 form::hidden(array('lang'),$_POST['lang']). 175 form::hidden(array('sortby'),$_POST['sortby']). 176 form::hidden(array('order'),$_POST['order']). 177 form::hidden(array('page'),$_POST['page']). 178 form::hidden(array('nb'),$_POST['nb']); 179 } 180 181 # --BEHAVIOR-- adminPostsActionsContent 182 $core->callBehavior('adminPostsActionsContent',$core,$action,$hidden_fields); 183 184 if ($action == 'category') 185 { 186 echo '<h2>'.__('Change category for entries').'</h2>'; 187 188 # categories list 189 # Getting categories 190 $categories_combo = array(' ' => ''); 191 try { 192 $categories = $core->blog->getCategories(); 193 while ($categories->fetch()) { 194 $categories_combo[$categories->cat_title] = $categories->cat_id; 195 } 196 } catch (Exception $e) { } 197 198 echo 199 '<form action="posts_actions.php" method="post">'. 200 '<p><label class="classic">'.__('Category:').' '. 201 form::combo('new_cat_id',$categories_combo,''). 202 '</label> '; 203 204 echo 205 $hidden_fields. 206 form::hidden(array('action'),'category'). 207 '<input type="submit" value="'.__('save').'" /></p>'. 208 '</form>'; 209 } 210 elseif ($action == 'author' && $core->auth->check('admin',$core->blog->id)) 211 { 212 echo '<h2>'.__('Change author for entries').'</h2>'; 213 214 echo 215 '<form action="posts_actions.php" method="post">'. 216 '<p><label class="classic">'.__('Author ID:').' '. 217 form::field('new_auth_id',20,255). 218 '</label> '; 219 220 echo 221 $hidden_fields. 222 form::hidden(array('action'),'author'). 223 '<input type="submit" value="'.__('save').'" /></p>'. 224 '</form>'; 225 } 226 227 echo '<p><a href="'.str_replace('&','&',$redir).'">'.__('back').'</a></p>'; 228 229 dcPage::close(); 230 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |