function mobile_tools_edit_mobile_role in Mobile Tools 6
Same name and namespace in other branches
- 5 mobile_tools.module \mobile_tools_edit_mobile_role()
- 7.2 mobile_tools_roles/mobile_tools_roles.module \mobile_tools_edit_mobile_role()
- 7.2 mobile_tools_roles/mobile_tools_roles.inc \mobile_tools_edit_mobile_role()
Function helping in saving and deleting the mobile roles
Parameters
$op: the operation that has to be performed: 'delete' will delete the mobile role, 'add' will add the mobile role.
$role: the $role object of the normal role (the already existing non-mobile role)
2 calls to mobile_tools_edit_mobile_role()
- mobile_tools_roles_configuration_submit in ./
mobile_tools_roles.inc - Submit handler for the roles configuration form. It organises the mobile context for each user role.
- mobile_tools_roles_settings_submit in ./
mobile_tools_roles.inc - Submit function for the mobile tools / mobile roles configuration page
File
- ./
mobile_tools_roles.inc, line 261 - Contains the functionality to add mobile user roles
Code
function mobile_tools_edit_mobile_role($op, $role) {
switch ($op) {
case 'delete':
db_query('DELETE FROM {role} WHERE rid = %d', $role->sibling['id']);
db_query('DELETE FROM {mobile_tools_roles_relations} WHERE mrid = %d', $role->sibling['id']);
break;
case 'add':
$result = db_query("INSERT INTO {role} (name) VALUES ('%s')", $role->name . ' (Mobile)');
db_query("INSERT INTO {mobile_tools_roles_relations} (rid, mrid) VALUES (%d, %d)", $role->id, db_last_insert_id('role', 'rid'));
break;
}
}