12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- class GetFilesToResumeAction implements IAction {
- public function execute() {
- $projectId = $_POST['project_id'] ?? $_GET['project_id'];
- $userId = $_SESSION['user_id'];
- $startOffset = $_POST['start'] ?? $_GET['start'] ?? 0;
- $limit = $_POST['limit'] ?? $_GET['limit'] ?? 0;
- $limitString = "";
- if ($limit > 0) {
- $limitString = " LIMIT " . $limit . " OFFSET " . $startOffset;
- }
- $sql = "SELECT rowid as upload_id, filepath FROM upload_logs WHERE project_id = :project_id AND user_id = :user_id".$limitString.";";
- $db = SqliteDatabase::getSingleton();
- $preparedQuery = $db->prepare($sql);
- $preparedQuery->bindValue(':project_id', $projectId);
- $preparedQuery->bindValue(':user_id', $userId);
- $result = $preparedQuery->execute();
- $missingFiles = array();
- while($row = $result->fetchArray(SQLITE3_ASSOC)) {
- $missingFiles[] = $row;
- }
- $sql = "SELECT count(*) AS count FROM upload_logs WHERE project_id = :project_id AND user_id = :user_id;";
- $preparedQuery = $db->prepare($sql);
- $preparedQuery->bindValue(':project_id', $projectId);
- $preparedQuery->bindValue(':user_id', $userId);
- $result = $preparedQuery->execute();
- $remainingFilesResult = $result->fetchArray(SQLITE3_ASSOC);
- $remainingFiles = $remainingFilesResult["count"];
- return array("files" => $missingFiles, "total" => $remainingFiles);
- }
- }
|