- Renamed view system/messages/messageSent.php to system/messages/htmlSuccess.php

- Added new view system/messages/htmlError.php
- Renamed view system/messages/messageWrite.php to system/messages/htmlWriteTemplate.php
- Added new widget views: widgets/Dropdown_widget.php and widgets/MultipleDropdown_widget.php
- Added new CSS public/css/Widgets.css
- Controller system/FASMessages:
	- Renamed method write to writeTemplate and method writeReply to writeReplyTemplate
	- Removed all the private methods and moved all the logic to model CL/Messages_model
	- Methods writeTemplate and writeReplyTemplate do not need anymore the sender id as parameter
- Controller system/Messages:
	- Renamed method write to writeTemplate
	- Renamed method send to sendImplicitTemplate
	- Renamed method sendJson to sendExplicitTemplateJson
	- Moved all the logic to model CL/Messages_model
- Adapted php and JS code to use these new methods names and interfaces
- Removed public method getIsAdmin from MessageLib
- Method _sendMessage of MessageLib now returns the saved message ids
- Added new package olifolkerd/tabulator to composer
- Added new parameter widgets to view templates/FHC-Header.php
- Added new HTML widget widgets/Dropdown_widget and widgets/MultipleDropdown_widget
- Added constants REPLY_SUBJECT_PREFIX and REPLY_BODY_PREFIX to model CL/Messages_model
- Added new public methods prepareHtmlWriteTemplatePersons, prepareHtmlWriteTemplatePrestudents, sendImplicitTemplate, sendExplicitTemplate, getVorlage, parseMessageText and getMessageFromIds to model CL/Messages_model
- Added new private methods _getAuthUser, _lowerReplaceSpaceArrayKeys, _addOeToPrestudents, _personLog and _prepareHtmlWriteTemplate to model CL/Messages_model
This commit is contained in:
Paolo
2019-06-18 18:25:26 +02:00
parent 5bda5eb966
commit f6e0f58b3d
23 changed files with 802 additions and 613 deletions
+23 -154
View File
@@ -11,17 +11,15 @@ class FASMessages extends Auth_Controller
{
parent::__construct(
array(
'write' => 'basis/message:rw',
'writeReply' => 'basis/message:rw'
'writeTemplate' => 'basis/message:rw',
'writeReplyTemplate' => 'basis/message:rw'
)
);
// Loads the message library
$this->load->library('MessageLib');
// Loads the widget library
$this->load->library('WidgetLib');
// Loads model CLMessagesModel which contains the GUI logic
$this->load->model('CL/Messages_model', 'CLMessagesModel');
// Phrases used in loaded views
$this->loadPhrases(
array(
'global',
@@ -30,162 +28,33 @@ class FASMessages extends Auth_Controller
);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Write a new message
* Writes a new message to a prestudent using templates
*/
public function write($sender_id)
public function writeTemplate()
{
$prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
$prestudents = $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);
// Loads the view to write a new message with a template
$this->load->view(
'system/messages/htmlWriteTemplate',
$this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents)
);
}
/**
* Write a reply
* Writes a reply to a message identified by parameters $message_id and $recipient_id
* The recipient is a prestudent
* Uses templates
*/
public function writeReply($sender_id, $msg_id, $receiver_id)
public function writeReplyTemplate($message_id, $recipient_id)
{
$prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s)
$prestudents = $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);
// 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)
);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
*
*/
private function _getMessage($msg_id, $receiver_id)
{
$msg = $this->messagelib->getMessage($msg_id, $receiver_id);
if (isError($msg))
{
show_error(getData($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(getData($msgVarsData));
}
return $msgVarsData;
}
/**
* Wrapper method to call messagelib->getMessageVarsPerson
*/
private function _getMessageVarsPerson()
{
$variables = $this->messagelib->getMessageVarsPerson();
if (isError($variables)) show_error(getData($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(getData($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(getData($isAdmin));
return getData($isAdmin);
}
}