You are here

function dynamic_banner_set_banner in Dynamic Banner 7

Same name and namespace in other branches
  1. 7.2 dynamic_banner.module \dynamic_banner_set_banner()
  2. 8.x dynamic_banner.module \dynamic_banner_set_banner()

Set a banner for a given path, preventing duplicates. Note if dbid comes in null then we are creating a banner

1 call to dynamic_banner_set_banner()
dynamic_banner_admin_form_submit in includes/callbacks.inc
Save a new Banner to the database

File

includes/callbacks.inc, line 664
Dynamic Banner Admin Pages and various other functions to make them work Most of the code in this file was derived from path module

Code

function dynamic_banner_set_banner($path, $imgurl, $imgfid, $text, $link, $mode, $time_on, $time_off, $dbid = NULL) {
  if (!$mode) {
    $mode = BANNER_DEFAULT_BANNER_MODE;
  }

  // First we check if we are dealing with an existing alias and delete or modify it based on dbid.
  // we dont need to do a complicated check here because the code already made it for us
  if ($dbid) {

    // Update the existing banner.
    db_update('dynamic_banner')
      ->fields(array(
      'path' => $path,
      'imgurl' => $imgurl,
      'imgfid' => $imgfid,
      'text' => $text,
      'link' => $link,
      'mode' => $mode,
      'start_time' => $time_on,
      'end_time' => $time_off,
    ))
      ->condition('dbid', $dbid)
      ->execute();
  }
  else {
    db_insert('dynamic_banner')
      ->fields(array(
      'path' => $path,
      'imgurl' => $imgurl,
      'imgfid' => $imgfid,
      'text' => $text,
      'link' => $link,
      'mode' => $mode,
      'start_time' => $time_on,
      'end_time' => $time_off,
    ))
      ->execute();
  }
}