You are here

function fonts_com_get_domains_in_project in @font-your-face 7.2

Same name and namespace in other branches
  1. 6.2 modules/fonts_com/fonts_com.module \fonts_com_get_domains_in_project()
  2. 7 modules/fonts_com/fonts_com.module \fonts_com_get_domains_in_project()

Gets list of domains in a given project.

2 calls to fonts_com_get_domains_in_project()
fonts_com_project_info_form in modules/fonts_com/fonts_com.module
Returns project info form array.
fonts_com_save_domains_in_project in modules/fonts_com/api.inc
Saves list of domains in a given project.

File

modules/fonts_com/api.inc, line 240
API functions.

Code

function fonts_com_get_domains_in_project($project_id) {
  $domains = array();
  $path = '/rest/json/Domains/?wfspstart=0&wfsplimit=100&wfspid=' . $project_id;
  $response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
    'headers' => fonts_com_api_headers($path),
  ));
  if ($response->code == 200) {
    $data = json_decode($response->data);
    if ($data->Domains->TotalRecords > 0) {
      $domain = $data->Domains->Domain;
      $domains = fonts_com_unknown_to_array($domain);
    }

    // if
  }
  else {
    drupal_set_message(t('There was an error importing a project (@project) domain list from Fonts.com.', array(
      '@project' => $project_id,
    )), 'error');
    fontyourface_log('Invalid drupal_http_request response: @response', array(
      '@response' => print_r($response, TRUE),
    ));
  }

  // else
  return $domains;
}