[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/station/ -> station.admin.inc (source)

   1  <?php
   2  
   3  // $Id: station.admin.inc,v 1.2 2009/06/04 16:05:03 drewish Exp $
   4  
   5  /**
   6   * Admin settings form.
   7   */
   8  function station_admin_settings() {
   9    $form['station_clock'] = array(
  10      '#type' => 'radios',
  11      '#title' => t('Time format'),
  12      '#options' => array(12 => t('12-hour (am/pm)'), 24 => t('24-hour')),
  13      '#default_value' => variable_get('station_clock', 12),
  14      '#description' => t('This setting determines whether times are formatted using a 12 or 24-hour clock.'),
  15    );
  16  
  17    $form['station_remote'] = array(
  18      '#type' => 'fieldset',
  19      '#title' => t('Sub-module Integration'),
  20      '#description' => t('The Station module is designed to allow different modules to be run on different servers. So the archive could be on a dedicated machine while the schedule runs on your primary webserver.'),
  21    );
  22  
  23    if (!module_exists('station_archive')) {
  24      $form['station_remote']['station_remote_archive_url'] = array(
  25        '#type' => 'textfield',
  26        '#title' => t('Station Archive remote URL'),
  27        '#default_value' => variable_get('station_remote_archive_url', ''),
  28        '#description' => t("The archive module is not enabled on this machine. If you have it installed up on a different Drupal server, enter the URL here. If this is blank no archive links will be provided. Please include the trailing slash: i.e. http://example.com/"),
  29      );
  30    }
  31    else {
  32      $form['station_remote']['archive_status'] = array(
  33        '#type' => 'item',
  34        '#title' => t('Station Archive module is enabled'),
  35        '#value' => t("The Station Archive module is enabled on this machine. This can be used by the Station Schedule module to provide users links to a program's archived audio."),
  36      );
  37    }
  38  
  39    if (!module_exists('station_schedule')) {
  40      $form['station_remote']['station_remote_schedule_url'] = array(
  41        '#type' => 'textfield',
  42        '#title' => t('Station Schedule remote URL'),
  43        '#default_value' => variable_get('station_remote_schedule_url', ''),
  44        '#description' => t("The station schedule module is not enabled on this machine. The Station module can connect to another Drupal server running the station schedule module and retrieve information on scheduled programs via XML-RPC. If this is left blank, no connection will be attempted but things may not work. Omit the trailing slash, i.e.: http://example.com or http://example.com/drupal"),
  45      );
  46      if ($schedules = station_get_schedules()) {
  47        $options = array();
  48        foreach (station_get_schedules() as $nid => $schedule) {
  49          $options[$nid] = $schedule['title'];
  50        }
  51        $form['station_remote']['station_remote_schedule_nid'] = array(
  52          '#type' => 'select',
  53          '#title' => t('Schedule'),
  54          '#default_value' => variable_get('station_remote_schedule_nid', 0),
  55          '#options' => $options,
  56          '#description' => t("This you select the schedule that will be used as the default for backwards compatibility."),
  57        );
  58      }
  59      $form['station_remote']['station_remote_schedule_offset'] = array(
  60        '#type' => 'textfield',
  61        '#title' => t('Station Schedule remote minute adjustment'),
  62        '#default_value' => variable_get('station_remote_schedule_offset', 0),
  63        '#description' => t("If the clocks on your two servers aren't accurately synchronized the archive will end up with the wrong names for programs. This number of minutes (positive or negative) will be added to the time before checking the schedule."),
  64      );
  65    }
  66    else {
  67      $form['station_remote']['schedule_status'] = array(
  68        '#type' => 'item',
  69        '#title' => t('Station Schedule module is enabled'),
  70        '#value' => t('The Station Schedule module is enabled on this machine. This information can be used by the Now Playing block and Station Archive module.'),
  71      );
  72    }
  73  
  74    return system_settings_form($form);
  75  }
  76  
  77  /**
  78   * Checks that the RPC endpoint is valid.
  79   */
  80  function station_admin_settings_validate($form, &$form_state) {
  81    if (!module_exists('station_schedule')) {
  82      // check station url
  83      if ($url = $form_state['values']['station_remote_schedule_url']) {
  84        $url = check_url($url .'/xmlrpc.php');
  85        $ret = xmlrpc($url, 'station.program.get.at', time(), 0);
  86        if (xmlrpc_error_msg()) {
  87          form_set_error('station_remote_schedule_url',
  88            t('You must provide a a valid URL for a Drupal site with the station schedule module installed.<br />Specific error: %xmlrpc-error', array('%xmlrpc-error' => xmlrpc_error_msg()))
  89          );
  90        }
  91      }
  92  
  93      // check that the offset is an integer
  94      $offset = $form_state['values']['station_remote_schedule_offset'];
  95      if (!(is_numeric($offset) && intval($offset) == $offset)) {
  96        form_set_error('station_remote_schedule_offset', t('The offset must be an integer.'));
  97      }
  98    }
  99  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7