You are here

function _rotor_save in Rotor Banner 6.2

Same name and namespace in other branches
  1. 7 rotor.module \_rotor_save()
1 call to _rotor_save()
rotor_nodeapi in ./rotor.module

File

./rotor.module, line 225
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function _rotor_save(&$node) {
  if (!$node->nid) {
    return;
  }
  if (is_object($node->rotor_image)) {
    $fid = upload_element_save($node->rotor_image, 'rotor', FILE_EXISTS_RENAME);
  }
  else {
    $fid = db_result(db_query("SELECT fid FROM {rotor_item} WHERE nid = %d", $node->nid));
  }
  $exists = db_result(db_query("SELECT 1 FROM {rotor_item} WHERE nid = %d", $node->nid));
  if ($exists) {
    db_query("UPDATE {rotor_item} SET fid = %d, alt_text = '%s', image_title = '%s', url = '%s', link_target = '%s' WHERE nid = %d", $fid, $node->alt_text, $node->image_title, $node->url, $node->link_target, $node->nid);
  }
  else {
    db_query("INSERT INTO {rotor_item} (nid, fid, alt_text, image_title, url, link_target)\n      VALUES (%d, %d, '%s', '%s', '%s', '%s')", $node->nid, $fid, $node->alt_text, $node->image_title, $node->url, $node->link_target);
  }
}