[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: admin.trash.php 5412 2006-10-10 22:08:59Z Saka $ 4 * @package Joomla 5 * @subpackage Trash 6 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 7 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 17 18 // ensure user has access to this function 19 if (!($acl->acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_trash' ))) { 20 mosRedirect( 'index2.php', _NOT_AUTH ); 21 } 22 23 require_once( $mainframe->getPath( 'admin_html' ) ); 24 require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); 25 26 $mid = josGetArrayInts( 'mid' ); 27 $cid = josGetArrayInts( 'cid' ); 28 29 switch ($task) { 30 case 'deleteconfirm': 31 viewdeleteTrash( $cid, $mid, $option ); 32 break; 33 34 case 'delete': 35 deleteTrash( $cid, $option ); 36 break; 37 38 case 'restoreconfirm': 39 viewrestoreTrash( $cid, $mid, $option ); 40 break; 41 42 case 'restore': 43 restoreTrash( $cid, $option ); 44 break; 45 46 default: 47 viewTrash( $option ); 48 break; 49 } 50 51 52 /** 53 * Compiles a list of trash items 54 */ 55 function viewTrash( $option ) { 56 global $database, $mainframe, $mosConfig_list_limit; 57 58 $catid = $mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 'content' ); 59 $limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) ); 60 $limitstart = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) ); 61 62 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 63 64 if ($catid=="content") { 65 // get the total number of content 66 $query = "SELECT count(*)" 67 . "\n FROM #__content AS c" 68 . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" 69 . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'" 70 . "\n WHERE c.state = -2" 71 ; 72 $database->setQuery( $query ); 73 $total = $database->loadResult(); 74 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 75 76 // Query content items 77 $query = "SELECT c.*, g.name AS groupname, cc.name AS catname, s.name AS sectname" 78 . "\n FROM #__content AS c" 79 . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" 80 . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" 81 . "\n INNER JOIN #__groups AS g ON g.id = c.access" 82 . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" 83 . "\n WHERE c.state = -2" 84 . "\n ORDER BY s.name, cc.name, c.title" 85 ; 86 $database->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); 87 $content = $database->loadObjectList(); 88 89 $num = $total; 90 if ( $limit < $total ) { 91 $num = $limit; 92 } 93 for ( $i = 0; $i < $num-1; $i++ ) { 94 if ( ( $content[$i]->sectionid == 0 ) && ( $content[$i]->catid == 0 ) ) { 95 $content[$i]->sectname = 'Static Content'; 96 } 97 } 98 } else { 99 // get the total number of menu 100 $query = "SELECT count(*)" 101 . "\n FROM #__menu AS m" 102 . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" 103 . "\n WHERE m.published = -2" 104 ; 105 $database->setQuery( $query ); 106 $total = $database->loadResult(); 107 108 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 109 110 // Query menu items 111 $query = "SELECT m.name AS title, m.menutype AS sectname, m.type AS catname, m.id AS id" 112 . "\n FROM #__menu AS m" 113 . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out" 114 . "\n WHERE m.published = -2" 115 . "\n ORDER BY m.menutype, m.ordering, m.ordering, m.name" 116 ; 117 $database->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); 118 $content = $database->loadObjectList(); 119 } 120 121 // Build the select list 122 $listselect = array(); 123 $listselect[] = mosHTML::makeOption( 'content', 'Content Items' ); 124 $listselect[] = mosHTML::makeOption( 'menu', 'Menu Items' ); 125 $selected = "all"; 126 127 $list = mosHTML::selectList( $listselect, 'catid', 'class="inputbox" size="1" ' . 'onchange="document.adminForm.submit();"', 'value', 'text', $catid ); 128 129 HTML_trash::showList( $option, $content, $pageNav, $list, $catid ); 130 } 131 132 133 /** 134 * Compiles a list of the items you have selected to permanently delte 135 */ 136 function viewdeleteTrash( $cid, $mid, $option ) { 137 global $database; 138 139 if (!in_array( 0, $cid )) { 140 // Content Items query 141 mosArrayToInts( $cid ); 142 $cids = 'a.id=' . implode( ' OR a.id=', $cid ); 143 $query = "SELECT a.title AS name" 144 . "\n FROM #__content AS a" 145 . "\n WHERE ( $cids )" 146 . "\n ORDER BY a.title" 147 ; 148 $database->setQuery( $query ); 149 $items = $database->loadObjectList(); 150 $id = $cid; 151 $type = 'content'; 152 } else if (!in_array( 0, $mid )) { 153 // Content Items query 154 mosArrayToInts( $mid ); 155 $mids = 'a.id=' . implode( ' OR a.id=', $mid ); 156 $query = "SELECT a.name" 157 . "\n FROM #__menu AS a" 158 . "\n WHERE ( $mids )" 159 . "\n ORDER BY a.name" 160 ; 161 $database->setQuery( $query ); 162 $items = $database->loadObjectList(); 163 $id = $mid; 164 $type = 'menu'; 165 } 166 167 HTML_trash::showDelete( $option, $id, $items, $type ); 168 } 169 170 171 /** 172 * Permanently deletes the selected list of trash items 173 */ 174 function deleteTrash( $cid, $option ) { 175 global $database; 176 177 $type = mosGetParam( $_POST, 'type', array(0) ); 178 179 $total = count( $cid ); 180 181 if ( $type == 'content' ) { 182 $obj = new mosContent( $database ); 183 $fp = new mosFrontPage( $database ); 184 foreach ( $cid as $id ) { 185 $id = intval( $id ); 186 $obj->delete( $id ); 187 $fp->delete( $id ); 188 } 189 } else if ( $type == 'menu' ) { 190 $obj = new mosMenu( $database ); 191 foreach ( $cid as $id ) { 192 $id = intval( $id ); 193 $obj->delete( $id ); 194 } 195 } 196 197 $msg = $total. " Item(s) successfully Deleted"; 198 mosRedirect( "index2.php?option=$option&mosmsg=". $msg ."" ); 199 } 200 201 202 /** 203 * Compiles a list of the items you have selected to permanently delte 204 */ 205 function viewrestoreTrash( $cid, $mid, $option ) { 206 global $database; 207 208 if (!in_array( 0, $cid )) { 209 // Content Items query 210 mosArrayToInts( $cid ); 211 $cids = 'a.id=' . implode( ' OR a.id=', $cid ); 212 $query = "SELECT a.title AS name" 213 . "\n FROM #__content AS a" 214 . "\n WHERE ( $cids )" 215 . "\n ORDER BY a.title" 216 ; 217 $database->setQuery( $query ); 218 $items = $database->loadObjectList(); 219 $id = $cid; 220 $type = "content"; 221 } else if (!in_array( 0, $mid )) { 222 // Content Items query 223 mosArrayToInts( $mid ); 224 $mids = 'a.id=' . implode( ' OR a.id=', $mid ); 225 $query = "SELECT a.name" 226 . "\n FROM #__menu AS a" 227 . "\n WHERE ( $mids )" 228 . "\n ORDER BY a.name" 229 ; 230 $database->setQuery( $query ); 231 $items = $database->loadObjectList(); 232 $id = $mid; 233 $type = "menu"; 234 } 235 236 HTML_trash::showRestore( $option, $id, $items, $type ); 237 } 238 239 240 /** 241 * Restores items selected to normal - restores to an unpublished state 242 */ 243 function restoreTrash( $cid, $option ) { 244 global $database; 245 246 $type = mosGetParam( $_POST, 'type', array(0) ); 247 248 $total = count( $cid ); 249 250 // restores to an unpublished state 251 $state = 0; 252 $ordering = 9999; 253 254 if ( $type == 'content' ) { 255 // query to restore content items 256 mosArrayToInts( $cid ); 257 $cids = 'id=' . implode( ' OR id=', $cid ); 258 $query = "UPDATE #__content" 259 . "\n SET state = " . (int) $state . ", ordering = " . (int) $ordering 260 . "\n WHERE ( $cids )" 261 ; 262 $database->setQuery( $query ); 263 if ( !$database->query() ) { 264 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 265 exit(); 266 } 267 } else if ( $type == 'menu' ) { 268 sort( $cid ); 269 270 foreach ( $cid as $id ) { 271 $check = 1; 272 $row = new mosMenu( $database ); 273 $row->load( $id ); 274 275 // check if menu item is a child item 276 if ( $row->parent != 0 ) { 277 $query = "SELECT id" 278 . "\n FROM #__menu" 279 . "\n WHERE id = " . (int) $row->parent 280 . "\n AND ( published = 0 OR published = 1 )" 281 ; 282 $database->setQuery( $query ); 283 $check = $database->loadResult(); 284 285 if ( !$check ) { 286 // if menu items parent is not found that are published/unpublished make it a root menu item 287 $query = "UPDATE #__menu" 288 . "\n SET parent = 0, published = " . (int) $state . ", ordering = 9999" 289 . "\n WHERE id = " . (int) $id 290 ; 291 } 292 } 293 294 if ( $check ) { 295 // query to restore menu items 296 $query = "UPDATE #__menu" 297 . "\n SET published = " . (int) $state . ", ordering = 9999" 298 . "\n WHERE id = " . (int) $id 299 ; 300 } 301 302 $database->setQuery( $query ); 303 if ( !$database->query() ) { 304 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 305 exit(); 306 } 307 } 308 } 309 310 $msg = $total. " Item(s) successfully Restored"; 311 mosRedirect( "index2.php?option=$option&mosmsg=". $msg ."" ); 312 } 313 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |