You are here

function hosting_client_user_form_submit in Hosting 7.4

Same name and namespace in other branches
  1. 5 client/hosting_client.access.inc \hosting_client_user_form_submit()
  2. 6.2 client/hosting_client.access.inc \hosting_client_user_form_submit()
  3. 7.3 client/hosting_client.access.inc \hosting_client_user_form_submit()

Save the values submitted when editing or adding a user.

See also

hosting_client_user()

2 calls to hosting_client_user_form_submit()
HostingServerTestCase::testServer in server/hosting_server.test
hosting_client_user_presave in client/hosting_client.access.inc
Implements hook_user_presave().

File

client/hosting_client.access.inc, line 183
Control client node access.

Code

function hosting_client_user_form_submit($edit, $user) {
  if (array_key_exists('clients', $edit)) {
    foreach ($edit['clients'] as $client) {
      $query = db_delete('hosting_client_user')
        ->condition('user', $user->uid)
        ->condition('client', $client)
        ->execute();
    }
  }
  if (array_key_exists('hosting_client', $edit) && $edit['hosting_client']) {
    $client = hosting_get_client($edit['hosting_client']);
    $query = $id = db_insert('hosting_client_user')
      ->fields(array(
      'client' => $client->nid,
      'user' => $user->uid,
      'contact_type' => '',
    ))
      ->execute();
  }
}