function hosting_clone_post_hosting_clone_task in Hosting 6.2
Same name and namespace in other branches
- 7.4 clone/hosting_clone.drush.inc \hosting_clone_post_hosting_clone_task()
- 7.3 clone/hosting_clone.drush.inc \hosting_clone_post_hosting_clone_task()
File
- clone/
hosting_clone.drush.inc, line 35 - Drush include for the site cloning module.
Code
function hosting_clone_post_hosting_clone_task($task, $data) {
if ($task->ref->type == 'site') {
$target = $task->task_args['target_platform'];
$clone = new stdClass();
# copy some of the settings of the cloned site ($task->ref) to $clone
foreach (array(
'type',
'status',
'uid',
'comment',
'promote',
'moderate',
'sticky',
'name',
'format',
'client',
'db_server',
'profile',
'site_status',
'site_language',
) as $field) {
$clone->{$field} = $task->ref->{$field};
}
$clone->title = strtolower(trim($task->task_args['new_uri']));
$clone->hosting_name = $clone->title;
$clone->platform = $target;
$clone->import = 1;
# make sure the site doesn't reinstall...
$clone->verified = 0;
# ... and it does verify
$clone->aliases = isset($task->task_args['aliases']) ? $task->task_args['aliases'] : array();
$clone->redirection = isset($task->task_args['redirection']) ? $task->task_args['redirection'] : FALSE;
if ($clone->db_server != $task->task_args['new_db_server']) {
$clone->db_server = $task->task_args['new_db_server'];
}
$profile = hosting_package_instance_load(array(
'i.rid' => $target,
'p.short_name' => $data['context']['profile'],
));
if ($profile) {
$clone->profile = $profile->package_id;
}
node_save($clone);
// Record the backup created during clone.
$task->task_args['description'] = t('Pre-clone backup');
hosting_site_post_hosting_backup_task($task, $data);
}
}