Skip to content
Snippets Groups Projects
Commit 1b839d41 authored by Eric Bremner's avatar Eric Bremner
Browse files
parent 4d76c5c2
No related branches found
No related tags found
No related merge requests found
......@@ -821,7 +821,12 @@ class EntityDrupalWrapper extends EntityStructureWrapper {
}
else {
// This is not a property, so fallback on entity access.
return $this->entityAccess($op == 'edit' ? 'update' : 'view', $account);
if ($op == 'edit') {
// If the operation is "edit" determine if its actually a "create" for
// new un-saved entities, or an "update" for existing ones.
return $this->entityAccess($this->getIdentifier() ? 'update' : 'create', $account);
}
return $this->entityAccess('view', $account);
}
}
......
......@@ -670,9 +670,11 @@ function entity_metadata_field_file_validate_item($items, $context) {
function entity_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) {
// First deal with the case where a $node is provided.
if (isset($node)) {
if ($op == 'create') {
if (empty($node->vid) && in_array($op, array('create', 'update'))) {
// This is a new node or the original node.
if (isset($node->type)) {
return node_access($op, $node->type, $account);
$op = !empty($node->is_new) && $node->is_new ? 'create' : 'update';
return node_access($op, $op == 'create' ? $node->type : $node, $account);
}
else {
throw new EntityMalformedException('Permission to create a node was requested but no node type was given.');
......@@ -906,10 +908,14 @@ function entity_metadata_user_save($account) {
/**
* Callback to delete a file.
* Watch out to not accidentilly implement hook_file_delete().
*
* Watch out to not accidentally implement hook_file_delete().
*/
function entity_metadata_delete_file($fid) {
file_delete(file_load($fid), TRUE);
if (!$file = file_load($fid)) {
return;
}
file_delete($file, TRUE);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment