function hosting_task_insert in Hosting 7.4
Same name and namespace in other branches
- 5 task/hosting_task.module \hosting_task_insert()
- 6.2 task/hosting_task.module \hosting_task_insert()
- 7.3 task/hosting_task.module \hosting_task_insert()
Implements hook_insert().
1 call to hosting_task_insert()
- hosting_task_update in task/
hosting_task.module - Implements hook_update().
File
- task/
hosting_task.module, line 945 - Web server node type is defined here.
Code
function hosting_task_insert($node) {
$node->executed = isset($node->executed) ? $node->executed : NULL;
$node->delta = isset($node->delta) ? $node->delta : NULL;
$id = db_insert('hosting_task')
->fields(array(
'vid' => $node->vid,
'nid' => $node->nid,
'task_type' => $node->task_type,
'task_status' => $node->task_status,
'rid' => $node->rid,
'executed' => $node->executed,
'delta' => $node->delta,
))
->execute();
// For new delete tasks, save the hosting_name into a task argument.
if ($node->task_type == 'delete' && !empty($node->ref_context)) {
$node->task_args['hosting_context'] = $node->ref_context;
}
if (isset($node->task_args) && is_array($node->task_args)) {
foreach ($node->task_args as $key => $value) {
$id = db_insert('hosting_task_arguments')
->fields(array(
'vid' => $node->vid,
'nid' => $node->nid,
'name' => $key,
'value' => $value,
))
->execute();
}
}
// If this is a delete task that was just inserted, delete the context so
// another entity can claim the namespace immediately.
if ($node->task_type == 'delete' && !empty($node->ref_context)) {
hosting_context_delete($node->rid);
// Add a new permanent path alias for the node.
$path = array(
'source' => "node/{$node->rid}",
'alias' => "hosting/c/{$node->ref_context}/{$node->rid}",
);
path_save($path);
}
module_invoke_all('hosting_task_update_status', $node, $node->task_status);
hosting_task_set_title($node);
}