function hosting_add_task in Hostmaster (Aegir) 6
Helper function to generate new task node
22 calls to hosting_add_task()
- drush_hosting_task_validate in modules/
hosting/ task.hosting.inc - Validate hook for the hosting-task Drush command.
- hook_hosting_TASK_TYPE_task_rollback in modules/
hosting/ hosting.api.php - Perform actions when a task has failed and has been rolled back.
- hosting_migrate_platform_submit in modules/
hosting/ migrate/ hosting_migrate.batch.inc - Implements hook_submit().
- hosting_migrate_platform_submit_batch in modules/
hosting/ migrate/ hosting_migrate.batch.inc - Batch callback for platform migration submission.
- hosting_package_update_4 in modules/
hosting/ package/ hosting_package.install - Package languages are associated to package instances, not packages
File
- modules/
hosting/ task/ hosting_task.module, line 345 - Web server node type is defined here.
Code
function hosting_add_task($nid, $type, $args = null, $status = HOSTING_TASK_QUEUED) {
global $user;
$task = hosting_get_most_recent_task($nid, $type);
$node = db_fetch_object(db_query("SELECT nid, uid, title FROM {node} WHERE nid=%d", $nid));
if (!$task) {
$task = new stdClass();
}
$task->type = 'task';
# TODO: make this pretty
$task->title = t("!type !title", array(
'!type' => $type,
'!title' => $node->title,
));
$task->task_type = $type;
$task->rid = $node->nid;
/*
* fallback the owner of the task to the owner of the node we operate
* upon
*
* this is mostly for the signup form, which runs as the anonymous
* user, but for which the node is set to the right user
*/
$task->uid = $user->uid ? $user->uid : $node->uid;
$task->status = 1;
$task->task_status = $status;
if ($status == HOSTING_TASK_QUEUED) {
$task->revision = TRUE;
}
#arguments, such as which backup to restore.
if (is_array($args)) {
$task->task_args = $args;
}
node_save($task);
return $task;
}