The access callback is not loading the correct object.

Also default user gets loaded.

CommentFileSizeAuthor
model-access.patch1.24 KBdomidc

Comments

ronald_istos’s picture

1. user_access loads the user object for you so we don't need to do this again

2. not sure why you think the wrong object is loaded...

domidc’s picture

I mean that the access argument expects the full object instead of just the type. Otherwise later in following function $type_name is not correct.

function model_access($op, $model = NULL, $account = NULL) {
	if (empty($account)) {
	  global $user;
	  $account = $user;
	}
	
  if (user_access('administer models', $account)) {
    return TRUE;
  }
  if (isset($model) && $type_name = $model->type) {
    $op = ($op == 'view') ? 'view' : 'edit';
    if (user_access("$op any $type_name model", $account)) {
      return TRUE;
    }
  }
  return FALSE;
}
Daniel_KM’s picture

Status: Active » Reviewed & tested by the community

Hi,

I confirm the second part of the patch.

Sincerely,

Daniel Berthereau
Infodoc & Knowledge management

anybody’s picture

Issue summary: View changes

Confirming RTBC!
@Maintainer: Could you add this to the next release?