mirror of
https://github.com/humhub/humhub.git
synced 2025-01-18 22:58:06 +01:00
Minor StorageManager cleanups
This commit is contained in:
parent
d06bf8e75b
commit
6e167a0b4f
@ -34,7 +34,7 @@ class StorageManager extends \yii\base\Component implements StorageManagerInterf
|
||||
/**
|
||||
* @var integer file mode
|
||||
*/
|
||||
public $chmod = 0744;
|
||||
public $fileMode = 0744;
|
||||
|
||||
/**
|
||||
* @var File
|
||||
@ -56,25 +56,6 @@ class StorageManager extends \yii\base\Component implements StorageManagerInterf
|
||||
return $this->getPath() . DIRECTORY_SEPARATOR . $variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path where the files of this file are located
|
||||
*
|
||||
* @return string the path
|
||||
*/
|
||||
protected function getPath()
|
||||
{
|
||||
if ($this->file->guid == '') {
|
||||
throw new \Exception('File GUID empty!');
|
||||
}
|
||||
|
||||
$path = Yii::getAlias($this->path) . DIRECTORY_SEPARATOR . $this->file->guid;
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or overwrites the file by given UploadedFile in store
|
||||
*
|
||||
@ -85,7 +66,7 @@ class StorageManager extends \yii\base\Component implements StorageManagerInterf
|
||||
{
|
||||
if (is_uploaded_file($file->tempName)) {
|
||||
move_uploaded_file($file->tempName, $this->get($variant));
|
||||
@chmod($this->get($variant), 0744);
|
||||
@chmod($this->get($variant), $this->fileMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,7 +87,7 @@ class StorageManager extends \yii\base\Component implements StorageManagerInterf
|
||||
public function setContent($content, $variant = null)
|
||||
{
|
||||
file_put_contents($this->get($variant), $this->content);
|
||||
@chmod($this->get($variant), $this->chmod);
|
||||
@chmod($this->get($variant), $this->fileMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,4 +123,23 @@ class StorageManager extends \yii\base\Component implements StorageManagerInterf
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path where the files of this file are located
|
||||
*
|
||||
* @return string the path
|
||||
*/
|
||||
protected function getPath()
|
||||
{
|
||||
if ($this->file->guid == '') {
|
||||
throw new \Exception('File GUID empty!');
|
||||
}
|
||||
|
||||
$path = Yii::getAlias($this->path) . DIRECTORY_SEPARATOR . $this->file->guid;
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\file\components;
|
||||
|
Loading…
x
Reference in New Issue
Block a user