You are here

public static function LdapQueryAdmin::getLdapQueryObjects in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_query/LdapQueryAdmin.class.php \LdapQueryAdmin::getLdapQueryObjects()
  2. 7.2 ldap_query/LdapQueryAdmin.class.php \LdapQueryAdmin::getLdapQueryObjects()

Parameters

string $sid either 'all' or the ldap server sid:

$type = 'all', 'enabled':

3 calls to LdapQueryAdmin::getLdapQueryObjects()
LdapQueryAdmin::validate in ldap_query/LdapQueryAdmin.class.php
ldap_views_plugin_query_ldap::options_form in ldap_views/plugins/ldap_views_plugin_query_ldap.inc
Add settings for the ui.
_ldap_query_get_queries in ldap_query/ldap_query.inc
see ldap_query_get_servers()

File

ldap_query/LdapQueryAdmin.class.php, line 20

Class

LdapQueryAdmin

Code

public static function getLdapQueryObjects($sid = 'all', $type = 'enabled', $class = 'LdapQuery') {
  $queries = array();
  if (module_exists('ctools')) {
    ctools_include('export');
    $select = ctools_export_load_object('ldap_query', 'all');
  }
  else {
    try {
      $select = db_select('ldap_query', 'ldap_query')
        ->fields('ldap_query')
        ->execute();
    } catch (Exception $e) {
      drupal_set_message(t('query index query failed. Message = %message, query= %query', array(
        '%message' => $e
          ->getMessage(),
        '%query' => $e->query_string,
      )), 'error');
      return array();
    }
  }
  foreach ($select as $result) {
    $query = $class == 'LdapQuery' ? new LdapQuery($result->qid) : new LdapQueryAdmin($result->qid);
    if (($sid == 'all' || $query->sid == $sid) && (!$type || $type == 'all' || ($query->status = 1 && $type == 'enabled'))) {
      $queries[$result->qid] = $query;
    }
  }
  return $queries;
}