mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-26 08:29:28 +00:00
- application/core/* -> CS compliant
- application/libraries/* -> CS compliant - FHC_Model isEntitled method now return error() or success() - Updated all code that uses isEntitled method from FHC_Model - Removed Squiz.PHP.DisallowSizeFunctionsInLoops from CS ruleset - Removed depracated method replace from DB_Model - Removed unused method pgArrayPhp from DB_Model - Renamed method arrayMergeIndex to _arrayCombine in DB_Model and set as private - Added method _manageUDFs to DB_Model (a wrapper for UDFLib->manageUDFs)
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Messaging Library for FH-Complete
|
||||
*/
|
||||
* Messaging Library for FH-Complete
|
||||
*/
|
||||
class MessageLib
|
||||
{
|
||||
const MSG_INDX_PREFIX = 'message_';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Get code igniter instance
|
||||
@@ -43,10 +46,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getMessage() - returns the spicified received message for a specified person
|
||||
*
|
||||
* @param string $msg_id REQUIRED
|
||||
* @param string $person_id REQUIRED
|
||||
* @return object
|
||||
*/
|
||||
public function getMessage($msg_id, $person_id)
|
||||
{
|
||||
@@ -62,9 +61,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
|
||||
*
|
||||
* @param string $uid REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
public function getMessagesByUID($uid, $all = false)
|
||||
{
|
||||
@@ -78,9 +74,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
|
||||
*
|
||||
* @param bigint $person_id REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
public function getMessagesByPerson($person_id, $all = false)
|
||||
{
|
||||
@@ -94,9 +87,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getSentMessagesByPerson() - Get all sent messages from a person identified by person_id
|
||||
*
|
||||
* @param bigint $person_id REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
public function getSentMessagesByPerson($person_id, $all = false)
|
||||
{
|
||||
@@ -110,9 +100,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getMessageByToken
|
||||
*
|
||||
* @param token string
|
||||
* @return array
|
||||
*/
|
||||
public function getMessageByToken($token)
|
||||
{
|
||||
@@ -156,9 +143,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* getCountUnreadMessages
|
||||
*
|
||||
* @param bigint $person_id REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
public function getCountUnreadMessages($person_id)
|
||||
{
|
||||
@@ -172,11 +156,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* updateMessageStatus() - will change status on message for particular user
|
||||
*
|
||||
* @param integer $msg_id REQUIRED
|
||||
* @param integer $user_id REQUIRED
|
||||
* @param integer $status_id REQUIRED - should come from config/message.php list of constants
|
||||
* @return array
|
||||
*/
|
||||
public function updateMessageStatus($message_id, $person_id, $status)
|
||||
{
|
||||
@@ -219,7 +198,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* sendMessage() - sends new internal message. This function will create a new thread
|
||||
*
|
||||
*/
|
||||
public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null, $multiPartMime = true)
|
||||
{
|
||||
@@ -270,7 +248,7 @@ class MessageLib
|
||||
$result = $this->_error('', MSG_ERR_SUBJECT_EMPTY);
|
||||
break;
|
||||
}
|
||||
else if (empty($body))
|
||||
elseif (empty($body))
|
||||
{
|
||||
$result = $this->_error('', MSG_ERR_BODY_EMPTY);
|
||||
break;
|
||||
@@ -295,13 +273,6 @@ class MessageLib
|
||||
|
||||
/**
|
||||
* sendMessageVorlage() - sends new internal message using a template
|
||||
*
|
||||
* @param integer $sender_id REQUIRED
|
||||
* @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
|
||||
* @param string $subject
|
||||
* @param string $body
|
||||
* @param integer $priority
|
||||
* @return array
|
||||
*/
|
||||
public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null, $multiPartMime = true)
|
||||
{
|
||||
@@ -375,19 +346,19 @@ class MessageLib
|
||||
$result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND);
|
||||
break;
|
||||
}
|
||||
else if (is_array($result->retval) && count($result->retval) > 0)
|
||||
elseif (is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
if (is_null($result->retval[0]->oe_kurzbz))
|
||||
{
|
||||
$result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND);
|
||||
break;
|
||||
}
|
||||
else if (empty($result->retval[0]->text))
|
||||
elseif (empty($result->retval[0]->text))
|
||||
{
|
||||
$result = $this->_error('', MSG_ERR_INVALID_TEMPLATE);
|
||||
break;
|
||||
}
|
||||
else if (empty($result->retval[0]->subject))
|
||||
elseif (empty($result->retval[0]->subject))
|
||||
{
|
||||
$result = $this->_error('', MSG_ERR_INVALID_TEMPLATE);
|
||||
break;
|
||||
@@ -453,7 +424,7 @@ class MessageLib
|
||||
// If the person has an email account
|
||||
if (!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '')
|
||||
{
|
||||
$href = $this->ci->config->item('message_server') . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
|
||||
$href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[0]->token;
|
||||
// Using a template for the html email body
|
||||
$body = $this->ci->parser->parse(
|
||||
'templates/mailHTML',
|
||||
@@ -533,10 +504,10 @@ class MessageLib
|
||||
$this->ci->loglib->logError('This person does not have an email account');
|
||||
// Writing errors in tbl_message_recipient
|
||||
$sme = $this->setMessageError(
|
||||
$result->retval[$i]->message_id,
|
||||
$result->retval[$i]->receiver_id,
|
||||
'This person does not have an email account',
|
||||
$result->retval[$i]->sentinfo
|
||||
$result->retval[$i]->message_id,
|
||||
$result->retval[$i]->receiver_id,
|
||||
'This person does not have an email account',
|
||||
$result->retval[$i]->sentinfo
|
||||
);
|
||||
if (!$sme)
|
||||
{
|
||||
@@ -570,10 +541,10 @@ class MessageLib
|
||||
|
||||
// Get a specific message from DB having EMAIL_KONTAKT_TYPE as relative contact type
|
||||
$result = $this->ci->RecipientModel->getMessages(
|
||||
EMAIL_KONTAKT_TYPE,
|
||||
null,
|
||||
null,
|
||||
$message_id
|
||||
EMAIL_KONTAKT_TYPE,
|
||||
null,
|
||||
null,
|
||||
$message_id
|
||||
);
|
||||
// Checks if errors were occurred
|
||||
if (isSuccess($result))
|
||||
@@ -588,7 +559,7 @@ class MessageLib
|
||||
if ($multiPartMime === true)
|
||||
{
|
||||
// Using a template for the html email body
|
||||
$href = $this->ci->config->item('message_server') . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
|
||||
$href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[0]->token;
|
||||
$bodyMsg = $this->ci->parser->parse(
|
||||
'templates/mailHTML',
|
||||
array(
|
||||
@@ -648,10 +619,10 @@ class MessageLib
|
||||
$this->ci->loglib->logError('Error while sending an email');
|
||||
// Writing errors in tbl_message_status
|
||||
$sme = $this->setMessageError(
|
||||
$result->retval[0]->message_id,
|
||||
$result->retval[0]->receiver_id,
|
||||
'Error while sending an email',
|
||||
$result->retval[0]->sentinfo
|
||||
$result->retval[0]->message_id,
|
||||
$result->retval[0]->receiver_id,
|
||||
'Error while sending an email',
|
||||
$result->retval[0]->sentinfo
|
||||
);
|
||||
if (!$sme)
|
||||
{
|
||||
@@ -674,10 +645,10 @@ class MessageLib
|
||||
$this->ci->loglib->logError('This person does not have an email account');
|
||||
// Writing errors in tbl_message_status
|
||||
$sme = $this->setMessageError(
|
||||
$result->retval[0]->message_id,
|
||||
$result->retval[0]->receiver_id,
|
||||
'This person does not have an email account',
|
||||
$result->retval[0]->sentinfo
|
||||
$result->retval[0]->message_id,
|
||||
$result->retval[0]->receiver_id,
|
||||
'This person does not have an email account',
|
||||
$result->retval[0]->sentinfo
|
||||
);
|
||||
if (!$sme)
|
||||
{
|
||||
@@ -702,8 +673,7 @@ class MessageLib
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Private Functions from here out!
|
||||
// ------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Update the table tbl_message_recipient
|
||||
@@ -740,7 +710,7 @@ class MessageLib
|
||||
{
|
||||
if (!is_null($prevSentInfo) && $prevSentInfo != '')
|
||||
{
|
||||
$sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo;
|
||||
$sentInfo = $prevSentInfo.SENT_INFO_NEWLINE.$sentInfo;
|
||||
}
|
||||
|
||||
$parameters = array('sent' => null, 'sentinfo' => $sentInfo);
|
||||
@@ -759,8 +729,8 @@ class MessageLib
|
||||
$this->ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid');
|
||||
// Get all the valid receivers id using the oe_kurzbz
|
||||
$receivers = $this->ci->BenutzerfunktionModel->loadWhere(
|
||||
'oe_kurzbz = \'' . $oe_kurzbz . '\''.
|
||||
' AND funktion_kurzbz = \'' . $this->ci->config->item('assistent_function') . '\'' .
|
||||
'oe_kurzbz = \''.$oe_kurzbz.'\''.
|
||||
' AND funktion_kurzbz = \''.$this->ci->config->item('assistent_function').'\''.
|
||||
' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))'
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user