mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
Changed logic to send notice email to a message recipient
This commit is contained in:
@@ -21,7 +21,6 @@ class Messages_model extends CI_Model
|
||||
</blockquote>';
|
||||
|
||||
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
|
||||
|
||||
// Recipients types
|
||||
const TYPE_PERSONS = 'persons';
|
||||
@@ -91,7 +90,7 @@ class Messages_model extends CI_Model
|
||||
{
|
||||
$ouOptions .= sprintf(
|
||||
"\n".'<option value="%s">%s</option>',
|
||||
is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : self::ALT_OE,
|
||||
is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : MessageLib::ALT_OE,
|
||||
$ou->bezeichnung . (is_numeric($ou->prestudent_id) ? '' : ' *')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,4 +18,19 @@ class Benutzer_model extends DB_Model
|
||||
return $this->loadWhere(array('person_id' => $person_id, 'aktiv' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getActiveUserByPersonIdAndOrganisationUnit($person_id, $oe_kurzbz)
|
||||
{
|
||||
$sql = 'SELECT b.uid
|
||||
FROM public.tbl_benutzer b
|
||||
JOIN public.tbl_prestudent ps USING (person_id)
|
||||
JOIN public.tbl_studiengang sg USING (studiengang_kz)
|
||||
WHERE ps.person_id = ?
|
||||
AND sg.oe_kurzbz = ?
|
||||
AND b.aktiv = TRUE';
|
||||
|
||||
return $this->execQuery($sql, array($person_id, $oe_kurzbz));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ class Kontakt_model extends DB_Model
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = "public.tbl_kontakt";
|
||||
$this->pk = "kontakt_id";
|
||||
$this->dbTable = 'public.tbl_kontakt';
|
||||
$this->pk = 'kontakt_id';
|
||||
}
|
||||
|
||||
|
||||
public function getWholeKontakt($kontakt_id, $person_id = null, $kontakttyp = null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
$this->addJoin("public.tbl_standort", "standort_id", "LEFT");
|
||||
$this->addJoin("public.tbl_firma", "firma_id", "LEFT");
|
||||
|
||||
|
||||
$this->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
$this->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
|
||||
if (isset($kontakt_id))
|
||||
{
|
||||
$result = $this->load($kontakt_id);
|
||||
@@ -26,22 +26,37 @@ class Kontakt_model extends DB_Model
|
||||
else
|
||||
{
|
||||
$parametersArray = array();
|
||||
|
||||
|
||||
if (!is_null($person_id))
|
||||
{
|
||||
$parametersArray["person_id"] = $person_id;
|
||||
$parametersArray['person_id'] = $person_id;
|
||||
}
|
||||
if (!is_null($kontakttyp))
|
||||
{
|
||||
$parametersArray["kontakttyp"] = $kontakttyp;
|
||||
$parametersArray['kontakttyp'] = $kontakttyp;
|
||||
}
|
||||
|
||||
|
||||
if (count($parametersArray) > 0)
|
||||
{
|
||||
$result = $this->loadWhere($parametersArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getContactByPersonId($person_id, $kontakttyp)
|
||||
{
|
||||
$sql = 'SELECT kontakt
|
||||
FROM public.tbl_kontakt
|
||||
WHERE zustellung = TRUE
|
||||
AND person_id = ?
|
||||
AND kontakttyp = ?
|
||||
ORDER BY updateamum, insertamum';
|
||||
|
||||
return $this->execQuery($sql, array($person_id, $kontakttyp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,71 +378,6 @@ class Recipient_model extends DB_Model
|
||||
return $this->execQuery($sql, array($person_id, $functions, $person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the messages to sent to an organisation unit
|
||||
*/
|
||||
public function getMessagesToSentToOE($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 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
|
||||
*/
|
||||
@@ -483,4 +418,27 @@ class Recipient_model extends DB_Model
|
||||
|
||||
return $this->execQuery($sql, array($person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getMessageById($message_id)
|
||||
{
|
||||
$sql = 'SELECT mm.message_id,
|
||||
mm.person_id AS sender_id,
|
||||
mm.subject,
|
||||
mm.body,
|
||||
mm.relationmessage_id,
|
||||
mm.oe_kurzbz AS sender_ou,
|
||||
mr.person_id AS receiver_id,
|
||||
mr.token,
|
||||
mr.sent,
|
||||
mr.sentinfo,
|
||||
mr.oe_kurzbz AS receiver_ou
|
||||
FROM public.tbl_msg_message mm
|
||||
JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id)
|
||||
WHERE mm.message_id = ?';
|
||||
|
||||
return $this->execQuery($sql, array($message_id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user