[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: admin.newsfeeds.php 5014 2006-09-11 19:35:26Z friesengeist $ 4 * @package Joomla 5 * @subpackage Newsfeeds 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', 'edit', 'users', $my->usertype, 'components', 'all' ) 20 | $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_newsfeeds' ))) { 21 mosRedirect( 'index2.php', _NOT_AUTH ); 22 } 23 24 require_once( $mainframe->getPath( 'admin_html' ) ); 25 require_once( $mainframe->getPath( 'class' ) ); 26 27 $cid = josGetArrayInts( 'cid' ); 28 29 switch ($task) { 30 31 case 'new': 32 editNewsFeed( 0, $option ); 33 break; 34 35 case 'edit': 36 editNewsFeed( intval( $cid[0] ), $option ); 37 break; 38 39 case 'editA': 40 editNewsFeed( $id, $option ); 41 break; 42 43 case 'save': 44 saveNewsFeed( $option ); 45 break; 46 47 case 'publish': 48 publishNewsFeeds( $cid, 1, $option ); 49 break; 50 51 case 'unpublish': 52 publishNewsFeeds( $cid, 0, $option ); 53 break; 54 55 case 'remove': 56 removeNewsFeeds( $cid, $option ); 57 break; 58 59 case 'cancel': 60 cancelNewsFeed( $option ); 61 break; 62 63 case 'orderup': 64 orderNewsFeed( intval( $cid[0] ), -1, $option ); 65 break; 66 67 case 'orderdown': 68 orderNewsFeed( intval( $cid[0] ), 1, $option ); 69 break; 70 71 default: 72 showNewsFeeds( $option ); 73 break; 74 } 75 76 /** 77 * List the records 78 * @param string The current GET/POST option 79 */ 80 function showNewsFeeds( $option ) { 81 global $database, $mainframe, $mosConfig_list_limit; 82 83 $catid = intval( $mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 0 ) ); 84 $limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) ); 85 $limitstart = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) ); 86 87 // get the total number of records 88 $query = "SELECT COUNT(*)" 89 . "\n FROM #__newsfeeds" 90 . ( $catid ? "\n WHERE catid = " . (int) $catid : '' ) 91 ; 92 $database->setQuery( $query ); 93 $total = $database->loadResult(); 94 95 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 96 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 97 98 // get the subset (based on limits) of required records 99 $query = "SELECT a.*, c.name AS catname, u.name AS editor" 100 . "\n FROM #__newsfeeds AS a" 101 . "\n LEFT JOIN #__categories AS c ON c.id = a.catid" 102 . "\n LEFT JOIN #__users AS u ON u.id = a.checked_out" 103 . ( $catid ? "\n WHERE a.catid = " . (int) $catid : '' ) 104 . "\n ORDER BY a.ordering" 105 ; 106 $database->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); 107 108 $rows = $database->loadObjectList(); 109 if ($database->getErrorNum()) { 110 echo $database->stderr(); 111 return false; 112 } 113 114 // build list of categories 115 $javascript = 'onchange="document.adminForm.submit();"'; 116 $lists['category'] = mosAdminMenus::ComponentCategory( 'catid', $option, $catid, $javascript ); 117 118 HTML_newsfeeds::showNewsFeeds( $rows, $lists, $pageNav, $option ); 119 } 120 121 /** 122 * Creates a new or edits and existing user record 123 * @param int The id of the user, 0 if a new entry 124 * @param string The current GET/POST option 125 */ 126 function editNewsFeed( $id, $option ) { 127 global $database, $my; 128 129 $catid = intval( mosGetParam( $_REQUEST, 'catid', 0 ) ); 130 131 $row = new mosNewsFeed( $database ); 132 // load the row from the db table 133 $row->load( (int)$id ); 134 135 if ($id) { 136 // do stuff for existing records 137 $row->checkout( $my->id ); 138 } else { 139 // do stuff for new records 140 $row->ordering = 0; 141 $row->numarticles = 5; 142 $row->cache_time = 3600; 143 $row->published = 1; 144 } 145 146 // build the html select list for ordering 147 $query = "SELECT a.ordering AS value, a.name AS text" 148 . "\n FROM #__newsfeeds AS a" 149 . "\n ORDER BY a.ordering" 150 ; 151 $lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $id, $query, 1 ); 152 153 // build list of categories 154 $lists['category'] = mosAdminMenus::ComponentCategory( 'catid', $option, intval( $row->catid ) ); 155 // build the html select list 156 $lists['published'] = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); 157 158 HTML_newsfeeds::editNewsFeed( $row, $lists, $option ); 159 } 160 161 /** 162 * Saves the record from an edit form submit 163 * @param string The current GET/POST option 164 */ 165 function saveNewsFeed( $option ) { 166 global $database, $my; 167 168 $row = new mosNewsFeed( $database ); 169 if (!$row->bind( $_POST )) { 170 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 171 exit(); 172 } 173 174 // pre-save checks 175 if (!$row->check()) { 176 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 177 exit(); 178 } 179 180 // save the changes 181 if (!$row->store()) { 182 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 183 exit(); 184 } 185 $row->checkin(); 186 $row->updateOrder(); 187 188 mosRedirect( 'index2.php?option='. $option ); 189 } 190 191 /** 192 * Publishes or Unpublishes one or more modules 193 * @param array An array of unique category id numbers 194 * @param integer 0 if unpublishing, 1 if publishing 195 * @param string The current GET/POST option 196 */ 197 function publishNewsFeeds( $cid, $publish, $option ) { 198 global $database, $my; 199 200 if (count( $cid ) < 1) { 201 $action = $publish ? 'publish' : 'unpublish'; 202 echo "<script> alert('Select a module to $action'); window.history.go(-1);</script>\n"; 203 exit; 204 } 205 206 mosArrayToInts( $cid ); 207 $cids = 'id=' . implode( ' OR id=', $cid ); 208 209 $query = "UPDATE #__newsfeeds" 210 . "\n SET published = ". intval( $publish ) 211 . "\n WHERE ( $cids )" 212 . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )" 213 ; 214 $database->setQuery( $query ); 215 if (!$database->query()) { 216 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 217 exit(); 218 } 219 220 if (count( $cid ) == 1) { 221 $row = new mosNewsFeed( $database ); 222 $row->checkin( $cid[0] ); 223 } 224 225 mosRedirect( 'index2.php?option='. $option ); 226 } 227 228 /** 229 * Removes records 230 * @param array An array of id keys to remove 231 * @param string The current GET/POST option 232 */ 233 function removeNewsFeeds( &$cid, $option ) { 234 global $database; 235 236 if (!is_array( $cid ) || count( $cid ) < 1) { 237 echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; 238 exit; 239 } 240 if (count( $cid )) { 241 mosArrayToInts( $cid ); 242 $cids = 'id=' . implode( ' OR id=', $cid ); 243 $query = "DELETE FROM #__newsfeeds" 244 . "\n WHERE ( $cids )" 245 . "\n AND checked_out = 0" 246 ; 247 $database->setQuery( $query ); 248 if (!$database->query()) { 249 echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 250 } 251 } 252 253 mosRedirect( 'index2.php?option='. $option ); 254 } 255 256 /** 257 * Cancels an edit operation 258 * @param string The current GET/POST option 259 */ 260 function cancelNewsFeed( $option ) { 261 global $database; 262 263 $row = new mosNewsFeed( $database ); 264 $row->bind( $_POST ); 265 $row->checkin(); 266 mosRedirect( 'index2.php?option='. $option ); 267 } 268 269 /** 270 * Moves the order of a record 271 * @param integer The id of the record to move 272 * @param integer The direction to reorder, +1 down, -1 up 273 * @param string The current GET/POST option 274 */ 275 function orderNewsFeed( $id, $inc, $option ) { 276 global $database; 277 278 $limit = intval( mosGetParam( $_REQUEST, 'limit', 0 ) ); 279 $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); 280 $catid = intval( mosGetParam( $_REQUEST, 'catid', 0 ) ); 281 282 $row = new mosNewsFeed( $database ); 283 $row->load( (int)$id ); 284 $row->move( $inc ); 285 286 mosRedirect( 'index2.php?option='. $option ); 287 } 288 ?>
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 |
![]() |