mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
- Reply Button in Inbox/outbox Page
- Write new message Button with Layer/Popup - Degree Programs drop down displays longer name (if prestudent bestätigt (alias interessent with bestaetigtam != null ) receiver-> dp, otherwise -> infocenter) - SQL to get OU recipient doesn't use beginn / End of function - Always set insertvon in tbl_msg_status - Add Multilanguage Support for Message Page (not completed yet) - If in sent mode do not set messages as read - Error message when there are no Messages available shouldnt be displayed
This commit is contained in:
@@ -62,7 +62,8 @@ class Messages_model extends CI_Model
|
||||
$statusData = array(
|
||||
'message_id' => $message_id,
|
||||
'person_id' => $person_id,
|
||||
'status' => MSG_STATUS_READ
|
||||
'status' => MSG_STATUS_READ,
|
||||
'insertvon' => getAuthUID()
|
||||
);
|
||||
|
||||
return $this->MsgStatusModel->insert($statusData); // insert and return result
|
||||
@@ -83,25 +84,61 @@ class Messages_model extends CI_Model
|
||||
{
|
||||
foreach (getData($ouResult) as $ou)
|
||||
{
|
||||
$ouOptions .= sprintf("\n".'<option value="%s">%s</option>', $ou->oe_kurzbz, $ou->bezeichnung);
|
||||
$ouOptions .= sprintf(
|
||||
"\n".'<option value="%s">%s</option>',
|
||||
is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : 'infocenter',
|
||||
$ou->bezeichnung
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array('organisationUnitOptions' => $ouOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares data for the view system/messages/ajaxWriteReply
|
||||
*/
|
||||
public function prepareAjaxWriteReply($token)
|
||||
{
|
||||
if (isEmptyString($token)) show_error('The given token is not valid');
|
||||
|
||||
// Retrieves message using the given token
|
||||
$messageResult = $this->MessageTokenModel->getMessageByToken($token);
|
||||
if (isError($messageResult)) show_error('An error occurred while loading this page, please contact the site administrator');
|
||||
|
||||
if (hasData($messageResult))
|
||||
{
|
||||
$message = getData($messageResult)[0]; // Found message data
|
||||
|
||||
// Retrieves message sender information
|
||||
$senderResult = $this->MessageTokenModel->getSenderData($message->sender_id);
|
||||
if (isError($senderResult)) show_error('An error occurred while loading this page, please contact the site administrator');
|
||||
|
||||
if (hasData($senderResult))
|
||||
{
|
||||
$sender = getData($senderResult)[0]; // Found sender data
|
||||
|
||||
$replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject;
|
||||
$replyBody = $this->_getReplyBody($message->body, $sender->vorname, $sender->nachname, $message->sent);
|
||||
|
||||
return array (
|
||||
'receiver' => $sender->vorname.' '.$sender->nachname, // yep! the sender of the sent message is the receiver of the reply message
|
||||
'subject' => $replySubject,
|
||||
'body' => $replyBody,
|
||||
'receiver_id' => $message->sender_id,
|
||||
'relationmessage_id' => $message->message_id,
|
||||
'token' => $token
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares data for the view system/messages/ajaxRead
|
||||
* If everything is fine returns a list of received messages (objects)
|
||||
*/
|
||||
public function prepareAjaxReadReceived()
|
||||
{
|
||||
// Name and surname of the logged user
|
||||
$loggedUserName = getAuthFirstname().' '.getAuthSurname();
|
||||
|
||||
// If empty then use a hard coded one
|
||||
if (isEmptyString($loggedUserName)) $loggedUserName = 'Me';
|
||||
|
||||
// Retrieves received messages for the logged user and its organisation units
|
||||
$receivedMessagesResult = $this->RecipientModel->getReceivedMessages(
|
||||
getAuthPersonId(),
|
||||
@@ -127,6 +164,7 @@ class Messages_model extends CI_Model
|
||||
$jsonRecord->sent = $sentDate->format('d/m/Y H:i:s');
|
||||
$jsonRecord->status = $receivedMessage->status;
|
||||
$jsonRecord->statusPersonId = $receivedMessage->statuspersonid;
|
||||
$jsonRecord->token = $receivedMessage->token;
|
||||
|
||||
$jsonArray[] = $jsonRecord;
|
||||
}
|
||||
@@ -143,12 +181,6 @@ class Messages_model extends CI_Model
|
||||
*/
|
||||
public function prepareAjaxReadSent()
|
||||
{
|
||||
// Name and surname of the logged user
|
||||
$loggedUserName = getAuthFirstname().' '.getAuthSurname();
|
||||
|
||||
// If empty then use a hard coded one
|
||||
if (isEmptyString($loggedUserName)) $loggedUserName = 'Me';
|
||||
|
||||
// Retrieves sent messages from the logged user
|
||||
$sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId());
|
||||
if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it
|
||||
@@ -164,11 +196,20 @@ class Messages_model extends CI_Model
|
||||
$jsonRecord->message_id = $sentMessage->message_id;
|
||||
$jsonRecord->subject = $sentMessage->subject;
|
||||
$jsonRecord->body = $sentMessage->body;
|
||||
$jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname;
|
||||
$sentDate = new DateTime($sentMessage->sent);
|
||||
$jsonRecord->sent = $sentDate->format('d/m/Y H:i:s');
|
||||
$jsonRecord->status = $sentMessage->status;
|
||||
$jsonRecord->statusPersonId = $sentMessage->statuspersonid;
|
||||
$jsonRecord->token = $sentMessage->token;
|
||||
|
||||
if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID))
|
||||
{
|
||||
$jsonRecord->to = $sentMessage->sg;
|
||||
}
|
||||
else
|
||||
{
|
||||
$jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname;
|
||||
}
|
||||
|
||||
$jsonArray[] = $jsonRecord;
|
||||
}
|
||||
|
||||
@@ -529,13 +529,23 @@ class Prestudent_model extends DB_Model
|
||||
*/
|
||||
public function getOrganisationunitsByPersonId($person_id)
|
||||
{
|
||||
$query = 'SELECT o.oe_kurzbz, o.bezeichnung
|
||||
$query = 'SELECT o.oe_kurzbz,
|
||||
sg.bezeichnung,
|
||||
ps.prestudent_id
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN public.tbl_studiengang s USING(studiengang_kz)
|
||||
JOIN public.tbl_studiengang sg USING(studiengang_kz)
|
||||
JOIN public.tbl_organisationseinheit o USING(oe_kurzbz)
|
||||
LEFT JOIN (
|
||||
SELECT prestudent_id
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE bestaetigtam IS NOT NULL
|
||||
AND status_kurzbz = \'Interessent\'
|
||||
) ps USING(prestudent_id)
|
||||
WHERE p.person_id = ?
|
||||
GROUP BY o.oe_kurzbz, o.bezeichnung
|
||||
ORDER BY o.bezeichnung';
|
||||
GROUP BY o.oe_kurzbz,
|
||||
sg.bezeichnung,
|
||||
ps.prestudent_id
|
||||
ORDER BY sg.bezeichnung';
|
||||
|
||||
return $this->execQuery($query, array($person_id));
|
||||
}
|
||||
|
||||
@@ -57,11 +57,13 @@ class Recipient_model extends DB_Model
|
||||
m.oe_kurzbz,
|
||||
s.status,
|
||||
s.statusinfo,
|
||||
s.insertamum as statusamum
|
||||
s.insertamum as statusamum,
|
||||
b.uid
|
||||
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
|
||||
JOIN (
|
||||
SELECT * FROM public.tbl_msg_status WHERE status < ? ORDER BY insertamum DESC, status DESC
|
||||
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
|
||||
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id),
|
||||
LEFT JOIN public.tbl_benutzer b USING(person_id)
|
||||
WHERE r.token = ?
|
||||
LIMIT 1';
|
||||
|
||||
@@ -217,7 +219,8 @@ class Recipient_model extends DB_Model
|
||||
mr.token,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sentinfo
|
||||
mr.sentinfo,
|
||||
mr.oe_kurzbz
|
||||
FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id)
|
||||
LEFT JOIN (
|
||||
SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ?
|
||||
@@ -315,11 +318,12 @@ class Recipient_model extends DB_Model
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
MAX(ms.status) AS status,
|
||||
ms.person_id AS statusPersonId
|
||||
ms.person_id AS statusPersonId,
|
||||
mr.token
|
||||
FROM public.tbl_msg_recipient mr
|
||||
JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id)
|
||||
JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id)
|
||||
JOIN public.tbl_person p ON (p.person_id = mr.person_id)
|
||||
JOIN public.tbl_person p ON (p.person_id = mm.person_id)
|
||||
WHERE mr.person_id = ?
|
||||
AND mr.sent IS NOT NULL
|
||||
AND mr.sentinfo IS NULL
|
||||
@@ -330,7 +334,8 @@ class Recipient_model extends DB_Model
|
||||
mr.sent,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
ms.person_id
|
||||
ms.person_id,
|
||||
mr.token
|
||||
UNION
|
||||
-- Messages sent to a person that belongs to the recipient organisation unit
|
||||
SELECT mrou.message_id,
|
||||
@@ -341,14 +346,21 @@ class Recipient_model extends DB_Model
|
||||
pr.vorname,
|
||||
pr.nachname,
|
||||
MAX(ms.status) AS status,
|
||||
ms.person_id AS statusPersonId
|
||||
ms.person_id AS statusPersonId,
|
||||
mrou.token
|
||||
FROM public.tbl_person p
|
||||
JOIN public.tbl_benutzer b ON (b.person_id = p.person_id)
|
||||
JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid)
|
||||
JOIN (
|
||||
SELECT uid, oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND funktion_kurzbz IN ?
|
||||
) bf ON (bf.uid = b.uid)
|
||||
JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz)
|
||||
JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id)
|
||||
JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id)
|
||||
JOIN public.tbl_person pr ON (pr.person_id = mrou.person_id)
|
||||
JOIN public.tbl_person pr ON (pr.person_id = mm.person_id)
|
||||
WHERE p.person_id = ?
|
||||
AND mrou.sent IS NOT NULL
|
||||
AND mrou.sentinfo IS NULL
|
||||
@@ -359,12 +371,78 @@ class Recipient_model extends DB_Model
|
||||
mrou.sent,
|
||||
pr.vorname,
|
||||
pr.nachname,
|
||||
ms.person_id
|
||||
ms.person_id,
|
||||
mrou.token
|
||||
ORDER BY sent DESC';
|
||||
|
||||
return $this->execQuery($sql, array($person_id, $functions, $person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the recieved messages from an organisation unit where this person plays a role given by the parameter functions
|
||||
*/
|
||||
public function getReceivedMessagesByOE($oe_kurzbz, $functions, $kontaktType)
|
||||
{
|
||||
// Messages sent to a person that belongs to the recipient organisation unit
|
||||
$sql = 'SELECT mm.message_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mrou.person_id as receiver_id,
|
||||
mrou.sentinfo,
|
||||
mrou.token,
|
||||
mrou.oe_kurzbz,
|
||||
ks.kontakt as sender,
|
||||
kr.kontakt as receiver,
|
||||
mu.mitarbeiter_uid as employeeContact,
|
||||
mb.mitarbeiter_uid as senderemployeeContact
|
||||
FROM public.tbl_benutzer b
|
||||
JOIN (
|
||||
SELECT uid, oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND funktion_kurzbz IN ?
|
||||
) bf ON (bf.uid = b.uid)
|
||||
JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz)
|
||||
JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id)
|
||||
JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id)
|
||||
JOIN public.tbl_person pr ON (pr.person_id = mm.person_id)
|
||||
LEFT JOIN (
|
||||
SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ?
|
||||
) ks ON (ks.person_id = mm.person_id)
|
||||
LEFT JOIN (
|
||||
SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ?
|
||||
) kr ON (kr.person_id = mrou.person_id)
|
||||
LEFT JOIN (
|
||||
SELECT b.person_id,
|
||||
m.mitarbeiter_uid
|
||||
FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE b.aktiv = TRUE
|
||||
) mu ON (mu.person_id = mrou.person_id)
|
||||
LEFT JOIN (
|
||||
SELECT b.person_id,
|
||||
m.mitarbeiter_uid
|
||||
FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE b.aktiv = TRUE
|
||||
) mb ON (mb.person_id = mm.person_id)
|
||||
WHERE bf.oe_kurzbz = ?
|
||||
AND mrou.sent IS NULL
|
||||
AND mrou.sentinfo IS NOT NULL
|
||||
GROUP BY mm.message_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mrou.person_id,
|
||||
mrou.sentinfo,
|
||||
mrou.token,
|
||||
mrou.oe_kurzbz,
|
||||
ks.kontakt,
|
||||
kr.kontakt,
|
||||
mu.mitarbeiter_uid,
|
||||
mb.mitarbeiter_uid';
|
||||
|
||||
return $this->execQuery($sql, array($functions, $kontaktType, $kontaktType, $oe_kurzbz));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the sent message by the given person
|
||||
*/
|
||||
@@ -375,14 +453,18 @@ class Recipient_model extends DB_Model
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sent,
|
||||
p.person_id,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
MAX(ms.status) AS status,
|
||||
ms.person_id AS statusPersonId
|
||||
ms.person_id AS statusPersonId,
|
||||
sg.bezeichnung AS sg,
|
||||
mr.token
|
||||
FROM public.tbl_msg_message mm
|
||||
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)
|
||||
WHERE mm.person_id = ?
|
||||
AND mr.sent IS NOT NULL
|
||||
AND mr.sentinfo IS NULL
|
||||
@@ -391,9 +473,12 @@ class Recipient_model extends DB_Model
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mr.sent,
|
||||
p.person_id,
|
||||
p.vorname,
|
||||
p.nachname,
|
||||
ms.person_id
|
||||
ms.person_id,
|
||||
sg.bezeichnung,
|
||||
mr.token
|
||||
ORDER BY mr.sent DESC';
|
||||
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
|
||||
Reference in New Issue
Block a user