function _hosting_client_site_default in Hosting 7.3
Same name and namespace in other branches
- 6.2 client/hosting_client.module \_hosting_client_site_default()
- 7.4 client/hosting_client.module \_hosting_client_site_default()
Get the default value of the client field for a site node.
Parameters
object $node: The site to the the clients for.
Return value
string|null The client name.
1 call to _hosting_client_site_default()
- hosting_client_form_site_node_form_alter in client/
hosting_client.module - Implements hook_form_FORM_ID_alter().
File
- client/
hosting_client.module, line 903
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 (isset($node->client) && $node->client == $client_id || !$current_client_id) {
$current_client_id = $client_id;
}
}
}
if (!$current_client_id) {
$current_client_id = HOSTING_DEFAULT_CLIENT;
}
// Allow admins to override.
if (isset($node->client) && $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 = isset($node->client) ? $node->client : NULL;
}
return $client->title;
}