mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
- Added new config entry in mail config file called enable_debug
- If enable_debug is true then info about the mail are logged into the CI error logs - Fixed queries to get sent and received messages with Recipient_model, now messages for which a notice email was not sent are retrieved and messages are sorted by insertamum - CL/Messages_model: - Before setting a message as read check if a record is already present - If the recipient is a prestudent then in table tbl_msg_message oe_kurzbz is set with the ou of the prestudent - The sender id (person_id) now is get from the currently logged user also when replying - MessageLib->_sendNoticeEmails checks that the message was sent only from FAS (NOT from infocenter)
This commit is contained in:
@@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
*/
|
||||
class MailLib
|
||||
{
|
||||
const ENABLE_DEBUG = 'enable_debug';
|
||||
|
||||
private $sended; // Sended email counter
|
||||
|
||||
// Properties for storing the configuration
|
||||
@@ -15,6 +17,8 @@ class MailLib
|
||||
private $email_time_range;
|
||||
private $email_from_system;
|
||||
|
||||
private $_ci; // Codeigniter instance
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
@@ -24,16 +28,16 @@ class MailLib
|
||||
$this->sended = 0;
|
||||
|
||||
// Get CI instance
|
||||
$this->ci =& get_instance();
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// The second parameter is used to avoiding name collisions in the config array
|
||||
$this->ci->config->load('mail', true);
|
||||
$this->_ci->config->load('mail', true);
|
||||
|
||||
// CI Email library
|
||||
$this->ci->load->library('email');
|
||||
$this->_ci->load->library('email');
|
||||
|
||||
// Initializing email library with the loaded configurations
|
||||
$this->ci->email->initialize($this->ci->config->config['mail']);
|
||||
$this->_ci->email->initialize($this->_ci->config->config['mail']);
|
||||
|
||||
// Set the configuration properties with the standard configuration values
|
||||
$this->email_number_to_sent = $this->getEmailCfgItem('email_number_to_sent');
|
||||
@@ -48,6 +52,22 @@ class MailLib
|
||||
*/
|
||||
public function send($from, $to, $subject, $message, $alias = '', $cc = null, $bcc = null, $altMessage = '', $bulk = false, $autogenerated = false)
|
||||
{
|
||||
// If it is configured then log mail info into the CI error logs
|
||||
if ($this->getEmailCfgItem(self::ENABLE_DEBUG) === true)
|
||||
{
|
||||
$this->_ci->load->library('LogLib'); // Loads logging library
|
||||
|
||||
// Log them all!
|
||||
$this->_ci->loglib->logError('From: '.$from);
|
||||
$this->_ci->loglib->logError('To: '.$to);
|
||||
$this->_ci->loglib->logError('Subject: '.$subject);
|
||||
$this->_ci->loglib->logError('Message: '.$message);
|
||||
$this->_ci->loglib->logError('Alias: '.$alias);
|
||||
$this->_ci->loglib->logError('CC: '.$cc);
|
||||
$this->_ci->loglib->logError('BCC: '.$bcc);
|
||||
$this->_ci->loglib->logError('Alternative message: '.$altMessage);
|
||||
}
|
||||
|
||||
// If from is not specified then use the standard one
|
||||
if (is_null($from) || $from == '')
|
||||
{
|
||||
@@ -67,7 +87,7 @@ class MailLib
|
||||
}
|
||||
}
|
||||
|
||||
$this->ci->email->from($from, $alias);
|
||||
$this->_ci->email->from($from, $alias);
|
||||
|
||||
// Check if the email address of the debug recipient is a valid one
|
||||
$recipient = $to;
|
||||
@@ -83,20 +103,20 @@ class MailLib
|
||||
$recipientBCC = MAIL_DEBUG;
|
||||
}
|
||||
|
||||
$this->ci->email->to($recipient);
|
||||
if (!is_null($recipientCC)) $this->ci->email->cc($recipientCC);
|
||||
if (!is_null($recipientBCC)) $this->ci->email->bcc($recipientBCC);
|
||||
$this->ci->email->subject($subject);
|
||||
$this->ci->email->message($message);
|
||||
if (!isEmptyString($altMessage)) $this->ci->email->set_alt_message($altMessage);
|
||||
$this->_ci->email->to($recipient);
|
||||
if (!is_null($recipientCC)) $this->_ci->email->cc($recipientCC);
|
||||
if (!is_null($recipientBCC)) $this->_ci->email->bcc($recipientBCC);
|
||||
$this->_ci->email->subject($subject);
|
||||
$this->_ci->email->message($message);
|
||||
if (!isEmptyString($altMessage)) $this->_ci->email->set_alt_message($altMessage);
|
||||
|
||||
if($bulk)
|
||||
$this->ci->email->set_header('Precedence', 'bulk');
|
||||
$this->_ci->email->set_header('Precedence', 'bulk');
|
||||
if($autogenerated)
|
||||
$this->ci->email->set_header('Auto-Submitted', 'auto-generated');
|
||||
$this->_ci->email->set_header('Auto-Submitted', 'auto-generated');
|
||||
|
||||
// Avoid printing on standard output ugly error messages
|
||||
$result = @$this->ci->email->send();
|
||||
$result = @$this->_ci->email->send();
|
||||
|
||||
// If the email was succesfully sended then increment the counter
|
||||
// and checks if it has to wait until the sending of the next
|
||||
@@ -171,6 +191,6 @@ class MailLib
|
||||
*/
|
||||
private function getEmailCfgItem($itemName)
|
||||
{
|
||||
return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX);
|
||||
return $this->_ci->config->item($itemName, EMAIL_CONFIG_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user