You are here

function node_privacy_byrole_node_operations in node privacy byrole 6

Same name and namespace in other branches
  1. 5 node_privacy_byrole.module \node_privacy_byrole_node_operations()

Implementation of hook_node_operations().

Return value

array

File

./node_privacy_byrole.module, line 387
Set node access permissions by role.

Code

function node_privacy_byrole_node_operations() {
  $operations = array();
  foreach (user_roles() as $rid => $role) {
    $grants = array();
    $revokes = array();
    foreach (array(
      'view',
      'edit',
      'delete',
    ) as $priv) {
      $operations["grant-{$rid}-{$priv}"]['label'] = t('Grant !priv for !role', array(
        '!priv' => $priv,
        '!role' => $role,
      ));
      $operations["grant-{$rid}-{$priv}"]['callback'] = 'node_privacy_byrole_node_operations_update';
      $operations["grant-{$rid}-{$priv}"]['callback arguments'] = array(
        1,
        $rid,
        $priv,
      );
      $operations["revoke-{$rid}-{$priv}"]['label'] = t('Revoke !priv for !role', array(
        '!priv' => $priv,
        '!role' => $role,
      ));
      $operations["revoke-{$rid}-{$priv}"]['callback'] = 'node_privacy_byrole_node_operations_update';
      $operations["revoke-{$rid}-{$priv}"]['callback arguments'] = array(
        0,
        $rid,
        $priv,
      );
    }
  }
  return $operations;
}