You are here

class FeedsLdapQueryFetcher in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_feeds/FeedsLdapQueryFetcher.inc \FeedsLdapQueryFetcher
  2. 7 ldap_feeds/FeedsLdapQueryFetcher.inc \FeedsLdapQueryFetcher

Fetches data via LDAP Query.

Hierarchy

Expanded class hierarchy of FeedsLdapQueryFetcher

3 string references to 'FeedsLdapQueryFetcher'
ldap_feeds_feeds_plugins in ldap_feeds/ldap_feeds.module
Implements hook_feeds_plugins().
ldap_feeds_form_feeds_ui_mapping_form_alter in ldap_feeds/ldap_feeds.module
show some sample ldap user data to help with mapping interface
ldap_feeds_query_legend in ldap_feeds/ldap_feeds.module
add additional data to mapping form for ldap query fetcher

File

ldap_feeds/FeedsLdapQueryFetcher.inc, line 46
FeedsLdapQueryFetcher

View source
class FeedsLdapQueryFetcher extends FeedsFetcher {

  /**
   * Implements FeedsFetcher::fetch().
   */
  public function fetch(FeedsSource $source) {
    $source_config = $source
      ->getConfigFor($this);
    $result = new FeedsLdapQueryFetcherResult($source_config);
    return $result;
  }

  /**
   * Override parent::configDefaults().
   */
  public function configDefaults() {
    return array(
      'query_ids' => array(),
    );
  }

  /**
   * Override parent::configForm().
   */
  public function configForm(&$form_state) {
    $queries = ldap_query_get_queries(NULL, 'enabled');
    $query_options = array(
      0 => '--- select one or more queries ---',
    );
    foreach ($queries as $qid => $query) {
      $query_options[$qid] = $query->name;
    }
    $form = array();
    $form['query_ids'] = array(
      '#type' => 'select',
      '#title' => t('LDAP Query'),
      '#multiple' => TRUE,
      '#size' => min(10, count($query_options)),
      '#required' => TRUE,
      '#default_value' => $this->config['query_ids'],
      '#description' => t('If more than one query is selected, results from all the queries will be returned.') . ' ' . t('Queries can be added and edited at !link', array(
        '!link' => l(t('LDAP Query Admin'), LDAP_QUERY_INDEX_BASE_PATH),
      )),
      '#options' => $query_options,
    );
    return $form;
  }

  /**
   * Override parent::sourceForm().
   */
  public function sourceForm($source_config) {
    $tokens = array(
      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/edit/' . $this->id),
    );
    $form_state = array();
    $form = $this
      ->configForm($form_state);
    $form['preamble'] = array(
      '#type' => 'markup',
      '#markup' => t('This import is configured at !edit_link.', $tokens),
    );
    return $form;
  }

  /**
   * Override parent::sourceFormValidate().
   */
  public function sourceFormValidate(&$values) {

    // could execute query and see if it returns anything for validation
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsLdapQueryFetcher::configDefaults public function Override parent::configDefaults().
FeedsLdapQueryFetcher::configForm public function Override parent::configForm().
FeedsLdapQueryFetcher::fetch public function Implements FeedsFetcher::fetch().
FeedsLdapQueryFetcher::sourceForm public function Override parent::sourceForm().
FeedsLdapQueryFetcher::sourceFormValidate public function Override parent::sourceFormValidate().