You are here

function ldap_servers_features_export_render in LDAP integration 6

Implementation of hook_features_export_render. [component hook]

Creates code to export ldapauth DB tabel server records.

Parameters

string $module_name:

array $data:

array $export:

Return value

array

File

./ldapauth.features.inc, line 65
Feature related functions.

Code

function ldap_servers_features_export_render($module, $data, $export) {
  module_load_include('inc', 'ldapauth', 'includes/ldap.core');
  $code = array();
  $code[] = '  $servers = array();';

  // If this is an override check, export all current servers
  if (is_null($export)) {
    $servers = ldapauth_server_load_all(TRUE);
    foreach ($servers as $server) {
      unset($server->sid);
      $server = (array) $server;
      ksort($server);

      // Sort because updated tables don't match, new tables
      $code[] = "  \$servers['{$server['machine_name']}'] = " . features_var_export($server, '  ') . ";";
    }
  }
  else {
    foreach ($data as $name) {
      $server = ldapauth_server_load($name);
      unset($server->sid);
      $server = (array) $server;
      ksort($server);
      $code[] = "  \$servers['{$name}'] = " . features_var_export($server, '  ') . ";";
    }
  }
  $code[] = '  return $servers;';
  $code = implode("\n", $code);
  return array(
    'default_ldap_servers' => $code,
  );
}