Skip to content
Snippets Groups Projects
Commit fb75c9a0 authored by Joseph AKEL's avatar Joseph AKEL
Browse files

Merge branch 'fix/26614/2301.0.x' into '2301.0.x'

[26614] La clé de chiffrement par défaut est utilisé pour l'envoi de courriel à la création d'un utilisateur

See merge request maarch/MaarchParapheur!264
parents 261b086b 733b8a96
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ require 'vendor/autoload.php';
use Email\controllers\EmailController;
use Email\models\EmailModel;
use Exception;
use History\controllers\HistoryController;
use SrcCore\models\DatabasePDO;
......@@ -30,13 +31,19 @@ EmailScript::send(['configPath' => $argv[1], 'emailId' => $argv[2], 'userId' =>
class EmailScript
{
public static function send(array $args)
/**
* @param array $args
* @return array
* @throws Exception
*/
public static function send(array $args): array
{
DatabasePDO::reset();
new DatabasePDO(['configPath' => $args['configPath']]);
$GLOBALS['id'] = $args['userId'];
$_SERVER['MAARCH_ENCRYPT_KEY'] = $args['encryptKey'];
$_SERVER['CONFIG_DIR'] = $args['configPath'];
$isSent = EmailController::sendEmail(['emailId' => $args['emailId']]);
if (!empty($isSent['success'])) {
......
<?php
/**
* Copyright Maarch since 2008 under license.
* See LICENSE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
* Copyright Maarch since 2008 under license.
* See LICENSE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Core Config Model
* @author dev@maarch.org
* @ingroup core
*/
* @brief Core Config Model
* @author dev@maarch.org
* @ingroup core
*/
namespace SrcCore\models;
use Exception;
class CoreConfigModel
{
public static function getConfigPath()
{
$path = empty($_SERVER['CONFIG_DIR']) ? $_SERVER['REDIRECT_CONFIG_DIR'] : $_SERVER['CONFIG_DIR'];
return $path;
return empty($_SERVER['CONFIG_DIR']) ? $_SERVER['REDIRECT_CONFIG_DIR'] : $_SERVER['CONFIG_DIR'];
}
/**
* @throws Exception
*/
public static function getConfig()
{
$path = CoreConfigModel::getConfigPath();
$loadedJson = CoreConfigModel::getJsonLoaded(['path' => $path . '/config.json']);
return $loadedJson;
return CoreConfigModel::getJsonLoaded(['path' => $path . '/config.json']);
}
/**
* Get the timezone
*
* @return string
* @throws Exception
*/
public static function getTimezone()
public static function getTimezone(): string
{
$timezone = 'Europe/Paris';
$loadedJson = CoreConfigModel::getConfig();
......@@ -52,16 +53,11 @@ class CoreConfigModel
/**
* Get the tmp dir
*
* @return string
*/
public static function getTmpPath()
public static function getTmpPath(): string
{
if (isset($_SERVER['MAARCH_TMP_DIR'])) {
$tmpDir = $_SERVER['MAARCH_TMP_DIR'];
} else {
$tmpDir = sys_get_temp_dir();
}
$tmpDir = $_SERVER['MAARCH_TMP_DIR'] ?? sys_get_temp_dir();
if (!is_dir($tmpDir)) {
mkdir($tmpDir, 0755);
......@@ -70,6 +66,9 @@ class CoreConfigModel
return $tmpDir . '/';
}
/**
* @throws Exception
*/
public static function getXmlLoaded(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['path']);
......@@ -83,6 +82,9 @@ class CoreConfigModel
return $xmlfile;
}
/**
* @throws Exception
*/
public static function getJsonLoaded(array $args)
{
ValidatorModel::notEmpty($args, ['path']);
......@@ -97,7 +99,10 @@ class CoreConfigModel
return $jsonFile;
}
public static function getEncryptKey()
/**
* @throws Exception
*/
public static function getEncryptKey(): string
{
$encryptKey = "Security Key Maarch Parapheur #2008";
......@@ -112,6 +117,9 @@ class CoreConfigModel
return $encryptKey;
}
/**
* @throws Exception
*/
public static function hasEncryptKeyChanged(): bool
{
$encryptKey = CoreConfigModel::getEncryptKey();
......@@ -119,7 +127,7 @@ class CoreConfigModel
return $encryptKey !== "Security Key Maarch Parapheur #2008" && $encryptKey !== "Security Key Maarch Parapheur 2008";
}
public static function getLibrariesDirectory()
public static function getLibrariesDirectory(): ?string
{
if (isset($_SERVER['LIBRARIES_DIR'])) {
$librariesDirectory = rtrim($_SERVER['LIBRARIES_DIR'], '/') . '/';
......@@ -132,7 +140,7 @@ class CoreConfigModel
return $librariesDirectory;
}
public static function getSetaPdfFormFillerLibrary()
public static function getSetaPdfFormFillerLibrary(): ?string
{
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = null;
......@@ -143,7 +151,7 @@ class CoreConfigModel
return $libPath;
}
public static function getSetaPdfSignerLibrary()
public static function getSetaPdfSignerLibrary(): ?string
{
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = null;
......@@ -154,11 +162,11 @@ class CoreConfigModel
return $libPath;
}
public static function getFpdiPdfParserLibrary()
public static function getFpdiPdfParserLibrary(): ?string
{
$configPath = CoreConfigModel::getConfigPath();
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = null;
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = null;
if (!empty($libDir) && is_file($libDir . 'FPDI-PDF-Parser/src/autoload.php')) {
$libPath = $libDir . 'FPDI-PDF-Parser/src/autoload.php';
......@@ -168,7 +176,7 @@ class CoreConfigModel
return $libPath;
}
public static function getSimpleSamlLibrary()
public static function getSimpleSamlLibrary(): ?string
{
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = null;
......@@ -179,7 +187,7 @@ class CoreConfigModel
return $libPath;
}
public static function getUniqueId()
public static function getUniqueId(): string
{
$parts = explode('.', microtime(true));
$sec = $parts[0];
......@@ -196,6 +204,9 @@ class CoreConfigModel
return $uniqueId;
}
/**
* @throws Exception
*/
public static function getSignatureModes()
{
$modes = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment