Merged in release/3.3 (pull request #6486)

Release/3.3

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2018-05-28 13:58:39 +00:00
41 changed files with 4158 additions and 2504 deletions

File diff suppressed because one or more lines are too long

View File

@@ -600,3 +600,74 @@ function setExtStateManagerSetProvider(cache, additionalPrefix) {
} catch (e) {
}
}
/**
* Download file with object XMLHttpRequest|ActiveXObject, with response type BLOB
*
* @param string method POST
* @param string url endpoint
* @param object headers
* @param object formData
* @param function callBack
*/
function downloadFile(method, url, headers, formData, callBack) {
var xhr,
win = window,
value = 'blob',
loadingFile = new Ext.LoadMask(Ext.getBody(), {msg: _('ID_LOADING')});
method = method || 'POST';
loadingFile.show();
if (win.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (win.ActiveXObject) {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
}
win.URL = win.URL || win.webkitURL;
xhr.open(method, url, true);
xhr.responseType = value;
Object.keys(headers).forEach(function (key) {
xhr.setRequestHeader(key, headers[key]);
});
xhr.onload = function (e) {
loadingFile.hide();
if (xhr.status === 200) {
if (xhr.getResponseHeader("Content-Disposition") !== null) {
var fileName = xhr.getResponseHeader("Content-Disposition").match(/\sfilename="([^"]+)"(\s|$)/)[1];
var blob = xhr.response;
if ((navigator.userAgent.indexOf("MSIE") !== -1) ||
(navigator.userAgent.indexOf("Trident") !== -1) ||
(navigator.userAgent.indexOf("Edge") !== -1)) {
win.navigator.msSaveBlob(blob, fileName);
} else {
var doc = win.document,
a = doc.createElementNS('http://www.w3.org/1999/xhtml', 'a'),
event = doc.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.href = win.URL.createObjectURL(blob);
a.download = fileName;
a.dispatchEvent(event);
}
if (typeof(callBack) !== 'undefined') {
callBack(xhr);
}
} else {
PMExt.error(_('ID_ERROR'), _('ID_UNEXPECTED_ERROR_OCCURRED_PLEASE'));
}
} else {
PMExt.error(_('ID_ERROR'), xhr.statusText);
}
};
xhr.send(formData);
}

View File

