You are here

function fb_cron_form_alter in Drupal for Facebook 5

Implementation of hook_form_alter.

File

./fb_cron.module, line 19
This module helps administer facebook-specific actions to be performed during cron jobs.

Code

function fb_cron_form_alter($form_id, &$form) {

  // Add our settings to the fb_app edit form.
  if (is_array($form['fb_app_data'])) {
    $node = $form['#node'];
    $fb_app_data = fb_app_get_data($node->fb_app);
    $fb_cron_data = $fb_app_data['fb_cron'];
    $form['fb_app_data']['fb_cron'] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Facebook cron settings'),
      '#description' => t('Allows application-specific actions to be performed during cron jobs.  Enable the Actions, Facebook Actions, and Facebook Infinite Session modules to do anything truly useful here.'),
    );
    if (module_exists('actions')) {
      $options = array();
      foreach (actions_get_all_actions() as $aid => $action) {
        if ($action['type'] == t('Facebook App')) {
          $options[$action['type']][$aid] = $action['description'];
        }
      }
      $form['fb_app_data']['fb_cron']['actions'] = array(
        '#type' => 'select',
        '#title' => t('Actions'),
        '#default_value' => $fb_cron_data['actions'],
        '#multiple' => TRUE,
        '#required' => FALSE,
        '#options' => $options,
        '#description' => t('Select one or more actions to perform when cron jobs are executed. Note that you should select actions intended to operate on Facebook Applications, and not actions intended to operate on nodes.'),
      );
    }
  }
}