-
Notifications
You must be signed in to change notification settings - Fork 42
Access Control Level
This module adds a whole new Access Control Level to your CodeIgniter Skeleton application.
The link to this module will be provided soon. Once the package downloaded:
- Head to modules installation on the dashboard and upload the archive.
- Unzip package files into your
application/modules
ORcontent/modules
folders.
There are several functions you may use but, please NEVER use available classes (Ianhub_Acl_Role
and Ianhub_Acl_Roles).
Some functions save settings into options
table, so it might be better to run this on themes/plugins activation.
This function may be used to instantiate the Ianhub_Acl_Roles
class then have direct access to its methods.
$acl = acl_instance();
$acl->add_role($slug, $name, $capabilities);
This function is used to add new roles to your application. It takes three (3) arguments:
-
$slug
(string) : a unique slug (username) used to stored your new role. -
$name
(string) : the name your new role will have. -
$capabilities
(array) : An array of capibitilies and their status (TRUE
orFALSE
)
acl_add_role('admin', 'administrator', array(
'manage_themes' => true,
'manage_modules' => true,
'manage_plugins' => true,
'manage_users' => true,
'add_users' => true,
// ...
));
// Returns a `Ianhub_Acl_Role` object on success,
// null if that role already exists.
This function is used to remove a previously stored role.
// We remove "admin" we added obove.
acl_remove_role('admin'); // That's all.
// Returns true if the role was removed, else false.
Retrieves a role object if found.
// acl_get_role($role_slug);
$admin = acl_get_role('admin');
// The result wil be an object:
array(
'name' => 'Administrator',
'capabilities'=> array(
'manage_themes' => true,
// ...
),
);
Checks whether the given role slug is available.
// acl_is_role($slug);
acl_is_role('manager');
// Returns: true if the role is found, else false.
Returns the list of previously all registered roles objects.
Returns default users role (string).
$role = acl_get_default_role();
echo $role; // Default: "regular".
Returns default users role upon registration.
// acl_set_defaul_role($role_slug);
acl_set_default_role('regular');
Retrieve list of all registered roles ad their names.
$names = acl_get_names();
// array(
// 'admininstrator' => 'Administrator',
// 'manager' => 'Manager',
// 'regular' => 'Regular',
// );
Adds capability to the given role.
// acl_add_cap($role, $cap, $status);
acl_add_cap('moderator', 'manage_users', true);
acl_add_cap('moderator', 'manage_options', false);
Removes capability from role.
// acl_remove_cap($role, $cap);
acl_remove_cap('moderator', 'manage_options');
You can execute some actions on retrieved roles:
$admin = acl_get_role('admin'); // Returns the role object.
$admin->add_cap($cap, $status); // To add capability.
$admin->remove_cap($cap); // To remove capability.
$admin->has_cap($cap); // To check if the role has the capability.
Simply returns an instance of Ianhub_Acl_Users
class.
Returns an array of all user's compabilities. If the user has none, it returns user's role capabilities. IF, for some reason, nothing was found, it returns an empty array.
// $user may be user's ID/username or KB_User instance.
$caps = acl_user_caps($user); // Returns an array;
Checks whether the selected user has the given capability. The capability must exist and MUST be set to TRUE
.
// $user may be user's ID/username or KB_User instance.
$status = acl_user_has_cap($user, 'manage_options'); // Boolean
Promotes the selected user to the given role. The role must exit to proceed. Otherwise, it will return false.
// $user may be user's ID/username or KB_User instance.
$status = acl_user_promote($user, 'manager');
Demotes the user back to default users role (default: regular).
// $user may be user's ID/username or KB_User instance.
$status = acl_user_demote($user);
Removes a previously added capability from user capabilities list.
// $user may be user's ID/username or KB_User instance.
acl_user_remove_cap($user, 'manage_themes');
Overview
- Home
- Installation Instructions
- CodeIgniter Modifications
- Hooks System
- Custom Classes
- Custom Libraries
- Custom Helpers
- Data Cache Object
Tables and Libraries
Developers Section
Dashboard Contexts
Public Contexts