Helpers_user: The user API that never was
I was writing an install profile for a out-of-the-box workflow install profile to be used by media organizations today, when I ran into the rote task of adding roles and permissions.
(for reference, see my last article on workflow configuration in drupal)
So being the programmer who will write something in a day which takes an hour to run to save 5 minutes, I decided to scratch a long standing itch:
The Drupal User System API.
I love the simplicity of the drupal user system, but like many things in drupal, it wants you to use forms to admin it, and the DB model is inherently tied to the controller (not good).
So I decided to contribute this to the helpers module. It provides some simple functions like:
helpers_user_help($section)
permissions_get(unknown_type $rid)
permissions_set(unknown_type $rid, unknown_type $perms = array)
role_add(string $name)
role_get(int $rid = 0, string $name = “”)
user_add_roles($uid, $roles = array)
user_delete_roles($uid, $roles = array)
Simple stuff, but AFAIK, lacking in drupal.
In addition, I also wrote a full set of simplete tests for it which can be found in the tests directory.
The patch can be found at:
http://drupal.org/node/252058
Hope others find this helpful!
-Jacob