You are here

function fonts_com_save_domains_in_project in @font-your-face 7.2

Saves list of domains in a given project.

1 call to fonts_com_save_domains_in_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 274
API functions.

Code

function fonts_com_save_domains_in_project($project_id, $new_domains) {
  $old_domains = array();
  $domain_to_index = array();
  $old_domain_objects = fonts_com_get_domains_in_project($project_id);
  foreach ($old_domain_objects as $index => $old_domain_object) {
    $domain_to_index[$old_domain_object->DomainName] = $index;
    $old_domains[] = $old_domain_object->DomainName;
  }

  // foreach
  $add_domains = array_diff($new_domains, $old_domains);
  $delete_domains = array_diff($old_domains, $new_domains);
  foreach ($delete_domains as $delete_domain) {
    $delete_domain_object = $old_domain_objects[$domain_to_index[$delete_domain]];
    fonts_com_delete_domain($project_id, $delete_domain_object->DomainID);
  }

  // foreach
  foreach ($add_domains as $add_domain) {
    fonts_com_add_domain($project_id, $add_domain);
  }

  // foreach
  fonts_com_publish();
}