Find the Exponential Software extensions you want
UNIX name | Owner | Status |
---|---|---|
bcmemberofrole | Brookins Consulting | stable |
Version | Compatible with |
---|---|
N/A | N/A |
Name: BCMemberOfRole
Description: eZ Publish Class and Template Operators based on OWSimpleOperator extension for eZ Publish
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 from http://www.gnu.org/licenses/gpl-2.0.txt
A copy of the exact license supported is provided within the bcmemberofrole extension in doc/LICENSE
Please feel free to use this solution freely.
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 'BCMemberOfRoleOperators' 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 to each of the available user roleIDs untill 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
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 'BCMemberOfRoleOperators' 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.
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