function hosting_client_platform_access_form_submit in Hosting 7.4
Same name and namespace in other branches
- 6.2 client/hosting_client.module \hosting_client_platform_access_form_submit()
- 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 856
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;
$platform = $form_state['build_info']['args'][0];
$existing = isset($platform->clients) ? $platform->clients : array();
// Remove the selected client(s).
foreach ($clients as $cid => $remove) {
if ($remove) {
db_delete('hosting_platform_client_access')
->condition('pid', $platform->nid)
->condition('cid', $cid)
->execute();
}
}
// Add the new client.
if ($new_client) {
$client = hosting_get_client($new_client);
if ($client) {
db_insert('hosting_platform_client_access')
->fields(array(
'pid' => $platform->nid,
'cid' => $client->nid,
))
->execute();
}
else {
$add_client = '';
if (user_access('create client') || user_access('administer clients')) {
$add_client = ' ' . t('or') . '' . l(t('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 . '.');
}
}
}