You are here

function recommender_settings_form_submit in Recommender API 7.3

Same name and namespace in other branches
  1. 6.3 recommender.admin.inc \recommender_settings_form_submit()
  2. 6.2 recommender.module \recommender_settings_form_submit()
  3. 7.4 recommender.admin.inc \recommender_settings_form_submit()
  4. 7.5 recommender.admin.inc \recommender_settings_form_submit()

File

./recommender.admin.inc, line 101

Code

function recommender_settings_form_submit($form, &$form_state) {

  // save settings
  if ($form_state['clicked_button']['#name'] == 'save') {
    $rows = db_query("SELECT name FROM {recommender_app} ORDER BY name");
    foreach ($rows as $row) {
      $name = $row->name;
      $cron = $form_state['values'][$name];
      if ($cron == 'null') {
        $cron = NULL;
      }
      db_query('UPDATE {recommender_app} SET cron=:cron WHERE name=:name', array(
        ':cron' => $cron,
        ':name' => $name,
      ));
    }
    drupal_set_message(t("The settings have been saved."));
  }
  else {
    if ($form_state['clicked_button']['#name'] == 'run') {
      $apps = $form_state['values']['apps'];
      variable_set('recommender_apps', $apps);

      // trigger recommender_run()
      foreach ($apps as $app_name) {
        if (!empty($app_name)) {
          recommender_create_command($app_name);
        }
      }
    }
  }
}