You are here

function override_node_options_permission in Override Node Options 7

Same name and namespace in other branches
  1. 8 override_node_options.module \override_node_options_permission()

Implements hook_permission().

File

./override_node_options.module, line 14
Main module file for override_node_options.

Code

function override_node_options_permission() {

  // Global permissions which apply to all node types.
  $permissions = array(
    'administer override node options' => array(
      'title' => t('Administer override node options.'),
    ),
  );
  $show_perms = variable_get('override_node_options_permissions', array(
    'general',
    'specific',
  ));
  if (in_array('general', $show_perms, TRUE)) {
    $permissions += array(
      'override all published option' => array(
        'title' => t('Override published option for all node types.'),
      ),
      'override all promote to front page option' => array(
        'title' => t('Override promote to front page option for all node types.'),
      ),
      'override all sticky option' => array(
        'title' => t('Override sticky option for all node types.'),
      ),
      'override all revision option' => array(
        'title' => t('Override revision option for all node types.'),
      ),
      'enter all revision log entry' => array(
        'title' => t('Enter revision log entry for all node types.'),
      ),
      'override all authored on option' => array(
        'title' => t('Override authored on option for all node types.'),
      ),
      'override all authored by option' => array(
        'title' => t('Override authored by option for all node types.'),
      ),
    );
    if (module_exists('comment')) {
      $permissions += array(
        'override all comment setting option' => array(
          'title' => t('Override comment setting option for all node types.'),
        ),
      );
    }
  }
  if (in_array('specific', $show_perms, TRUE)) {

    // Generate override node permissions for all applicable node types.
    foreach (node_permissions_get_configured_types() as $type) {
      $permissions += override_node_options_list_permissions($type);
    }
  }
  return $permissions;
}