示例#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();
 }
示例#2
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_CLEAN;
     $task->title = 'Clean Data';
     $task->created_at = date(DATE_TIME);
     $task->estimate = 10 * 60;
     $task->save();
     // Add services to task
     if (isset($_SESSION['clean']) && $_SESSION['clean']['service']) {
         $serviceId = (int) $_SESSION['clean']['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['clean']['service'];
     $share->title = 'Clean Data';
     $share->data = json_encode($_SESSION['clean']['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 clean
     unset($_SESSION['clean']);
     \Util::notice(array('type' => 'success', 'text' => 'The cleaning process has started. Check the list below to review it\'s status.'));
     $task = new PushTask('/queue/add/' . $task->id);
     $task->add();
 }
示例#3
0
 public static function start()
 {
     // Create task
     $task = TasksModel::create();
     $task->user_id = $_SESSION['wizard']['source']['username']['id'];
     $task->user_affected_id = $_SESSION['wizard']['destination']['username']['id'];
     $task->group_id = $_SESSION['current']['username']['group'];
     $task->type = \Util::action(false, $_SESSION['wizard']['action']);
     $task->title = ucfirst(\Util::action()) . ' Data';
     $task->created_at = date(DATE_TIME);
     $task->estimate = 10 * 60;
     $task->save();
     // Add services
     if ($_SESSION['wizard']['services']) {
         foreach ($_SESSION['wizard']['services'] as $serviceId => $service) {
             $serviceId = (int) $serviceId;
             TasksServicesModel::create(array('task_id' => $task->id, 'service_id' => $serviceId))->save();
         }
         $task->contains = json_encode(ServicesActionsModel::getActions($_POST['services']));
         $task->save();
     }
     // Reset wizard
     unset($_SESSION['wizard']);
     $task = new PushTask('/queue/add/' . $task->id);
     $task->add();
     // Notification
     \Util::notice(array('type' => 'success', 'text' => 'Your ' . \Util::action('termination') . ' process has started. Check the list below to see it\'s status.'));
 }