mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
installer changes and fileManager impovements
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -291,6 +291,36 @@ class Manager
|
||||
return $fullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new dir
|
||||
*
|
||||
* @param string | array $path
|
||||
* @param int $permission - ex. 0755
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $permission = null)
|
||||
{
|
||||
$fullPath = $this->concatPaths($path);
|
||||
|
||||
if (file_exists($fullPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isset($permission)) {
|
||||
$defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();
|
||||
$permission = (string) $defaultPermissions['dir'];
|
||||
$permission = base_convert($permission, 8, 10);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = mkdir($fullPath, $permission, true);
|
||||
} catch (\Exception $e) {
|
||||
$GLOBALS['log']->critical('Permission denied: unable to generate a folder on the server - '.$fullPath);
|
||||
}
|
||||
|
||||
return isset($result) ? $result : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new file if not exists with all folders in the path.
|
||||
@@ -310,10 +340,10 @@ class Manager
|
||||
return true;
|
||||
}
|
||||
|
||||
$pathParts= pathinfo($filePath);
|
||||
$pathParts = pathinfo($filePath);
|
||||
if (!file_exists($pathParts['dirname'])) {
|
||||
$dirPermission= $defaultPermissions['dir'];
|
||||
$dirPermission= is_string($dirPermission) ? base_convert($dirPermission,8,10) : $dirPermission;
|
||||
$dirPermission = $defaultPermissions['dir'];
|
||||
$dirPermission = is_string($dirPermission) ? base_convert($dirPermission,8,10) : $dirPermission;
|
||||
|
||||
if (!mkdir($pathParts['dirname'], $dirPermission, true)) {
|
||||
$GLOBALS['log']->critical('Permission denied: unable to generate a folder on the server - '.$pathParts['dirname']);
|
||||
@@ -438,21 +468,21 @@ class Manager
|
||||
* Get a directory name from the path
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $isFullPath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDirName($path)
|
||||
{
|
||||
$pieces= explode(Utils\Util::getSeparator(), $path);
|
||||
if (empty($pieces[count($pieces)-1])) {
|
||||
unset($pieces[count($pieces)-1]);
|
||||
}
|
||||
public function getDirName($path, $isFullPath = true)
|
||||
{
|
||||
$pathInfo = pathinfo($path);
|
||||
|
||||
if ($this->getFileName($path)!=$path) {
|
||||
return $pieces[count($pieces)-2];
|
||||
if (!$isFullPath) {
|
||||
$pieces = explode('/', $pathInfo['dirname']);
|
||||
|
||||
return $pieces[count($pieces)-1];
|
||||
}
|
||||
|
||||
return $pieces[count($pieces)-1];
|
||||
return $pathInfo['dirname'];
|
||||
}
|
||||
|
||||
|
||||
@@ -470,27 +500,7 @@ class Manager
|
||||
return false;
|
||||
}
|
||||
|
||||
return '<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
return '<?php
|
||||
|
||||
return '.var_export($content, true).';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -96,7 +96,8 @@ class Unifier
|
||||
//get matadata files
|
||||
$fileList = $this->getFileManager()->getFileList($dirPath, $recursively, '\.json$');
|
||||
|
||||
$defaultValues = $this->loadDefaultValues($this->getFileManager()->getDirName($dirPath), $type);
|
||||
$dirName = $this->getFileManager()->getDirName($dirPath, false);
|
||||
$defaultValues = $this->loadDefaultValues($dirName, $type);
|
||||
|
||||
$content= array();
|
||||
$unsets= array();
|
||||
|
||||
@@ -208,7 +208,7 @@ class Installer
|
||||
|
||||
$entity->set('userName', $userName);
|
||||
$entity->set('password', md5($password));
|
||||
$entity->set('lastName', 'Administrator');
|
||||
$entity->set('lastName', 'Admin');
|
||||
$entity->set('isAdmin', '1');
|
||||
|
||||
$userId = $this->getEntityManager()->saveEntity($entity);
|
||||
|
||||
@@ -105,6 +105,61 @@ class ManagerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($result, $this->reflection->invokeMethod('concatPaths', array($input)) );
|
||||
}
|
||||
|
||||
function testGetDirName()
|
||||
{
|
||||
$input = 'data/logs/espo.log';
|
||||
$result = 'logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
|
||||
$input = 'data/logs/espo.log/';
|
||||
$result = 'logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
|
||||
$input = 'application/Espo/Resources/metadata/entityDefs';
|
||||
$result = 'metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
|
||||
$input = 'application/Espo/Resources/metadata/entityDefs/';
|
||||
$result = 'metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
|
||||
$input = '/application/Espo/Resources/metadata/entityDefs';
|
||||
$result = 'metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
|
||||
$input = 'notRealPath/logs/espo.log';
|
||||
$result = 'logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input, false));
|
||||
}
|
||||
|
||||
|
||||
function testGetDirNameFullPath()
|
||||
{
|
||||
$input = 'data/logs/espo.log';
|
||||
$result = 'data/logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
|
||||
$input = 'data/logs/espo.log/';
|
||||
$result = 'data/logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
|
||||
$input = 'application/Espo/Resources/metadata/entityDefs';
|
||||
$result = 'application/Espo/Resources/metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
|
||||
$input = 'application/Espo/Resources/metadata/entityDefs/';
|
||||
$result = 'application/Espo/Resources/metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
|
||||
$input = '/application/Espo/Resources/metadata/entityDefs';
|
||||
$result = '/application/Espo/Resources/metadata';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
|
||||
$input = 'notRealPath/logs/espo.log';
|
||||
$result = 'notRealPath/logs';
|
||||
$this->assertEquals($result, $this->object->getDirName($input));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'database' =>
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'testOption' => 'Another Wrong Value',
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'User' =>
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'Global' =>
|
||||
|
||||
Reference in New Issue
Block a user