Commit 58770409 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'master' into readOnly

parents 23b8b74d 23126819
......@@ -6045,7 +6045,7 @@ Send emails. Every mail will be logged in the table `mailLog`. Attachments are s
+--------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| E | encode|decode|none |**Body**: will be htmlspecialchar() encoded, decoded (default) or none (untouched). | |
+--------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| M | html |**Body**: will be send as a HTML mail. | |
| mode | html |**Body**: will be send as a HTML mail. | |
+--------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
* **e|E**: By default, QFQ stores values 'htmlspecialchars()' encoded. If such values have to send by email, the html entities are
......
......@@ -20,6 +20,7 @@ class HelperFile {
* Iterate over array $files. Delete only named files which are stored in '/tmp/' . DOWNLOAD_FILE_PREFIX.
*
* @param array $files
* @throws CodeException
* @throws UserFormException
*/
public static function cleanTempFiles(array $files) {
......@@ -63,6 +64,8 @@ class HelperFile {
* Creates a temporary directory.
* Be aware: '/tmp' is under systemd/apache2 (Ubuntu 18...) remapped to something like: '/tmp/systemd-private-...-apache2.service-.../tmp'
*
* @return bool|string
* @throws CodeException
* @throws UserFormException
*/
public static function mktempdir() {
......@@ -111,7 +114,7 @@ class HelperFile {
return array();
}
$pathFileName = self::correctRelativPathFileName($pathFileName);
$pathFileName = self::correctRelativePathFileName($pathFileName);
if (!file_exists($pathFileName)) {
return array();
......@@ -129,7 +132,7 @@ class HelperFile {
* @param $pathFileName
* @return string
*/
public static function correctRelativPathFileName($pathFileName) {
public static function correctRelativePathFileName($pathFileName) {
if (empty($pathFileName)) {
return '';
......@@ -283,6 +286,7 @@ class HelperFile {
* @param $filename
* @param string $logFilename
* @return string
* @throws CodeException
* @throws UserFormException
*/
public static function unlink($filename, $logFilename = '') {
......
......@@ -34,6 +34,7 @@ class OnArray {
* @return string
*/
public static function toString(array $dataArray, $keyValueGlue = '=', $rowGlue = '&', $encloseValue = '') {
if (count($dataArray) === 0) {
return '';
}
......
......@@ -1259,6 +1259,7 @@ class Support {
* @param $pathFileName
* @param bool $overwrite
* @param bool|int $chmodDir , 'false' if not change
* @throws CodeException
* @throws UserFormException
*/
public static function moveFile($srcFile, $pathFileName, $overwrite, $chmodDir = false) {
......
......@@ -69,10 +69,10 @@ class SendMail {
if (!empty($redirectAllMail)) {
$addBody = "All QFQ outgoing mails are caught and redirected to you." . PHP_EOL . "Original receiver(s) are ..." . PHP_EOL;
$addBody .= 'TO: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER]??'') . PHP_EOL;
$addBody .= 'CC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_CC]??'') . PHP_EOL;
$addBody .= 'BCC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_BCC]??'') . PHP_EOL;
$addBody .= 'SENDER: ' . ($mailConfig[SENDMAIL_TOKEN_SENDER]??'') . PHP_EOL;
$addBody .= 'TO: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER] ?? '') . PHP_EOL;
$addBody .= 'CC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_CC] ?? '') . PHP_EOL;
$addBody .= 'BCC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_BCC] ?? '') . PHP_EOL;
$addBody .= 'SENDER: ' . ($mailConfig[SENDMAIL_TOKEN_SENDER] ?? '') . PHP_EOL;
$addBody .= PHP_EOL . "==========================================" . PHP_EOL . PHP_EOL;
// Check if the given body is a HTML body.
......@@ -163,7 +163,7 @@ class SendMail {
$logFile = $this->store->getVar(SYSTEM_MAIL_LOG, STORE_SYSTEM);
if ($logFile != '' && $logFile !== false) {
$args[] = '-l "' . $logFile . '"';;
$args[] = '-l "' . $logFile . '"';
}
if (!empty($mailConfig[SENDMAIL_TOKEN_RECEIVER_CC])) {
......@@ -238,13 +238,13 @@ class SendMail {
$output = Support::qfqExec($cmd, $rc);
if($rc!=0){
if(!is_file($sendEmail) || !is_readable($sendEmail)){
if ($rc != 0) {
if (!is_file($sendEmail) || !is_readable($sendEmail)) {
throw new UserFormException(json_encode([ERROR_MESSAGE_TO_USER => "Command 'sendEmail' not found."
, ERROR_MESSAGE_SUPPORT => $sendEmail]), ERROR_SENDMAIL);
}
if(!is_executable($sendEmail)){
if (!is_executable($sendEmail)) {
throw new UserFormException(json_encode([ERROR_MESSAGE_TO_USER => "Command 'sendEmail' not executable."
, ERROR_MESSAGE_SUPPORT => $sendEmail]), ERROR_SENDMAIL);
}
......@@ -266,8 +266,8 @@ class SendMail {
* Creates a new MailLog Record based on $mailArr / $header.
*
* @param array $mailConfig
*
* @param string $attachmentsLine
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
......@@ -277,12 +277,17 @@ class SendMail {
$log = array();
$attachments = '';
if (!empty($mailConfig[SENDMAIL_TOKEN_ATTACHMENT]) && is_array($mailConfig[SENDMAIL_TOKEN_ATTACHMENT])) {
$attachments = OnArray::toString($mailConfig[SENDMAIL_TOKEN_ATTACHMENT]);
}
$header = 'OoO:' . $mailConfig[SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT];
if (!empty($mailConfig[SENDMAIL_TOKEN_HEADER])) {
$header .= PHP_EOL . 'Custom: ' . $mailConfig[SENDMAIL_TOKEN_HEADER];
}
if (!empty($mailConfig[SENDMAIL_TOKEN_ATTACHMENT])) {
$header .= PHP_EOL . 'Attachment: ' . $mailConfig[SENDMAIL_TOKEN_ATTACHMENT];
$header .= PHP_EOL . 'Attachment: ' . $attachments;
}
// Log
......
......@@ -189,6 +189,7 @@ class Config {
/**
* @param array $config
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
......@@ -243,6 +244,7 @@ class Config {
/**
* @param array $config
* @param string $reason
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
......
......@@ -300,6 +300,14 @@ class Store {
$config[SYSTEM_SEND_E_MAIL] = $config[SYSTEM_EXT_PATH] . '/Source/external/sendEmail';
// Make path absolute
foreach ([SYSTEM_MAIL_LOG, SYSTEM_QFQ_LOG, SYSTEM_SQL_LOG] AS $key) {
if (!empty($config[$key]) && $config[$key][0] != '/') {
$config[$key] = $config[SYSTEM_SITE_PATH] . '/' . $config[$key];
}
}
// In case the database credentials are given in the old style: copy them to the new style
if (!isset($config[SYSTEM_DB_1_USER]) && isset($config[SYSTEM_DB_USER])) {
$config[SYSTEM_DB_1_USER] = $config[SYSTEM_DB_USER];
......@@ -685,7 +693,7 @@ class Store {
$len = strlen(SIP_PREFIX_BASE64);
while ($useStores !== false && $useStores!=='') {
while ($useStores !== false && $useStores !== '') {
$store = $useStores[0]; // current store
$finalKey = $key;
......
......@@ -318,9 +318,11 @@ INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord,
sql1, parameter, feIdContainer, subrecordOption, dynamicUpdate, bsLabelColumns, bsInputColumns,
bsNoteColumns, modeSql, placeholder, encode)
VALUES (2, 'feIdContainer', 'Container', 'show', 'select', 'all', 'native', 120, 0, 0,
'<a href="{{documentation:Y}}#class-container">Info</a>', '', '',
'<a href="{{documentation:Y}}#class-container">Info</a>', '',
'{{feIdContainer:R:::{{SELECT fe.feIdContainer FROM FormElement AS fe WHERE fe.formId={{formId:S}} AND fe.feIdContainer!=0 ORDER BY fe.modified DESC LIMIT 1}}}}',
'{{!SELECT fe.id, CONCAT(fe.type, " / ", fe.name, " (", COUNT(feSub.id), ")" ) FROM FormElement As fe LEFT JOIN FormElement As feSub ON feSub.feIdContainer=fe.id WHERE fe.formId={{formId:SR0}} AND fe.class="container" GROUP BY fe.id ORDER BY fe.type, fe.ord, fe.name }}',
'emptyItemAtStart', 100, '', 'no', '', '', '',
'emptyItemAtStart',
100, '', 'no', '', '', '',
'{{SELECT IF(COUNT(fe.id)>0, "show", "hidden") FROM Form AS f LEFT JOIN FormElement AS fe ON f.id=fe.formId AND fe.class="container" WHERE f.id={{formId:S0}} GROUP BY f.id}}',
'', 'specialchar'),
(2, 'enabled', 'Enabled', 'show', 'checkbox', 'all', 'native', 130, 0, 0,
......
......@@ -342,7 +342,6 @@ class StoreTest extends TestCase {
SYSTEM_CMD_WKHTMLTOPDF => '/opt/wkhtmltox/bin/wkhtmltopdf',
SYSTEM_DATE_FORMAT => 'yyyy-mm-dd',
SYSTEM_THROW_GENERAL_ERROR => 'no',
SYSTEM_QFQ_LOG => SYSTEM_QFQ_LOG_FILE,
SYSTEM_SQL_LOG_MODE => SQL_LOG_MODE_MODIFY,
SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_AUTO,
SYSTEM_DB_INIT => 'set names utf8',
......@@ -388,8 +387,6 @@ class StoreTest extends TestCase {
F_BUTTON_ON_CHANGE_CLASS => 'btn-info alert-info',
SYSTEM_DB_NAME_DATA => '<DB>',
SYSTEM_DB_NAME_QFQ => '<DB>',
SYSTEM_SQL_LOG => SYSTEM_SQL_LOG_FILE,
SYSTEM_MAIL_LOG => SYSTEM_MAIL_LOG_FILE,
'DB_2_USER' => '<DBUSER>',
'DB_2_SERVER' => '<DBSERVER>',
'DB_2_PASSWORD' => '<DBPW>',
......@@ -440,7 +437,8 @@ EOT;
# The following won't be checked by content, cause they will change on different installations.
// foreach ([ SYSTEM_SQL_LOG, SYSTEM_MAIL_LOG, SYSTEM_SITE_PATH, SYSTEM_EXT_PATH, SYSTEM_SEND_E_MAIL] as $key) {
foreach ([SYSTEM_SITE_PATH, SYSTEM_EXT_PATH, SYSTEM_SEND_E_MAIL, SYSTEM_SESSION_TIMEOUT_SECONDS] as $key) {
foreach ([SYSTEM_SITE_PATH, SYSTEM_EXT_PATH, SYSTEM_SEND_E_MAIL, SYSTEM_SESSION_TIMEOUT_SECONDS, SYSTEM_QFQ_LOG,
SYSTEM_SQL_LOG, SYSTEM_MAIL_LOG] as $key) {
$this->assertTrue(isset($config[$key]), "Missing default value for '$key' ");
unset ($config[$key]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment