You are here

function panels_save_panels in Panels 5

1 call to panels_save_panels()
panels_edit_form_submit in ./panels.module

File

./panels.module, line 692

Code

function panels_save_panels($panels) {
  $panels->access = implode(', ', $panels->access);
  if ($panels->did) {
    db_query("UPDATE {panels_info} SET title = '%s', access = '%s', path = '%s', css_id = '%s', layout = '%s' WHERE did = %d", $panels->title, $panels->access, $panels->path, $panels->css_id, $panels->layout, $panels->did);
    db_query("DELETE FROM {panels_area} WHERE did = %d", $panels->did);
  }
  else {
    $panels->did = db_next_id("{panels_info_id}");

    // Put this in the form so modules can utilize the did of a new panel.
    $GLOBALS['form_values']['did'] = $panels->did;
    db_query("INSERT INTO {panels_info} (did, title, access, path, css_id, layout) VALUES (%d, '%s', '%s', '%s', '%s', '%s')", $panels->did, $panels->title, $panels->access, $panels->path, $panels->css_id, $panels->layout);
  }
  foreach ($panels->content as $area => $info) {
    foreach ($info as $position => $block) {
      if (is_numeric($position)) {

        // don't save some random form stuff that may've been here.
        $block = (object) $block;
        db_query("INSERT INTO {panels_area} (did, area, type, configuration, position) VALUES(%d, '%s', '%s', '%s', %d)", $panels->did, $area, $block->type, serialize($block->configuration), $position);
      }
    }
  }
  menu_rebuild();
}