[dev] [patch] Permissions for Menus
Marko Djukic
marko at oblo.com
Sun May 4 04:29:34 PDT 2003
why not just have the permission as "imp" or "mnemo"? then when we do get to
have permission inheritance it will be the root permission of whatever is
tagged on, "imp:somethingelse:andelse"...
plus why name it "menu:imp" it should be more logical so that it is checked even
if someone types "/imp" in the url which has nothing to do with menus.
marko
Quoting Joe Wilson <joe.wilson at mindcandy.org>:
> The following patch provides the ability to use the permissions subsystem to
> control whether a given menu option is displayed in the main Horde navigation
> menu. If the $app['status'] parameter is set to 'perm', the permission of
> the
> user is checked for 'menu:'.$app. If the user has read permission, the menu
> item is listed as active, inactive otherwise. For example, to allow a user
> to
> access imp, you would create the permission "menu:imp" and give the user read
> access.
>
> Joe
>
> Index: horde/menu.php
> ===================================================================
> RCS file: /usr/local/cvs/horde/horde/menu.php,v
> retrieving revision 2.38
> diff -r2.38 menu.php
> 21,23c21,24
> < foreach ($registry->applications as $app => $params) {
> < if (array_key_exists('menu_parent', $params)) {
> < $children[$params['menu_parent']][$app] = $params;
> ---
> > foreach ($registry->listApps(array('active', 'heading', 'notoolbar'))
> as
> $app) {
> > $menu_parent = $registry->getParam('menu_parent', $app);
> > if ($menu_parent) {
> > $children[$menu_parent][$app] = $registry->applications[$app];
> 29,30c30,31
> < foreach ($registry->applications as $app => $params) {
> < $tmp[$app] = $params;
> ---
> > foreach ($registry->listApps(array('active', 'heading', 'notoolbar'))
> as
> $app) {
> > $tmp[$app] = $registry->applications[$app];
> 36c37
> < if ($cparams['status'] == 'active') {
> ---
> > if ($registry->getParam('status', $capp) == 'active') {
> 43c44,48
> < }
> ---
> > } else {
> > if ($registry->getParam('status', $app) == 'heading') {
> > unset($tmp[$app]);
> > }
> > }
> Index: horde/lib/Registry.php
> ===================================================================
> RCS file: /usr/local/cvs/horde/horde/lib/Registry.php,v
> retrieving revision 1.150
> diff -r1.150 Registry.php
> 179c179,180
> < if (in_array($params['status'], $filter)) {
> ---
> > $status = $this->getParam('status', $app);
> > if (in_array($status, $filter)) {
> 756a758,768
> >
> > if ($parameter == 'status' && $ret == 'perm') {
> > require_once HORDE_BASE . '/lib/Perms.php';
> > $perm = &Perms::singleton();
> > if ($perm->hasPermission("menu:" . $app, Auth::getAuth(),
> _PERMS_READ)) {
> > $ret = 'active';
> > } else {
> > $ret = 'inactive';
> > }
> > }
> >
>
>
>
> --
> Horde developers mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org
>
More information about the dev
mailing list