You are here

function panels_mini_edit_form_submit in Panels 6.2

Same name and namespace in other branches
  1. 5.2 panels_mini/panels_mini.module \panels_mini_edit_form_submit()

Process submission of the mini panel edit form.

File

panels_mini/panels_mini.admin.inc, line 516
Administrative items for the panels mini module.

Code

function panels_mini_edit_form_submit($form, &$form_state) {
  $panel_mini = $form_state['values']['panel_mini'];
  if ($panel_mini->pid != 'new' && $panel_mini->name != $form_state['values']['name']) {

    // update all existing mini panels to point to this one appropriately.
    db_query("UPDATE {blocks} b SET delta = '%s' WHERE b.module = 'panels_mini' AND b.delta = '%s'", $form_state['values']['name'], $panel_mini->name);

    // Above was blocks; these are actual panel panes.
    $result = db_query("SELECT * FROM {panels_pane} WHERE type = 'panels_mini' and subtype = '%s'", $panel_mini->name);
    while ($pane = db_fetch_object($result)) {
      $conf = unserialize($pane->configuration);
      $conf['name'] = $form_state['values']['name'];
      db_query("UPDATE {panels_pane} SET configuration = '%s', subtype = '%s' WHERE pid = %d", serialize($conf), $conf['name'], $pane->pid);
    }
  }
  $panel_mini->title = $form_state['values']['title'];
  $panel_mini->name = $form_state['values']['name'];
  $panel_mini->category = empty($form_state['values']['category']) ? '' : $form_state['values']['category'];
  if ($panel_mini->pid == 'new') {
    unset($_SESSION['pm_import']);
    drupal_set_message(t('Your new mini panel %title has been saved.', array(
      '%title' => $panel_mini->title,
    )));
    panels_mini_save($panel_mini);
    $form_state['values']['pid'] = $panel_mini->pid;
    $layout = panels_get_layout($panel_mini->display->layout);
    if ($layout['settings form']) {
      $form_state['redirect'] = "admin/panels/panel-mini/{$panel_mini->name}/edit-settings/next";
    }
    $form_state['redirect'] = "admin/panels/panel-mini/{$panel_mini->name}/edit-context/next";
  }
  else {
    drupal_set_message(t('Your changes have been saved.'));
    panels_mini_save($panel_mini);
  }
}