You are here

function clients_get_connections in Web Service Clients 7

Loads all connections

Parameters

$types: (optional) Specify a single type or a list of types to include. If omitted, all are returned.

Return value

Array of connections.

4 calls to clients_get_connections()
clients_connections_checkbox_options in ./clients.module
FormAPI helper to get a list of clients for a checkboxes form element.
clients_connections_list in ./clients.connection.admin.inc
Page callback: list connections.
clients_connections_select_options in ./clients.module
FormAPI helper to get a list of clients for a select form element.
clients_resources_form in ./clients.module
@todo validate uniqueness of name

File

./clients.module, line 602
Clients module - handles keys and service connections and provides an API for clients

Code

function clients_get_connections($types = array()) {
  if (!is_array($types)) {
    $types = array(
      $types,
    );
  }
  if (count($types)) {
    $placeholders = implode(',', array_fill(0, count($types), "'%s'"));
    $where = "WHERE type IN ({$placeholders})";
  }
  else {
    $where = '';
  }
  $connections = array();
  $result = db_query("SELECT * FROM {clients_connections}  {$where} ORDER BY name", $types);
  while ($connection = db_fetch_object($result)) {
    $connections[$connection->cid] = array(
      'name' => $connection->name,
      'type' => $connection->type,
      'endpoint' => $connection->endpoint,
    );
  }
  return $connections;
}