You are here

function _node_limit_add_access in Node Limit 7

Same name and namespace in other branches
  1. 8 old/node_limit.module \_node_limit_add_access()

Rewriten access callback for node/add page. Avoid access to this page when the user does not have the right to add any content type.

1 string reference to '_node_limit_add_access'
node_limit_menu_alter in ./node_limit.module
Implements hook_menu_alter().

File

./node_limit.module, line 136

Code

function _node_limit_add_access() {
  $types = node_type_get_types();
  foreach ($types as $type) {
    if (node_hook($type->type, 'form') && node_limit_access($type->type, $context = 'node_add')) {
      return TRUE;
    }
  }
  if (user_access('administer content types')) {

    // There are no content types defined that the user has permission to create,
    // but the user does have the permission to administer the content types, so
    // grant them access to the page anyway.
    return TRUE;
  }
  return FALSE;
}