Commit 88d29f05 authored by Damien's avatar Damien

Merge branch 'develop' into 'master'

Develop

See merge request maarch/MaarchCourrier!161
parents 31598f84 e9a76e2e
......@@ -719,7 +719,7 @@ class htmlMimeMail
case 'mail':
$subject = '';
if (!empty($this->headers['Subject'])) {
$subject = $this->_encodeHeader($this->header['Subject'], $this->build_params['head_charset']);
$subject = $this->_encodeHeader($this->headers['Subject'], $this->build_params['head_charset']);
unset($this->headers['Subject']);
}
......
......@@ -33,7 +33,7 @@ class RequestSeda
{
//create session if NO SESSION
/*if (empty($_SESSION['user'])) {
if (empty($_SESSION['user'])) {
require_once('core/class/class_functions.php');
include_once('core/init.php');
require_once('core/class/class_portal.php');
......@@ -76,7 +76,7 @@ class RequestSeda
$businessAppTools->build_business_app_config();
$coreTools->load_modules_config($_SESSION['modules']);
$coreTools->load_menu($_SESSION['modules']);
}*/
}
$this->statement = [];
if ($db) {
......
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CONFIG>
<Lang>fr</Lang> <!-- fr, en-->
<MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory>
<LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR-->
<DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR-->
<dateToPurgeDEL>31/12/2019</dateToPurgeDEL> <!-- FORMAT : DD/MM/YYYY date à partir de laquelle on purge en remontant le passé les courriers et PJ supprimées, si vide, ne sera pas purgé -->
<dateToPurgeOBS>31/12/2019</dateToPurgeOBS> <!-- FORMAT : DD/MM/YYYY date à partir de laquelle on purge en remontant le passé les PJ obsolètes, si vide, ne sera pas purgé -->
<debug>true</debug> <!-- NO PURGE ONLY SIMULATION, entry false to launch the real purge -->
</CONFIG>
<CONFIG_BASE>
<databaseserver>127.0.0.1</databaseserver>
<databaseserverport>5432</databaseserverport>
<databasetype>POSTGRESQL</databasetype>
<databasename>MaarchCourrier</databasename>
<databaseuser>maarch</databaseuser>
<databasepassword>maarch</databasepassword>
</CONFIG_BASE>
<LOG4PHP>
<enabled>true</enabled>
<Log4PhpLogger>loggerTechnique</Log4PhpLogger>
<Log4PhpBusinessCode>life_cycle_purge</Log4PhpBusinessCode>
<Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath>
</LOG4PHP>
</ROOT>
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Library to process the garbage_collector
*
* @file
* @author Laurent Giovannoni <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup life_cycle
*/
/**
* @brief Class to include the file error
*
* @ingroup life_cycle
*/
class IncludeFileError extends Exception
{
public function __construct($file)
{
$this->file = $file;
parent :: __construct('Include File \'$file\' is missing!', 1);
}
}
try {
include('Maarch_CLITools/ArgsParser.php');
include('LoggerLog4php.php');
include('Maarch_CLITools/FileHandler.php');
include('Maarch_CLITools/ConsoleHandler.php');
} catch (IncludeFileError $e) {
echo 'Maarch_CLITools required ! \n (pear.maarch.org)\n';
exit(106);
}
include('batch_tools.php');
// Globals variables definition
$state = '';
$configFile = '';
$MaarchDirectory = '';
$batchDirectory = '';
$batchName = 'process_garbage_collector';
$table = '';
$adrTable = '';
$view = '';
$steps = Array();
$docservers = Array();
$docserverSourcePath = '';
$docserverSourceFingerprint = '';
$databasetype = '';
$exitCode = 0;
$running_date = date('Y-m-d H:i:s');
$func = '';
$db = '';
$db2 = '';
$docserverControler = '';
$wb = '';
$docserversFeatures = array();
$lckFile = '';
$errorLckFile = '';
$totalProcessedResources = 0;
$dateToPurgeDEL = '';
$dateToPurgeOBS = '';
$log4PhpEnabled = false;
$resAlreadyDone = false;
$attachAlreadyDone = false;
$obsAlreadyDone = false;
$debug = 'true';
// Defines scripts arguments
$argsparser = new ArgsParser();
// The config file
$argsparser->add_arg(
'config',
array(
'short' => 'c',
'long' => 'config',
'mandatory' => true,
'help' => 'Config file path is mandatory.',
)
);
$argsparser->add_arg(
'mode',
array(
'short' => 'm',
'long' => 'mode',
'mandatory' => true,
'help' => 'Mode (count|purge) is mandatory.',
)
);
// The path of the log directory
$argsparser->add_arg(
'logs',
array(
'short' => 'logs',
'long' => 'logs',
'mandatory' => false,
'help' => '',
)
);
// Parsing script options
try {
$options = $argsparser->parse_args($GLOBALS['argv']);
// If option = help then options = false and the script continues ...
if ($options == false) {
exit(0);
}
} catch (MissingArgumentError $e) {
if ($e->arg_name == 'config') {
echo 'Configuration file missing' . PHP_EOL;
exit(101);
}
if ($e->arg_name == 'mode') {
echo 'mode(count|purge) missinng' . PHP_EOL;
exit(105);
}
}
// Log management
//$GLOBALS['logger'] = new Logger();
$GLOBALS['logger'] = new Logger4Php();
$GLOBALS['logger']->set_threshold_level('DEBUG');
$console = new ConsoleHandler();
$GLOBALS['logger']->add_handler($console);
if (!empty($options['logs'])) {
if (!is_dir($options['logs'] . '/process_garbage_collector/')) {
mkdir($options['logs'] . '/process_garbage_collector/', 0770, true);
}
$logFile = $options['logs'] . '/process_garbage_collector/'
. date('Y-m-d_H-i-s') . '.log';
} else {
if (!is_dir('logs/process_garbage_collector/')) {
mkdir('logs/process_garbage_collector/', 0770, true);
}
$logFile = 'logs/process_garbage_collector/'
. date('Y-m-d_H-i-s') . '.log';
}
$file = new FileHandler($logFile);
$GLOBALS['logger']->add_handler($file);
$GLOBALS['logger']->write('STATE:INIT', 'INFO');
$txt = '';
foreach (array_keys($options) as $key) {
if (isset($options[$key]) && $options[$key] == false) {
$txt .= $key . '=false,';
} else {
$txt .= $key . '=' . $options[$key] . ',';
}
}
$GLOBALS['logger']->write($txt, 'DEBUG');
$GLOBALS['configFile'] = $options['config'];
$GLOBALS['logger']->write($txt, 'INFO');
// Tests existence of config file
if (!file_exists($GLOBALS['configFile'])) {
$GLOBALS['logger']->write('Configuration file ' . $GLOBALS['configFile']
. ' does not exist', 'ERROR', 102);
exit(102);
}
// Loading config file
$GLOBALS['logger']->write('Load xml config file:' . $GLOBALS['configFile'],
'INFO');
$xmlconfig = simplexml_load_file($GLOBALS['configFile']);
if ($xmlconfig == FALSE) {
$GLOBALS['logger']->write('Error on loading config file:'
. $GLOBALS['configFile'], 'ERROR', 103);
exit(103);
}
$GLOBALS['mode'] = $options['mode'];
if (
strtolower($GLOBALS['mode']) <> 'count'
&& strtolower($GLOBALS['mode']) <> 'purge'
) {
$GLOBALS['logger']->write('Error on mode, must be count or purge:'
. $GLOBALS['mode'], 'ERROR', 105);
exit(105);
}
// Load the config vars
$CONFIG = $xmlconfig->CONFIG;
$lang = (string) $CONFIG->Lang;
$GLOBALS['MaarchDirectory'] = (string) $CONFIG->MaarchDirectory;
$GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'modules/life_cycle/batch/';
$logLevel = (string) $CONFIG->LogLevel;
$GLOBALS['logger']->set_threshold_level($logLevel);
$DisplayedLogLevel = (string) $CONFIG->DisplayedLogLevel;
$GLOBALS['databasetype'] = (string) $xmlconfig->CONFIG_BASE->databasetype;
$GLOBALS['dateToPurgeDEL'] = (string) $CONFIG->dateToPurgeDEL;
$GLOBALS['dateToPurgeOBS'] = (string) $CONFIG->dateToPurgeOBS;
$GLOBALS['debug'] = (string) $CONFIG->debug;
if (empty($GLOBALS['debug'])) {
$GLOBALS['debug'] = 'true';
}
if (empty($GLOBALS['dateToPurgeDEL']) && empty($GLOBALS['dateToPurgeOBS'])) {
$GLOBALS['logger']->write('dateToPurgeDEL or dateToPurgeOBS must be filled', 'ERROR', 1);
exit(105);
}
$i = 0;
set_include_path(get_include_path() . PATH_SEPARATOR
. $GLOBALS['MaarchDirectory']);
//log4php params
$log4phpParams = $xmlconfig->LOG4PHP;
if ((string) $log4phpParams->enabled == 'true') {
$GLOBALS['logger']->set_log4PhpLibrary(
$GLOBALS['MaarchDirectory']
. 'apps/maarch_entreprise/tools/log4php/Logger.php'
);
$GLOBALS['logger']->set_log4PhpLogger((string) $log4phpParams->Log4PhpLogger);
$GLOBALS['logger']->set_log4PhpBusinessCode((string) $log4phpParams->Log4PhpBusinessCode);
$GLOBALS['logger']->set_log4PhpConfigPath((string) $log4phpParams->Log4PhpConfigPath);
$GLOBALS['logger']->set_log4PhpBatchName('life_cycle_process_garbage_collector');
}
if ($logLevel == 'DEBUG') {
error_reporting(E_ALL);
}
$GLOBALS['logger']->change_handler_log_level($file, $logLevel);
$GLOBALS['logger']->change_handler_log_level($console, $DisplayedLogLevel);
unset($xmlconfig);
// Include library
try {
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_functions.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db_pdo.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_core_tools.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/core_tables.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docservers_controler.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/docservers_tools.php');
Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docserver_types_controler.php');
} catch (IncludeFileError $e) {
$GLOBALS['logger']->write(
'Problem with the php include path:'
. get_include_path(), 'ERROR', 111
);
exit(111);
}
$coreTools = new core_tools();
$coreTools->load_lang($lang, $GLOBALS['MaarchDirectory'], 'maarch_entreprise');
session_start();
$_SESSION['modules_loaded'] = array();
$GLOBALS['func'] = new functions();
$GLOBALS['db'] = new Database($GLOBALS['configFile']);
$GLOBALS['db2'] = new Database($GLOBALS['configFile']);
$GLOBALS['dbLog'] = new Database($GLOBALS['configFile']);
$GLOBALS['docserverControler'] = new docservers_controler();
$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . '/'
. $GLOBALS['batchName'] . '_error.lck';
$GLOBALS['lckFile'] = $GLOBALS['batchDirectory'] . '/'
. $GLOBALS['batchName'] . '.lck';
if (file_exists($GLOBALS['errorLckFile'])) {
$GLOBALS['logger']->write(
'Error persists, please solve this before launching a new batch',
'ERROR', 29
);
exit(29);
}
if (file_exists($GLOBALS['lckFile'])) {
$GLOBALS['logger']->write(
'An instance of the garbage_collector batch : is already in progress',
'ERROR', 109
);
exit(109);
}
$semaphore = fopen($GLOBALS['lckFile'], 'a');
fwrite($semaphore, '1');
fclose($semaphore);
Bt_getWorkBatch();
$GLOBALS['wb'] = rand() . $GLOBALS['wbCompute'];
Bt_updateWorkBatch();
$GLOBALS['logger']->write('Batch number:' . $GLOBALS['wb'], 'INFO');
if (strtolower($GLOBALS['mode']) == 'purge') {
if (strtolower($GLOBALS['debug']) == 'false') {
$GLOBALS['logger']->write('YOUR ARE NOT IN DEBUG MODE, DATA WILL BE ERASED', 'INFO');
} else {
$GLOBALS['logger']->write('your are in debug mode', 'INFO');
}
} else {
$GLOBALS['logger']->write('your are in count mode', 'INFO');
}
This diff is collapsed.
#!/bin/sh
path='/var/www/html/MaarchCourrier/modules/life_cycle/batch'
cd $path
php 'process_garbage_collector.php' -c /var/www/html/MaarchCourrier/modules/life_cycle/batch/config/config_garbage_collector.xml -m count
......@@ -242,9 +242,13 @@ class SendMessageExchangeController
$oComment = new stdClass();
$date = new DateTime($value['creation_date']);
$entityRoot = \Entity\models\EntityModel::getEntityRootById(['entityId' => $value['entity_id']]);
$userEntity = \Entity\models\entitymodel::getByEntityId(['entityId' => $value['entity_id']]);
$oComment->value = $value['firstname'].' '.$value['lastname'].' - '.$date->format('d-m-Y H:i:s').' ('.$entityRoot['entity_label'].' - '.$userEntity['entity_label'].') : '.$value['note_text'];
$additionalUserInfos = '';
if (!empty($value['entity_id'])) {
$entityRoot = \Entity\models\EntityModel::getEntityRootById(['entityId' => $value['entity_id']]);
$userEntity = \Entity\models\entitymodel::getByEntityId(['entityId' => $value['entity_id']]);
$additionalUserInfos = ' ('.$entityRoot['entity_label'].' - '.$userEntity['entity_label'].')';
}
$oComment->value = $value['firstname'].' '.$value['lastname'].' - '.$date->format('d-m-Y H:i:s'). $additionalUserInfos . ' : '.$value['note_text'];
array_push($aReturn, $oComment);
}
}
......@@ -451,7 +455,7 @@ class SendMessageExchangeController
$aDefaultConfig = \Sendmail\Controllers\ReceiveMessageExchangeController::readXmlConfig();
$traCommunicationObject->Channel = $aArgs['ChannelType'];
$traCommunicationObject->value = $aDefaultConfig['m2m_communication_type'][$aArgs['ChannelType']];
$traCommunicationObject->value = rtrim($aDefaultConfig['m2m_communication_type'][$aArgs['ChannelType']], "/");
$TransferringAgencyObject->OrganizationDescriptiveMetadata->Communication = [$traCommunicationObject];
......
......@@ -740,4 +740,17 @@ abstract class SendmailAbstract extends Database
return _EMAIL_DRAFT;
}
}
public function messageExchangeStatus(array $args)
{
if ($args['status'] == 'S') {
return _EMAIL_SENT;
} elseif ($args['status'] == 'E') {
return _EMAIL_ERROR;
} elseif ($args['status'] == 'W') {
return _EMAIL_WAIT;
} else {
return _EMAIL_DRAFT;
}
}
}
......@@ -457,7 +457,7 @@ if ($mode == 'add') {
}
$content .= '><span style="font-size: 10px;color: rgb(22, 173, 235);">'.$attachment_type.'</span> <span style="font-size: 10px;color: grey;">('.$att_type.' - '.$filesize.')</span><br/><strong>'.$description.'</strong>';
if ($attachment_files[$i]['pdf_exist'] && $format != 'pdf') {
if ($attachment_files[$i]['pdf_exist'] && $format != 'pdf' && $formContent != 'messageExchange') {
$content .= ' (<input style="margin: 0px" title="envoyer la version PDF" type="checkbox" id="join_attachment_'.$i.'" name="'.$inputName.'"'
.' class="check" value="'
.$id.'#PDF" />version pdf)';
......
......@@ -135,7 +135,7 @@ if (!empty($tab)) {
$tab[$i][$j]["order"] = 'account_id';
}
if ($tab[$i][$j][$value]=="status_label") {
$tab[$i][$j]['value'] = $sendmail_tools->emailStatus(['status' => $tab[$i][$j]['value']]);
$tab[$i][$j]['value'] = $sendmail_tools->messageExchangeStatus(['status' => $tab[$i][$j]['value']]);
$tab[$i][$j]["label"] = _STATUS;
$tab[$i][$j]["size"] = "1";
$tab[$i][$j]["label_align"] = "left";
......
......@@ -301,7 +301,7 @@ switch ($mode) {
$userInfo = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id', 'mail']]);
$aSenderInfo = explode(",", $_REQUEST['sender_email']);
if (!empty($aSenderInfo[1])) {
if (!empty($aSenderInfo[1]) && !empty($aSenderInfo[0])) {
$entityInfo = \Entity\models\EntityModel::getByEntityId(['entityId' => $aSenderInfo[0], 'select' => ['id']]);
}
$isSent = \Email\controllers\EmailController::createEmail([
......
......@@ -266,7 +266,7 @@ function Bt_refusedSignedMail($aArgs = [])
[$aArgs['resIdMaster'], $creatorName . $aArgs['noteContent']]
);
}
$GLOBALS['db']->query("UPDATE ".$aArgs['tableAttachment']." SET status = 'A_TRA' WHERE res_id = ?", [$aArgs['resIdAttachment']]);
$GLOBALS['db']->query("UPDATE ".$aArgs['tableAttachment']." SET status = 'A_TRA', external_id = external_id - 'signatureBookId' WHERE res_id = ?", [$aArgs['resIdAttachment']]);
$GLOBALS['db']->query('UPDATE listinstance SET process_date = NULL WHERE res_id = ? AND difflist_type = ?', [$aArgs['resIdMaster'], 'VISA_CIRCUIT']);
$GLOBALS['db']->query("UPDATE res_letterbox SET status = '" . $aArgs['refusedStatus'] . "' WHERE res_id = ?", [$aArgs['resIdMaster']]);
......
......@@ -335,7 +335,7 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
}
$GLOBALS['logger']->write('Document validated', 'INFO');
$GLOBALS['db']->query("UPDATE res_version_attachments set status = 'OBS' WHERE res_id = ?", [$resId]);
$GLOBALS['db']->query("UPDATE res_version_attachments set status = 'OBS', external_id = external_id - 'signatureBookId' WHERE res_id = ?", [$resId]);
if (!empty($value->onlyVisa) && $value->onlyVisa) {
$status = $validatedStatusOnlyVisa;
} else {
......@@ -450,7 +450,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
}
$GLOBALS['logger']->write('Document validated', 'INFO');
$GLOBALS['db']->query("UPDATE res_attachments SET status = 'OBS' WHERE res_id = ?", [$resId]);
$GLOBALS['db']->query("UPDATE res_attachments SET status = 'OBS', external_id = external_id - 'signatureBookId' WHERE res_id = ?", [$resId]);
if (!empty($value->onlyVisa) && $value->onlyVisa) {
$status = $validatedStatusOnlyVisa;
} else {
......
......@@ -59,7 +59,7 @@
"ng2-dnd": "^5.0.2",
"node-sass": "^4.12.0",
"nodemon": "^1.19.1",
"npm-check-updates": "^3.1.8",
"npm-check-updates": "^3.1.12",
"rxjs": "^6.5.1",
"tslib": "^1.9.3",
"typescript": "3.2.4",
......
......@@ -192,6 +192,7 @@ $app->get('/header', \SrcCore\controllers\CoreController::class . ':getHeader');
//Home
$app->get('/home', \Home\controllers\HomeController::class . ':get');
$app->get('/home/lastRessources', \Home\controllers\HomeController::class . ':getLastRessources');
$app->get('/home/maarchParapheurDocuments', \Home\controllers\HomeController::class . ':getMaarchParapheurDocuments');
//Jnlp
$app->post('/jnlp', \ContentManagement\controllers\JnlpController::class . ':generateJnlp');
......@@ -271,7 +272,6 @@ $app->get('/natures', \Resource\controllers\ResController::class . ':getNatures'
$app->get('/resources/{resId}/isAllowed', \Resource\controllers\ResController::class . ':isAllowedForCurrentUser');
$app->post('/resources/checkFileUpload', \Resource\controllers\StoreController::class . ':checkFileUpload');
//ResourcesList
$app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}', \Resource\controllers\ResourceListController::class . ':get');
$app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions', \Resource\controllers\ResourceListController::class . ':getActions');
......@@ -338,8 +338,11 @@ $app->post('/users/{id}/password', \User\controllers\UserController::class . ':r
$app->put('/users/{id}/password', \User\controllers\UserController::class . ':updatePassword');
$app->get('/users/{userId}/status', \User\controllers\UserController::class . ':getStatusByUserId');
$app->put('/users/{id}/status', \User\controllers\UserController::class . ':updateStatus');
$app->put('/users/{id}/maarchParapheur', \User\controllers\UserController::class . ':sendToMaarchParapheur');
$app->put('/users/{id}/externalSignatures', \User\controllers\UserController::class . ':sendSignaturesToMaarchParapheur');
$app->put('/users/{id}/createInMaarchParapheur', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':sendUserToMaarchParapheur');
$app->put('/users/{id}/linkToMaarchParapheur', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':linkUserToMaarchParapheur');
$app->put('/users/{id}/unlinkToMaarchParapheur', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':unlinkUserToMaarchParapheur');
$app->get('/users/{id}/statusInMaarchParapheur', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':userStatusInMaarchParapheur');
$app->put('/users/{id}/externalSignatures', \ExternalSignatoryBook\controllers\MaarchParapheurController::class . ':sendSignaturesToMaarchParapheur');
$app->post('/users/{id}/groups', \User\controllers\UserController::class . ':addGroup');
$app->put('/users/{id}/groups/{groupId}', \User\controllers\UserController::class . ':updateGroup');
$app->delete('/users/{id}/groups/{groupId}', \User\controllers\UserController::class . ':deleteGroup');
......
......@@ -247,6 +247,17 @@ class EmailController
$phpmailer = new PHPMailer();
$emailFrom = empty($configuration['from']) ? $email['sender']['email'] : $configuration['from'];
if (empty($email['sender']['entityId'])) {
// Usefull for old sendmail server which doesn't support accent encoding
$setFrom = TextFormatModel::normalize(['string' => "{$user['firstname']} {$user['lastname']}"]);
$phpmailer->setFrom($emailFrom, ucwords($setFrom));
} else {
$entity = EntityModel::getById(['id' => $email['sender']['entityId'], 'select' => ['short_label']]);
// Usefull for old sendmail server which doesn't support accent encoding
$setFrom = TextFormatModel::normalize(['string' => $entity['short_label']]);
$phpmailer->setFrom($emailFrom, ucwords($setFrom));
}
if (in_array($configuration['type'], ['smtp', 'mail'])) {
if ($configuration['type'] == 'smtp') {
$phpmailer->isSMTP();
......@@ -267,18 +278,6 @@ class EmailController
$phpmailer->Password = PasswordModel::decrypt(['cryptedPassword' => $configuration['password']]);
}
}
$emailFrom = empty($configuration['from']) ? $email['sender']['email'] : $configuration['from'];
if (empty($email['sender']['entityId'])) {
// Usefull for old sendmail server which doesn't support accent encoding
$setFrom = TextFormatModel::normalize(['string' => "{$user['firstname']} {$user['lastname']}"]);
$phpmailer->setFrom($emailFrom, ucwords($setFrom));
} else {
$entity = EntityModel::getById(['id' => $email['sender']['entityId'], 'select' => ['short_label']]);
// Usefull for old sendmail server which doesn't support accent encoding
$setFrom = TextFormatModel::normalize(['string' => $entity['short_label']]);
$phpmailer->setFrom($emailFrom, ucwords($setFrom));
}
} elseif ($configuration['type'] == 'sendmail') {
$phpmailer->isSendmail();
} elseif ($configuration['type'] == 'qmail') {
......
......@@ -20,6 +20,8 @@ use Group\models\GroupModel;
use Resource\models\ResModel;
use Slim\Http\Request;
use Slim\Http\Response;
use SrcCore\models\CoreConfigModel;
use SrcCore\models\CurlModel;
use User\models\UserModel;
use Parameter\models\ParameterModel;
......@@ -84,10 +86,24 @@ class HomeController
$assignedBaskets[$key]['ownerLogin'] = UserModel::getById(['id' => $assignedBasket['owner_user_id'], 'select' => ['user_id']])['user_id'];
}
$isMaarchParapheurConnected = false;
$loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/visa/xml/remoteSignatoryBooks.xml']);
if (!empty($loadedXml)) {
foreach ($loadedXml->signatoryBook as $value) {
if ($value->id == "maarchParapheur") {
if (!empty($value->url) && !empty($value->userId) && !empty($value->password)) {
$isMaarchParapheurConnected = true;
}
break;
}
}
}
return $response->withJson([
'regroupedBaskets' => $regroupedBaskets,
'assignedBaskets' => $assignedBaskets,
'homeMessage' => $homeMessage,
'regroupedBaskets' => $regroupedBaskets,
'assignedBaskets' => $assignedBaskets,
'homeMessage' => $homeMessage,
'isMaarchParapheurConnected' => $isMaarchParapheurConnected
]);
}
......@@ -114,4 +130,57 @@ class HomeController
'lastResources' => $lastResources,
]);
}
public function getMaarchParapheurDocuments(Request $request, Response $response)
{
$user = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['external_id']]);
$externalId = json_decode($user['external_id'], true);
if (empty($externalId['maarchParapheur'])) {
return $response->withStatus(400)->withJson(['errors' => 'User is not linked to Maarch Parapheur']);
}
$loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/visa/xml/remoteSignatoryBooks.xml']);
if (empty($loadedXml)) {
return $response->withStatus(400)->withJson(['errors' => 'SignatoryBooks configuration file missing']);
}
$url = '';
$userId = '';
$password = '';
foreach ($loadedXml->signatoryBook as $value) {
if ($value->id == "maarchParapheur") {
$url = $value->url;
$userId = $value->userId;
$password = $value->password;
break;
}
}
if (empty($url)) {
return $response->withStatus(400)->withJson(['errors' => 'Maarch Parapheur configuration missing']);
}
$curlResponse = CurlModel::execSimple([
'url' => rtrim($url, '/') . '/rest/documents',
'basicAuth' => ['user' => $userId, 'password' => $password],
'headers' => ['content-type:application/json'],
'method' => 'GET',
'queryParams' => ['userId' => $externalId['maarchParapheur'], 'limit' => 10]
]);
if ($curlResponse['code'] != '200') {
if (!empty($curlResponse['response']['errors'])) {
$errors = $curlResponse['response']['errors'];
} else {
$errors = $curlResponse['errors'];
}
if (empty($errors)) {
$errors = 'An error occured. Please check your configuration file.';
}
return $response->withStatus(400)->withJson(['errors' => $errors]);
}
return $response->withJson($curlResponse['response']);
}
}
......@@ -765,11 +765,16 @@ class ResController
$select = explode(',', $data['select']);
$sve_start_date = false;
if ($keySve = array_search('sve_start_date', array_map('trim', $select))) {
$keySve = array_search('sve_start_date', array_map('trim', $select));
if ($keySve !== false) {
unset($select[$keySve]);
$sve_start_date = true;
}
if ($sve_start_date && empty($select)) {
$select[] = 'res_id';
}
if (!PreparedClauseController::isRequestValid(['select' => $select, 'clause' => $data['clause'], 'orderBy' => $data['orderBy'], 'limit' => $data['limit'], 'userId' => $GLOBALS['userId']])) {
return $response->withStatus(400)->withJson(['errors' => _INVALID_REQUEST]);
}
......
This diff is collapsed.
......@@ -60,13 +60,13 @@ abstract class UserModelAbstract
public static function getByExternalId(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['externalId', 'signatoryBookName']);
ValidatorModel::notEmpty($aArgs, ['externalId', 'externalName']);
ValidatorModel::intVal($aArgs, ['externalId']);
$aUser = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],