mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 16:32:20 +00:00
Merge branch 'feature-3716/Messaging_inbox_outbox_user'
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
|
||||
@@ -110,43 +130,34 @@ class MailLib
|
||||
}
|
||||
|
||||
/**
|
||||
* To ovveride the configurations
|
||||
* Overrides configuration parameters
|
||||
* If the given parameters are not null or empty strings then they are used to override
|
||||
* the following properties of this object:
|
||||
* - email_number_to_sent
|
||||
* - email_number_per_time_range
|
||||
* - email_time_range
|
||||
* - email_from_system
|
||||
*/
|
||||
public function overrideConfigs($cfg)
|
||||
public function overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem)
|
||||
{
|
||||
if (!is_null($cfg))
|
||||
if (is_numeric($numberToSent)) $this->email_number_to_sent = $numberToSent;
|
||||
|
||||
if (is_numeric($numberPerTimeRange)) $this->email_number_per_time_range = $numberPerTimeRange;
|
||||
|
||||
if (is_numeric($emailTimeRange)) $this->email_time_range = $emailTimeRange;
|
||||
|
||||
if (!isEmptyString($emailFromSystem) && filter_var($emailFromSystem, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
if (isset($cfg->email_number_to_sent) && is_numeric($cfg->email_number_to_sent))
|
||||
{
|
||||
$this->email_number_to_sent = $cfg->email_number_to_sent;
|
||||
}
|
||||
if (isset($cfg->email_number_per_time_range) && is_numeric($cfg->email_number_per_time_range))
|
||||
{
|
||||
$this->email_number_per_time_range = $cfg->email_number_per_time_range;
|
||||
}
|
||||
if (isset($cfg->email_time_range) && is_numeric($cfg->email_time_range))
|
||||
{
|
||||
$this->email_time_range = $cfg->email_time_range;
|
||||
}
|
||||
if (isset($cfg->email_from_system) && filter_var($cfg->email_from_system, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
$this->email_from_system = $cfg->email_from_system;
|
||||
}
|
||||
$this->email_from_system = $emailFromSystem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current configuration
|
||||
* Returns value of property email_number_to_sent
|
||||
*/
|
||||
public function getConfigs()
|
||||
public function getEmailNumberToSent()
|
||||
{
|
||||
$cfg = new stdClass();
|
||||
$cfg->email_number_to_sent = $this->email_number_to_sent;
|
||||
$cfg->email_number_per_time_range = $this->email_number_per_time_range;
|
||||
$cfg->email_time_range = $this->email_time_range;
|
||||
$cfg->email_from_system = $this->email_from_system;
|
||||
|
||||
return $cfg;
|
||||
return $this->email_number_to_sent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,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);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -165,16 +165,6 @@ class PhrasesLib
|
||||
}
|
||||
|
||||
/**
|
||||
* parseVorlagetext() - will parse a Vorlagetext.
|
||||
*/
|
||||
public function parseVorlagetext($text, $data = array())
|
||||
{
|
||||
if (isEmptyString($text)) return error('Not a valid text');
|
||||
|
||||
return $this->_ci->parser->parse_string($text, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a phrases from the the property _phrases with the given parameters
|
||||
* It also replace parameters inside the phrase if they are provided
|
||||
* @param string $category Category name which is used to categorize the phrase.
|
||||
@@ -201,7 +191,7 @@ class PhrasesLib
|
||||
{
|
||||
if (!is_array($parameters)) $parameters = array(); // if params is not an array
|
||||
|
||||
return $this->_ci->parser->parse_string($_phrase->text, $parameters, true); // parsing
|
||||
return parseText($_phrase->text, $parameters); // parsing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,18 +188,4 @@ class VorlageLib
|
||||
$vorlagetext = $this->ci->VorlageStudiengangModel->update($vorlagestudiengang_id, $data);
|
||||
return $vorlagetext;
|
||||
}
|
||||
|
||||
/**
|
||||
* parseVorlagetext() - will parse a Vorlagetext.
|
||||
*
|
||||
* @param string $text REQUIRED
|
||||
* @param array $data REQUIRED
|
||||
* @return string
|
||||
*/
|
||||
public function parseVorlagetext($text, $data = array())
|
||||
{
|
||||
if (isEmptyString($text)) return error('Not a valid text');
|
||||
|
||||
return $this->ci->parser->parse_string($text, $data, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user