Path

ez projects / bcmemberofrole


BC Member Of Role

UNIX name Owner Status Version Compatible with
bcmemberofrole Brookins Consulting stable 0.1.7 eZ Publish 4.x -> eZ Publish 4.6 (Community Build 2011.10)
eZ Publish Class and Template Operators based on OWSimpleOperator extension for eZ Publish

About

Our first github.com based extension release for eZ Publish

This extension provides a much needed template operator for eZ Publish Templates.

The provided operators check if a user is a member of a specific role

Primary features

The example 'member_of_role', 'member_of_role_by_user_id' and 'member_of_role_by_user' template operators provided

Summary

Example 'member_of_role' template operator autoload configuration file (required) and OWSimpleOperator based 'BCMemberOfRoleOperator' class and method 'member_of_role' (required).

Provided class methods 'member_of_role', 'member_of_role_by_user_id' and 'member_of_role_by_user' (template operators) accept and requires two parameters.
The methods above require both UserID (integer, contentobject_id) / User (ezuser class object) and RoleID parameters.

The base method fetches the user, user roles, iterates over user roles and compares RoleID param till it finds a match and returns true, false if no match is found / etc.
This code can also be used statically within custom PHP code without making any changes. Remember to clear cache and regenerate autoloads! 

Compatibility

This solution is compatible with eZ Publish 4.x -> eZ Publish Community Build 2011.10 and PHP 5.x

This solution depends on and requires the OWSimpleOperator extension is installed correctly

Distribution

This source code is distributed publicly as a solution by Brookins Consulting on github.com

https://github.com/brookinsconsulting/bcmemberofrole

Please feel free to use this solution freely.

This solution is made available in reference to the following forum thread,

http://share.ez.no/forums/developer/user-ans-rules

How to install extension

- Simply install eZ Publish (as needed, share.ez.no/download )

- Install OWSimpleOperator extension (as needed, https://github.com/Open-Wide/OWSimpleOperator )

- Download the code for this extension from github.com, https://github.com/brookinsconsulting/bcmemberofrole

- Regenerate autoloads and clear cache!

The implementation

The above two PHP files provided a solution based on the OWSimpleOperator extension, https://github.com/Open-Wide/OWSimpleOperator

OWSimpleOperator extension makes available a simple to define PHP template operators.

The files provided by this Gist (autoloads and static object method PHP) provide a template operator method to check if a userID is a member of a specific roleID

Example files above provide the 'member_of_role' template operator autoload configuration file (required) and OWSimpleOperator based 'BCMemberOfRoleOperator' class and method 'member_of_role' (also required).

Provided class method 'member_of_role' and 'member_of_role_by_user_id' (template operators) accepts and requires two parameters: UserID and RoleID (Both required).

Provided class method 'member_of_role_by_user' (template operator) accepts and requires two parameters: User (class ezuser object) and RoleID (Both required).

The base method fetches the user, user roles, iterates over user roles and compares RoleID param till it finds a match and returns true, false if no match is found / etc.

Usage

See doc/USAGE for complete eZ Publish PHP and Template example usages provided by extension.

Legal Copyright and License

This solution is copyright (C) 1999 - 2011 Brookins Consulting and licensed under the terms of the GNU General Public License (v2 or later).

A copy of the exact license supported is available on the web fromhttp://www.gnu.org/licenses/gpl-2.0.txt

A copy of the exact license supported is provided within the bcmemberofrole extension in the file doc/LICENSE

Please feel free to use this solution freely.

References

This source code is posted in reference to the following forum thread, http://share.ez.no/forums/developer/user-ans-rules

This public github.com repository, https://github.com/brookinsconsulting/bcmemberofrole

Brookins Consulting on github, https://github.com/brookinsconsulting

Brookins Consulting's Gists, https://gist.github.com/brookinsconsulting

Brookins Consulting on projects.ez.no, http://projects.ez.no/users/community/brookins_consulting

eZ Publish, http://share.ez.no

No news yet.

This project has no reviews yet. Be the first one to review it!

No forum messages yet.