Skip to content

Commit

Permalink
Merge pull request #67 from Leantime/hotfixes-2.0.3
Browse files Browse the repository at this point in the history
Hotfixes 2.0.3
  • Loading branch information
marcelfolaron authored Dec 6, 2019
2 parents e549188 + 641b111 commit 61cea25
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 33 deletions.
2 changes: 1 addition & 1 deletion config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class settings {
*/
private $debug = '1';

public $appVersion = "2.0.2";
public $appVersion = "2.0.3";

public $dbVersion = "2.0";

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leantime",
"version": "2.0.2",
"version": "2.0.3",
"description": "Project Management Tools",
"main": "gruntfile.js",
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions public/userfiles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
86 changes: 57 additions & 29 deletions src/core/class.fileupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class fileupload
*/
public $real_name='';

/**
* @access public
* @var array parts of the path
*/
public $path_parts=array();

/**
* @access public
* @var object configuration object
Expand Down Expand Up @@ -99,21 +105,40 @@ function __construct()

}

return false;

}

/**
* @return string
* @throws \Exception
*/
public function getAbsolutePath()
{
$path = realpath(__DIR__."/../../".$this->path);
if($path === false){
throw new Exception("Path not valid");
throw new \Exception("Path not valid");
}else{
return $path;
}
}

/**
* @return string
* @throws \Exception
*/
public function getPublicFilesPath()
{
$path = realpath(__DIR__."/../../public/userfiles");
if($path === false){
throw new \Exception("Path not valid");
}else{
return $path;
}
}




/**
* initFile - init variables of file
Expand Down Expand Up @@ -180,15 +205,12 @@ public function renameFile($name)
* upload - move file from tmp-folder to S3
*
* @access public
* @param bool $resize
* @param int $w
* @param int $h
* @return boolean
*/
public function upload()
{

if($this->config->useS3 === true) {
if($this->config->useS3 == true) {
//S3 upload
return $this->uplodToS3();
}else{
Expand All @@ -202,22 +224,42 @@ public function upload()
public function uploadPublic()
{

try {
// Upload data.
$file = fopen($this->file_tmp_name, "rb");
if($this->config->useS3 == true) {

$this->s3Client->upload($this->config->s3Bucket, $this->config->s3FolderName."/".$this->file_name, $file, "public-read");
$url = $this->s3Client->getObjectUrl($this->config->s3Bucket, $this->config->s3FolderName."/".$this->file_name);
try {
// Upload data.
$file = fopen($this->file_tmp_name, "rb");

return $url;
$this->s3Client->upload($this->config->s3Bucket, $this->config->s3FolderName."/".$this->file_name, $file, "public-read");
$url = $this->s3Client->getObjectUrl($this->config->s3Bucket, $this->config->s3FolderName."/".$this->file_name);

} catch (S3Exception $e) {
return $url;

error_reporting($e->getMessage());
return false;
} catch (S3Exception $e) {

error_reporting($e->getMessage());
return false;

}

}else{

try {

if (move_uploaded_file($this->file_tmp_name, $this->getPublicFilesPath() . "/" . $this->file_name)) {
return "/userfiles/".$this->file_name;
}

}catch(\Exception $e){

error_reporting($e->getMessage());
return false;
}

}

return false;

}

private function uplodToS3()
Expand Down Expand Up @@ -248,7 +290,7 @@ private function uploadLocal() {
return true;
}

}catch(Exception $e){
}catch(\Exception $e){

error_reporting($e->getMessage());
return false;
Expand All @@ -258,20 +300,6 @@ private function uploadLocal() {

}


/**
* deleteFile - delete file from server
*
* @access public
* @param $file
* @return boolean
*/
public function deleteFile($file)
{

//TODO: Write a method to remove file from S3
return true;
}

}

2 changes: 1 addition & 1 deletion src/domain/files/repositories/class.files.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function deleteFile($id)

}

public function upload($file,$module,$moduleId,$resize=false,$w=200,$h=200)
public function upload($file,$module,$moduleId)
{

$upload = new core\fileupload();
Expand Down
1 change: 0 additions & 1 deletion src/domain/setting/js/settingRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ leantime.settingRepository = (function () {
}
).success(
function (resp) {
console.log(resp);
jQuery('#save-logo').removeClass('running');
location.reload();
}
Expand Down

0 comments on commit 61cea25

Please sign in to comment.