You are here

function hosting_task_load in Hosting 7.3

Same name and namespace in other branches
  1. 5 task/hosting_task.module \hosting_task_load()
  2. 6.2 task/hosting_task.module \hosting_task_load()
  3. 7.4 task/hosting_task.module \hosting_task_load()

Implements hook_load().

File

task/hosting_task.module, line 1045
Web server node type is defined here.

Code

function hosting_task_load($nodes) {

  // Invoke hook_hosting_tasks().
  $types = module_invoke_all('hosting_tasks');

  // Invoke hook_hosting_tasks_alter().
  drupal_alter('hosting_tasks', $types);
  foreach ($nodes as $nid => &$node) {
    $additions = db_query('SELECT task_type, executed, delta, rid, task_status, r.type as ref_type FROM {hosting_task} t LEFT JOIN {node} r ON t.rid = r.nid WHERE t.vid = :vid', array(
      ':vid' => $node->vid,
    ))
      ->fetch();
    $result = db_query("SELECT name, value FROM {hosting_task_arguments} WHERE vid = :vid", array(
      ':vid' => $node->vid,
    ));
    if ($result) {
      $additions->task_args = array();
      while ($arg = $result
        ->fetch()) {
        $additions->task_args[$arg->name] = $arg->value;
      }
    }
    foreach ($additions as $property => &$value) {
      $node->{$property} = is_numeric($value) ? (int) $value : $value;
    }

    // Load task_command property from hook_hosting_tasks data.
    $node->task_command = $types[$node->ref_type][$node->task_type]['command'];
  }
}