[dev] Horde Permissions / Howto?

Jan Schneider jan at horde.org
Wed Aug 3 00:15:16 PDT 2005


Zitat von ali mohammed <nefertitian at gmail.com>:

> I was wondering if anybody could help me provide a bit of guidance
> with regard to creating custom permissions with the horde framework. I
> tried figuring out the source code of perms.php and other related
> files but was largely unsuccessful, atleast as of now.

Note that if you want custom permissions in a sense that you not only 
require the normal matrix of permissions, but also integer, enum or 
other permission types, you have to use CVS HEAD code.
These permissions are documented at http://wiki.horde.org/PermHowTo.

> If I am to create a application (say 'appname') and wish to create
> custom permissions, somebody mentioned I need to use the
> _appname_perms() function in api.php file. Is below a valid pseudo
> code to create them? Assume that I am trying to divide the application
> access based on 'study' names such as 'study001', 'study002',
> 'study003', etc.
>
> function _appname_perms() {
> ...code...code...
> }
>
> The above function would then return a $perms array that contains
> something like this:
> $perms['tree']['appname']['sources']['study_sqldatabasesource']=
> $perms['tree']['appname']['sources']['prefs']=
> $perms['title']['appname:studies']='appname:studies:study001';
> $perms['title']['appname:studies']='appname:studies:study002';
> $perms['title']['appname:studies']='appname:studies:study003';
>
> Is the above $perms array correctly defined with regard to the custom
> permissions that I need to create?

No. I assume 'prefs' for example is one of your permission names?

$perms['tree']['appname']['sources']['prefs'] = false;
$perms['title']['appname:sources:prefs'] = 'Some Description';

Though, this is already a permission two levels deep, you need another 
permissions, even if unused, one level up:

$perms['tree']['appname']['sources'] = false;
$perms['title']['appname:sources'] = 'Some Other Description';

> And assuming it is correct, I was able to create the above custom
> perms successfully, how do I check for valid permissions and how do i
> edit those perms to add certain groups of users.

You edit them through the permissions UI in the Administration area. 
And you check permissions with the Perms API, e.g. 
$perms->hasPermission(). See http://dev.horde.org/ for API docs.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the dev mailing list