@@ -2654,20 +2654,17 @@ class Bootstrap
/**
* Stores a message in the log file, if the file size exceeds
*
* @param string $channel
* @param string $message
* @param array $context
* @param string $file
* @param string $pathData
* @param string $ws workspace
*
* @return void
* @param string $channel The logging channel
* @param int $level The logging level
* @param string $message The log message
* @param array $context The log context
* @param string $workspace name workspace
* @param string $file name file
* @param string $pathData path of file
*/
public static function registerMonolog($channel, $level, $message, $context, $ws, $file = 'cron.log', $pathData = PATH_DATA)
public static function registerMonolog($channel, $level, $message, $context, $workspace, $file = 'cron.log', $pathData = PATH_DATA)
{
$fileLog = $pathData .'sites'. PATH_SEP . $ws . PATH_SEP . 'log' . PATH_SEP . $file;
$registerLogger = MonologProvider::getSingleton($channel, $fileLog);
$registerLogger = MonologProvider::getSingleton($channel, $file);
$registerLogger->addLog($level, $message, $context);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +1,366 @@
<?php
/**
* class.monologProvider.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
class MonologProvider
{
/**
* @var MonologProvider
*/
private static $instance = null;
public $aWorkspaces = null;
public $formatter;
public $streamRoutating;
public $registerLogger;
/**
* @var LineFormatter
*/
private $formatter;
/**
* @var RotatingFileHandler
*/
private $streamRoutating;
/**
* @var Logger
*/
private $registerLogger;
//the default format "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
public $output = "<%level%> %datetime% %channel% %level_name%: %message% %context% %extra%\n";
public $dateFormat = "M d H:i:s";
public $numOfKeepFiles = 60;
public $levelDebug = 100;
public $bubble = true;
public $filePermission = 0666;
private $output = "<%level%> %datetime% %channel% %level_name%: %message% %context% %extra%\n";
private $dateFormat = 'M d H:i:s';
/**
* The maximal amount of files to keep (0 means unlimited)
* @var int
*/
private $maxFilesToKeep;
/**
* @var int level debug
*/
private $levelDebug;
/**
* Whether the messages that are handled can bubble up the stack or not
* @var boolean
*/
private $bubble = true;
/**
* @var int file permissions
*/
private $filePermission;
/**
* @var string path file
*/
private $pathFile;
public function __construct ($channel, $fileLog)
/**
* Logging levels from loo protocol defined in RFC 5424
*
* @var array $levels Logging levels
*/
protected static $levels = [
'DEBUG' => 100,
'INFO' => 200,
'NOTICE' => 250,
'WARNING' => 300,
'ERROR' => 400,
'CRITICAL' => 500,
'ALERT' => 550,
'EMERGENCY' => 600
];
public function __construct($channel, $fileLog)
{
//Set Formatter
$this->formatter = new Monolog\Formatter\LineFormatter($this->output, $this->dateFormat);
// getting configuration from env.ini
$sysConf = System::getSystemConfiguration();
//Set level debug
$levelDebug = 'DEBUG';
$this->setLevelDebug($levelDebug);
//Set path where the file will be saved
$defaultPath = $path = PATH_DATA . 'sites' . PATH_SEP . config('system.workspace') . PATH_SEP . 'log' . PATH_SEP;
if (isset($sysConf['logs_location'])) {
$path = !empty($sysConf['logs_location']) ? $sysConf['logs_location'] : $path;
}
$this->setPathFile($path);
//Set maximal amount of files to keep (0 means unlimited)
$maxFilesToKeep = 60;
if (isset($sysConf['logs_max_files'])) {
$maxFilesToKeep = !empty($sysConf['logs_max_files']) ? $sysConf['logs_max_files'] : $maxFilesToKeep;
}
$this->setMaxFiles($maxFilesToKeep);
/**
* The permissions are normally set at the operating system level, and it's the IT administrator responsibility to set the correct file permissions
* It's not recommendable define in the env.ini configuration
*/
$permissionFile = 0666;
$permissionFile = is_int($permissionFile) ? decoct($permissionFile) : $permissionFile;
$this->setFilePermission($permissionFile);
$this->setFormatter();
$this->setConfig($channel, $fileLog);
$this->testWriteLog($channel, $fileLog, [
$defaultPath
]);
}
/**
* Test write log
*
* @param string $channel
* @param string $fileLog
* @param array $paths
*/
private function testWriteLog($channel, $fileLog, $paths)
{
$fileInfo = pathinfo($fileLog);
$timedFilename = str_replace(
['{filename}', '{date}'],
[$fileInfo['filename'], date('Y-m-d')],
'{filename}-{date}'
);
if (!empty($fileInfo['extension'])) {
$timedFilename .= '.' . $fileInfo['extension'];
}
if (!file_exists($this->getPathFile() . $timedFilename)) {
try {
$this->getLogger()->addInfo('Start writing the log file');
} catch (UnexpectedValueException $exception) {
//In case that the file can not be written, it will be written to the standard log file.
error_log($exception->getMessage());
if ($paths) {
$path = array_shift($paths);
$this->setPathFile($path);
$this->setConfig($channel, $fileLog);
$this->testWriteLog($channel, $fileLog, $paths);
}
} catch (Exception $exception) {
//In case of an exception, it will be written to the standard log file.
error_log($exception->getMessage());
}
}
}
/**
* Return Formatter
*
* @return LineFormatter
*/
public function getFormatter()
{
return $this->formatter;
}
/**
* Set LineFormatter $formatter
*/
public function setFormatter()
{
$this->formatter = new LineFormatter($this->getOutput(), $this->getDateFormat());
}
/**
* @return RotatingFileHandler
*/
public function getStream()
{
return $this->streamRoutating;
}
/**
* @param string File name
*/
public function setStream($fileLog)
{
//Set Routating Handler
$this->streamRoutating = new Monolog\Handler\RotatingFileHandler($fileLog, $this->numOfKeepFiles, $this->levelDebug, $this->bubble, $this->filePermission);
$this->streamRoutating->setFormatter($this->formatter);
$this->streamRoutating = new RotatingFileHandler($this->getPathFile() . $fileLog,
$this->getMaxFiles(),
$this->getLevelDebug(),
$this->isBubble(),
$this->getFilePermissionOctDec());
$this->streamRoutating->setFormatter($this->getFormatter());
}
/**
* @return Logger
*/
public function getLogger()
{
return $this->registerLogger;
}
/**
* @param string $channel The logging channel
*/
public function setLogger($channel)
{
//Create the channel and register the Logger with StreamRoutating
$this->registerLogger = new Monolog\Logger($channel);
$this->registerLogger->pushProcessor(new Monolog\Processor\IntrospectionProcessor());
$this->registerLogger->pushHandler($this->streamRoutating);
$this->registerLogger = new Logger($channel);
$this->registerLogger->pushProcessor(new IntrospectionProcessor());
$this->registerLogger->pushHandler($this->getStream());
}
/**
* Return format output
* @return string
*/
public function getOutput()
{
return $this->output;
}
/**
* Set format output
*
* @param string $output
*/
public function setOutput($output)
{
$this->output = $output;
}
/**
* Return date format
* @return string
*/
public function getDateFormat()
{
return $this->dateFormat;
}
/**
* Set date format
* @param string $dateFormat
*/
public function setDateFormat($dateFormat)
{
$this->dateFormat = $dateFormat;
}
/**
* Return is can bubble up the stack or not.
*
* @return boolean
*/
public function isBubble()
{
return $this->bubble;
}
/**
* Set bubble
*
* @param boolean $bubble
*/
public function setBubble($bubble)
{
$this->bubble = $bubble;
}
/**
* Return level debug
*
* @return int
*/
public function getLevelDebug()
{
return $this->levelDebug;
}
/**
* Return max files
*
* @return int
*/
public function getMaxFiles()
{
return $this->maxFilesToKeep;
}
/**
* Set max files
*
* @param int $maxFilesToKeep
*/
public function setMaxFiles($maxFilesToKeep)
{
$this->maxFilesToKeep = $maxFilesToKeep;
}
/**
* Return permissions of file
*
* @return int
*/
public function getFilePermission()
{
return $this->filePermission;
}
/**
* Returns the decimal equivalent of the octal number represented by the octal_string argument.
*
* @return int
*/
public function getFilePermissionOctDec()
{
return octdec($this->filePermission);
}
/**
* Set file permissions
*
* @param int $filePermission
*/
public function setFilePermission($filePermission)
{
$this->filePermission = $filePermission;
}
/**
* Returns the path where the file will be saved
*
* @return string
*/
public function getPathFile()
{
return $this->pathFile;
}
/**
* Set path
*
* @param string $pathFile
*/
public function setPathFile($pathFile)
{
$pathSep = '/';
if (strpos($pathFile, '\\') !== false) {
$pathSep = '\\';
}
if (substr($pathFile, -1, strlen($pathSep)) !== $pathSep) {
$pathFile .= $pathSep;
}
$this->pathFile = $pathFile;
}
/**
* Set level debug by string
*
* @param string $levelDebug
*/
public function setLevelDebug($levelDebug)
{
$level = static::$levels['DEBUG'];
if (isset(static::$levels[$levelDebug])) {
$level = static::$levels[$levelDebug];
}
$this->levelDebug = $level;
}
/**
@@ -55,9 +369,9 @@ class MonologProvider
* @access public
* @return object
*/
public static function getSingleton ($channel, $fileLog)
public static function getSingleton($channel, $fileLog)
{
if (self::$instance == null) {
if (self::$instance === null) {
self::$instance = new MonologProvider($channel, $fileLog);
} else {
self::$instance->setConfig($channel, $fileLog);
@@ -69,55 +383,27 @@ class MonologProvider
* Set channel and fileLog
*
* @access public
* @return object
*
* @param string $channel The logging channel
* @param string $fileLog name file
*/
public function setConfig ($channel, $fileLog)
public function setConfig($channel, $fileLog)
{
//Set Routating Handler
$this->streamRoutating = new Monolog\Handler\RotatingFileHandler($fileLog, $this->numOfKeepFiles, $this->levelDebug, $this->bubble, $this->filePermission);
$this->streamRoutating->setFormatter($this->formatter);
//Create the channel and register the Logger with StreamRoutating
$this->registerLogger = new Monolog\Logger($channel);
$this->registerLogger->pushProcessor(new Monolog\Processor\IntrospectionProcessor());
$this->registerLogger->pushHandler($this->streamRoutating);
$this->setStream($fileLog);
$this->setLogger($channel);
}
/**
* to register log
* Register log
*
* @access public
* @return void
*
* @param int $level The logging level
* @param string $message The log message
* @param array $context The log context
*/
public function addLog ($level, $message, $context)
public function addLog($level, $message, $context)
{
switch ($level) {
case 100://DEBUG
$this->registerLogger->addDebug($message, $context);
break;
case 200://INFO
$this->registerLogger->addInfo($message, $context);
break;
case 250://NOTICE
$this->registerLogger->addNotice($message, $context);
break;
case 300://WARNING
$this->registerLogger->addWarning($message, $context);
break;
case 400://ERROR
$this->registerLogger->addError($message, $context);
break;
case 500://CRITICAL
$this->registerLogger->addCritical($message, $context);
break;
case 550://ALERT
$this->registerLogger->addAlert($message, $context);
break;
case 600://EMERGENCY
$this->registerLogger->addEmergency($message, $context);
break;
default:
$this->registerLogger->addDebug($message, $context);
}
$this->getLogger()->addRecord($level, $message, $context);
}
}

View File

@@ -1103,7 +1103,7 @@ EOREGEX;
*/
private function process_expr_list ($tokens)
{
$expr = "";
$expr = [];
$type = "";
$prev_token = "";
$skip_next = false;

View File

@@ -281,7 +281,7 @@ class RBAC
* gets the Role and their permissions for Administrator Processmaker
*
* @access public
* @return $this->permissionsAdmin[ $permissionsAdmin ]
* @return array $this->permissionsAdmin[ $permissionsAdmin ]
*/
public function loadPermissionAdmin()
{
@@ -611,7 +611,13 @@ class RBAC
"PER_UID" => "00000000000000000000000000000065",
"PER_CODE" => "PM_SETUP_CUSTOM_CASES_LIST",
"PER_NAME" => "Setup Custom Cases List"
],
[
'PER_UID' => '00000000000000000000000000000067',
'PER_CODE' => 'PM_SETUP_LOG_FILES',
'PER_NAME' => 'Log Files'
]
];
return $permissionsAdmin;