Duffer Derek
<?php
namespace App\Repository\Transfer;
use App\Repository\General\Async;
use App\Repository\General\DB;
use PDO;
/**
* Created by IntelliJ IDEA.
* User: jis
* Date: 1/4/17
* Time: 2:59 PM
*/
class TransferRepo
{
public function startTransfer()
{
$user = 77126906;
// check a process is running or not? make sure only one process running
if ($this->isProcessRunning($user)) {
echo "There is a running process. Please wait!";
return;
}
// start the process async and return a message
Async::callAsync("copy-async/start-transfer?user=" . $user);
echo "The transfer process started. This will take some time to finish. Will get a mail notification when finished.";
}
public function isProcessRunning($user)
{
//todo remove this
$sql = "select `id` from `transfer_process` where `user`=:user and `end_time` IS NULL";
$STH = DB::prepare($sql);
$STH->execute(array(
'user' => $user,
));
$result = $STH->fetchAll(PDO::FETCH_ASSOC);
if (!$result || count($result) < 1) {
return false; // no running process
}
return true;
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists