You are here

function seochecklist_admin_settings_submit in SEO Checklist 6.2

Same name and namespace in other branches
  1. 5.2 seochecklist.module \seochecklist_admin_settings_submit()
  2. 5 SEOChecklist.module \SEOChecklist_admin_settings_submit()
  3. 6.3 seochecklist.admin.inc \seochecklist_admin_settings_submit()
  4. 7.3 seochecklist.admin.inc \seochecklist_admin_settings_submit()

Submit callback for seochecklist_admin_settings().

File

./seochecklist.module, line 132
SEO Checklist module allows users to track important SEO techniques on the website.

Code

function seochecklist_admin_settings_submit($form, &$form_state) {

  // Saving checked modules.
  if ($form_state['values']['op'] == t('Save')) {
    $checked[] = array(
      0,
    );
    foreach ($form_state['values'] as $key => $value) {
      if (preg_match('/seochecklist_nodetypes/', $key)) {
        $key = explode('_', $key);
        $key = $key[2];

        // Module $value is checked.
        $existing = db_result(db_query("SELECT option_checked FROM {seo_checklist} WHERE id= %d", $key));
        if ($existing) {
          db_query("UPDATE {seo_checklist} SET date_changed = '%s', option_checked = %d WHERE id = %d", date("Y-m-d H:i:s"), $value, $key);
        }
        else {
          db_query("update {seo_checklist} set option_checked = %d WHERE id = %d", $value, $key);
        }
        $checked[] = $value;
      }
    }

    // Special values not in database.
    variable_set('seo_checklist_link', intval($form_state['values']['Bottom_code']));
    variable_set('seo_checklist_thanks', intval($form_state['values']['Bottom_code_more']));
    variable_set('seo_checklist_podcast', intval($form_state['values']['Bottom_code_podcast']));

    // Store zero for all unchecked items.
    db_query("UPDATE {seo_checklist} SET option_checked = 0 WHERE id NOT IN (" . db_placeholders($checked) . ")", $checked);
  }

  // Check for already installed modules.
  if ($form_state['values']['op'] == t('Check for already Installed Modules')) {
    $result = db_query("SELECT * FROM {seo_checklist} WHERE module != ''");
    while ($data = db_fetch_object($result)) {
      if (module_exists(strtolower($data->module))) {
        db_query("UPDATE {seo_checklist} SET option_checked = %d, date_changed = '%s' where id = %d", $data->id, date('Y-m-d H:i:s'), $data->id);
      }
      else {
        db_query("UPDATE {seo_checklist} SET option_checked = %d where id = %d", 0, $data->id);
      }
    }
  }
}