You are here

function progress_set_progress in Progress 7

Same name and namespace in other branches
  1. 8 progress.module \progress_set_progress()
  2. 6 progress.module \progress_set_progress()

Set progress

Parameters

string $name: Name of progress

string $message: Message for progress

double $progress: Current progress (0 - 1)

Return value

mixed Result from db execute()

1 call to progress_set_progress()
progress_set_intervalled_progress in ./progress.module
Set intervalled progress Use when you don't need to spam the progress table every time.

File

./progress.module, line 48
Progress framework for keeping track of progresses

Code

function progress_set_progress($name, $message, $progress) {
  $current = microtime(TRUE);
  $result = db_update('progress')
    ->fields(array(
    'progress' => $progress,
    'message' => $message,
    'current_stamp' => $current,
  ))
    ->condition('name', $name)
    ->execute();
  if (module_exists('nodejs')) {
    $start_stamp = db_query("SELECT start_stamp FROM {progress} WHERE name = :name", array(
      ':name' => $name,
    ))
      ->fetchField();
    $object = (object) array(
      'name' => $name,
      'progress' => $progress,
      'message' => $message,
      'current_stamp' => $current,
      'start_stamp' => $start_stamp,
    );
    $message = (object) array(
      'channel' => 'progress',
      'data' => (object) array(
        'action' => 'setProgress',
        'progress' => $object,
        'timestamp' => microtime(TRUE),
      ),
      'callback' => 'nodejsProgress',
    );
    drupal_alter('progress_message', $message);
    nodejs_send_content_channel_message($message);
  }
  return $result;
}