resources
menus, admin_capable and user_capable
Posted by: Jo on April 6, 2009 | Updated: April 8, 2009 03:51 PM
If anyone has noticed, there is an extra column in the Modules List view called 'Properties'. This 'Properties' column was introduced to Xaraya around the 1.1.0 release with the changesdue branch merge.
In this list, clicking on this option for a given module displays what is actually system module information that is supposedly non changeable except by the module author. It is system information like the short module name. The fields here, namely admin_capable and user_capable, signify certain characteristics of the module. They are not supposed to be used as changeable variables in the GUI by site admins.
I have always felt that the current practice in Xaraya to use these system variables for another function, namely switching a module's entry in User or Admin menus on or off, has been erroneous. Using these system variables also switches off the menu items for everyone and all menus with the current code which is not convenient or even wanted in many cases.
System information for a module should not be changed by the user and secondly, there are better ways to turn menu items on and off that are less confusing and provide more flexibility. Not only that, using these system variables for yet another function than originally intended, can in many if not most cases lead to problems in code longer term.
In fact, when i went to fix a bug recently this is exactly what happened - i ran into problems due to this.
There has been a bug around for ages that presents itself when a module author changes the xarversion.php information such as category, class, admin_capable or user_capable fields. This information has not been updated to a site's database in all cases. I fixed this recently. However, this exposes a number of problems with using the latter two fields for menu switches.
Of course, if someone has been using this 'properties' admin_capable, and user_capable variables to switch menu items on and off, their menus are immediately 'broken' in that the updated information from xarversion.php will overwrite their settings. On a live site this could be a major issue if a menu item disappears, or one appears that shouldn't.
What i have done is remove this 'properties' column and so called 'feature' from the modules listing. Now, module authors can reliably update information if necessary in xarversion.php and it will be updated to the database and not changed until they decide.
For site administrators, they have one less confusing column in the Modules Listing - after all 'properties' is itself not a good name given it is used in dynamic data regularly with another meaning.
This also means that modules such as 'simpleadmin' that rely on this use of admin_capable, and use_capable variables and switching should not be used.
So, what about menu entries for modules?
How to switch them on and off?
Well, you don't need extra modules loaded on site, with more to learn, and more to bog down a site with, to handle switching module items on and off in menus.
The latest changes in Xarigami core affect the Base module User Menu block, and Adminmenu blocks.
Now, you can have as many different Admin Menus as you want, and switch off module entries as needed in those menu blocks. You can also override the block templates just like any other block and template them as you like, individually if required. You might have one block for technical administrators, another for content editors.
The user Menu block has been updated to match the interface in the Adminmenu block - a checkbox list is used with modules to select or deselect for inclusion in your menu. This removes the rather cumbersome text field that required users to first, remember module names, and secondly type them in correctly into the text field.
You will require privileges to hide/display the blocks for relevant groups on your site. The way this is done will depend on your site roles and privileges setup but is easily accomplished with Xarigami block privileges. If anyone needs a hand, post in the Xarigami support forums.
These changes herald the way for some more exciting changes with respect to menus in Xarigami!
Existing sites should have admin and user menu blocks upgrade automatically, as the blocks recognize the older variables which are formally deprecated. Code to support these older vars will be removed at Xarigami 1.5.0 .
Related project : xarigami core
| « prev | next» |