You are here

function block_modify in Patterns 7.2

Wraps several calls to several drupal_form_submit to update the settings of a block. This operation affects only the block table, block_custom table is not affected in case is a custom block

Parameters

string $form_id String containing the form ID. In the case of custom functions the value is empty.:

array $form_state Set of values after parsing the action.:

2 string references to 'block_modify'
block_patterns in patterns_components/components/block.inc
block_patterns_cleanup in patterns_components/components/block.inc
Implements hook_patterns_cleanup().

File

patterns_components/components/block.inc, line 525

Code

function block_modify($form_id, &$form_state) {

  //We can use the all the optional fields provided by the pattern after removing the ones that compound the key
  $fields_to_remove = array(
    'tag' => $form_state['values']['tag'],
    'module' => $form_state['values']['module'],
    'delta' => $form_state['values']['delta'],
    'theme' => $form_state['values']['theme'],
  );
  $fields = array_diff_key($form_state['values'], $fields_to_remove);
  $query = db_update('block')
    ->fields($fields)
    ->condition('module', $form_state['values']['module'])
    ->condition('delta', $form_state['values']['delta'])
    ->condition('theme', $form_state['values']['theme'])
    ->execute();
  $msg = t('Updated the following fields for block created by module %module with delta %delta for theme %theme: %fields.', array(
    '%module' => $form_state['values']['module'],
    '%delta' => $form_state['values']['delta'],
    '%theme' => $form_state['values']['theme'],
    '%fields' => implode(', ', array_keys($fields)),
  ));
  return patterns_results(PATTERNS_SUCCESS, $msg);
}