Vanilla 1 Documentation Archive


~~NOTOC~~ ====== Class Library: People ====== ===== Class RoleManager ===== ==== Overview: ==== ---- RoleManager performs the necessary database interactions for reading and writing [[Vanilla/Role.html|Role]] objects. It contains methods for fetching individual roles or a list of roles, saving roles to the database, and inactivating roles to prevent further use. ==== Fields: ==== ---- === Context === The handle to the [[Vanilla/Context.html|Context]] object. Should always be set when this class is in use. === Name === The class name (hardcoded). ==== Methods: ==== ---- === RoleManager [constructor] === == Signature: == <code php>$RoleManager = $Context->ObjectFactory->NewContextObject($Context, 'RoleManager');</code> == Description: == Constructs a new RoleManager, setting the class name and [[Vanilla/Context.html|Context]] handle. The [[Vanilla/Context.html|Context]] handle variable must be set for this class to behave properly. === GetRoleBuilder === == Signature: == <code php>SqlBuilder GetRoleBuilder([$GetUnauthenticated = '0'])</code> == Description: == Creates a [[Vanilla/SqlBuilder.html|SqlBuilder]] object designed to fetch a list of active roles. Unless the optional parameter is a boolean truth value, the role "Unauthenticated" is not included in the list. === GetRoleById === == Signature: == <code php>Role GetRoleById($RoleID)</code> == Description: == Populate a [[Vanilla/Role.html|Role]] object with the record matching the given role ID, provided the role is active. If no errors occurred while fetching the record from the database, the [[Vanilla/Role.html|Role]] object is returned. Results are indeterminate if multiple records match the parameter. === GetRoles === == Signature: == <code php>[Data Set] GetRoles([$RoleToExclude = '0'], [$GetUnauthenticated = '0'])</code> == Description: == Fetches and returns data for each of the active roles in the database. Any role with ID matching the first parameter is excluded from the list. If the second parameter is a truth value, and the first parameter does not match its ID, the "Unauthenticated" role is included in the list. The returned list of roles is ordered by priority (determines display order). === RemoveRole === == Signature: == <code php>[boolean] RemoveRole($RemoveRoleID,$ReplacementRoleID)</code> == Description: == Inactivates the role with the given ID (first parameter), and assigns all affected users to the role with the given replacement ID. Each user's role history is updated with a message that their previous role was obsoleted. Always returns a truth value. === SaveRole === == Signature: == <code php>Role/[boolean] SaveRole(&$Role)</code> == Description: == Saves the properties of a [[Vanilla/Role.html|Role]] object to the database. If the role already exists, this method loads the current properties from the database, then updates the permissions with the new values. (Consequence: SaveRole cannot be used to remove permission keys from a role.) The [[Vanilla/Role.html|Role]] object is then validated and its properties saved to the database. The return value is the [[Vanilla/Role.html|Role]] object whose values were saved, or a boolean false if an error occurred. === ValidateRole === == Signature: == <code php>[boolean] ValidateRole(&$Role)</code> == Description: == Ensures that the properties of the given [[Vanilla/Role.html|Role]] object are safe for database storage, and if so, formats them accordingly. Returns a truth value if no errors are encountered. If there were errors, the [[Vanilla/Role.html|Role]] object is left unchanged.

vanilla/vanilla_rolemanager.html.txt · Last modified: 2009/03/28 14:10
Vanilla 1 Documentation archive (Wiki by DokuWiki)