You are here

function cctags_settings_submit in cctags 7

Same name and namespace in other branches
  1. 6 cctags.admin.inc \cctags_settings_submit()

File

./cctags.admin.inc, line 38

Code

function cctags_settings_submit($form, &$form_state) {
  if (!form_get_errors()) {
    foreach ($form_state['values']['cctags_item'] as $key => $value) {
      $block = $value['cctags_item_block'];
      $page = $value['cctags_item_page'];
      $cctid = $value['cctid'];
      if ($block) {
        $block_name = check_plain($form['cctags_item'][$key]['cctags_item_block_name']['#value'] ? $form['cctags_item'][$key]['cctags_item_block_name']['#value'] : $form['cctags_item'][$key]['cctags_item_name']['#markup']);
        db_update('cctags')
          ->fields(array(
          'block_name' => $block_name,
        ))
          ->condition('cctid', $cctid)
          ->execute();
      }
      if ($page) {
        $page_path = $form['cctags_item'][$key]['cctags_item_page_path']['#value'] ? $form['cctags_item'][$key]['cctags_item_page_path']['#value'] : 'cctags/page/' . $cctid;
        db_update('cctags')
          ->fields(array(
          'page_path' => $page_path,
        ))
          ->condition('cctid', $cctid)
          ->execute();
      }
      db_update('cctags')
        ->fields(array(
        'block' => $block,
        'page' => $page,
      ))
        ->condition('cctid', $cctid)
        ->execute();
    }
    drupal_set_message(t('The Cctags configuration has been updated.'));
    _cctags_clear_cache($cctid, 'all');
    menu_rebuild();
  }
}