You are here

nr_owners.module in Node registration 7

File

submodules/nr_owners/nr_owners.module
View source
<?php

/**
 * Implements hook_menu_alter().
 */
function nr_owners_menu_alter(&$items) {
  $item =& $items['node/%node/node_registration/settings'];
  $item['access callback'] = 'nr_owners_nr_settings_page_access';
  $item['access arguments'] = array(
    1,
  );
}

/**
 * Access callback for node/%node/node_registration/settings.
 */
function nr_owners_nr_settings_page_access($node) {

  // Has settings access.
  if (node_registration_node_access($node, 'registration settings')) {

    // Settings page enabled or admin.
    $settings = _node_registration_node_type_settings($node->type);
    return user_access('administer node registration') || empty($settings->extra_nr_owners_no_settings_tab);
  }
}

/**
 * Implements hook_form_FORM_ID_alter() for node_registration_type_settings().
 */
function nr_owners_form_node_registration_type_settings_alter(&$form, &$form_state) {
  $registration_type = $form['#registration_type'];
  $type = $registration_type->type;
  $settings = _node_registration_node_type_settings($type);
  $form['events']['extra_nr_owners_no_settings_tab'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable settings tab on node page'),
    '#default_value' => !empty($settings->extra_nr_owners_no_settings_tab),
    '#description' => t('Access denies the settings tab for all people without Administer registration permission.'),
  );
}

/**
 * Implements hook_node_registration_node_access().
 */
function nr_owners_node_registration_node_access($node, $op, $account, $reason) {
  if (in_array($op, array(
    'registration settings',
    'administer',
  ))) {
    if (_node_registration_node_type_enabled($node->type) && $account->uid == $node->uid) {
      return TRUE;
    }
  }
}

/**
 * Implements hook_node_registration_access().
 */
function nr_owners_node_registration_access($registration, $op, $account, $reason) {
  if (in_array($op, array(
    'edit',
    'update',
  )) && $registration->node->uid == $account->uid) {
    return TRUE;
  }
}