| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @package Mambo Open Source |
* @package Mambo |
| 4 |
* @subpackage Menus |
* @subpackage Menus |
| 5 |
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
* @author Mambo Foundation Inc see README.php |
| 6 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @copyright (C) 2000 - 2009 Mambo Foundation Inc. |
| 7 |
|
* See COPYRIGHT.php for copyright notices and details. |
| 8 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 9 |
* |
* |
| 10 |
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
* Redistributions of files must retain the above copyright notice. |
| 11 |
* that Mambo remained free Open Source software owned and managed by the community. |
* |
| 12 |
* Mambo is Free Software |
* Mambo is free software; you can redistribute it and/or |
| 13 |
|
* modify it under the terms of the GNU General Public License |
| 14 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 15 |
*/ |
*/ |
| 16 |
|
|
| 17 |
/** ensure this file is being included by a parent file */ |
/** ensure this file is being included by a parent file */ |
| 46 |
break; |
break; |
| 47 |
|
|
| 48 |
case 'deleteconfirm': |
case 'deleteconfirm': |
| 49 |
deleteconfirm( $option, $cid[0] ); |
deleteconfirm( $option, $cid ); |
| 50 |
break; |
break; |
| 51 |
|
|
| 52 |
case 'deletemenu': |
case 'deletemenu': |
| 104 |
} |
} |
| 105 |
|
|
| 106 |
// Query to get published menu item counts |
// Query to get published menu item counts |
| 107 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 108 |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
| 109 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 110 |
. "\n WHERE a.published = 1" |
. "\n WHERE a.published = 1" |
| 115 |
$published = $database->loadObjectList(); |
$published = $database->loadObjectList(); |
| 116 |
|
|
| 117 |
// Query to get unpublished menu item counts |
// Query to get unpublished menu item counts |
| 118 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 119 |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
| 120 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 121 |
. "\n WHERE a.published = 0" |
. "\n WHERE a.published = 0" |
| 127 |
if (!$unpublished) $unpublished = array(); |
if (!$unpublished) $unpublished = array(); |
| 128 |
|
|
| 129 |
// Query to get trash menu item counts |
// Query to get trash menu item counts |
| 130 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 131 |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
$query = "SELECT a.menutype, count( a.menutype ) as num" |
| 132 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 133 |
. "\n WHERE a.published = -2" |
. "\n WHERE a.published = -2" |
| 213 |
// block to stop renaming of 'mainmenu' menutype |
// block to stop renaming of 'mainmenu' menutype |
| 214 |
if ( $old_menutype == 'mainmenu' ) { |
if ( $old_menutype == 'mainmenu' ) { |
| 215 |
if ( $menutype <> 'mainmenu' ) { |
if ( $menutype <> 'mainmenu' ) { |
| 216 |
echo "<script> alert(".T_('You cannot rename the "mainmenu" Menu as this will disrupt the proper operation of Mambo')."); window.history.go(-1); </script>\n"; |
echo "<script> alert('".T_('You cannot rename the "mainmenu" Menu as this will disrupt the proper operation of Mambo')."'); window.history.go(-1); </script>\n"; |
| 217 |
exit; |
exit; |
| 218 |
} |
} |
| 219 |
} |
} |
| 220 |
|
|
| 221 |
// check for unique menutype for new menus |
// check for unique menutype for new menus |
| 222 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 223 |
$query = "SELECT params" |
$query = "SELECT params" |
| 224 |
. "\n FROM #__modules" |
. "\n FROM #__modules" |
| 225 |
. "\n WHERE module = 'mod_mainmenu'" |
. "\n WHERE module = 'mod_mainmenu'" |
| 230 |
$pparser = new mosParameters($menu); |
$pparser = new mosParameters($menu); |
| 231 |
$params = $pparser->getParams(); |
$params = $pparser->getParams(); |
| 232 |
if ( $params->menutype == $menutype ) { |
if ( $params->menutype == $menutype ) { |
| 233 |
echo "<script> alert(".T_('A menu already exists with that name - you must enter a unique Menu Name')."); window.history.go(-1); </script>\n"; |
echo "<script> alert('".T_('A menu already exists with that name - you must enter a unique Menu Name')."'); window.history.go(-1); </script>\n"; |
| 234 |
exit; |
exit; |
| 235 |
} |
} |
| 236 |
} |
} |
| 258 |
|
|
| 259 |
// module assigned to show on All pages by default |
// module assigned to show on All pages by default |
| 260 |
// ToDO: Changed to become a mambo db-object |
// ToDO: Changed to become a mambo db-object |
| 261 |
|
// @RawSQLUse, trivial_implementation, INSERT |
| 262 |
$query = "INSERT INTO #__modules_menu VALUES ( $row->id, 0 )"; |
$query = "INSERT INTO #__modules_menu VALUES ( $row->id, 0 )"; |
| 263 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 264 |
if ( !$database->query() ) { |
if ( !$database->query() ) { |
| 315 |
|
|
| 316 |
// change menutype of all menuitems using old menutype |
// change menutype of all menuitems using old menutype |
| 317 |
if ( $menutype <> $old_menutype ) { |
if ( $menutype <> $old_menutype ) { |
| 318 |
|
// @RawSQLUse, trivial_implementation, UPDATE |
| 319 |
$query = "UPDATE #__menu SET menutype = '$menutype' WHERE menutype = '$old_menutype'"; |
$query = "UPDATE #__menu SET menutype = '$menutype' WHERE menutype = '$old_menutype'"; |
| 320 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 321 |
$database->query(); |
$database->query(); |
| 331 |
/** |
/** |
| 332 |
* Compiles a list of the items you have selected to permanently delte |
* Compiles a list of the items you have selected to permanently delte |
| 333 |
*/ |
*/ |
| 334 |
function deleteConfirm( $option, $type ) { |
function deleteConfirm( $option, $types ) { |
| 335 |
global $database; |
global $database; |
| 336 |
|
|
| 337 |
if ( $type == 'mainmenu' ) { |
if ( in_array('mainmenu', $types )) { |
| 338 |
echo "<script> alert(".T_('You cannot delete the "mainmenu" menu as it is a core menu')."); window.history.go(-1); </script>\n"; |
$types = array_diff($types, array('mainmenu')); |
| 339 |
exit(); |
echo "<script> alert('".T_('You cannot delete the "mainmenu" menu as it is a core menu')."'); </script>\n"; |
| 340 |
} |
} |
| 341 |
|
|
| 342 |
|
$menus = implode("','",$types); |
| 343 |
// list of menu items to delete |
// list of menu items to delete |
| 344 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 345 |
$query = "SELECT a.name, a.id" |
$query = "SELECT a.name, a.id" |
| 346 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 347 |
. "\n WHERE ( a.menutype IN ( '$type' ) )" |
. "\n WHERE ( a.menutype IN ( '$menus' ) )" |
| 348 |
. "\n ORDER BY a.name" |
. "\n ORDER BY a.name" |
| 349 |
; |
; |
| 350 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 351 |
$items = $database->loadObjectList(); |
$items = $database->loadObjectList(); |
| 352 |
|
|
| 353 |
|
foreach ($types as $type) { |
| 354 |
// list of modules to delete |
// list of modules to delete |
| 355 |
$query = "SELECT id" |
$query = "SELECT id" |
| 356 |
. "\n FROM #__modules" |
. "\n FROM #__modules" |
| 359 |
; |
; |
| 360 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 361 |
$mods = $database->loadResultArray(); |
$mods = $database->loadResultArray(); |
|
|
|
| 362 |
foreach ( $mods as $module ) { |
foreach ( $mods as $module ) { |
| 363 |
$row = new mosModule( $database ); |
$row = new mosModule( $database ); |
| 364 |
$row->load( $module ); |
$row->load( $module ); |
| 368 |
$mid[] = $module; |
$mid[] = $module; |
| 369 |
} |
} |
| 370 |
} |
} |
| 371 |
|
} |
| 372 |
|
|
| 373 |
@$mids = implode( ',', $mid ); |
@$mids = implode( ',', $mid ); |
| 374 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 375 |
$query = "SELECT id, title" |
$query = "SELECT id, title" |
| 376 |
. "\n FROM #__modules" |
. "\n FROM #__modules" |
| 377 |
. "\n WHERE id IN ( $mids )" |
. "\n WHERE id IN ( $mids )" |
| 389 |
global $database; |
global $database; |
| 390 |
|
|
| 391 |
if ( $type == 'mainmenu' ) { |
if ( $type == 'mainmenu' ) { |
| 392 |
echo "<script> alert(".T_('You cannot delete the "mainmenu" menu as it is a core menu')."); window.history.go(-1); </script>\n"; |
echo "<script> alert('".T_('You cannot delete the "mainmenu" menu as it is a core menu')."'); window.history.go(-1); </script>\n"; |
| 393 |
exit(); |
exit(); |
| 394 |
} |
} |
| 395 |
|
|
| 399 |
$mids = implode( ',', $mids ); |
$mids = implode( ',', $mids ); |
| 400 |
} |
} |
| 401 |
// delete menu items |
// delete menu items |
| 402 |
|
// @RawSQLUse, trivial_implementation, DELETE |
| 403 |
$query = "DELETE FROM #__menu" |
$query = "DELETE FROM #__menu" |
| 404 |
. "\n WHERE ( id IN ( $mids ) )" |
. "\n WHERE ( id IN ( $mids ) )" |
| 405 |
; |
; |
| 418 |
// checks whether any modules to delete |
// checks whether any modules to delete |
| 419 |
if ( $cids ) { |
if ( $cids ) { |
| 420 |
// delete modules |
// delete modules |
| 421 |
|
// @RawSQLUse, trivial_implementation, DELETE |
| 422 |
$database->setQuery( "DELETE FROM #__modules WHERE id IN ( $cids )" ); |
$database->setQuery( "DELETE FROM #__modules WHERE id IN ( $cids )" ); |
| 423 |
if ( !$database->query() ) { |
if ( !$database->query() ) { |
| 424 |
echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; |
echo "<script> alert('". $database->getErrorMsg() ."'); window.history.go(-1); </script>\n"; |
| 425 |
exit; |
exit; |
| 426 |
} |
} |
| 427 |
// delete all module entires in mos_modules_menu |
// delete all module entires in mos_modules_menu |
| 428 |
|
// @RawSQLUse, trivial_implementation, DELETE |
| 429 |
$database->setQuery( "DELETE FROM #__modules_menu WHERE moduleid IN ( ". $cids ." )" ); |
$database->setQuery( "DELETE FROM #__modules_menu WHERE moduleid IN ( ". $cids ." )" ); |
| 430 |
if ( !$database->query() ) { |
if ( !$database->query() ) { |
| 431 |
echo "<script> alert('". $database->getErrorMsg() ."');</script>\n"; |
echo "<script> alert('". $database->getErrorMsg() ."');</script>\n"; |
| 451 |
global $database; |
global $database; |
| 452 |
|
|
| 453 |
// Content Items query |
// Content Items query |
| 454 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 455 |
$query = "SELECT a.name, a.id" |
$query = "SELECT a.name, a.id" |
| 456 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 457 |
. "\n WHERE ( a.menutype IN ( '". $type ."' ) )" |
. "\n WHERE ( a.menutype IN ( '". $type ."' ) )" |
| 474 |
$module_name = mosGetParam( $_POST, 'module_name', 'New Module' ); |
$module_name = mosGetParam( $_POST, 'module_name', 'New Module' ); |
| 475 |
|
|
| 476 |
// check for unique menutype for new menu copy |
// check for unique menutype for new menu copy |
| 477 |
|
// @RawSQLUse, trivial_implementation, SELECT |
| 478 |
$query = "SELECT params" |
$query = "SELECT params" |
| 479 |
. "\n FROM #__modules" |
. "\n FROM #__modules" |
| 480 |
. "\n WHERE module = 'mod_mainmenu'" |
. "\n WHERE module = 'mod_mainmenu'" |
| 485 |
$pparser = new mosParameters($menu); |
$pparser = new mosParameters($menu); |
| 486 |
$params = $pparser->getParams(); |
$params = $pparser->getParams(); |
| 487 |
if ( $params->menutype == $menu_name ) { |
if ( $params->menutype == $menu_name ) { |
| 488 |
echo "<script> alert(".T_('A menu with that name already exists - you must enter a unique Menu Name')."); window.history.go(-1); </script>\n"; |
echo "<script> alert('".T_('A menu with that name already exists - you must enter a unique Menu Name')."'); window.history.go(-1); </script>\n"; |
| 489 |
exit; |
exit; |
| 490 |
} |
} |
| 491 |
} |
} |
| 538 |
$row->updateOrder( "position='". $row->position ."'" ); |
$row->updateOrder( "position='". $row->position ."'" ); |
| 539 |
// module assigned to show on All pages by default |
// module assigned to show on All pages by default |
| 540 |
// ToDO: Changed to become a mambo db-object |
// ToDO: Changed to become a mambo db-object |
| 541 |
|
// @RawSQLUse, trivial_implementation, INSERT |
| 542 |
$query = "INSERT INTO #__modules_menu VALUES ( $row->id, 0 )"; |
$query = "INSERT INTO #__modules_menu VALUES ( $row->id, 0 )"; |
| 543 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 544 |
if ( !$database->query() ) { |
if ( !$database->query() ) { |