You are here

function _node_gallery_add_permissions in Node Gallery 6.3

_node_gallery_add_permissions() is a helper function to add permissions by role to the db

1 call to _node_gallery_add_permissions()
_node_gallery_give_all_users_permission in ./node_gallery.install

File

./node_gallery.install, line 480
Install, update and uninstall functions for the node_gallery module.

Code

function _node_gallery_add_permissions($rid, $permissions) {
  if (!is_array($permissions)) {
    $permissions = explode(', ', $permissions);
  }
  $current_perms = explode(', ', db_result(db_query("SELECT perm FROM {permission} WHERE rid=%d", $rid)));
  foreach ($permissions as $permission) {
    if (!in_array($permission, $current_perms)) {
      $current_perms[] = $permission;
    }
  }
  $current_perms = implode(', ', $current_perms);
  $return = db_query("UPDATE {permission} SET perm= '%s' WHERE rid=%d", $current_perms, $rid);
  return $return;
}