Mail archive
acf

[Acf] Fixed submenus for ACF

From: Mika Havela <mika.havela_at_gmail.com>
Date: Thu, 3 Apr 2008 12:06:36 +0200

Hi nangel and mmason.
The last 2-3 weeks I have not been able to do so much on ACF due to
other assignments. But now I'm back on track again (I hope).
So I have been looking at the ACF's we have been working on, and made
some adjustments and enhancements.
I'm also very glad to see that you have been working on the
logon/logoff functionallity and the menus.
The main menus works just fine (as I assume they should), but the
submenus didn't show.
Because of some of the ACF's needs some changes that's made to core, I
would really like to make a new release on 'core' just to be able to
have all updates on next Alpine release. It's mostly layout things
(when it comes to the changes in core), so it's not /that/ important
to have a new release on 'core'.
But because the submenus didn't show (on current core/trunk) I had a
look at the code mmason did on the menus, and tried to figure out what
caused the submenus not to show, and I found out that mmason was on
track of the problem (he even wrote a note that indicated what needed
to be changed).
So I took the liberty to change the code so that the submenus started to work.
So I'm making a new release on 'core' (including the updates I made)
and I hope that I haven't ruined toooo much of your work.
I feel sorry to step into your work (because your doing good), but I
really wanted to make the new release... and that's why I
changed/modified your code (sorry about that).
But things should work now.

Still there is some things that's not done to the menubuilder (when
reading the code I can see that you have plans to fix some of those
things when you get the time).
* Just because submenus are hidden, it doesn't mean that you can't
write the URL manually
* The /roles file is not that easy to administer. (IMHO it would be a
good idea to change lib/roles.lua to read the roles from the *.menu
files instead) (I have not touched lib/roles.lua)

I tagged "core/tag/release-0.3.1" before I started to change things,
so you can revert things if you want.
After I did my changes, I tagged "core/tag/release-0.3.2" and made a
release for next Alpine-release. So trunk (and "tag/release-0.3.2")
holds the new modifications.

I hope you are not too disappointed at me when messing up your work.


Here's the diff on what I did to the menubuilder code.

Index: /root/acf/core/trunk/app/acf_www-controller.lua
===================================================================
--- /root/acf/core/trunk/app/acf_www-controller.lua (revision 903)
+++ /root/acf/core/trunk/app/acf_www-controller.lua (working copy)
_at_@ -24,12 +24,18 @@
        sessiondata.menu.mainmenu = m.get_menuitems(self.conf.appdir)
        sessiondata.menu.submenu = m.get_submenuitems(self.conf.appdir)

+local temp
 if sessiondata.userinfo == nil then
        --we are dealing with an unknown user
 p = {"ALL"}
        --this will be whatever the "UNKNOWN" role is ... right now it is ALL
        --temp should be the
-local temp = format.string_to_table(roll.get_roles_perm(self,p),",")
+temp = format.string_to_table(roll.get_roles_perm(self,p),",")
+else
+ --we don't need to figure out what permission have it is in sessiondata
+temp = format.string_to_table(sessiondata.userinfo.perm,",")
+end
+
        --lets apply permissions
        for a,b in pairs(sessiondata.menu.mainmenu) do
                for k,v in pairs(temp) do
_at_@ -55,52 +61,32 @@
         for c,d in pairs(sessiondata.menu.submenu[a]) do
                for k,v in pairs(temp) do
                local control,acti = string.match(v,"(%a+):(%a+)")
+ if (a == control) then
                        if sessiondata.menu.submenu[a][c].action == acti then
                          sessiondata.menu.submenu[a][c].match = "yes"
                          break
                        else
                          sessiondata.menu.submenu[a][c].match = "no"
                          end
- end
- end
- end
-else
- --we don't need to figure out what permission have it is in sessiondata
- local temp = format.string_to_table(sessiondata.userinfo.perm,",")
- for a,b in pairs(sessiondata.menu.mainmenu) do
- for e,f in pairs(temp) do
- local control,acti = string.match(f,"(%a+):(%a+)")
- if sessiondata.menu.mainmenu[a].controller ==
control then
- if sessiondata.menu.mainmenu[a].action
== acti then
- sessiondata.menu.mainmenu[a].match = "yes"
- break
- else
- sessiondata.menu.mainmenu[a].match = "no"
- end
- else
- sessiondata.menu.mainmenu[a].match = "no"
                        end
- if sessiondata.menu.mainmenu[a].controller ==
"menuhints" then
- sessiondata.menu.mainmenu[a].match = "yes"
- end
- end
+ end
+ end
        end

-end
        local temptab = {}
        for a,b in pairs(sessiondata.menu.mainmenu) do
                if sessiondata.menu.mainmenu[a].match ~= "no" then
                temptab[#temptab +1 ] = sessiondata.menu.mainmenu[a]
- end
        end
+ end

        sessiondata.menu.mainmenu = temptab
        local tempsub = {}
        for c,d in pairs(sessiondata.menu.submenu) do
         for e,f in pairs(sessiondata.menu.submenu[c]) do
                if sessiondata.menu.submenu[c][e].match ~= "no" then
- tempsub[#tempsub +1] = sessiondata.menu.submenu[c][e]
- --may need this to be c
+ if not (tempsub[c]) then tempsub[c] = {} end
+ tempsub[c][#tempsub[c] +1] =
sessiondata.menu.submenu[c][e]
                end
         end
        end
Received on Thu Apr 03 2008 - 12:06:36 GMT