Merge branch 'feature-3716/Messaging_inbox_outbox_user'

This commit is contained in:
Andreas Österreicher
2020-02-20 14:59:49 +01:00
83 changed files with 4886 additions and 3385 deletions
-87
View File
@@ -1,87 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Redirect extends FHC_Controller
{
/**
* API constructor
*/
public function __construct()
{
parent::__construct();
// Loads model MessageTokenModel
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
}
/**
* redirectByToken
*
* - Loads the message using a token
* - Loads the root of the organisation unit tree using the oe_kurzbz present in the message
* - Redirect to the aufnahme related to the found organisation unit
*/
public function redirectByToken($token)
{
$msg = $this->MessageTokenModel->getMessageByToken($token);
if (isError($msg))
{
show_error(getError($msg));
}
$oe_kurzbz = null;
if (hasData($msg)) $oe_kurzbz = getData($msg)[0]->oe_kurzbz;
if ($oe_kurzbz != null && $oe_kurzbz != '')
{
$organisationRoot = null;
$getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz);
if (isSuccess($getOERoot)) // If no errors occurred
{
$organisationRoot = getData($getOERoot);
}
else
{
show_error('No organisation unit present in the message');
}
$addonAufnahmeUrls = $this->config->item('message_redirect_url');
if(!isset($addonAufnahmeUrls[$organisationRoot]))
$organisationRoot = 'fallback';
if (isset($token)
&& hasData($msg)
&& is_array($addonAufnahmeUrls)
&& $organisationRoot != null
&& isset($addonAufnahmeUrls[$organisationRoot]))
{
redirect($addonAufnahmeUrls[$organisationRoot] . '?token=' . $token);
}
}
else
{
$addonAufnahmeUrls = $this->config->item('message_redirect_url');
if (isset($token)
&& hasData($msg)
&& is_array($addonAufnahmeUrls)
&& isset($addonAufnahmeUrls['fallback']))
{
redirect($addonAufnahmeUrls['fallback'] . '?token=' . $token);
}
}
}
}
-150
View File
@@ -1,150 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Handles sending messages with token
* NOTE: in this controller is not possible to include/call everything
* that automatically call the authentication system, like the most of models or libraries
*/
class ViewMessage extends FHC_Controller
{
/**
* API constructor
*/
public function __construct()
{
parent::__construct();
// Loading config file message
$this->config->load('message');
// Load model MessageToken_model, not calling the authentication system
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
$this->load->model('CL/Messages_model', 'CLMessagesModel');
}
/**
* Using the MessageTokenModel instead of MessageLib to allow
* viewing the message without prompting the login
*/
public function toHTML($token)
{
$msg = $this->MessageTokenModel->getMessageByToken($token);
if (isError($msg))
{
show_error(getError($msg));
}
if (is_array(getData($msg)) && count(getData($msg)) > 0)
{
$setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token);
if (isError($setReadMessageStatusByToken))
{
show_error(getError($setReadMessageStatusByToken));
}
$sender_id = getData($msg)[0]->sender_id;
$receiver_id = getData($msg)[0]->receiver_id;
$sender = $this->MessageTokenModel->getSenderData($sender_id);
// To decide how to change the redirection
$isEmployee = $this->MessageTokenModel->isEmployee($receiver_id);
if (isError($isEmployee))
{
show_error(getError($isEmployee));
}
if($this->config->item('redirect_view_message_url') != '')
$href = $this->config->item('message_server').$this->config->item('redirect_view_message_url').$token;
else
$href = '';
$data = array (
'sender_id' => $sender_id,
'sender' => getData($sender)[0],
'message' => getData($msg)[0],
'isEmployee' => hasData($isEmployee),
'href' => $href
);
$this->load->view('system/messages/messageHTML.php', $data);
}
}
/**
* write the reply
*/
public function writeReply()
{
$token = $this->input->get('token');
if (isEmptyString($token))
{
show_error('No token supplied');
}
$msg = null;
// Get message data if possible
$msg = $this->MessageTokenModel->getMessageByToken($token);
if (!hasData($msg))
{
show_error('No message found');
}
$msg = getData($msg)[0];
// Get variables
$receiverData = $this->MessageTokenModel->getPersonData($msg->sender_id);
if (!hasData($receiverData))
{
show_error('No sender found');
}
$data = array (
'receivers' => getData($receiverData),
'message' => $msg,
'token' => $token
);
$this->load->view('system/messages/messageWriteReply', $data);
}
/**
* Send a reply
*/
public function sendReply()
{
$subject = $this->input->post('subject');
$body = $this->input->post('body');
$persons = $this->input->post('persons');
$relationmessage_id = $this->input->post('relationmessage_id');
$token = $this->input->post('token');
if (!isset($relationmessage_id) || $relationmessage_id == '' || !isset($token) || $token == '')
{
show_error('Error while sending reply');
}
$sendReply = $this->CLMessagesModel->sendReply($subject, $body, $persons, $relationmessage_id, $token);
if (isError($sendReply))
{
show_error(getError($sendReply));
}
$this->load->view('system/messages/messageReplySent');
}
}
+267 -267
View File
@@ -1,267 +1,267 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Person extends APIv1_Controller
{
/**
* Person API constructor.
*/
public function __construct()
{
parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r'));
// Load model PersonModel
$this->load->model('person/person_model', 'PersonModel');
}
/**
* @return void
*/
public function getPerson()
{
$person_id = $this->get('person_id');
$code = $this->get('code');
$email = $this->get('email');
if (isset($code) || isset($email) || isset($person_id))
{
if (isset($code) && isset($email))
{
$result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email);
}
else
{
$parametersArray = array();
if (isset($code))
{
$parametersArray['zugangscode'] = $code;
}
else
{
$parametersArray['person_id'] = $person_id;
}
$result = $this->PersonModel->loadWhere($parametersArray);
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function getCheckBewerbung()
{
$email = $this->get('email');
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
if (isset($email))
{
$result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function postPerson()
{
$person = $this->post();
$validation = $this->_validate($person);
if (isSuccess($validation))
{
if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != ''))
{
$result = $this->PersonModel->updatePerson($person);
}
else
{
$result = $this->PersonModel->insert($person);
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response($validation, REST_Controller::HTTP_OK);
}
}
private function _validate($person)
{
// If $person is consistent
if (!isset($person) || (isset($person) && !is_array($person)))
{
return error('Any parameters posted');
}
// Trim all the values
foreach($person as $key => $value)
{
if (gettype($value) == 'string')
{
$person[$key] = trim($value);
}
}
if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16)
{
return error('Sprache darf nicht laenger als 16 Zeichen sein');
}
if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16)
{
return error('Anrede darf nicht laenger als 16 Zeichen sein');
}
if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32)
{
return error('Titelpost darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64)
{
return error('Titelpre darf nicht laenger als 64 Zeichen sein');
}
if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64)
{
return error('Nachname darf nicht laenger als 64 Zeichen sein');
}
if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname'])))
{
return error('Nachname muss eingegeben werden');
}
if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32)
{
return error('Vorname darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128)
{
return error('Vornamen darf nicht laenger als 128 Zeichen sein');
}
if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128)
{
return error('Geburtsort darf nicht laenger als 128 Zeichen sein');
}
if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256)
{
return error('Homepage darf nicht laenger als 256 Zeichen sein');
}
if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32)
{
return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10)
{
return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein');
}
if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1)
{
return error('Familienstand ist ungueltig');
}
if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
{
return error('Anzahl der Kinder ist ungueltig');
}
if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false))
{
return error('Aktiv ist ungueltig');
}
if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32)
{
return error('Insertvon darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32)
{
return error('Updatevon darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3)
{
return error('Geburtsnation darf nicht laenger als 3 Zeichen sein');
}
if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3)
{
return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein');
}
if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1))
{
return error('Geschlecht darf nicht laenger als 1 Zeichen sein');
}
if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
{
return error('Geschlecht muss w, m oder u sein!');
}
if (isset($person['svnr']))
{
if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16
&& mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10)
{
return error('SVNR muss 10, 12 oder 16 Zeichen lang sein');
}
if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12)
{
//SVNR mit Pruefziffer pruefen
//Die 4. Stelle in der SVNR ist die Pruefziffer
//(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer
//Falls nicht, ist die SVNR ungueltig
$gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6);
$erg = 0;
$tmpSvnr = substr($person['svnr'], 0, 10);
//Quersumme bilden
for ($i = 0; $i < 10; $i++)
{
$erg += $gewichtung[$i] * $tmpSvnr{$i};
}
if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11
{
return error('SVNR ist ungueltig');
}
if (mb_strlen($person['svnr']) == 12)
{
$last = substr($person['svnr'], 10, 12);
if ($last{0} != 'v' || !is_numeric($last{1}))
{
return error('SVNR ist ungueltig');
}
}
}
//Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt.
if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '')
{
if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum'])
&& !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum']))
{
return error('Format des Geburtsdatums ist ungueltig');
}
}
}
return success('Input data are valid');
}
}
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Person extends APIv1_Controller
{
/**
* Person API constructor.
*/
public function __construct()
{
parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r'));
// Load model PersonModel
$this->load->model('person/person_model', 'PersonModel');
}
/**
* @return void
*/
public function getPerson()
{
$person_id = $this->get('person_id');
$code = $this->get('code');
$email = $this->get('email');
if (isset($code) || isset($email) || isset($person_id))
{
if (isset($code) && isset($email))
{
$result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email);
}
else
{
$parametersArray = array();
if (isset($code))
{
$parametersArray['zugangscode'] = $code;
}
else
{
$parametersArray['person_id'] = $person_id;
}
$result = $this->PersonModel->loadWhere($parametersArray);
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function getCheckBewerbung()
{
$email = $this->get('email');
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
if (isset($email))
{
$result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function postPerson()
{
$person = $this->post();
$validation = $this->_validate($person);
if (isSuccess($validation))
{
if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != ''))
{
$result = $this->PersonModel->updatePerson($person);
}
else
{
$result = $this->PersonModel->insert($person);
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response($validation, REST_Controller::HTTP_OK);
}
}
private function _validate($person)
{
// If $person is consistent
if (!isset($person) || (isset($person) && !is_array($person)))
{
return error('Any parameters posted');
}
// Trim all the values
foreach($person as $key => $value)
{
if (gettype($value) == 'string')
{
$person[$key] = trim($value);
}
}
if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16)
{
return error('Sprache darf nicht laenger als 16 Zeichen sein');
}
if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16)
{
return error('Anrede darf nicht laenger als 16 Zeichen sein');
}
if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32)
{
return error('Titelpost darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64)
{
return error('Titelpre darf nicht laenger als 64 Zeichen sein');
}
if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64)
{
return error('Nachname darf nicht laenger als 64 Zeichen sein');
}
if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname'])))
{
return error('Nachname muss eingegeben werden');
}
if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32)
{
return error('Vorname darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128)
{
return error('Vornamen darf nicht laenger als 128 Zeichen sein');
}
if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128)
{
return error('Geburtsort darf nicht laenger als 128 Zeichen sein');
}
if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256)
{
return error('Homepage darf nicht laenger als 256 Zeichen sein');
}
if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32)
{
return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10)
{
return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein');
}
if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1)
{
return error('Familienstand ist ungueltig');
}
if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
{
return error('Anzahl der Kinder ist ungueltig');
}
if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false))
{
return error('Aktiv ist ungueltig');
}
if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32)
{
return error('Insertvon darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32)
{
return error('Updatevon darf nicht laenger als 32 Zeichen sein');
}
if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3)
{
return error('Geburtsnation darf nicht laenger als 3 Zeichen sein');
}
if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3)
{
return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein');
}
if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1))
{
return error('Geschlecht darf nicht laenger als 1 Zeichen sein');
}
if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
{
return error('Geschlecht muss w, m oder u sein!');
}
if (isset($person['svnr']))
{
if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16
&& mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10)
{
return error('SVNR muss 10, 12 oder 16 Zeichen lang sein');
}
if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12)
{
//SVNR mit Pruefziffer pruefen
//Die 4. Stelle in der SVNR ist die Pruefziffer
//(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer
//Falls nicht, ist die SVNR ungueltig
$gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6);
$erg = 0;
$tmpSvnr = substr($person['svnr'], 0, 10);
//Quersumme bilden
for ($i = 0; $i < 10; $i++)
{
$erg += $gewichtung[$i] * $tmpSvnr{$i};
}
if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11
{
return error('SVNR ist ungueltig');
}
if (mb_strlen($person['svnr']) == 12)
{
$last = substr($person['svnr'], 10, 12);
if ($last{0} != 'v' || !is_numeric($last{1}))
{
return error('SVNR ist ungueltig');
}
}
}
//Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt.
if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '')
{
if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum'])
&& !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum']))
{
return error('Format des Geburtsdatums ist ungueltig');
}
}
}
return success('Input data are valid');
}
}
@@ -144,26 +144,26 @@ class Message extends APIv1_Controller
*/
public function postMessage()
{
$validation = $this->_validatePostMessage($this->post());
$postMessage = $this->_validatePostMessage($this->post());
if (isSuccess($validation))
if (isSuccess($postMessage))
{
$result = $this->messagelib->sendMessage(
isset($this->post()['person_id']) ? $this->post()['person_id'] : null,
isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null,
$this->post()['subject'],
$this->post()['body'],
PRIORITY_NORMAL,
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null,
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true
$result = $this->messagelib->sendMessageUser(
$this->post()['receiver_id']), // receiverPersonId
$this->post()['subject'], // subject
$this->post()['body'], // body
$this->post()['person_id']) ? $this->post()['person_id'] : null, // sender_id
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id
MSG_PRIORITY_NORMAL, // priority
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime
);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response($validation, REST_Controller::HTTP_OK);
$this->response($postMessage, REST_Controller::HTTP_OK);
}
}
@@ -172,26 +172,27 @@ class Message extends APIv1_Controller
*/
public function postMessageVorlage()
{
$validation = $this->_validatePostMessageVorlage($this->post());
$postMessage = $this->_validatePostMessageVorlage($this->post());
if (isSuccess($validation))
if (isSuccess($postMessage))
{
$result = $this->messagelib->sendMessageVorlage(
isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null,
isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null,
$this->post()['vorlage_kurzbz'],
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit
$this->post()['data'],
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null,
isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null,
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true
$result = $this->messagelib->sendMessageUserTemplate(
isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, // receiversPersonId
$this->post()['vorlage_kurzbz'], // vorlage
$this->post()['data'], // parseData
isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null, // orgform
isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null, // sender_id
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id
MSG_PRIORITY_NORMAL, // priority
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime
);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response($validation, REST_Controller::HTTP_OK);
$this->response($postMessage, REST_Controller::HTTP_OK);
}
}
@@ -220,26 +221,26 @@ class Message extends APIv1_Controller
/**
* _validatePostMessage
*/
private function _validatePostMessage($message = null)
private function _validatePostMessage($post = null)
{
if (!isset($message))
if (!isset($post))
{
return error('Parameter is null');
}
if (!isset($message['subject']))
if (!isset($post['subject']))
{
return error('subject is not set');
}
if( !isset($message['body']))
if (!isset($post['body']))
{
return error('body is not set');
}
if (!isset($message['receiver_id']) && !isset($message['oe_kurzbz']))
if (!isset($post['receiver_id']))
{
return error('If a receiver_id is not given a oe_kurzbz must be specified');
return error('receiver_id is not set');
}
return success('Input data are valid');
return success();
}
/**
@@ -14,22 +14,25 @@
if (!defined("BASEPATH")) exit("No direct script access allowed");
class MailJob extends Auth_Controller
class MailJob extends CLI_Controller
{
/**
* API constructor
*/
public function __construct()
{
// An empty array as parameter will ensure that this controller is ONLY callable from command line
parent::__construct(array());
parent::__construct();
// Loads MessageLib
$this->load->library('MessageLib');
}
public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null)
/**
* Send all not sent messages
* Parameters are used to overrride messages and mail configuration
*/
public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null)
{
$this->messagelib->sendAll($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system);
$this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem);
}
}
@@ -1,191 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class FASMessages extends Auth_Controller
{
/**
*
*/
public function __construct()
{
parent::__construct(
array(
'write' => 'basis/message:rw',
'writeReply' => 'basis/message:rw'
)
);
// Loads the message library
$this->load->library('MessageLib');
// Loads the widget library
$this->load->library('WidgetLib');
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Write a new message
*/
public function write($sender_id)
{
$prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
if (!is_numeric($sender_id))
{
show_error('The current logged user person_id is not defined');
}
$msgVarsData = $this->_getMsgVarsData($prestudent_id);
// Retrieves message vars for a person from view view vw_msg_vars_person
$variablesArray = $this->_getMessageVarsPerson();
// Organisation units used to get the templates
$oe_kurzbz = $this->_getOeKurzbz($sender_id);
// Admin or commoner?
$isAdmin = $this->_getIsAdmin($sender_id);
$data = array(
'recipients' => getData($msgVarsData),
'variables' => $variablesArray,
'oe_kurzbz' => $oe_kurzbz, // used to get the templates
'isAdmin' => $isAdmin
);
$this->load->view('system/messages/messageWrite', $data);
}
/**
* Write a reply
*/
public function writeReply($sender_id, $msg_id, $receiver_id)
{
$prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
if (!is_numeric($sender_id))
{
show_error('The current logged user person_id is not defined');
}
if (!is_numeric($msg_id))
{
show_error('The msg_id must be a number');
}
if (!is_numeric($receiver_id))
{
show_error('The receiver_id must be a number');
}
$msg = $this->_getMessage($msg_id, $receiver_id);
$msgVarsData = $this->_getMsgVarsData($prestudent_id);
// Retrieves message vars for a person from view view vw_msg_vars_person
$variablesArray = $this->_getMessageVarsPerson();
// Organisation units used to get the templates
$oe_kurzbz = $this->_getOeKurzbz($sender_id);
// Admin or commoner?
$isAdmin = $this->_getIsAdmin($sender_id);
$data = array(
'recipients' => getData($msgVarsData),
'message' => $msg,
'variables' => $variablesArray,
'oe_kurzbz' => $oe_kurzbz, // used to get the templates
'isAdmin' => $isAdmin
);
$this->load->view('system/messages/messageWrite', $data);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
*
*/
private function _getMessage($msg_id, $receiver_id)
{
$msg = $this->messagelib->getMessage($msg_id, $receiver_id);
if (isError($msg))
{
show_error(getError($msg));
}
elseif (!hasData($msg))
{
show_error('The selected message does not exist');
}
else
{
$msg = getData($msg)[0];
}
return $msg;
}
/**
* Retrieves message vars from view vw_msg_vars
*/
private function _getMsgVarsData($prestudent_id)
{
$this->load->model('system/Message_model', 'MessageModel');
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if (isError($msgVarsData))
{
show_error(getError($msgVarsData));
}
return $msgVarsData;
}
/**
* Wrapper method to call messagelib->getMessageVarsPerson
*/
private function _getMessageVarsPerson()
{
$variables = $this->messagelib->getMessageVarsPerson();
if (isError($variables)) show_error(getError($variables));
return getData($variables);
}
/**
* Wrapper method to call messagelib->getOeKurzbz
*/
private function _getOeKurzbz($sender_id)
{
$oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id);
if (isError($oe_kurzbz)) show_error(getError($oe_kurzbz));
return getData($oe_kurzbz);
}
/**
* Wrapper method to call messagelib->getIsAdmin
*/
private function _getIsAdmin($sender_id)
{
$isAdmin = $this->messagelib->getIsAdmin($sender_id);
if (isError($isAdmin)) show_error(getError($isAdmin));
return getData($isAdmin);
}
}
-210
View File
@@ -1,210 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Messages extends Auth_Controller
{
/**
*
*/
public function __construct()
{
parent::__construct(
array(
'write' => array('basis/message:rw', 'infocenter:rw'),
'send' => array('basis/message:rw', 'infocenter:rw'),
'sendJson' => array('basis/message:rw', 'infocenter:rw'),
'getVorlage' => array('basis/message:r', 'infocenter:r'),
'parseMessageText' => array('basis/message:r', 'infocenter:r'),
'getMessageFromIds' => array('basis/message:r', 'infocenter:r')
)
);
// Loads the message library
$this->load->library('MessageLib');
// Loads the widget library
$this->load->library('WidgetLib');
$this->load->model('system/Message_model', 'MessageModel');
$this->load->model('CL/Messages_model', 'CLMessagesModel');
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Write a new message
*/
public function write()
{
$person_id = $this->input->post('person_id');
$sender_id = null;
$authUser = $this->CLMessagesModel->getAuthUser();
if (isError($authUser))
{
show_error(getError($authUser));
}
else
{
$sender_id = getData($authUser)[0]->person_id;
}
$msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
if (isError($msgVarsData)) show_error(getError($msgVarsData));
// Retrieves message vars for a person from view view vw_msg_vars_person
$variables = $this->messagelib->getMessageVarsPerson();
if (isError($variables)) show_error(getError($variables));
// Organisation units used to get the templates
$oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id);
if (isError($oe_kurzbz)) show_error(getError($oe_kurzbz));
// Admin or commoner?
$isAdmin = $this->messagelib->getIsAdmin($sender_id);
if (isError($isAdmin)) show_error(getError($isAdmin));
$data = array (
'recipients' => getData($msgVarsData),
'variables' => getData($variables),
'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates
'isAdmin' => getData($isAdmin)
);
$this->load->view('system/messages/messageWrite', $data);
}
/**
* Send message
*/
public function send()
{
$persons = $this->input->post('persons');
$relationmessage_id = $this->input->post('relationmessage_id');
$msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons);
$send = $this->CLMessagesModel->send($msgVarsData, $relationmessage_id);
$this->load->view('system/messages/messageSent', array('success' => isSuccess($send)));
}
/**
* Send message, response is in JSON format
*/
public function sendJson()
{
$prestudents = $this->input->post('prestudents');
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz');
$oe_kurzbz = $this->input->post('oe_kurzbz');
$msgVars = $this->input->post('msgvars');
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents);
// Adds the organisation unit to each prestudent
if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData))
{
$this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData);
}
$send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars);
if (isError($send))
{
$this->outputJsonError(getError($send));
}
else
{
$this->outputJsonSuccess(getData($send));
}
}
/**
* getVorlage
*/
public function getVorlage()
{
$vorlage_kurzbz = $this->input->get('vorlage_kurzbz');
$result = null;
if (!isEmptyString($vorlage_kurzbz))
{
$this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
$this->VorlagestudiengangModel->addOrder('version','DESC');
$result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz));
}
else
{
$result = error('The given vorlage_kurzbz is not valid');
}
if (isError($result) || !hasData($result))
{
$this->outputJsonError(getError($result));
}
else
{
$this->outputJsonSuccess(getData($result));
}
}
/**
* parseMessageText
*/
public function parseMessageText()
{
$person_id = $this->input->get('person_id');
$text = $this->input->get('text');
$parsedText = '';
$data = null;
if (is_numeric($person_id))
{
$data = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
}
else
{
$data = error('The given person_id is not a valid number');
}
if (isError($data) || !hasData($data))
{
$this->outputJsonError(getError($data));
}
else
{
$parsedText = $this->messagelib->parseMessageText($text, $this->CLMessagesModel->replaceKeys((array)getData($data)[0]));
$this->outputJsonSuccess($parsedText);
}
}
/**
* Outputs message data for a message (identified my msg id and receiver id) in JSON format
* @param $msg_id
* @param $receiver_id
*/
public function getMessageFromIds()
{
$msg_id = $this->input->get('msg_id');
$receiver_id = $this->input->get('receiver_id');
$msg = $this->messagelib->getMessage($msg_id, $receiver_id);
$this->output
->set_content_type('application/json')
->set_output(json_encode(array(getData($msg)[0])));
}
}
+1 -1
View File
@@ -269,7 +269,7 @@ class Vorlage extends Auth_Controller
show_error(getError($vorlagetext));
$data = array(
'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm)
'text' => parseText($vorlagetext->retval[0]->text, $jsonDecodedForm)
);
$this->load->view('system/vorlage/templatetextPreview', $data);
@@ -649,7 +649,7 @@ class InfoCenter extends Auth_Controller
public function reloadMessages($person_id)
{
$messages = $this->MessageModel->getMessagesOfPerson($person_id, 1);
$this->load->view('system/messages/messageList.php', array('messages' => $messages->retval));
$this->load->view('system/infocenter/messageList.php', array('messages' => $messages->retval));
}
/**
@@ -0,0 +1,60 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class FASMessages extends Auth_Controller
{
/**
*
*/
public function __construct()
{
parent::__construct(
array(
'writeTemplate' => 'basis/message:rw',
'writeReplyTemplate' => 'basis/message:rw'
)
);
// Loads model CLMessagesModel which contains the GUI logic
$this->load->model('CL/Messages_model', 'CLMessagesModel');
// Phrases used in loaded views
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
/**
* Writes a new message to a prestudent using templates
*/
public function writeTemplate()
{
$prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
// Loads the view to write a new message with a template
$this->load->view(
'system/messages/htmlWriteTemplate',
$this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents)
);
}
/**
* Writes a reply to a message identified by parameters $message_id and $recipient_id
* The recipient is a prestudent
* Uses templates
*/
public function writeReplyTemplate($message_id, $recipient_id)
{
$prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
// Loads the view to write a new message with a template
$this->load->view(
'system/messages/htmlWriteTemplate',
$this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents, $message_id, $recipient_id)
);
}
}
@@ -0,0 +1,112 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* NOTE: MessageClient extends FHC_Controller and NOT Auth_Controller to be able to use
* the authentication system without the need to load the permissions system
*/
class MessageClient extends FHC_Controller
{
public function __construct()
{
parent::__construct();
// Loads authentication library and starts authentication
// NOTE: it is loaded here because the controller extends FHC_Controller and NOT Auth_Controller
$this->load->library('AuthLib');
// Loads model CLMessagesModel which contains the GUI logic
$this->load->model('CL/Messages_model', 'CLMessagesModel');
// Phrases used in loaded views
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
/**
* Starts the GUI used to read all the personal messages
*/
public function read()
{
// Loads the view to read messages
$this->load->view('system/messages/ajaxRead');
}
/**
* Starts the GUI used to write a personal message to an organisation unit
*/
public function write()
{
// Loads the view to write a message
$this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite());
}
/**
* Starts the GUI used to reply to a received personal message
*/
public function writeReply()
{
$token = $this->input->get('token');
// Loads the view to reply to a message
$this->load->view('system/messages/ajaxWriteReply', $this->CLMessagesModel->prepareAjaxWriteReply($token));
}
/**
* Returns JSON that that contains all the received messages by the currently logged user
*/
public function listReceivedMessages()
{
$this->outputJson($this->CLMessagesModel->prepareAjaxReadReceived());
}
/**
* Returns JSON that that contains all the sent messages by the currently logged user
*/
public function listSentMessages()
{
$this->outputJson($this->CLMessagesModel->prepareAjaxReadSent());
}
/**
* Sends a message to an organisation unit
*/
public function sendMessageToOU()
{
$receiverOU = $this->input->post('receiverOU');
$subject = $this->input->post('subject');
$body = $this->input->post('body');
$this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body));
}
/**
* Sends a message to an organisation unit
*/
public function sendMessageReply()
{
$receiver_id = $this->input->post('receiver_id');
$relationmessage_id = $this->input->post('relationmessage_id');
$token = $this->input->post('token');
$subject = $this->input->post('subject');
$body = $this->input->post('body');
$this->outputJson($this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token));
}
/**
* Set a message as read
*/
public function setMessageRead()
{
$message_id = $this->input->post('message_id');
$statusPersonId = $this->input->post('statusPersonId');
$this->outputJson($this->CLMessagesModel->setMessageRead($message_id, $statusPersonId));
}
}
@@ -0,0 +1,144 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Messages extends Auth_Controller
{
public function __construct()
{
parent::__construct(
array(
'writeTemplate' => array('basis/message:rw', 'infocenter:rw'),
'sendImplicitTemplate' => array('basis/message:rw', 'infocenter:rw'),
'sendExplicitTemplateJson' => array('basis/message:rw', 'infocenter:rw'),
'getVorlage' => array('basis/message:r', 'infocenter:r'),
'parseMessageText' => array('basis/message:r', 'infocenter:r'),
'getMessageFromIds' => array('basis/message:r', 'infocenter:r')
)
);
// Loads model CLMessagesModel which contains the GUI logic
$this->load->model('CL/Messages_model', 'CLMessagesModel');
// Phrases used in loaded views
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
// -----------------------------------------------------------------------------------------------------------------
// Methods with HTML output
/**
* Initialize all the parameters used by view system/messages/htmlWriteTemplate
* to build a GUI used to write a messate to user/s using a template
*/
public function writeTemplate()
{
$persons = $this->input->post('person_id');
// Loads the view to write a new message with a template
$this->load->view(
'system/messages/htmlWriteTemplate',
$this->CLMessagesModel->prepareHtmlWriteTemplatePersons($persons)
);
}
/**
* Send a new message or reply to user/s
* If a relationmessage_id this message is a reply to another one
* Body is a template and will be parsed using information present in persons parameter
*/
public function sendImplicitTemplate()
{
$subject = $this->input->post('subject');
$body = $this->input->post('body');
$recipients_ids = $this->input->post('recipients_ids');
$relationmessage_id = $this->input->post('relationmessage_id');
$type = $this->input->post('type');
$sendImplicitTemplate = $this->CLMessagesModel->sendImplicitTemplate($type, $recipients_ids, $subject, $body, $relationmessage_id);
if (isSuccess($sendImplicitTemplate))
{
$this->load->view('system/messages/htmlMessageSentSuccess');
}
else
{
$this->load->view('system/messages/htmlMessageSentError');
}
}
// -----------------------------------------------------------------------------------------------------------------
// Methods with JSON output called by this controller and FASMessages (view system/messages/htmlWriteTemplate)
/**
* Returns an object that represent a template store in database
* If no templates are found with the given parameter or the given parameter is an empty string,
* then an error is returned
*/
public function getVorlage()
{
$vorlage_kurzbz = $this->input->get('vorlage_kurzbz');
$this->outputJson($this->CLMessagesModel->getVorlage($vorlage_kurzbz));
}
/**
* Parse the given given text using data from the given user
* Use the CI parser which performs simple text substitution for pseudo-variable
*/
public function parseMessageText()
{
$receiver_id = $this->input->get('receiver_id');
$text = $this->input->get('text');
$type = $this->input->get('type');
if ($type == Messages_model::TYPE_PERSONS)
{
$this->outputJson($this->CLMessagesModel->parseMessageTextPerson($receiver_id, $text));
}
elseif ($type == Messages_model::TYPE_PRESTUDENTS)
{
$this->outputJson($this->CLMessagesModel->parseMessageTextPrestudent($receiver_id, $text));
}
else
{
$this->outputJsonError('Not a person nor a prestudent was provided');
}
}
// -----------------------------------------------------------------------------------------------------------------
// Methods with JSON output called by infocenter
/**
* Outputs message data for a message (identified my msg id and receiver id) in JSON format
*/
public function getMessageFromIds()
{
$message_id = $this->input->get('msg_id');
$receiver_id = $this->input->get('receiver_id');
$this->outputJson($this->CLMessagesModel->getMessageFromIds($message_id, $receiver_id));
}
/**
* Send a new message
* - The recipients are prestudents
* - An email template with message var may be provided
* - A global organisation unit may be provided, otherwise is used the prestudent one
* - A template is explicitly specified
*/
public function sendExplicitTemplateJson()
{
$prestudents = $this->input->post('prestudents');
$oe_kurzbz = $this->input->post('oe_kurzbz');
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz');
$msgVars = $this->input->post('msgvars');
$sendExplicitTemplate = $this->CLMessagesModel->sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars);
$this->outputJson(getData($sendExplicitTemplate));
}
}
@@ -0,0 +1,134 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Handles sending messages with token
* NOTE: it extends FHC_Controller instead of Auth_Controller because authentication is not needed
*/
class ViewMessage extends FHC_Controller
{
public function __construct()
{
parent::__construct();
// Loading config file message
$this->config->load('message');
// Load model MessageToken_model, not calling the authentication system
$this->load->model('CL/Messages_model', 'CLMessagesModel');
// Phrases used in loaded views
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
/**
* Display a message in read mode only using the specified token
*/
public function toHTML($token)
{
// Loads the view to read a received message using its token as identifier
$this->load->view('system/messages/htmlRead', $this->CLMessagesModel->prepareHtmlRead($token));
}
/**
* Write a reply message to a received one using its token as identifier
*/
public function writeReply()
{
$token = $this->input->get('token'); // gets received message token
// Loads the view to write a reply message
$this->load->view('system/messages/htmlWriteReply', $this->CLMessagesModel->prepareHtmlWriteReply($token));
}
/**
* Send a reply message (no templates are used)
*/
public function sendReply()
{
$subject = $this->input->post('subject');
$body = $this->input->post('body');
$receiver_id = $this->input->post('receiver_id');
$relationmessage_id = $this->input->post('relationmessage_id');
$token = $this->input->post('token');
$sendReply = $this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token);
if (isSuccess($sendReply))
{
$this->load->view('system/messages/htmlMessageSentSuccess');
}
else
{
$this->load->view('system/messages/htmlMessageSentError');
}
}
/**
* With the given token redirects the user to reply page configured in the config/message.php file
*/
public function redirectByToken($token)
{
// Loads model MessageTokenModel
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
// Retrieves the single message data using the given token
$msg = $this->MessageTokenModel->getMessageByToken($token);
// If it is an error or it does not contain data show an error
if (!hasData($msg)) show_error('MSG-ERR-0001: An error occurred while redirecting, please contact the administrator');
// else
$oe_kurzbz = getData($msg)[0]->oe_kurzbz;
$organisationRoot = null; // by default is null
// If an organisation unit is present in the message tries to retrieve the root organisation unit
// from the one found in the message
if (!isEmptyString($oe_kurzbz))
{
// Retrieves the root organisation unit from the one found in the message
$getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz);
// If it is an error or it does not contain data show an error
if (!hasData($getOERoot)) show_error('MSG-ERR-0002: An error occurred while redirecting, please contact the administrator');
// else
$organisationRoot = getData($getOERoot)[0]->oe_kurzbz;
}
// Retrieves the possible redirecting URLs array from configs
$messageRedirectUrls = $this->config->item('message_redirect_url');
// If it is not a valid array then show an error
if (isEmptyArray($messageRedirectUrls)) show_error('MSG-ERR-0003: An error occurred while redirecting, please contact the administrator');
// If this organisation unit root is not configured as an entry in the possible redirecting URLs array,
// then tries to use the default one...
if (!isset($messageRedirectUrls[$organisationRoot]))
{
$organisationRoot = 'fallback';
// ...if even the default one is not present show an error
if (!isset($messageRedirectUrls[$organisationRoot]))
{
show_error('MSG-ERR-0004: An error occurred while redirecting, please contact the administrator');
}
}
// Finally if everything was right then the user can be redirected
redirect($messageRedirectUrls[$organisationRoot] . '?token=' . $token);
}
}