Fix pulling attachments, file checking
This commit is contained in:
parent
027ff8f029
commit
3cdcc411a4
@ -64,7 +64,7 @@ class UserContext {
|
||||
$userContext = new UserContext();
|
||||
$userContext->id = $dataRow['id'];
|
||||
$userContext->username = $dataRow['user'];
|
||||
$userContext->admin = $dataRow['isadmin'];
|
||||
$userContext->admin = $dataRow['isadmin'] === '1';
|
||||
$userContext->name = $dataRow['name'];
|
||||
$userContext->email = $dataRow['email'];
|
||||
$userContext->signature = $dataRow['signature'];
|
||||
|
@ -33,7 +33,7 @@ class UserContextBuilder {
|
||||
throw new InvalidAuthenticationTokenException();
|
||||
}
|
||||
|
||||
return $this->fromDataRow($userRow);
|
||||
return UserContext::fromDataRow($userRow);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,6 +42,10 @@ class Ticket {
|
||||
$attachments = explode(',', $row['attachments']);
|
||||
$attachmentArray = array();
|
||||
foreach ($attachments as $attachment) {
|
||||
if (trim($attachment) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attachmentRow = explode('#', $attachment);
|
||||
$attachmentModel = new Attachment();
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace DataAccess\Files;
|
||||
|
||||
|
||||
use BusinessLogic\Exceptions\ApiFriendlyException;
|
||||
|
||||
class FileReader {
|
||||
/**
|
||||
* @param $name string - The file name (including extension)
|
||||
@ -13,6 +15,11 @@ class FileReader {
|
||||
function readFromFile($name, $folder) {
|
||||
// __DIR__ === '/{ROOT}/api/DataAccess/Files
|
||||
$location = __DIR__ . "/../../../{$folder}/{$name}";
|
||||
|
||||
if (!file_exists($location)) {
|
||||
throw new ApiFriendlyException("The file '{$name}' does not exist on the server", "File Not Found", 404);
|
||||
}
|
||||
|
||||
$fileContents = file_get_contents($location);
|
||||
|
||||
if ($fileContents === false) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user