This commit is contained in:
Yuri Kuznetsov
2024-01-24 10:44:24 +02:00
parent 2d7d8812fd
commit e4af67aa68
+20 -23
View File
@@ -27,20 +27,18 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
class SystemHelper extends \Espo\Core\Utils\System use Espo\Core\Utils\File\Manager;
use Espo\Core\Utils\File\Permission;
use Espo\Core\Utils\System;
class SystemHelper extends System
{ {
protected $config; protected $config;
protected $mainConfig; protected $mainConfig;
protected $apiPath; protected $apiPath;
protected $modRewriteUrl = '/'; protected $modRewriteUrl = '/';
protected $writableDir = 'data'; protected $writableDir = 'data';
protected $combineOperator = '&&'; protected $combineOperator = '&&';
protected $writableMap; protected $writableMap;
public function __construct() public function __construct()
@@ -53,19 +51,10 @@ class SystemHelper extends \Espo\Core\Utils\System
$this->apiPath = $this->config['apiPath']; $this->apiPath = $this->config['apiPath'];
$permission = new \Espo\Core\Utils\File\Permission(new \Espo\Core\Utils\File\Manager()); $permission = new Permission(new Manager());
$this->writableMap = $permission->getWritableMap(); $this->writableMap = $permission->getWritableMap();
} }
protected function getMainConfig($optionName, $returns = null)
{
if (isset($this->mainConfig[$optionName])) {
return $this->mainConfig[$optionName];
}
return $returns;
}
public function initWritable() public function initWritable()
{ {
if (is_writable($this->writableDir)) { if (is_writable($this->writableDir)) {
@@ -102,9 +91,7 @@ class SystemHelper extends \Espo\Core\Utils\System
$pageUrl .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; $pageUrl .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} }
$baseUrl = str_ireplace('/install/index.php', '', $pageUrl); return str_ireplace('/install/index.php', '', $pageUrl);
return $baseUrl;
} }
public function getApiPath() public function getApiPath()
@@ -209,12 +196,19 @@ class SystemHelper extends \Espo\Core\Utils\System
* @param bool $isFile * @param bool $isFile
* @return string * @return string
*/ */
public function getPermissionCommands($path, $permissions = ['644', '755'], $isSudo = false, $isFile = null, $changeOwner = true, $isCd = true) public function getPermissionCommands(
{ $path,
$permissions = ['644', '755'],
$isSudo = false,
$isFile = null,
$changeOwner = true,
$isCd = true
) {
if (is_string($path)) { if (is_string($path)) {
$path = array_fill(0, 2, $path); $path = array_fill(0, 2, $path);
} }
list($chmodPath, $chownPath) = $path;
[$chmodPath, $chownPath] = $path;
$commands = array(); $commands = array();
@@ -226,11 +220,13 @@ class SystemHelper extends \Espo\Core\Utils\System
$pathList = []; $pathList = [];
$recursivePathList = []; $recursivePathList = [];
foreach ($chmodPath as $pathItem) { foreach ($chmodPath as $pathItem) {
if (isset($this->writableMap[$pathItem]) && !$this->writableMap[$pathItem]['recursive']) { if (isset($this->writableMap[$pathItem]) && !$this->writableMap[$pathItem]['recursive']) {
$pathList[] = $pathItem; $pathList[] = $pathItem;
continue; continue;
} }
$recursivePathList[] = $pathItem; $recursivePathList[] = $pathItem;
} }
@@ -248,6 +244,7 @@ class SystemHelper extends \Espo\Core\Utils\System
$commands[] = $chown; $commands[] = $chown;
} }
} }
return implode(' ' . $this->combineOperator . ' ', $commands).';'; return implode(' ' . $this->combineOperator . ' ', $commands).';';
} }