Source for file admin.menumanager.php
Documentation is available at admin.menumanager.php
* @copyright Refer to copyright.php
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author Mambo Foundation Inc see README.php
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// ensure user has access to this function
if (!$acl->acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_menumanager' )) {
mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') );
require_once( $mainframe->getPath( 'admin_html' ) );
deleteconfirm( $option, $cid );
* Compiles a list of menumanager items
global $database, $mainframe, $mosConfig_list_limit;
$limit =
$mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
$limitstart =
$mainframe->getUserStateFromRequest( "view{".
$option .
"}limitstart", 'limitstart', 0 );
$total =
count( $menuTypes );
foreach ( $menuTypes as $a ) {
// query to get number of modules for menutype
$query =
"SELECT count( id )"
.
"\n WHERE module = 'mod_mainmenu'"
.
"\n AND params LIKE '%$a%'"
$database->setQuery( $query );
$modules =
$database->loadResult();
$menus[$i]->modules =
$modules;
// Query to get published menu item counts
$query =
"SELECT a.menutype, count( a.menutype ) as num"
.
"\n WHERE a.published = 1"
.
"\n GROUP BY a.menutype"
.
"\n ORDER BY a.menutype"
$database->setQuery( $query );
$published =
$database->loadObjectList();
// Query to get unpublished menu item counts
$query =
"SELECT a.menutype, count( a.menutype ) as num"
.
"\n WHERE a.published = 0"
.
"\n GROUP BY a.menutype"
.
"\n ORDER BY a.menutype"
$database->setQuery( $query );
$unpublished =
$database->loadObjectList();
if (!$unpublished) $unpublished =
array();
// Query to get trash menu item counts
$query =
"SELECT a.menutype, count( a.menutype ) as num"
.
"\n WHERE a.published = -2"
.
"\n GROUP BY a.menutype"
.
"\n ORDER BY a.menutype"
$database->setQuery( $query );
$trash =
$database->loadObjectList();
if (!$trash) $trash =
array();
for( $i =
0; $i <
$total; $i++
) {
foreach ( $published as $count ) {
if ( $menus[$i]->type ==
$count->menutype ) {
$menus[$i]->published =
$count->num;
if ( @!$menus[$i]->published ) {
$menus[$i]->published =
'-';
// adds unpublished count
foreach ( $unpublished as $count ) {
if ( $menus[$i]->type ==
$count->menutype ) {
$menus[$i]->unpublished =
$count->num;
if ( @!$menus[$i]->unpublished ) {
$menus[$i]->unpublished =
'-';
foreach ( $trash as $count ) {
if ( $menus[$i]->type ==
$count->menutype ) {
$menus[$i]->trash =
$count->num;
if ( @!$menus[$i]->trash ) {
require_once( $GLOBALS['mosConfig_absolute_path'] .
'/administrator/includes/pageNavigation.php' );
$pageNav =
new mosPageNav( $total, $limitstart, $limit );
* Edits a mod_mainmenu module
* @param option options for the edit mode
// setting default values
$row->module =
'mod_mainmenu';
* Creates a new mod_mainmenu module, which makes the menu visible
* this is a workaround until a new dedicated table for menu management can be created
$old_menutype =
mosGetParam( $_POST, 'old_menutype', '' );
// block to stop renaming of 'mainmenu' menutype
if ( $old_menutype ==
'منوی اصلی' ) {
if ( $menutype <>
'منوی اصلی' ) {
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";
// check for unique menutype for new menus
.
"\n WHERE module = 'mod_mainmenu'"
$database->setQuery( $query );
$menus =
$database->loadResultArray();
foreach ( $menus as $menu ) {
$params =
$pparser->getParams();
if ( $params->menutype ==
$menutype ) {
echo
"<script> alert('".
T_('A menu already exists with that name - you must enter a unique Menu Name').
"'); window.history.go(-1); </script>\n";
// create a new module for the new menu
$row->params =
'menutype='.
$menutype;
// check then store data in db
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
$row->updateOrder( "position='".
$row->position .
"'" );
// module assigned to show on All pages by default
// ToDO: Changed to become a mambo db-object
$query =
"INSERT INTO #__modules_menu VALUES ( $row->id, 0 )";
$database->setQuery( $query );
if ( !$database->query() ) {
echo
"<script> alert('".
$database->getErrorMsg().
"'); window.history.go(-1); </script>\n";
$msg =
sprintf(T_('New Menu created [ %s ]'), $menutype);
// change menutype being of all mod_mainmenu modules calling old menutype
.
"\n WHERE module = 'mod_mainmenu'"
.
"\n AND params LIKE '%$old_menutype%'"
$database->setQuery( $query );
$modules =
$database->loadResultArray();
foreach ( $modules as $module ) {
$params =
$pparser->getParams();
if ( $params->menutype ==
$old_menutype ) {
$params->menutype =
$menutype;
// save changes to module 'menutype' param
foreach ( $params as $k=>
$v) {
$row->params =
implode( "\n", $txt );
// check then store data in db
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
// change menutype of all menuitems using old menutype
if ( $menutype <>
$old_menutype ) {
$query =
"UPDATE #__menu SET menutype = '$menutype' WHERE menutype = '$old_menutype'";
$database->setQuery( $query );
$msg =
T_('Menu Items & Modules updated');
mosRedirect( 'index2.php?option=com_menumanager', $msg );
* Compiles a list of the items you have selected to permanently delte
echo
"<script> alert('".
T_('You cannot delete the "mainmenu" menu as it is a core menu').
"'); </script>\n";
// list of menu items to delete
$query =
"SELECT a.name, a.id"
.
"\n WHERE ( a.menutype IN ( '$menus' ) )"
$database->setQuery( $query );
$items =
$database->loadObjectList();
foreach ($types as $type) {
// list of modules to delete
.
"\n WHERE module = 'mod_mainmenu'"
.
"\n AND params LIKE '%$type%'"
$database->setQuery( $query );
$mods =
$database->loadResultArray();
foreach ( $mods as $module ) {
$params =
$pparser->getParams();
if ( $params->menutype ==
$type ) {
$query =
"SELECT id, title"
.
"\n WHERE id IN ( $mids )"
$database->setQuery( $query );
@$modules =
$database->loadObjectList();
* Deletes menu items(s) you have selected
if ( $type ==
'منوی اصلی' ) {
echo
"<script> alert('".
T_('You cannot delete the "mainmenu" menu as it is a core menu').
"'); window.history.go(-1); </script>\n";
$query =
"DELETE FROM #__menu"
.
"\n WHERE ( id IN ( $mids ) )"
$database->setQuery( $query );
if ( !$database->query() ) {
echo
"<script> alert('".
$database->getErrorMsg() .
"');</script>\n";
// checks whether any modules to delete
$database->setQuery( "DELETE FROM #__modules WHERE id IN ( $cids )" );
if ( !$database->query() ) {
echo
"<script> alert('".
$database->getErrorMsg() .
"'); window.history.go(-1); </script>\n";
// delete all module entires in mos_modules_menu
$database->setQuery( "DELETE FROM #__modules_menu WHERE moduleid IN ( ".
$cids .
" )" );
if ( !$database->query() ) {
echo
"<script> alert('".
$database->getErrorMsg() .
"');</script>\n";
// reorder modules after deletion
$mod->updateOrder( "position='left'" );
$mod->updateOrder( "position='right'" );
* Compiles a list of the items you have selected to Copy
$query =
"SELECT a.name, a.id"
.
"\n WHERE ( a.menutype IN ( '".
$type .
"' ) )"
$database->setQuery( $query );
$items =
$database->loadObjectList();
* Copies a complete menu, all its items and creates a new module, using the name speified
function copyMenu( $option, $cid, $type ) {
$menu_name =
mosGetParam( $_POST, 'menu_name', 'New Menu' );
$module_name =
mosGetParam( $_POST, 'module_name', 'New Module' );
// check for unique menutype for new menu copy
.
"\n WHERE module = 'mod_mainmenu'"
$database->setQuery( $query );
$menus =
$database->loadResultArray();
foreach ( $menus as $menu ) {
$params =
$pparser->getParams();
if ( $params->menutype ==
$menu_name ) {
echo
"<script> alert('".
T_('A menu with that name already exists - you must enter a unique Menu Name').
"'); window.history.go(-1); </script>\n";
$original =
new mosMenu( $database );
foreach( $mids as $mid ) {
$copy->parent =
$a_ids[$original->parent];
$copy->menutype =
$menu_name;
echo
"<script> alert('".
$copy->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$copy->getError().
"'); window.history.go(-1); </script>\n";
$a_ids[$original->id] =
$copy->id;
// create the module copy
$row->title =
$module_name;
$row->module =
'mod_mainmenu';
$row->params =
'menutype='.
$menu_name;
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
$row->updateOrder( "position='".
$row->position .
"'" );
// module assigned to show on All pages by default
// ToDO: Changed to become a mambo db-object
$query =
"INSERT INTO #__modules_menu VALUES ( $row->id, 0 )";
$database->setQuery( $query );
if ( !$database->query() ) {
echo
"<script> alert('".
$database->getErrorMsg().
"'); window.history.go(-1); </script>\n";
$msg =
sprintf(Tn_('Copy of Menu `%s` created, consisting of %d item', 'Copy of Menu `%s` created, consisting of %d items', $total), $type, $total);
* Cancels an edit operation
* @param option options for the operation
mosRedirect( 'index2.php?option=' .
$option .
'&task=view' );
Documentation generated on Mon, 05 May 2008 16:15:33 +0400 by phpDocumentor 1.4.0