If a message is sent from:

- An organization unit: when opened via token then the organization unit is displayed as sender and no answer button is displayed
- The system sender: when opened via token then it is displayed as sender: "System sender"
This commit is contained in:
Paolo
2022-09-06 14:24:42 +02:00
parent 075e8ede0a
commit 10ce6128de
2 changed files with 28 additions and 9 deletions
+27 -8
View File
@@ -50,6 +50,8 @@ class Messages_model extends CI_Model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
// Loads model Benutzer_model
$this->load->model('person/Benutzer_model', 'BenutzerModel');
// Loads model Studiengang_model
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
}
@@ -280,18 +282,35 @@ class Messages_model extends CI_Model
$srmsbtResult = $this->MessageTokenModel->setReadMessageStatusByToken($token);
if (isError($srmsbtResult)) show_error(getError($srmsbtResult));
// Retrieves message sender information
$senderResult = $this->MessageTokenModel->getSenderData($message->sender_id);
if (isError($senderResult)) show_error(getError($senderResult));
if (!hasData($senderResult)) show_error('No sender information found');
// Sender name
$sender = 'System sender'; // default fallback
$sender = getData($senderResult)[0]; // Found sender data
// If the sender is a person
if (isEmptyString($message->oe_kurzbz))
{
// And if this person is not the system sender
if ($message->sender_id != $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID))
{
// Retrieves message sender information
$senderResult = $this->MessageTokenModel->getSenderData($message->sender_id);
if (isError($senderResult)) show_error(getError($senderResult));
if (!hasData($senderResult)) show_error('No sender information found');
// If the sender is not the system sender and the receiver is not the system sender
// and are present configurations to reply
$sender = getData($senderResult)[0]->vorname.' '.getData($senderResult)[0]->nachname;
}
}
else // otherwise if the sender is an organization unit (degree program)
{
$ouResult = $this->StudiengangModel->loadWhere(array('oe_kurzbz' => $message->oe_kurzbz));
if (isError($ouResult)) show_error(getError($ouResult));
if (!hasData($ouResult)) show_error('No organization unit information found');
$sender = getData($ouResult)[0]->bezeichnung;
}
// If the sender is not the system sender and configurations to reply exist
$hrefReply = '';
if ($message->sender_id != $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)
&& $message->receiver_id != $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)
&& !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL)))
{
$hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER).
@@ -44,7 +44,7 @@
</td>
<td>
<?php echo $sender->vorname.' '.$sender->nachname; ?>
<?php echo $sender; ?>
</td>
</tr>