function file_admin_entity_presave in File admin 7
Implements hook_entity_presave().
Set created timestamp and file admin settings when entity is created.
File
- ./
file_admin.module, line 61 - Enhances file administration by adding published, promote, and sticky fields.
Code
function file_admin_entity_presave($entity, $type) {
if ($type == 'file' && !isset($entity->fid)) {
$entity->created = REQUEST_TIME;
$file_options = variable_get('file_admin_file_options_' . $entity->type, array(
'published' => 'published',
));
foreach (array(
'published',
'promote',
'sticky',
) as $key) {
$entity->{$key} = (int) (isset($file_options[$key]) && $file_options[$key]);
}
}
}