Elxis CMS Forum

Extensions => Templates => Topic started by: rotor on July 16, 2007, 03:46:31

Title: Menu and User Levels [solved]
Post by: rotor on July 16, 2007, 03:46:31
Hi,

I have installed  rt_elemental (Rocketthemes) on my site and am having a little problem with the menu permissions.

The main menu is the com_mainmenu from elxis and works fine.

The top menu is a moomenu from rocketthemes and isnt working properly. I have the permissions set up for all items as public_frontend and visitors can see and use the menu. But as soon as you log in the menu disappears and no more menu?


Any help would be greatly appreciated

Geoff

Title: Re: Menu and User Levels [solved]
Post by: rotor on July 16, 2007, 03:53:27
Solved ...

All I had to do was show Show UnAuthorized Links in elxis main config


 ::)


Geoff
Title: Re: Menu and User Levels [solved]
Post by: datahell on July 16, 2007, 07:22:42
No, this is not the solution. Your menu seems that contain incompatible (and dangerous) to Elxis code. Open it and if you find something like this:

AND access <= $my->gid

change it to:

AND access IN ($my->allowed)

Also you must add language check inside the queries:

AND ((language LIKE '%$lang%') OR (language IS NULL))
Title: Re: Menu and User Levels [solved]
Post by: rotor on July 16, 2007, 09:59:29

ok,

tried to add the language code into this:

if ($mosConfig_shownoauth) {
     $database->setQuery("SELECT m.*, count(p.parent) as cnt" .
   "\nFROM #__menu AS m" .
   "\nLEFT JOIN #__menu AS p ON p.parent = m.id" .
    "\nWHERE m.menutype='$menutype' AND m.published='1'" .
   "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
      } else {
     $database->setQuery("SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" .
   "\nFROM #__menu AS m" .
   "\nLEFT JOIN #__menu AS p ON p.parent = m.id" .
    "\nWHERE m.menutype='$menutype' AND m.published='1' AND m.access <= '$my->gid'" .
   "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
   }

This is what it ended up as:

if ($mosConfig_shownoauth) {
     $database->setQuery("SELECT m.*, count(p.parent) as cnt" .
   "\nFROM #__menu AS m" .
   "\nLEFT JOIN #__menu AS p ON p.parent = m.id" .
    "\nWHERE m.menutype='$menutype' AND m.published='1'" .
   "\n AND ((language LIKE '%$lang%') OR (language IS NULL))" .
   "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
      } else {
     $database->setQuery("SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" .
   "\nFROM #__menu AS m" .
   "\nLEFT JOIN #__menu AS p ON p.parent = m.id" .
    "\nWHERE m.menutype='$menutype' AND m.published='1' AND m.access <= '$my->gid'" .
   "\n AND ((language LIKE '%$lang%') OR (language IS NULL))" .
   "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
   }

I got this warning on the site page:

PHP WARNING
PHP: Invalid argument supplied for foreach()
uri: index.php?option=com_edir&Itemid=5
path: /components/com_edir/edir.php
version: Elxis 2006.4 Stable rev1080 [ Nestor ] 04-December-2006 23:08 GMT+2
WARNING(2): /home/ozpla3/public_html/oztravelspot/templates/rt_elemental/rt_moomenu.php, line 97

--------------------------------------------------------------------------------------------------------------------

and also got an error when I tried to replace the gid with allowed as:

if($my->gid){

if($my->allowed){

Also tried to delete out the statement as in the com_mainmenu but got errors.

Do you think it not a good idea to use these templates then?? Is there some one that would like to look at this template to check that it is safe to use with elxis??

It would be appreciated very much!!

Cheers

Geoff
Title: Re: Menu and User Levels [solved]
Post by: datahell on July 16, 2007, 12:02:27
If you look to my first post I did not said you to replace $my->gid with $my->allowed.

Here is the right query:

global $lang;

if ($mosConfig_shownoauth) {
     $database->setQuery("SELECT m.*, count(p.parent) as cnt" .
   "\n FROM #__menu AS m" .
   "\n LEFT JOIN #__menu AS p ON p.parent = m.id" .
   "\n WHERE m.menutype='$menutype' AND m.published='1'" .
   "\n AND ((m.language LIKE '%$lang%') OR (m.language IS NULL))".
   "\n GROUP BY m.id ORDER BY m.parent, m.ordering ");
 } else {
     $database->setQuery("SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" .
   "\n FROM #__menu AS m" .
   "\n LEFT JOIN #__menu AS p ON p.parent = m.id" .
   "\n WHERE m.menutype='$menutype' AND m.published='1' AND m.access IN (".$my->allowed.")" .
   "\n AND ((m.language LIKE '%$lang%') OR (m.language IS NULL))".
   "\n GROUP BY m.id ORDER BY m.parent, m.ordering ");
}


Notice: The query is NOT ADODB compatible but it will work if your database is mysql.

Title: Re: Menu and User Levels [solved]
Post by: rotor on July 16, 2007, 14:23:44
Thanks datahell ...

Works ok now ... much appreciated


Geoff
Title: Re: Menu and User Levels [solved]
Post by: azmi2 on November 18, 2012, 08:17:14
dear datahell

is it possible to create sub menu in top menu?

thanks
Title: Re: Menu and User Levels [solved]
Post by: datahell on November 18, 2012, 10:31:08
Off course. Just set a menu item to have as parent an other item.