You are here

function panels_mini_edit_form_submit in Panels 5.2

Same name and namespace in other branches
  1. 6.2 panels_mini/panels_mini.admin.inc \panels_mini_edit_form_submit()

Process submission of the mini panel edit form.

File

panels_mini/panels_mini.module, line 579
panels_mini.module

Code

function panels_mini_edit_form_submit($form_id, $form_values) {
  $panel_mini = $form_values['panel_mini'];
  if ($panel_mini->pid != 'new' && $panel_mini->name != $form_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_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_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_values['title'];
  $panel_mini->name = $form_values['name'];
  $panel_mini->category = empty($form_values['category']) ? '' : $form_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);
    $GLOBALS['form_values']['pid'] = $panel_mini->pid;
    $layout = panels_get_layout($panel_mini->display->layout);
    if ($layout['settings form']) {
      return "admin/panels/panel-mini/{$panel_mini->name}/edit/settings/next";
    }
    return "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);
  }
}