function rotor_submit in Rotor Banner 5
Same name and namespace in other branches
- 5.7 rotor.module \rotor_submit()
- 6.2 rotor.module \rotor_submit()
- 6 rotor.module \rotor_submit()
- 7 rotor.module \rotor_submit()
Node form submit function. We handle the image submition.
File
- ./
rotor.module, line 351 - A rotor banner consists in a set of images that will be changing. This module is made using jquery.
Code
function rotor_submit(&$node) {
$upload_dir = file_directory_path();
if (!empty($_FILES['files']['name']['rotor_image'])) {
if (file_check_directory($upload_dir, FILE_CREATE_DIRECTORY)) {
$file = file_save_upload('rotor_image', file_directory_path(), FILE_EXISTS_RENAME);
if (!$file) {
drupal_set_message(t("The uploaded file %filename was unable to be saved. The destination directory may not be writable.", array(
'%filename' => $file_saved['filename'],
)), "error");
watchdog('rotor', 'Imaged not saved: ' . $file_saved['filepath']);
}
else {
$file = (object) $file;
$file->fid = db_next_id('{files}_fid');
db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize);
$node->rotor_image = $file->fid;
watchdog('rotor', 'Imaged saved: ' . $file->filepath);
}
}
else {
drupal_set_message(t("The uploaded file was unable to be saved. The destination directory does not exist."), "error");
}
}
// Remove the target attribute if not selected.
if (!$node->link_target || $node->link_target == "default") {
$node->link_target = '';
}
}