diff --git a/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php b/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php index eef3764fad110e015df1ce171ce393023a410b87..9d9f3e6303725080fe86e68839dbe61db2f82e2d 100755 --- a/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php +++ b/apps/maarch_entreprise/indexing_searching/add_multi_contacts.php @@ -35,7 +35,6 @@ require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_users.php'; -require_once 'modules/sendmail/sendmail_tables.php'; require_once 'modules/notifications/notifications_tables_definition.php'; require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; diff --git a/modules/life_cycle/batch/load_process_emails.php b/modules/life_cycle/batch/load_process_emails.php index 83d7a704b00ef1d6bdbcb82b7a23a6a246bef942..b00e94d37d0112db2f11892c6fcddc45b96ce094 100755 --- a/modules/life_cycle/batch/load_process_emails.php +++ b/modules/life_cycle/batch/load_process_emails.php @@ -11,7 +11,7 @@ class IncludeFileError extends Exception { - public function __construct($file) + public function __construct($file) { $this->file = $file; parent :: __construct('Include File \'$file\' is missing!', 1); @@ -54,7 +54,7 @@ require 'batch_tools.php'; $argsparser = new ArgsParser(); // The config file $argsparser->add_arg( - 'config_sendmail', + 'config_sendmail', array( 'short' => 'cs', 'long' => 'config_sendmail', @@ -64,7 +64,7 @@ $argsparser->add_arg( ); $argsparser->add_arg( - 'config', + 'config', array( 'short' => 'c', 'long' => 'config', @@ -98,14 +98,16 @@ $GLOBALS['logger']->write($txt, 'DEBUG'); $GLOBALS['configFile'] = $options['config_sendmail']; // Loading config file $GLOBALS['logger']->write( - 'Load xml config file:' . $GLOBALS['configFile'], + 'Load xml config file:' . $GLOBALS['configFile'], 'INFO' ); // Tests existence of config file if (!file_exists($GLOBALS['configFile'])) { $GLOBALS['logger']->write( - 'Configuration file ' . $GLOBALS['configFile'] - . ' does not exist', 'ERROR', 102 + 'Configuration file ' . $GLOBALS['configFile'] + . ' does not exist', + 'ERROR', + 102 ); echo "\nConfiguration file " . $GLOBALS['configFile'] . " does not exist ! \nThe batch cannot be launched !\n\n"; exit(102); @@ -115,8 +117,10 @@ $xmlconfig = simplexml_load_file($GLOBALS['configFile']); if ($xmlconfig == false) { $GLOBALS['logger']->write( - 'Error on loading config file:' - . $GLOBALS['configFile'], 'ERROR', 103 + 'Error on loading config file:' + . $GLOBALS['configFile'], + 'ERROR', + 103 ); exit(103); } @@ -125,9 +129,9 @@ if ($xmlconfig == false) { // Load config $config = $xmlconfig->CONFIG; $lang = (string)$config->Lang; -$GLOBALS['maarchDirectory'] = $_SESSION['config']['corepath'] = (string)$config->MaarchDirectory; +$GLOBALS['maarchDirectory'] = $_SESSION['config']['corepath'] = (string)$config->MaarchDirectory; $_SESSION['config']['app_id'] = (string) $config->MaarchApps; -$GLOBALS['CustomId'] = $_SESSION['custom_override_id'] = (string)$config->CustomId; +$GLOBALS['CustomId'] = $_SESSION['custom_override_id'] = (string)$config->CustomId; $GLOBALS['TmpDirectory'] = $GLOBALS['maarchDirectory'] . 'modules' . DIRECTORY_SEPARATOR . 'life_cycle' . DIRECTORY_SEPARATOR . 'batch'. DIRECTORY_SEPARATOR . 'tmp'; $GLOBALS['batchDirectory'] = $GLOBALS['maarchDirectory'] . 'modules' . DIRECTORY_SEPARATOR . 'life_cycle' . DIRECTORY_SEPARATOR . 'batch'; @@ -160,40 +164,35 @@ $GLOBALS['charset'] = (string)$mailerParams->charset; try { Bt_myInclude( - $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' + $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_functions.php' ); Bt_myInclude( - $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' + $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_db_pdo.php' ); Bt_myInclude( - $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' + $GLOBALS['maarchDirectory'] . 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_core_tools.php' ); Bt_myInclude( - $GLOBALS['maarchDirectory'] . 'apps' . DIRECTORY_SEPARATOR . 'maarch_entreprise' + $GLOBALS['maarchDirectory'] . 'apps' . DIRECTORY_SEPARATOR . 'maarch_entreprise' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_users.php' - ); - Bt_myInclude( - $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "sendmail" - . DIRECTORY_SEPARATOR . "sendmail_tables.php" - ); + ); Bt_myInclude( - $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "sendmail" + $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR . "class". DIRECTORY_SEPARATOR . "class_modules_tools.php" ); Bt_myInclude( - $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "entities" + $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "class". DIRECTORY_SEPARATOR . "class_manage_entities.php" ); Bt_myInclude( $GLOBALS['maarchDirectory'] . $path_to_mailer - ); - + ); } catch (IncludeFileError $e) { $GLOBALS['logger']->write( - 'Problem with the php include path:' .$e .' '. get_include_path(), + 'Problem with the php include path:' .$e .' '. get_include_path(), 'ERROR' ); exit(); @@ -210,12 +209,11 @@ $_SESSION['config']['databasetype'] = (string)$dbConfig->databasetype; $i = 0; foreach ($xmlconfig->COLLECTION as $col) { - $GLOBALS['collections'][$i] = array( - 'id' => (string) $col->Id, - 'table' => (string) $col->Table, - 'version_table' => (string) $col->VersionTable, - 'view' => (string) $col->View, + 'id' => (string) $col->Id, + 'table' => (string) $col->Table, + 'version_table' => (string) $col->VersionTable, + 'view' => (string) $col->View, 'adr' => (string) $col->Adr, 'extensions' => (string) $col->Extension ); @@ -225,14 +223,16 @@ foreach ($xmlconfig->COLLECTION as $col) { $GLOBALS['configFileStat'] = $options['config']; // Loading config file $GLOBALS['logger']->write( - 'Load xml config file:' . $GLOBALS['configFileStat'], + 'Load xml config file:' . $GLOBALS['configFileStat'], 'INFO' ); // Tests existence of config file if (!file_exists($GLOBALS['configFileStat'])) { $GLOBALS['logger']->write( - 'Configuration file ' . $GLOBALS['configFileStat'] - . ' does not exist', 'ERROR', 102 + 'Configuration file ' . $GLOBALS['configFileStat'] + . ' does not exist', + 'ERROR', + 102 ); echo "\nConfiguration file " . $GLOBALS['configFileStat'] . " does not exist ! \nThe batch cannot be launched !\n\n"; exit(102); @@ -242,8 +242,10 @@ $xmlconfigStat = simplexml_load_file($GLOBALS['configFileStat']); if ($xmlconfigStat == false) { $GLOBALS['logger']->write( - 'Error on loading config file:' - . $GLOBALS['configFileStat'], 'ERROR', 103 + 'Error on loading config file:' + . $GLOBALS['configFileStat'], + 'ERROR', + 103 ); exit(103); } @@ -260,15 +262,16 @@ $GLOBALS['func'] = new functions(); $GLOBALS['db'] = new Database($GLOBALS['configFile']); -$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR +$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] .'_error.lck'; -$GLOBALS['lckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR +$GLOBALS['lckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] . '.lck'; if (file_exists($GLOBALS['errorLckFile'])) { $GLOBALS['logger']->write( - 'Error persists, please solve this before launching a new batch', - 'ERROR', 13 + 'Error persists, please solve this before launching a new batch', + 'ERROR', + 13 ); exit(13); } diff --git a/modules/sendmail/batch/load_process_emails.php b/modules/sendmail/batch/load_process_emails.php index fa488ed09bd6638b15cfb08ec72d47a8012ce98b..647ee7c162c30d243187ffaab5cdcd9a14e7f342 100755 --- a/modules/sendmail/batch/load_process_emails.php +++ b/modules/sendmail/batch/load_process_emails.php @@ -178,10 +178,6 @@ try { $GLOBALS['maarchDirectory'] . 'apps' . DIRECTORY_SEPARATOR . 'maarch_entreprise' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_users.php' ); - Bt_myInclude( - $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "sendmail" - . DIRECTORY_SEPARATOR . "sendmail_tables.php" - ); Bt_myInclude( $GLOBALS['maarchDirectory'] . "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR . "class". DIRECTORY_SEPARATOR . "class_modules_tools.php" diff --git a/modules/sendmail/batch/process_emails.php b/modules/sendmail/batch/process_emails.php index 281ca9eeecde428c68f6fc33cb564fc8fc3b4fb2..b86016ccb0dbc712186d0ccb17af1101590c92b9 100755 --- a/modules/sendmail/batch/process_emails.php +++ b/modules/sendmail/batch/process_emails.php @@ -33,8 +33,7 @@ while ($state <> 'END') { * [LOAD_EMAIL : List the records to proceed] */ case 'LOAD_EMAILS': - $query = "SELECT * FROM " . EMAILS_TABLE - . " WHERE email_status = 'W' and send_date is NULL"; + $query = "SELECT * FROM sendmail WHERE email_status = 'W' and send_date is NULL"; $stmt = Bt_doQuery($GLOBALS['db'], $query); $totalEmailsToProcess = $stmt->rowCount(); $currentEmail = 0; @@ -396,8 +395,7 @@ while ($state <> 'END') { } } //Update emails table - $query = "UPDATE " . EMAILS_TABLE - . " SET send_date = CURRENT_TIMESTAMP " + $query = "UPDATE sendmail SET send_date = CURRENT_TIMESTAMP " . ", email_status = ? " . " WHERE email_id = ? "; $stmt = Bt_doQuery($GLOBALS['db'], $query, array($exec_result, $email->email_id)); @@ -436,8 +434,3 @@ array_map('unlink', glob($_SESSION['config']['tmppath']."/*")); //unlink($GLOBALS['lckFile']); exit($GLOBALS['exitCode']); - - - - - diff --git a/modules/sendmail/class/class_modules_tools_Abstract.php b/modules/sendmail/class/class_modules_tools_Abstract.php index 9b0a11efc7f68d3f6c3a4a4bf5cfc18a5c1474ea..a56bd42ffb0603079610c8d0935236d3b4166ac6 100755 --- a/modules/sendmail/class/class_modules_tools_Abstract.php +++ b/modules/sendmail/class/class_modules_tools_Abstract.php @@ -12,7 +12,6 @@ try { include_once "core/class/class_db.php"; include_once "core/class/class_security.php"; - include_once "modules/sendmail/sendmail_tables.php"; } catch (Exception $e) { functions::xecho($e->getMessage()).' // '; } @@ -761,4 +760,17 @@ abstract class SendmailAbstract extends Database return $explode[1]; } } + + public function emailStatus(array $args) + { + if ($args['status'] == 'SENT') { + return _EMAIL_SENT; + } elseif ($args['status'] == 'ERROR') { + return _EMAIL_ERROR; + } elseif ($args['status'] == 'WAITING') { + return _EMAIL_WAIT; + } else { + return _EMAIL_DRAFT; + } + } } diff --git a/modules/sendmail/mail_form.php b/modules/sendmail/mail_form.php index 52cdb0d7b20a26f265f19ec178e004d8705ab148..3c21eeaebec2ecbcc3a6fa7a209a7f233404a9be 100755 --- a/modules/sendmail/mail_form.php +++ b/modules/sendmail/mail_form.php @@ -28,7 +28,6 @@ require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'] .DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR .'class_users.php'; -require_once 'modules/sendmail/sendmail_tables.php'; require_once 'modules'.DIRECTORY_SEPARATOR.'sendmail'.DIRECTORY_SEPARATOR .'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'; require_once 'modules/sendmail/class/class_email_signatures.php'; diff --git a/modules/sendmail/mail_form_to_contact.php b/modules/sendmail/mail_form_to_contact.php index 5b58a917446b57ead0afffd39130a8db1c4077e2..116f2224a0c024eabc5e8d7677b3b632f3874e57 100755 --- a/modules/sendmail/mail_form_to_contact.php +++ b/modules/sendmail/mail_form_to_contact.php @@ -39,7 +39,6 @@ require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'] .DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR .'class_users.php'; -require_once 'modules/sendmail/sendmail_tables.php'; require_once 'modules'.DIRECTORY_SEPARATOR.'sendmail'.DIRECTORY_SEPARATOR .'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'; require_once 'modules/sendmail/class/class_email_signatures.php'; diff --git a/modules/sendmail/sendmail.php b/modules/sendmail/sendmail.php index 0df1adc6f5a52f2e9dd76c21fef9b874126c375c..164b28265acbb2b9d9657e9592e67a57579a6958 100755 --- a/modules/sendmail/sendmail.php +++ b/modules/sendmail/sendmail.php @@ -18,10 +18,10 @@ * @version $Revision$ * @ingroup sendmail */ + require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php'; require_once 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR .'class'.DIRECTORY_SEPARATOR.'class_lists.php'; -require_once 'modules'.DIRECTORY_SEPARATOR.'sendmail'.DIRECTORY_SEPARATOR.'sendmail_tables.php'; require_once 'modules'.DIRECTORY_SEPARATOR.'sendmail'.DIRECTORY_SEPARATOR .'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'; @@ -253,7 +253,7 @@ if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) { $tab[$i][$j]['order'] = 'email_object_short'; } if ($tab[$i][$j][$value] == 'status_img') { - $tab[$i][$j]['value'] = \Email\controllers\EmailController::emailStatus(['status' => $tab[$i][$j]['value']]); + $tab[$i][$j]['value'] = $sendmail_tools->emailStatus(['status' => $tab[$i][$j]['value']]); $tab[$i][$j]['label'] = _STATUS; $tab[$i][$j]['size'] = '10'; $tab[$i][$j]['label_align'] = 'left'; diff --git a/modules/sendmail/sendmail_ajax_content.php b/modules/sendmail/sendmail_ajax_content.php index 98e4b2ada252d1b15e389c89171894b5e74ce9b4..db07fd31b86e9131f3a4ee210710910397c59945 100755 --- a/modules/sendmail/sendmail_ajax_content.php +++ b/modules/sendmail/sendmail_ajax_content.php @@ -38,7 +38,6 @@ require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_users.php'; -require_once 'modules/sendmail/sendmail_tables.php'; require_once 'modules/notifications/notifications_tables_definition.php'; require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php"; diff --git a/modules/sendmail/sendmail_tables.php b/modules/sendmail/sendmail_tables.php deleted file mode 100755 index bec57f65126845436de80c34efd2d20074302e18..0000000000000000000000000000000000000000 --- a/modules/sendmail/sendmail_tables.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/* -* Copyright 2013 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief sendmail tables declarations -* -* -* @file -* @author Yves Christian Kapkpo <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup sendmail -*/ -if (! defined('EMAILS_TABLE')) { - define('EMAILS_TABLE', 'sendmail'); -} diff --git a/src/app/email/controllers/EmailController.php b/src/app/email/controllers/EmailController.php index b1ac44f410287841e892a7222468a98aa2b80b7d..8e90674f6ab29cd6b32ed62db7e2996db1aa8f9e 100644 --- a/src/app/email/controllers/EmailController.php +++ b/src/app/email/controllers/EmailController.php @@ -509,17 +509,4 @@ class EmailController return $response->withStatus(204); } - - public static function emailStatus(array $args) - { - if ($args['status'] == 'SENT') { - return _EMAIL_SENT; - } elseif ($args['status'] == 'ERROR') { - return _EMAIL_ERROR; - } elseif ($args['status'] == 'WAITING') { - return _EMAIL_WAIT; - } else { - return _EMAIL_DRAFT; - } - } }