mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
Merge branch 'hotfix/3.0.2'
This commit is contained in:
@@ -98,9 +98,11 @@ class CronManager
|
||||
|
||||
protected function getLastRunTime()
|
||||
{
|
||||
$lastRunTime = $this->getFileManager()->getPhpContents($this->lastRunTime);
|
||||
if (!is_int($lastRunTime)) {
|
||||
$lastRunTime = time() - (intval($this->getConfig()->get('cron.minExecutionTime')) + 60);
|
||||
$lastRunData = $this->getFileManager()->getPhpContents($this->lastRunTime);
|
||||
|
||||
$lastRunTime = time() - intval($this->getConfig()->get('cron.minExecutionTime')) - 1;
|
||||
if (is_array($lastRunData) && !empty($lastRunData['time'])) {
|
||||
$lastRunTime = $lastRunData['time'];
|
||||
}
|
||||
|
||||
return $lastRunTime;
|
||||
@@ -108,7 +110,10 @@ class CronManager
|
||||
|
||||
protected function setLastRunTime($time)
|
||||
{
|
||||
return $this->getFileManager()->putPhpContents($this->lastRunTime, $time);
|
||||
$data = array(
|
||||
'time' => $time,
|
||||
);
|
||||
return $this->getFileManager()->putPhpContents($this->lastRunTime, $data);
|
||||
}
|
||||
|
||||
protected function checkLastRunTime()
|
||||
@@ -183,7 +188,6 @@ class CronManager
|
||||
$cronScheduledJob->addLogRecord($job['scheduled_job_id'], $status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,15 +109,18 @@ class Job
|
||||
* Get Jobs by ScheduledJobId and date
|
||||
*
|
||||
* @param string $scheduledJobId
|
||||
* @param string $date
|
||||
* @param string $time
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJobByScheduledJob($scheduledJobId, $date)
|
||||
public function getJobByScheduledJob($scheduledJobId, $time)
|
||||
{
|
||||
$dateObj = new \DateTime($time);
|
||||
$timeWithoutSeconds = $dateObj->format('Y-m-d H:i:');
|
||||
|
||||
$query = "SELECT * FROM job WHERE
|
||||
scheduled_job_id = '".$scheduledJobId."'
|
||||
AND execute_time = '".$date."'
|
||||
AND execute_time LIKE '".$timeWithoutSeconds."%'
|
||||
AND deleted = 0
|
||||
LIMIT 1";
|
||||
|
||||
|
||||
@@ -62,12 +62,14 @@ class Manager
|
||||
*/
|
||||
public function getFileList($path, $recursively = false, $filter = '', $onlyFileType = null, $isReturnSingleArray = false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
$path = $this->concatPaths($path);
|
||||
|
||||
$result = array();
|
||||
|
||||
if (!file_exists($path) || !is_dir($path)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$cdir = scandir($path);
|
||||
foreach ($cdir as $key => $value)
|
||||
{
|
||||
@@ -373,9 +375,11 @@ class Manager
|
||||
*
|
||||
* @param string | array $path
|
||||
* @param int $permission - ex. 0755
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $permission = null)
|
||||
public function mkdir($path, $permission = null, $recursive = false)
|
||||
{
|
||||
$fullPath = $this->concatPaths($path);
|
||||
|
||||
@@ -383,14 +387,23 @@ class Manager
|
||||
return true;
|
||||
}
|
||||
|
||||
$defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();
|
||||
|
||||
if (!isset($permission)) {
|
||||
$defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();
|
||||
$permission = (string) $defaultPermissions['dir'];
|
||||
$permission = base_convert($permission, 8, 10);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = mkdir($fullPath, $permission, true);
|
||||
|
||||
if (!empty($defaultPermissions['user'])) {
|
||||
$this->getPermissionUtils()->chown($fullPath);
|
||||
}
|
||||
|
||||
if (!empty($defaultPermissions['group'])) {
|
||||
$this->getPermissionUtils()->chgrp($fullPath);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$GLOBALS['log']->critical('Permission denied: unable to create the folder on the server - '.$fullPath);
|
||||
}
|
||||
@@ -490,8 +503,8 @@ class Manager
|
||||
$dirPermission = $defaultPermissions['dir'];
|
||||
$dirPermission = is_string($dirPermission) ? base_convert($dirPermission,8,10) : $dirPermission;
|
||||
|
||||
if (!mkdir($pathParts['dirname'], $dirPermission, true)) {
|
||||
throw new Error('Permission denied: unable to create a folder on the server - '.$pathParts['dirname']);
|
||||
if (!$this->mkdir($pathParts['dirname'], $dirPermission, true)) {
|
||||
throw new Error('Permission denied: unable to create a folder on the server - ' . $pathParts['dirname']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ class Permission
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get default settings
|
||||
*
|
||||
@@ -137,7 +136,6 @@ class Permission
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current permissions
|
||||
*
|
||||
@@ -216,7 +214,6 @@ class Permission
|
||||
return $this->chmodRecurse($path, $permission['file'], $permission['dir']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change permissions recursive
|
||||
*
|
||||
@@ -232,27 +229,20 @@ class Permission
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_file($path)) {
|
||||
if (!is_dir($path)) {
|
||||
return $this->chmodReal($path, $fileOctal);
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
$result = $this->chmodReal($path, $dirOctal);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chmodRecurse($path. Utils\Util::getSeparator() .$item, $fileOctal, $dirOctal);
|
||||
}
|
||||
|
||||
return $this->chmodReal($path, $dirOctal);
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
foreach ($allFiles as $item) {
|
||||
$result &= $this->chmodRecurse($path . Utils\Util::getSeparator() . $item, $fileOctal, $dirOctal);
|
||||
}
|
||||
|
||||
return false;
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change owner permission
|
||||
*
|
||||
@@ -262,7 +252,7 @@ class Permission
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function chown($path, $user='', $recurse=false)
|
||||
public function chown($path, $user = '', $recurse = false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
@@ -295,13 +285,18 @@ class Permission
|
||||
return false;
|
||||
}
|
||||
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chownRecurse($path. Utils\Util::getSeparator() .$item, $user);
|
||||
if (!is_dir($path)) {
|
||||
return $this->chownReal($path, $user);
|
||||
}
|
||||
|
||||
return $this->chownReal($path, $user);
|
||||
$result = $this->chownReal($path, $user);
|
||||
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
foreach ($allFiles as $item) {
|
||||
$result &= $this->chownRecurse($path . Utils\Util::getSeparator() . $item, $user);
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,15 +342,19 @@ class Permission
|
||||
return false;
|
||||
}
|
||||
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chgrpRecurse($path. Utils\Util::getSeparator() .$item, $group);
|
||||
if (!is_dir($path)) {
|
||||
return $this->chgrpReal($path, $group);
|
||||
}
|
||||
|
||||
return $this->chgrpReal($path, $group);
|
||||
}
|
||||
$result = $this->chgrpReal($path, $group);
|
||||
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
foreach ($allFiles as $item) {
|
||||
$result &= $this->chgrpRecurse($path . Utils\Util::getSeparator() . $item, $group);
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change permissions recursive
|
||||
|
||||
@@ -175,6 +175,16 @@ class Installer
|
||||
'passwordSalt' => $this->getPasswordHash()->generateSalt(),
|
||||
);
|
||||
|
||||
$owner = $this->getFileManager()->getPermissionUtils()->getDefaultOwner(true);
|
||||
$group = $this->getFileManager()->getPermissionUtils()->getDefaultGroup(true);
|
||||
|
||||
if (!empty($owner)) {
|
||||
$data['defaultPermissions']['user'] = $owner;
|
||||
}
|
||||
if (!empty($group)) {
|
||||
$data['defaultPermissions']['group'] = $group;
|
||||
}
|
||||
|
||||
$data = array_merge($data, $initData);
|
||||
$result = $this->saveConfig($data);
|
||||
|
||||
@@ -207,7 +217,7 @@ class Installer
|
||||
|
||||
public function setPreferences($preferences)
|
||||
{
|
||||
$currencyList = $this->getConfig()->get('currencyList');
|
||||
$currencyList = $this->getConfig()->get('currencyList', array());
|
||||
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
|
||||
|
||||
$preferences['currencyList'] = array($preferences['defaultCurrency']);
|
||||
|
||||
Reference in New Issue
Block a user