protected function FeedsEntityProcessor::entitySaveAccess in Feeds entity processor 7
Overrides parent::entitySaveAccess().
@todo Is checking the uid safe? A quick glance through core and some contrib seems to say yes.
File
- src/
FeedsEntityProcessor.inc, line 140 - Contains FeedsEntityProcessor.
Class
- FeedsEntityProcessor
- Creates entities from feed items.
Code
protected function entitySaveAccess($entity) {
// The check will be skipped for anonymous users.
if (!$this->config['authorize'] || empty($entity->uid)) {
return;
}
// If the uid was mapped directly, rather than by email or username, it
// could be invalid.
if (!($author = user_load($entity->uid))) {
throw new FeedsAccessException(t('User %uid is not a valid user.', array(
'%uid' => $entity->uid,
)));
}
$op = !empty($entity->is_new) ? 'create' : 'update';
// Check if user can create/update the entity.
if (entity_access($op, $this
->entityType(), $entity, $author)) {
return;
}
$args = array(
'%name' => $author->name,
'%op' => $op,
'%entity' => $this
->entityType(),
);
throw new FeedsAccessException(t('User %name is not authorized to %op entity %entity.', $args));
}