/**
 * Implementation of hook_node_import_types().
 */
function path_redirect_node_import_types() {
  return array(
    'path_redirect' => array(
      'title' => t('Path redirect'),
      'can_create' => user_access('administer redirects'), <-- Why can't we do this?
      'create' => ...
    )
  );
}

It didn't make sense why I can't just use a boolean value for can_create in hook_node_import_types(), like hook_menu(), especially if it's a simple user_access check. Patch attached for this feature.

CommentFileSizeAuthor
0-node-import-can-create-boolean-D6.patch1022 bytesdave reid

Comments

Robrecht Jacques’s picture

Status: Active » Needs review

Yes that makes sense and patch looks fine.

Robrecht Jacques’s picture

Status: Needs review » Fixed

Committed to CVS. Will be included in -rc5. Thanks!

Implemented it in user_node_import_types(), node_node_import_types() and taxonomy_node_import_types().

dave reid’s picture

Status: Fixed » Needs review

I would probably also suggest one small quick change just in-case the can create function returns a non-boolean value that is equal, but not identical to TRUE.

Instead of:
+ if ($typeinfo['can_create'] === TRUE || (function_exists($function = $typeinfo['can_create']) && $function($type) === TRUE)) {
Use:
+ if ($typeinfo['can_create'] === TRUE || (function_exists($function = $typeinfo['can_create']) && $function($type) == TRUE)) {

Robrecht Jacques’s picture

Status: Needs review » Fixed

Committed. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.