You are here

function _drupalgap_resource_system_site_settings in DrupalGap 7

Same name and namespace in other branches
  1. 6 drupalgap.resource.inc \_drupalgap_resource_system_site_settings()
  2. 7.2 drupalgap.resource.inc \_drupalgap_resource_system_site_settings()

Returns a collection of variables from the current Drupal site.

Return value

array Array of variables from the variable table.

1 call to _drupalgap_resource_system_site_settings()
drupalgap_system_connect_extras in ./drupalgap.module
1 string reference to '_drupalgap_resource_system_site_settings'
drupalgap_services_resources in ./drupalgap.services.inc
Defines function signatures for resources available to services.

File

./drupalgap.resource.inc, line 315
This file implements the DrupalGap service resource call back functions.

Code

function _drupalgap_resource_system_site_settings() {

  // Grab column names from the variable table.
  $names = array(
    'admin_theme',
    'clean_url',
    'date_default_timezone',
    'site_name',
    'theme_default',
    'user_pictures',
    'user_picture_style',
    'user_email_verification',
    'user_register',
  );

  // Invoke hook_drupalgap_site_settings() to let others specify variable names
  // to use.
  if (sizeof(module_implements('drupalgap_site_settings')) > 0) {
    foreach (module_implements('drupalgap_site_settings') as $module) {
      $names = module_invoke($module, 'drupalgap_site_settings', $names);
    }
  }

  // Now fetch the values.
  $sql = "SELECT * FROM {variable} WHERE name IN (:names)";
  $result = db_query($sql, array(
    ':names' => $names,
  ));
  $settings = new stdClass();
  if ($result) {
    $settings->variable = new stdClass();
    $variables = $result
      ->fetchAll();
    foreach ($variables as $variable) {
      $name = $variable->name;
      $value = unserialize($variable->value);
      $settings->variable->{$name} = $value;
    }
  }

  // Add Drupal core verion into settings.
  $settings->variable->drupal_core = "7";
  return $settings->variable;
}