function hosting_import_site in Hosting 6.2
Same name and namespace in other branches
- 5 site/hosting_site.module \hosting_import_site()
Helper function to generate update a site node during import.
Parameters
$site_id: The node ID of the existing site node to update.
$data: An associative array of data to add to the site node. Keys should correspond to properties on the node object to overwrite.
$platform: The node ID of the platform that the site is deployed on.
1 call to hosting_import_site()
File
- site/
hosting_site.module, line 524
Code
function hosting_import_site($site_id, $data, $platform) {
global $user;
$client = node_load(HOSTING_DEFAULT_CLIENT);
if ($data['client_name']) {
$client = hosting_import_client($data['client_name']);
}
$site = node_load($site_id);
$site->nid = $site_id;
$site->uid = $client->uid;
$site->status = 1;
$site->site_status = 1;
$site->platform = $platform;
$site->no_verify = TRUE;
$site->verified = time();
$site->client = $client->nid ? $client->nid : HOSTING_DEFAULT_CLIENT;
$site->cron_key = $data['cron_key'] ? $data['cron_key'] : '';
$site->aliases = $data['aliases'] ? $data['aliases'] : array();
$site->db_server = $site->db_server ? $site->db_server : HOSTING_DEFAULT_DB_SERVER;
$site->site_language = $data['language'] ? $data['language'] : 'en';
// Drupal 6 introduced a language field on nodes
unset($data['language']);
$profile = hosting_package_instance_load(array(
'i.rid' => $platform,
'p.short_name' => $data['profile'],
));
if (!$profile) {
$profile = hosting_package_instance_load(array(
'i.rid' => $platform,
'p.short_name' => 'default',
));
}
$site->profile = $profile->package_id;
// cast site object to array, will be using various array_* functions on the data.
$site = (array) $site;
// Protect the fields already in the site object.
foreach (array_keys($site) as $key) {
unset($data[$key]);
}
// Load all the original node fields.
$site = array_merge((array) node_load($site_id), $site);
// Map the imported fields onto the node object.
$site = array_merge($site, $data);
// Cast back to object.
$site = (object) $site;
node_save($site);
}