function imageblock_save in Image Block 6
Saves a user-created image block in the database.
2 calls to imageblock_save()
- imageblock_add_block_form_submit in ./
imageblock.module - Save the new custom block.
- imageblock_block in ./
imageblock.module - Implements hook_block().
File
- ./
imageblock.module, line 246 - imageblock.module Primarily Drupal hooks.
Code
function imageblock_save($edit, $delta) {
if (!filter_access($edit['format'])) {
$edit['format'] = FILTER_FORMAT_DEFAULT;
}
$data = array();
if (!empty($edit['imageblock_imagecache'])) {
$data['imageblock_imagecache'] = $edit['imageblock_imagecache'];
}
if (!empty($edit['imageblock_link'])) {
$data['imageblock_link'] = $edit['imageblock_link'];
}
if (!empty($edit['imageblock_link_target'])) {
$data['imageblock_link_target'] = $edit['imageblock_link_target'];
}
$old_file = imageblock_get_file($delta);
if (!empty($edit['imageblock_file'])) {
$file = $edit['imageblock_file'];
if (!empty($file->fid)) {
file_set_status($file, FILE_STATUS_PERMANENT);
if (!empty($old_file->fid)) {
file_delete($old_file->filepath);
db_query('DELETE FROM {files} WHERE fid = %d', $old_file->fid);
}
}
}
db_query("UPDATE {imageblock} SET body = '%s', info = '%s', format = %d, fid = %d, data = '%s' WHERE bid = %d", $edit['body'], $edit['info'], $edit['format'], !empty($file->fid) ? $file->fid : $old_file->fid, serialize($data), $delta);
return TRUE;
}