Example #1
0
 public static function start()
 {
     // Create task
     $task = TasksModel::create();
     $task->user_id = $_SESSION['current']['username']['id'];
     $task->user_affected_id = $_SESSION['current']['username']['id'];
     $task->group_id = $_SESSION['current']['username']['group'];
     $task->type = TasksModel::TYPE_BACKUP;
     $task->title = 'Backup Data';
     $task->created_at = date(DATE_TIME);
     $task->estimate = 10 * 60;
     $task->status = TasksModel::STATUS_PROGRESS;
     $task->save();
     // Add services
     if ($_POST['services']) {
         foreach ($_POST['services'] as $serviceId) {
             $serviceId = (int) $serviceId;
             $taskService = TasksServicesModel::create(array('task_id' => $task->id, 'service_id' => $serviceId))->save();
         }
         $task->contains = json_encode(ServicesActionsModel::getActions($_POST['services']));
         $task->save();
     }
     \Util::notice(array('type' => 'success', 'text' => 'The backup process has started. Check the list below to review it\'s status.'));
     $task = new PushTask('/queue/backup/' . $task->id);
     $task->add();
 }
 /**
  * Push a raw payload onto the queue.
  *
  * @param  string  $payload
  * @param  string  $queue
  * @param  array   $options
  * @return mixed
  */
 public function pushRaw($payload, $queue = null, array $options = array())
 {
     if ($this->shouldEncrypt) {
         $payload = $this->crypt->encrypt($payload);
     }
     $task = new PushTask($this->url, array(self::PAYLOAD_REQ_PARAM_NAME => $payload), $options);
     return $task->add($this->getQueue($queue));
 }
 /**
  * {@inheritDoc}
  */
 public function pushMessage($queueName, $message)
 {
     $task = new PushTask($this->resolveEndpoint($queueName), compact('message'));
     $task->add($queueName);
 }
Example #4
0
 public function testPushTaskWithNameAndETA()
 {
     $req = self::buildBulkAddRequest();
     $add_req = $req->getAddRequest(0);
     $add_req->setTaskName('customTaskName');
     $add_req->setEtaUsec($add_req->getEtaUsec() + 5 * 1000000.0);
     $resp = new TaskQueueBulkAddResponse();
     $this->apiProxyMock->expectCall('taskqueue', 'BulkAdd', $req, $resp);
     $task = new PushTask('/someUrl', [], ['delay_seconds' => 5, 'name' => 'customTaskName']);
     $task_name = $task->add();
     $this->assertEquals('customTaskName', $task_name);
     $this->apiProxyMock->verify();
 }
Example #5
0
require_once 'google/appengine/api/users/User.php';
require_once 'google/appengine/api/users/UserService.php';
use google\appengine\api\taskqueue\PushTask;
use google\appengine\api\users\User;
use google\appengine\api\users\UserService;
$user = UserService::getCurrentUser();
$email = $user->getEmail();
?>
<html>
  <head><title>Send Site</title></head>
  <body>
    <p>Enter the a URL.
    <form method="POST">
      URL: <input type="text" size="50" name="url">
      <input
        type="submit"
        value="Send to <?php 
echo htmlentities($email, ENT_QUOTES);
?>
">
    </form>
    <?php 
if (isset($_POST['url'])) {
    $task = new PushTask('/sendpage', ['url' => $_POST['url'], 'email' => $email]);
    $task->add();
    echo "<b>Sending url!</b>";
}
?>
  </body>
</html>
Example #6
0
 public static function revert($taskId)
 {
     $task = new PushTask('/queue/add/' . $taskId . '/revert');
     $task->add();
     // Notification
     \Util::notice(array('type' => 'success', 'text' => 'Your cleaning process is now beeing reverted. Check the list below to see it\'s status.'));
     \Router::redirect('clean');
 }
Example #7
0
 public static function start()
 {
     // Create task
     $task = TasksModel::create();
     $task->user_id = $_SESSION['current']['username']['id'];
     $task->user_affected_id = $_SESSION['current']['username']['id'];
     $task->group_id = $_SESSION['current']['username']['group'];
     $task->type = TasksModel::TYPE_SHARE;
     $task->title = 'Share Data';
     $task->created_at = date(DATE_TIME);
     $task->estimate = 10 * 60;
     $task->save();
     // Add services to task
     if (isset($_SESSION['share']) && $_SESSION['share']['service']) {
         $serviceId = (int) $_SESSION['share']['service'];
         TasksServicesModel::create(array('task_id' => $task->id, 'service_id' => $serviceId))->save();
         $task->save();
     }
     // Create share
     $share = SharesModel::create();
     $share->task_id = $task->id;
     $share->user_id = $_SESSION['current']['username']['id'];
     $share->service_id = $_SESSION['share']['service'];
     $share->title = 'Share Data';
     $share->data = json_encode($_SESSION['share']['selectedData']);
     $share->link = sha1($task->user_id . time());
     $share->expires = 86400;
     $share->created_at = date(DATE_TIME);
     $share->status = SharesModel::STATUS_ACTIVE;
     $share->save();
     // Reset share
     unset($_SESSION['share']);
     \Util::notice(array('type' => 'success', 'text' => 'The sharing process has started. Check the list below to review it\'s status.'));
     $task = new PushTask('/queue/add/' . $task->id);
     $task->add();
 }