You are here

function recommender_settings_form in Recommender API 6.2

Same name and namespace in other branches
  1. 6.3 recommender.admin.inc \recommender_settings_form()
  2. 7.3 recommender.admin.inc \recommender_settings_form()
  3. 7.4 recommender.admin.inc \recommender_settings_form()
  4. 7.5 recommender.admin.inc \recommender_settings_form()
1 string reference to 'recommender_settings_form'
recommender_menu in ./recommender.module

File

./recommender.module, line 197

Code

function recommender_settings_form() {
  $form = array();
  $form['settings'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => t('Settings'),
    '#description' => t('Change settings for Recommender API based modules.'),
  );
  $form['settings']['cron_freq'] = array(
    '#title' => t('Recommender running frequency in cron job.'),
    '#type' => 'select',
    '#default_value' => variable_get('recommender_cron_freq', 'never'),
    '#options' => array(
      'never' => 'Never',
      'immediately' => 'Immediately',
      'hourly' => t('Hourly'),
      'every6hr' => t('Every 6 hours'),
      'every12hr' => t('Every 12 hours'),
      'daily' => t('Daily'),
      'weekly' => t('Weekly'),
    ),
    '#description' => t("Please specify the optional frequency to run recommender algorithms in cron. Note that this is a time consuming operation and might timeout or affect your other cron tasks. Not recommended for large site. Consider using the Drush script with system cron."),
  );
  $form['settings']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#name' => 'save',
  );
  $form['run'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => t('Run recommender'),
    '#description' => t('Running recommender involves complex matrix computation and could probably take some time. Please be patient. You can also run recommender with Drush.'),
  );
  $options = drupal_map_assoc(module_implements('run_recommender'));
  $modules = module_list();
  if (empty($options)) {
    $form['run']['note'] = array(
      '#title' => 'Note',
      '#type' => 'item',
      '#description' => t('No recommender modules available.'),
    );
  }
  else {
    $form['run']['modules'] = array(
      '#title' => t('Choose modules'),
      '#default_value' => variable_get('recommender_modules', array()),
      '#type' => 'checkboxes',
      '#description' => t('Please select which modules to run the recommender'),
      '#options' => $options,
    );
  }
  $form['run']['run'] = array(
    '#type' => 'submit',
    '#value' => t('Run recommender now'),
    '#name' => 'run',
    '#disabled' => $options == NULL ? TRUE : FALSE,
  );
  return $form;
}