You are here

function quotes_block_configure_save in Quotes 7

Same name and namespace in other branches
  1. 6 quotes.module \quotes_block_configure_save()

Quotes block configuration save.

We save our data to the quotes_block tables as in D6.

Parameters

int $delta: The blocks ID value we are saving.

1 call to quotes_block_configure_save()
quotes_block_save in ./quotes.module
Implements hook_block_save().

File

./quotes.module, line 1406
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_block_configure_save($delta, $edit) {
  $vals = array(
    $edit['name'],
    $edit['block_type'],
    preg_replace('<[,\\s]+>', ',', trim($edit['nid_filter'])),
    $edit['aid_filter'] == array(
      '0',
    ) ? '' : implode(',', (array) $edit['aid_filter']),
    $edit['rid_filter'] == array(
      -1 => '-1',
    ) ? '' : implode(',', (array) $edit['rid_filter']),
    $edit['uid_filter'] == array(
      -1 => '-1',
    ) ? '' : implode(',', (array) $edit['uid_filter']),
    // I'm not sure why it returns 0, but it works for me.
    $edit['tid_filter'] == array(
      -1 => '-1',
    ) ? '' : implode(',', (array) $edit['tid_filter']),
    $edit['cron_interval'] ? $edit['cron_interval'] : 0,
    $edit['cron_step'],
    $edit['block_count'],
    $edit['show_titles'],
    $edit['show_citation'],
    // We only save the "more" text for random blocks.
    $edit['block_type'] == 0 ? $edit['block_more'] : NULL,
    $edit['view_text'],
    $edit['max_length'],
    // Frequency is only for random blocks.
    $edit['block_type'] == 0 ? $edit['rand_freq'] : 100,
    $delta,
  );
  db_update('quotes_blocks')
    ->fields(array(
    'name' => $vals[0],
    'block_type' => $vals[1],
    'nid_filter' => $vals[2],
    'aid_filter' => $vals[3],
    'rid_filter' => $vals[4],
    'uid_filter' => $vals[5],
    'tid_filter' => $vals[6],
    'cron_interval' => $vals[7],
    'cron_step' => $vals[8],
    'count' => $vals[9],
    'show_titles' => $vals[10],
    'show_citation' => $vals[11],
    'more_text' => $vals[12],
    'view_text' => $vals[13],
    'max_length' => $vals[14],
    'rand_freq' => $vals[15],
  ))
    ->condition('bid', $delta)
    ->execute();
}