You are here

function hosting_task_fetch_tasks in Hostmaster (Aegir) 6

1 call to hosting_task_fetch_tasks()
hosting_task_table in modules/hosting/task/hosting_task.module
A concise table listing of the tasks affecting this node

File

modules/hosting/task/hosting_task.module, line 1124
Web server node type is defined here.

Code

function hosting_task_fetch_tasks($rid) {
  $node = node_load($rid);
  $tasks = hosting_available_tasks($node->type);
  $result = db_query("SELECT n.nid, t.task_type, t.task_status FROM {node} n LEFT JOIN {hosting_task} t ON n.vid=t.vid\n    WHERE n.type = 'task' AND t.rid = %d\n    ORDER BY t.task_status ASC, n.changed DESC", $rid);
  while ($obj = db_fetch_object($result)) {
    $return[$obj->task_type] = array(
      'nid' => $obj->nid,
      'task_status' => $obj->task_status,
      'exists' => TRUE,
    );
  }
  $tasks = hosting_available_tasks($node->type);
  ksort($tasks);
  foreach ($tasks as $type => $hook_task) {
    if (!isset($return[$type])) {
      $return[$type] = array();
    }
    $access_callback = !empty($hook_task['access callback']) ? $hook_task['access callback'] : 'hosting_task_menu_access';
    $task = array();
    $task = array_merge($return[$type], $hook_task);
    $allowed = isset($task['exists']) && !in_array($task['task_status'], array(
      HOSTING_TASK_QUEUED,
      HOSTING_TASK_PROCESSING,
    )) || !isset($task['exists']);
    if ($allowed && !$task['hidden'] && $access_callback($node, $type)) {
      $task['task_permitted'] = TRUE;
    }
    $task['class'] = hosting_task_status_class($task['task_status']);
    $return[$type] = $task;
  }
  return $return;
}