diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 7673a6d71..0ede1591d 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -21,6 +21,7 @@ class Messages_model extends CI_Model '; const NO_AUTH_UID = 'online'; // hard coded uid if no authentication is performed + const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent /** * Constructor @@ -86,7 +87,7 @@ class Messages_model extends CI_Model { $ouOptions .= sprintf( "\n".'', - is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : 'infocenter', + is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : self::ALT_OE, $ou->bezeichnung ); } @@ -182,7 +183,7 @@ class Messages_model extends CI_Model public function prepareAjaxReadSent() { // Retrieves sent messages from the logged user - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId(), self::ALT_OE); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 4d5e4b986..8f5dfa397 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -446,7 +446,7 @@ class Recipient_model extends DB_Model /** * Gets all the sent message by the given person */ - public function getSentMessages($person_id) + public function getSentMessages($person_id, $altOe = '') { $sql = 'SELECT mm.message_id, mm.relationmessage_id, @@ -464,7 +464,12 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - LEFT JOIN public.tbl_studiengang sg ON (sg.oe_kurzbz = mr.oe_kurzbz) + LEFT JOIN ( + SELECT oe_kurzbz, bezeichnung + FROM public.tbl_studiengang + UNION + SELECT ?, ? + ) sg ON (sg.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -481,6 +486,6 @@ class Recipient_model extends DB_Model mr.token ORDER BY mr.sent DESC'; - return $this->execQuery($sql, array($person_id)); + return $this->execQuery($sql, array($altOe, ucfirst($altOe), $person_id)); } }