You are here

function hosting_client_platform_access_form_submit in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 client/hosting_client.module \hosting_client_platform_access_form_submit()
  2. 7.3 client/hosting_client.module \hosting_client_platform_access_form_submit()

Submit handler for the client platform access form.

1 string reference to 'hosting_client_platform_access_form_submit'
hosting_client_platform_access_form in client/hosting_client.module
Page callback for the client platform access form.

File

client/hosting_client.module, line 697

Code

function hosting_client_platform_access_form_submit($form, $form_state) {
  $clients = $form_state['values']['clients'];
  $new_client = isset($form_state['values']['new_client']) ? $form_state['values']['new_client'] : FALSE;
  $existing = $form['#parameters']['2']->clients;
  $platform = $form['#parameters']['2']->nid;

  // Remove the selected client(s).
  foreach ($clients as $cid => $remove) {
    if ($remove) {
      db_query("DELETE FROM {hosting_platform_client_access} WHERE pid = %d AND cid = %d", $platform, $cid);
    }
  }

  // Add the new client.
  if ($new_client) {
    $client = hosting_get_client($new_client);
    if ($client) {
      db_query("INSERT INTO {hosting_platform_client_access} (pid, cid) VALUES (%d, %d)", $platform, $client->nid);
    }
    else {
      $add_client = '';
      if (user_access('create client') || user_access('administer clients')) {
        $add_client = ' or ' . l('add a new client', 'node/add/client');
      }
      form_set_error('new_client', t('The client name (%client) was not recognized. Please try again', array(
        '%client' => $new_client,
      )) . $add_client . '.');
    }
  }
}