function _hosting_client_site_default in Hosting 6.2
Same name and namespace in other branches
- 7.4 client/hosting_client.module \_hosting_client_site_default()
- 7.3 client/hosting_client.module \_hosting_client_site_default()
Get the default value of the client field for a site node.
Parameters
$node: The site to the the clients for.
1 call to _hosting_client_site_default()
- hosting_site_form in site/
hosting_site.form.inc - Implements hook_form().
File
- client/
hosting_client.module, line 733
Code
function _hosting_client_site_default($node) {
# find the right client
global $user;
$current_client_id = 0;
if ($user->uid) {
$client_ids = hosting_get_client_from_user($user->uid);
$clients = array();
foreach ($client_ids as $client_id => $client_permissions) {
$client_id = $client_id ? $client_id : HOSTING_DEFAULT_CLIENT;
$client = node_load($client_id);
$clients[$client->title] = $client->title;
if ($node->client == $client_id || !$current_client_id) {
$current_client_id = $client_id;
}
}
if (!$current_client_id && !user_access('administer clients')) {
form_set_error('client', t('Your user is not associated with any clients so you are not allowed to create new sites'));
}
}
if (!$current_client_id) {
$current_client_id = HOSTING_DEFAULT_CLIENT;
}
// allow admins to override
if ($node->client && user_access('administer clients')) {
$current_client_id = $node->client;
}
$client = node_load($current_client_id);
if (!$client) {
# we give up, couldn't find a client, we're probably in a preview so
# just use the node client
$client = new stdClass();
$client->title = $node->client;
}
return $client->title;
}