You are here

function fonts_com_save_project in @font-your-face 7.2

Update.

1 call to fonts_com_save_project()
fonts_com_project_edit_form_submit in modules/fonts_com/fonts_com.module
Saves changes to project.

File

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

Code

function fonts_com_save_project(&$project) {
  $path = '/rest/json/Projects/';
  $method = 'POST';
  if (isset($project->ProjectKey)) {
    $path .= '?wfspid=' . $project->ProjectKey;
    $method = 'PUT';
  }

  // if
  $response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
    'headers' => fonts_com_api_headers($path),
    'method' => $method,
    'data' => 'wfsproject_name=' . $project->ProjectName,
  ));
  if ($response->code == 200) {
    $data = json_decode($response->data);
    $projects = fonts_com_unknown_to_array($data->Projects->Project);
    foreach ($projects as $response_project) {
      if ($response_project->ProjectName == $project->ProjectName) {
        $project->ProjectKey = $response_project->ProjectKey;
      }

      // if
    }

    // foreach
    return TRUE;
  }
  else {
    drupal_set_message(t('There was an error saving project to Fonts.com.'), 'error');
    fontyourface_log('Invalid drupal_http_request response: @response', array(
      '@response' => print_r($response, TRUE),
    ));
  }

  // else
  return FALSE;
}