User Roles www.prodigyview.com
Follow Along With Code               Example1. Download a copy of the example code at  www.prodigyview.com/source.2. Insta...
OverviewObjectiveLearn to create, update, delete, user roles. Also learn howto assign users to a roleRequirements Install...
What are roles?A user’s ability to access an area can either be restricted by auser’s access levels or a user’s roles. Rol...
Creating A RoleRoles are created with only a few simple arguments, theonly required arguments being the name of the role. ...
Adding/Removing A Role             From UserUser roles do not any good if they are just sitting there. Solets assign them ...
Updating A Role Part 1   Whoops we made a boo-boo and spelt something wrong   and need to update the role. First we need t...
Updating A Role Part 2Now that we have the role, and most importantly the roleid, lets update the role. Change the fields ...
Finding User Roles Now we want to search for user roles. In the slide on creating a user role we set a role_type.Lets sear...
Deleting A RoleDeleting a role is relatively simple task. Simply pass therole ID to deleteUserRole and the role will no lo...
The Not So Obvious1. Retrieving the role information by the role name   seems nice but if you have two roles with the same...
Challenge!We know how to create a user role and how to add a roleto a user.Create the roles ‘Administrator’ and ‘Super Adm...
API ReferenceFor a better understanding of the users, visit the api byclicking on the link below.PVUsers                 M...
Upcoming SlideShare
Loading in …5
×

User Roles Basics CMS PHP

4,460 views

Published on

Learn how to create, update, find and delete user roles in ProdigyView. Also learn how to assign users to roles

Published in: Technology
  • Be the first to comment

  • Be the first to like this

User Roles Basics CMS PHP

  1. 1. User Roles www.prodigyview.com
  2. 2. Follow Along With Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to examples/user/UserRoles.php
  3. 3. OverviewObjectiveLearn to create, update, delete, user roles. Also learn howto assign users to a roleRequirements Install version of ProdigyView with a database connection Understanding of basic user managementEstimated Time10 Minutes www.prodigyview.com
  4. 4. What are roles?A user’s ability to access an area can either be restricted by auser’s access levels or a user’s roles. Roles are more complexthan access levels in that a user can have multiple roles thatthey belong too. In this tutorial we will be covering:1. Creating A Role2. Assigning a Role to A User3. Updating a Role4. Searching for a Role5. Removing A roleLimiting access by a role is discussed in the security tutorial onroles and access level.
  5. 5. Creating A RoleRoles are created with only a few simple arguments, theonly required arguments being the name of the role. Thearguments are passed as an array intoPVUsers::addUserRole1. Arguments for defining the role 2. Pass arguments to create role and return the roles id www.prodigyview.com
  6. 6. Adding/Removing A Role From UserUser roles do not any good if they are just sitting there. Solets assign them to a user using the functionaddUserToRole().1. The id of the user to add to the role 2. The name of the role
  7. 7. Updating A Role Part 1 Whoops we made a boo-boo and spelt something wrong and need to update the role. First we need to start out by getting the role from the database. The role can either be retrieved by the name or the id.1. Retrieve the roles data by 2. Retrieve the roles data by the name of thethe role id role 3. The roles information returned in an array
  8. 8. Updating A Role Part 2Now that we have the role, and most importantly the roleid, lets update the role. Change the fields you want to inthe array and pass it to updateUserRole function.Update complete.1. Change information the role 2. Pass array to update method
  9. 9. Finding User Roles Now we want to search for user roles. In the slide on creating a user role we set a role_type.Lets search on that field. What will be returned is an array of roles that we can iterate through. Like any other list, PV Standard Search Arguments are used. 1. Search the user roles based on type2. Returns an array of arrays ofuser role information 3. Iterate through the roles to retrieve information of each role that matches the arguments passed
  10. 10. Deleting A RoleDeleting a role is relatively simple task. Simply pass therole ID to deleteUserRole and the role will no longerexist. www.prodigyview.com
  11. 11. The Not So Obvious1. Retrieving the role information by the role name seems nice but if you have two roles with the same name, this will be a problem because it will only pick one of them.2. To get the roles assigned to a user, use the PVUsers::getAssignedUserRole() www.prodigyview.com
  12. 12. Challenge!We know how to create a user role and how to add a roleto a user.Create the roles ‘Administrator’ and ‘Super Administrator’3x times. When adding the roles, give a differentrole_type too each(site_1, site_2, site_3). Add the userONLY to the roles that have the role_type being site_2. www.prodigyview.com
  13. 13. API ReferenceFor a better understanding of the users, visit the api byclicking on the link below.PVUsers More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com

×