indvdum@0:
indvdum@0:
Following are the methods you are able to use.
indvdum@0:
indvdum@0:
2.i. acl
indvdum@0:
indvdum@0:
The acl method is the initialisation routine for all the acl functions. If you intend calling any acl method you must first call this. The method takes as its one and only required parameter an associative array containing user information as stored in the database. This array must contain at least the following information; user_id, user_permissions and user_type. It is called in the following way:
indvdum@0:
indvdum@0:
indvdum@0: $auth->acl(userdata);
indvdum@0:
indvdum@0:
indvdum@0:
Where userdata is the array containing the aforementioned data.
indvdum@0:
indvdum@0:
2.ii. acl_get
indvdum@0:
indvdum@0:
This method is the primary way of determining what a user can and cannot do for a given option globally or in a given forum. The method should be called in the following way:
indvdum@0:
indvdum@0:
indvdum@0: $result = $auth->acl_get(option[, forum]);
indvdum@0:
indvdum@0:
indvdum@0:
Where option is a string representing the required option, e.g. 'f_list', 'm_edit', 'a_adduser', etc. By adding a ! in front of the option, e.g. '!f_list' the result of this method will be negated. The optional forum term is the integer forum_id.
indvdum@0:
indvdum@0:
The method returns a positive integer when the user is allowed to carry out the option and a zero if denied or the other way around if the option is prefixed with an exclamation mark.
indvdum@0:
indvdum@0:
If you specify a forum and there is also a global setting for the specified option then this method will return a positive integer if one of them evaluates to a positive integer. An example would be the m_approve option which can be set per forum but also globally. If a user has the global option he will automatically have m_approve in every forum.
indvdum@0:
indvdum@0:
There are some special options or flags which are used as prefixes for other options, e.g. 'f_' or 'm_'. These flags will automatically be set to a positive integer if the user has one or more permissions with the given prefix. A local setting will result in the flag being set only locally (so it will require a forum id to retrieve). If a user has one or more global permissions with the prefix acl_get will return a positive integer regardless of the forum id.
indvdum@0:
indvdum@0:
2.iii. acl_gets
indvdum@0:
indvdum@0:
This method is funtionally similar to acl_get in that it returns information on whether a user can or cannot carry out a given task. The difference here is the ability to test several different options in one go. This may be useful for testing whether a user is a moderator or an admin in one call. Rather than having to call and check acl_get twice.
indvdum@0:
indvdum@0:
The method should be called thus:
indvdum@0:
indvdum@0:
indvdum@0: $result = $auth->acl_gets(option1[, option2, ..., optionN, forum]);
indvdum@0:
indvdum@0:
indvdum@0:
As with the acl_get method the options are strings representing the required permissions to check. The forum again is an integer representing a given forum_id.
indvdum@0:
indvdum@0:
The method will return a positive integer if acl_get for one of the options evaluates to a positive integer (combines permissions with OR).
indvdum@0:
indvdum@0:
2.iv. acl_getf
indvdum@0:
indvdum@0:
This method is used to find out in which forums a user is allowed to carry out an operation or to find out in which forums he is not allowed to carry out an operation. The method should be called in the following way:
indvdum@0:
indvdum@0:
indvdum@0: $result = $auth->acl_getf(option[, clean]);
indvdum@0:
indvdum@0:
indvdum@0:
Just like in the acl_get method the option is a string specifying the permission which has to be checked (negation using ! is allowed). The second parameter is a boolean. If it is set to false this method returns all forums with either zero or a positive integer. If it is set to true only those forums with a positive integer as the result will be returned.
indvdum@0:
indvdum@0:
The method returns an associative array of the form:
indvdum@0:
indvdum@0:
indvdum@0: array(forum_id1 => array(option => integer), forum_id2 => ...)
indvdum@0:
indvdum@0:
indvdum@0:
Where option is the option passed to the method and integer is either zero or a positive integer and the same acl_get(option, forum_id) would return.
indvdum@0:
indvdum@0:
2.v. acl_getf_global
indvdum@0:
indvdum@0:
This method is used to find out whether a user has a permission in at least one forum or globally. This method is similar to checking whether acl_getf(option, true) returned one or more forums but it's faster. It should be called in the following way:
indvdum@0:
indvdum@0:
indvdum@0: $result = $auth->acl_getf_global(option)
indvdum@0:
indvdum@0:
indvdum@0:
As with the previous methods option is a string specifying the permission which has to be checked.
indvdum@0:
indvdum@0:
This method returns either zero or a positive integer.
indvdum@0:
indvdum@0:
2.vi. acl_cache
indvdum@0:
indvdum@0:
This should be considered a private method and not be called externally. It handles the generation of the user_permissions data from the basic user and group authorisation data. When necessary this method is called automatically by acl.
indvdum@0:
indvdum@0:
2.vii. acl_clear_prefetch
indvdum@0:
indvdum@0:
This method clears the user_permissions column in the users table for the given user. If the user ID passed is zero, the permissions cache is cleared for all users. This method should be called whenever permissions are set.
indvdum@0:
indvdum@0:
indvdum@0: // clear stored permissions for user 2
indvdum@0: $user_id = 2;
indvdum@0: $auth->acl_clear_prefetch($user_id);
indvdum@0:
indvdum@0:
indvdum@0:
This method returns void.
indvdum@0:
indvdum@0:
2.viii. acl_get_list
indvdum@0:
indvdum@0:
This method returns an an array describing which users have permissions in given fora. The resultant array contains an entry for permission that every user has in every forum when no arguments are passed.
indvdum@0:
indvdum@0:
indvdum@0: $user_id = array(2, 53);
indvdum@0: $permissions = array('f_list', 'f_read');
indvdum@0: $forum_id = array(1, 2, 3);
indvdum@0: $result = $auth->acl_get_list($user_id, $permissions, $forum_id);
indvdum@0:
indvdum@0:
indvdum@0:
The parameters may be of the following legal types:
indvdum@0:
indvdum@0: - $user_id:
false, int, array(int, int, int, ...)
indvdum@0: - $permissions:
false, string, array(string, string, ...)
indvdum@0: - $forum_id:
false, int, array(int, int, int, ...)
indvdum@0:
indvdum@0:
indvdum@0:
2.ix. Miscellaneous
indvdum@0:
indvdum@0:
There are other methods defined in the auth class which serve mostly as private methods, but are available for use if needed. Each of them is used to pull data directly from the database tables. They are:
indvdum@0:
indvdum@0: function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false)
indvdum@0: function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false)
indvdum@0: function acl_raw_data_single_user($user_id)
indvdum@0: function acl_raw_data($user_id = false, $opts = false, $forum_id = false)
indvdum@0: function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false)
indvdum@0:
indvdum@0:
indvdum@0:
Of these, acl_raw_data is the most general, but the others will be faster if you need a smaller amount of data.
indvdum@0:
indvdum@0: