You are here

function _invite_add_permission in Invite 7.2

Same name and namespace in other branches
  1. 5.2 invite.install \_invite_add_permission()
  2. 5 invite.install \_invite_add_permission()
  3. 6.2 invite.install \_invite_add_permission()

Helper function to add a permission to a role.

2 calls to _invite_add_permission()
invite_update_11 in ./invite.install
Add track permission to all roles that currently have send permission.
invite_update_9 in ./invite.install
Update limit and move some settings to the premissions table.

File

./invite.install, line 170
Installation file for invite module.

Code

function _invite_add_permission($rid, $permission) {
  if ($permission) {
    $current_perm = db_query("SELECT permission FROM {role_permission} WHERE rid = :rid", array(
      ':rid' => $rid,
    ))
      ->fetchField();
    if ($current_perm != '') {
      $current_perm .= ', ';
    }
    $current_perm .= $permission;
    db_update('role_permission')
      ->fields(array(
      'permission' => $current_perm,
    ))
      ->condition('rid', $rid)
      ->execute();
  }
}