From 306da46c80906dc4d9b8c390575be69016b81d87 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 25 Jan 2019 17:16:57 +0100 Subject: [PATCH 01/19] - Removed messagelink from controller system/infocenter/InfoCenter.php - Improved MessageLib - Added method getMessageVarsPerson to MessageLib - Moved JS from views/system/messageWrite.php to public/js/messaging/messageWrite.js - Added new controller controllers/system/FASMessages.php - Adapted content/fasoverlay.js.php and content/messages.js.php to use FASMessages --- .../controllers/system/FASMessages.php | 117 +++++ application/controllers/system/Messages.php | 238 +++++------ .../system/infocenter/InfoCenter.php | 5 +- application/libraries/MessageLib.php | 43 +- .../views/system/infocenter/stammdaten.php | 13 +- application/views/system/messageWrite.php | 404 ++++++------------ content/fasoverlay.js.php | 2 +- content/messages.js.php | 6 +- .../js/infocenter/infocenterPersonDataset.js | 2 +- public/js/messaging/messageWrite.js | 127 ++++++ 10 files changed, 530 insertions(+), 427 deletions(-) create mode 100644 application/controllers/system/FASMessages.php create mode 100644 public/js/messaging/messageWrite.js diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/FASMessages.php new file mode 100644 index 000000000..29a9a2a31 --- /dev/null +++ b/application/controllers/system/FASMessages.php @@ -0,0 +1,117 @@ + 'basis/message:rw' + ) + ); + + // 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('person/Person_model', 'PersonModel'); + + $this->loadPhrases( + array( + 'global', + 'ui' + ) + ); + } + + /** + * Write + */ + public function write($sender_id = null, $msg_id = null, $receiver_id = null) + { + $prestudent_id = $this->input->post('prestudent_id'); + $oe_kurzbz = array(); // a person may belongs to more organisation units + $msg = null; + + if (!is_numeric($sender_id)) + { + $personByUID = $this->PersonModel->getByUid(getAuthUID()); + + if (isError($personByUID) || !hasData($personByUID)) + { + show_error($personByUID->retval); + } + else + { + $sender_id = $personByUID->retval[0]->person_id; + } + } + + // Get message data if possible + if (is_numeric($msg_id) && is_numeric($receiver_id)) + { + $msg = $this->messagelib->getMessage($msg_id, $receiver_id); + if (isError($msg) || !hasData($msg)) + { + show_error($msg->retval); + } + else + { + $msg = $msg->retval[0]; + } + } + + // Retrieves message vars from view vw_msg_vars + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + if (isError($msgVarsData)) + { + show_error($msgVarsData->retval); + } + + // Retrieves message vars for a person from view view vw_msg_vars_person + $variablesArray = $this->messagelib->getMessageVarsPerson(); + + // Organisation units used to get the templates + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id); + if (isError($benutzerResult)) + { + show_error($benutzerResult->retval); + } + elseif (hasData($benutzerResult)) + { + foreach ($benutzerResult->retval as $val) + { + $oe_kurzbz[] = $val->oe_kurzbz; + } + } + + // Admin or commoner? + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id); + if (isError($isAdmin)) + { + show_error($isAdmin->retval); + } + + $data = array ( + 'sender_id' => $sender_id, + 'receivers' => $msgVarsData->retval, + 'message' => $msg, + 'variables' => $variablesArray, + 'oe_kurzbz' => $oe_kurzbz, // used to get the templates + 'isAdmin' => $isAdmin->retval, + 'personOnly' => false // indicates if sent only to persons + ); + + $this->load->view('system/messageWrite', $data); + } +} diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index d197f8458..27c029d20 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -4,8 +4,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends Auth_Controller { - private $uid; // contains the UID of the logged user - /** * */ @@ -28,43 +26,37 @@ class Messages extends Auth_Controller // Loads the widget library $this->load->library('WidgetLib'); + $this->load->model('system/Message_model', 'MessageModel'); $this->load->model('person/Person_model', 'PersonModel'); $this->loadPhrases( array( 'global', - 'person', - 'lehre', - 'ui', - 'infocenter' + 'ui' ) ); - - $this->_setAuthUID(); // sets property uid } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + /** - * write + * Write */ - public function write($sender_id = null, $msg_id = null, $receiver_id = null) + public function write() { - if ($sender_id === null) + $sender_id = null; + $recipients = $this->input->post('person_id'); + + $authUser = $this->PersonModel->getByUid(getAuthUID()); + if (isError($authUser)) { - $user_person = $this->PersonModel->getByUid($this->uid); - - if (isError($user_person)) - { - show_error($user_person->retval); - } - $sender_id = $user_person->retval[0]->person_id; + show_error($authUser->retval); + } + elseif (hasData($authUser)) + { + $sender_id = $authUser->retval[0]->person_id; } - - $prestudent_id = $this->input->post('prestudent_id'); - $person_id = $this->input->post('person_id'); - $personOnly = false; - - if (isset($person_id) && !isset($prestudent_id)) - $personOnly = true; $msg = null; @@ -87,10 +79,8 @@ class Messages extends Auth_Controller // Get variables $this->load->model('system/Message_model', 'MessageModel'); - if ($personOnly === true) - $this->getPersonMsgData($person_id, $variablesArray, $msgVarsData); - else - $this->getPrestudentMsgData($prestudent_id, $variablesArray, $msgVarsData); + + $this->getPersonMsgData($person_id, $variablesArray, $msgVarsData); // Organisation units used to get the templates $oe_kurzbz = array(); // A person can have more organisation units @@ -122,69 +112,7 @@ class Messages extends Auth_Controller 'personOnly' => $personOnly//indicates if sent only to persons ); - $v = $this->load->view('system/messageWrite', $data); - } - - /** - * gets Message Variables and their data for Prestudent - * @param $prestudent_id - * @param $variablesArray to be filled with variable names - * @param $msgVarsData to be filled with variable data - */ - private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData) - { - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - if ($msgVarsData->error) - { - show_error($msgVarsData->retval); - } - - if (!hasData($variables = $this->MessageModel->getMessageVars())) - { - unset($variables); - } - else - { - $variablesArray = array(); - // Skip person_id and prestudent_id - for ($i = 2; $i < count($variables->retval); $i++) - { - $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; - } - } - - array_shift($variables->retval); // Remove person_id - array_shift($variables->retval); // Remove prestudent_id - } - - /** - * gets Message Variables and their data for Person - * @param $person_id - * @param $variablesArray to be filled with variable names - * @param $msgVarsData to be filled with variable data - */ - private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData) - { - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - if ($msgVarsData->error) - { - show_error($msgVarsData->retval); - } - - if (!hasData($variables = $this->MessageModel->getMessageVarsPerson())) - { - unset($variables); - } - else - { - $variablesArray = array(); - // Skip person_id - for ($i = 1; $i < count($variables->retval); $i++) - { - $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; - } - array_shift($variables->retval); // Remove person_id - } + $this->load->view('system/messageWrite', $data); } /** @@ -226,7 +154,7 @@ class Messages extends Auth_Controller { if ($sender_id === null) { - $user_person = $this->PersonModel->getByUid($this->uid); + $user_person = $this->PersonModel->getByUid(getAuthUID()); if (!hasData($user_person)) { @@ -326,7 +254,7 @@ class Messages extends Auth_Controller 'kommunikation', 'core', null, - $this->uid + getAuthUID() ); } @@ -334,40 +262,6 @@ class Messages extends Auth_Controller } } - /** - * getPersonId - */ - private function getPersonId() - { - $person_id = null; - - if ($this->input->get('person_id') !== null) - { - $person_id = $this->input->get('person_id'); - } - elseif ($this->input->post('person_id') !== null) - { - $person_id = $this->input->get('person_id'); - } - - if (!is_numeric($person_id)) - { - show_error('Person_id is not numeric'); - } - - return $person_id; - } - - /** - * Retrieve the UID of the logged user and checks if it is valid - */ - private function _setAuthUID() - { - $this->uid = getAuthUID(); - - if (!$this->uid) show_error('User authentification failed'); - } - /** * getVorlage */ @@ -440,4 +334,92 @@ class Messages extends Auth_Controller ->set_output(json_encode(array($msg->retval[0]))); } + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * gets Message Variables and their data for Prestudent + * @param $prestudent_id + * @param $variablesArray to be filled with variable names + * @param $msgVarsData to be filled with variable data + */ + private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData) + { + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + if ($msgVarsData->error) + { + show_error($msgVarsData->retval); + } + + if (!hasData($variables = $this->MessageModel->getMessageVars())) + { + unset($variables); + } + else + { + $variablesArray = array(); + // Skip person_id and prestudent_id + for ($i = 2; $i < count($variables->retval); $i++) + { + $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; + } + } + + array_shift($variables->retval); // Remove person_id + array_shift($variables->retval); // Remove prestudent_id + } + + /** + * gets Message Variables and their data for Person + * @param $person_id + * @param $variablesArray to be filled with variable names + * @param $msgVarsData to be filled with variable data + */ + private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData) + { + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + if ($msgVarsData->error) + { + show_error($msgVarsData->retval); + } + + if (!hasData($variables = $this->MessageModel->getMessageVarsPerson())) + { + unset($variables); + } + else + { + $variablesArray = array(); + // Skip person_id + for ($i = 1; $i < count($variables->retval); $i++) + { + $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; + } + array_shift($variables->retval); // Remove person_id + } + } + + /** + * getPersonId + */ + private function getPersonId() + { + $person_id = null; + + if ($this->input->get('person_id') !== null) + { + $person_id = $this->input->get('person_id'); + } + elseif ($this->input->post('person_id') !== null) + { + $person_id = $this->input->get('person_id'); + } + + if (!is_numeric($person_id)) + { + show_error('Person_id is not numeric'); + } + + return $person_id; + } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 65a6aec07..6799cd445 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -1154,8 +1154,6 @@ class InfoCenter extends Auth_Controller show_error($user_person->retval); } - $messagelink = site_url('/system/Messages/write/'.$user_person->retval[0]->person_id); - $data = array ( 'lockedby' => $lockedby, 'lockedbyother' => $lockedbyother, @@ -1165,8 +1163,7 @@ class InfoCenter extends Auth_Controller 'messages' => $messages->retval, 'logs' => $logs, 'notizen' => $notizen->retval, - 'notizenbewerbung' => $notizen_bewerbung->retval, - 'messagelink' => $messagelink + 'notizenbewerbung' => $notizen_bewerbung->retval ); return $data; diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 45ccce876..6c2dfd4f2 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -39,6 +39,9 @@ class MessageLib $this->ci->lang->load('message'); } + //------------------------------------------------------------------------------------------------------------------ + // Public methods + /** * getMessage() - returns the specified received message for a specified person */ @@ -750,7 +753,37 @@ class MessageLib return $sent; } - // ------------------------------------------------------------------------ + /** + * parseMessageText + */ + public function parseMessageText($text, $data = array()) + { + return $this->ci->parser->parse_string($text, $data, true); + } + + /** + * Gets data for Person from view vw_msg_vars_person + * @param $person_id + */ + public function getMessageVarsPerson() + { + $variablesArray = array(); + $variables = $this->ci->MessageModel->getMessageVarsPerson(); + + if (hasData($variables)) + { + // Skip person_id + for ($i = 1; $i < count($variables->retval); $i++) + { + $variablesArray['{'.str_replace(' ', '_', strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; + } + array_shift($variables->retval); // Remove person_id + } + + return $variablesArray; + } + + //------------------------------------------------------------------------------------------------------------------ // Private methods /** @@ -932,12 +965,4 @@ class MessageLib { return success($retval, $code, MessageLib::MSG_INDX_PREFIX); } - - /** - * - */ - public function parseMessageText($text, $data = array()) - { - return $this->ci->parser->parse_string($text, $data, true); - } } diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 08058f099..2b481692e 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -66,7 +66,7 @@ - kontakte as $kontakt): ?> @@ -113,12 +113,11 @@
zugangscode)): ?> diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index e53872ac4..ef41b24bd 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -9,311 +9,167 @@ $this->load->view( 'tinymce' => true, 'sbadmintemplate' => true, 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), - 'customJSs' => array('public/js/bootstrapper.js') + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') ) ); ?> - -
-
-
-
-
- -
-
-
+
+
+
-
-
- -
-
- 1 && $i % 10 == 0) +
+ +
+
+ +
+
+
+ +
+
+ '; - } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } - ?> -
-
-
-
-
-
- -
  - subject; - } - ?> -
- -
-
-
-
-
-
- - body; - } - ?> - -
- -
-
- - + echo $receiver->Vorname." ".$receiver->Nachname."; "; + } + ?>
- -
-
-
-
- widgetlib->widget( - 'Vorlage_widget', - array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); - ?>
-
- -
-
- 0): ?> -
-
- +
+
+ +
  + subject; + } + ?> +
+ +
-
-
-
-
- - +
+ +
+
+ + -   - Refresh
-
- + +
+
+
+
+ widgetlib->widget( + 'Vorlage_widget', + array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), + array('name' => 'vorlage', 'id' => 'vorlageDnD') + ); + ?> +
+
+ +
+
+ 0): ?> +
+
+
+
-
- -
- +
+
+
+
+ + '."\n"; - } - ?> + foreach ($receivers as $receiver) + { + ?> + + + +   + Refresh +
+
+
- +
+
+ +
+ - - - + person_id.'">'."\n"; + } + ?> + + + + + + +
-
- - load->view("templates/FHC-Footer"); ?> diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index a4a2c4347..7f299f41d 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -1230,7 +1230,7 @@ function MessageNew() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/Messages/write/' + person_id; ?>; + var action = 'index.ci.php/system/FASMessages/write/' + person_id; ?>; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/content/messages.js.php b/content/messages.js.php index e61108eb6..e98985c0c 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -104,7 +104,7 @@ function MessagesNewMessage() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/Messages/write/' + MessageSenderPersonID; + var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } @@ -128,7 +128,7 @@ function MessagesSendAnswer() var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); - var action = 'index.ci.php/system/Messages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } @@ -188,4 +188,4 @@ function MessageIFrameInit() editor.style.backgroundColor="#FFFFFF"; MessageIFrameIsInitialized=true; } -} \ No newline at end of file +} diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index d4dbd5bad..641bc7c42 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -27,7 +27,7 @@ var InfocenterPersonDataset = { appendTableActionsHtml: function() { var currurl = window.location.href; - var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write"); + var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/write"; var formHtml = '
'; $("#datasetActionsTop").before(formHtml); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js new file mode 100644 index 000000000..17f73c51e --- /dev/null +++ b/public/js/messaging/messageWrite.js @@ -0,0 +1,127 @@ +const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages"; + +function tinymcePreviewSetContent() +{ + if ($("#tinymcePreview")) + { + if ($("#recipients").children(":selected").val() > -1) + { + parseMessageText($("#recipients").children(":selected").val(), tinyMCE.get("bodyTextArea").getContent()); + } + else + { + tinyMCE.get("tinymcePreview").setContent(""); + } + } +} + +function parseMessageText(receiver_id, text) +{ + $.ajax({ + dataType: "json", + url: CONTROLLER_URL + "/parseMessageText", + data: { + "person_id": receiver_id, + "text": text + }, + success: function(data, textStatus, jqXHR) + { + tinyMCE.get("tinymcePreview").setContent(data); + }, + error: function(jqXHR, textStatus, errorThrown) + { + alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText); + } + }); +} + +$(document).ready(function () +{ + tinymce.init({ + selector: "#bodyTextArea", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10 + }); + + tinymce.init({ + menubar: false, + toolbar: false, + statusbar: false, + readonly: 1, + selector: "#tinymcePreview", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_bottom_margin: 10 + }); + + if ($("#variables")) + { + $("#variables").dblclick(function () + { + if ($("#bodyTextArea")) + { + //if editor active add at cursor position, otherwise at end + if (tinymce.activeEditor.id === "bodyTextArea") + tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).children(":selected").val()); + else + tinyMCE.get("bodyTextArea").setContent(tinyMCE.get("bodyTextArea").getContent() + $(this).children(":selected").val()); + } + }); + } + + if ($("#recipients")) + { + $("#recipients").change(tinymcePreviewSetContent); + } + + if ($("#refresh")) + { + $("#refresh").click(tinymcePreviewSetContent); + } + + if ($("#sendButton") && $("#sendForm")) + { + $("#sendButton").click(function () + { + if ($("#subject") && $("#subject").val() != '' && tinyMCE.get("bodyTextArea").getContent() != '') + { + $("#sendForm").submit(); + } + else + { + alert("Subject and text are required fields!"); + } + }); + } + + if ($("#vorlageDnD")) + { + $("#vorlageDnD").change(function () + { + if (this.value != '') + { + $.ajax({ + dataType: "json", + url: CONTROLLER_URL + "/getVorlage", + data: { + "vorlage_kurzbz": this.value + }, + success: function(data, textStatus, jqXHR) + { + tinyMCE.get("bodyTextArea").setContent(data.retval[0].text); + $("#subject").val(data.retval[0].subject); + }, + error: function(jqXHR, textStatus, errorThrown) + { + alert(textStatus + " - " + errorThrown); + } + }); + } + }); + } + + $("#subject").focus(); + +}); From 2bf2cac383cf20884b5b582f0298fce9bafba9db Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 1 Feb 2019 12:04:20 +0100 Subject: [PATCH 02/19] - Added new method writeReply to FASMessages - Moved logic from Messages and MessageLib to MessageLib\ - Better code in views/system/messageWrite.php - Adapted content/messages.js.php to use writeReply --- .../controllers/system/FASMessages.php | 166 +++++--- application/libraries/MessageLib.php | 216 ++++++---- application/views/system/messageWrite.php | 185 +++++---- content/messages.js.php | 382 +++++++++--------- 4 files changed, 518 insertions(+), 431 deletions(-) diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/FASMessages.php index 29a9a2a31..60f961c8b 100644 --- a/application/controllers/system/FASMessages.php +++ b/application/controllers/system/FASMessages.php @@ -11,7 +11,8 @@ class FASMessages extends Auth_Controller { parent::__construct( array( - 'write' => 'basis/message:rw' + 'write' => 'basis/message:rw', + 'writeReply' => 'basis/message:rw' ) ); @@ -21,9 +22,6 @@ class FASMessages extends Auth_Controller // Loads the widget library $this->load->library('WidgetLib'); - $this->load->model('system/Message_model', 'MessageModel'); - $this->load->model('person/Person_model', 'PersonModel'); - $this->loadPhrases( array( 'global', @@ -32,86 +30,126 @@ class FASMessages extends Auth_Controller ); } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + /** - * Write + * Write a new message */ - public function write($sender_id = null, $msg_id = null, $receiver_id = null) + public function write($sender_id) { - $prestudent_id = $this->input->post('prestudent_id'); - $oe_kurzbz = array(); // a person may belongs to more organisation units - $msg = null; + $prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s) if (!is_numeric($sender_id)) { - $personByUID = $this->PersonModel->getByUid(getAuthUID()); - - if (isError($personByUID) || !hasData($personByUID)) - { - show_error($personByUID->retval); - } - else - { - $sender_id = $personByUID->retval[0]->person_id; - } + show_error('The current logged user person_id is not defined'); } - // Get message data if possible - if (is_numeric($msg_id) && is_numeric($receiver_id)) - { - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - if (isError($msg) || !hasData($msg)) - { - show_error($msg->retval); - } - else - { - $msg = $msg->retval[0]; - } - } - - // Retrieves message vars from view vw_msg_vars - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - if (isError($msgVarsData)) - { - show_error($msgVarsData->retval); - } + $msgVarsData = $this->_getMsgVarsData($prestudent_id); // Retrieves message vars for a person from view view vw_msg_vars_person $variablesArray = $this->messagelib->getMessageVarsPerson(); // Organisation units used to get the templates - $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); - $benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id); - if (isError($benutzerResult)) - { - show_error($benutzerResult->retval); - } - elseif (hasData($benutzerResult)) - { - foreach ($benutzerResult->retval as $val) - { - $oe_kurzbz[] = $val->oe_kurzbz; - } - } + $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); // Admin or commoner? - $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); - $isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id); - if (isError($isAdmin)) - { - show_error($isAdmin->retval); - } + $isAdmin = $this->messagelib->getIsAdmin($sender_id); - $data = array ( - 'sender_id' => $sender_id, - 'receivers' => $msgVarsData->retval, - 'message' => $msg, + $data = array( + 'recipients' => $msgVarsData->retval, 'variables' => $variablesArray, 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin->retval, - 'personOnly' => false // indicates if sent only to persons + 'isAdmin' => $isAdmin ); $this->load->view('system/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->messagelib->getMessageVarsPerson(); + + // Organisation units used to get the templates + $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); + + // Admin or commoner? + $isAdmin = $this->messagelib->getIsAdmin($sender_id); + + $data = array( + 'recipients' => $msgVarsData->retval, + 'message' => $msg, + 'variables' => $variablesArray, + 'oe_kurzbz' => $oe_kurzbz, // used to get the templates + 'isAdmin' => $isAdmin + ); + + $this->load->view('system/messageWrite', $data); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * + */ + private function _getMessage($msg_id, $receiver_id) + { + $msg = $this->messagelib->getMessage($msg_id, $receiver_id); + if (isError($msg)) + { + show_error($msg->retval); + } + elseif (!hasData($msg)) + { + show_error('The selected message does not exist'); + } + else + { + $msg = $msg->retval[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($msgVarsData->retval); + } + + return $msgVarsData; + } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 6c2dfd4f2..e59f45d2d 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -9,34 +9,36 @@ class MessageLib { const MSG_INDX_PREFIX = 'message_'; + private $_ci; + /** * Constructor */ public function __construct() { // Get code igniter instance - $this->ci =& get_instance(); + $this->_ci =& get_instance(); // Loads message configuration - $this->ci->config->load('message'); + $this->_ci->config->load('message'); // CI Parser library - $this->ci->load->library('parser'); + $this->_ci->load->library('parser'); // Loads LogLib - $this->ci->load->library('LogLib'); + $this->_ci->load->library('LogLib'); // Loads VorlageLib - $this->ci->load->library('VorlageLib'); + $this->_ci->load->library('VorlageLib'); // Loads Mail library - $this->ci->load->library('MailLib'); + $this->_ci->load->library('MailLib'); // Loading models - $this->ci->load->model('system/Message_model', 'MessageModel'); - $this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel'); - $this->ci->load->model('system/Recipient_model', 'RecipientModel'); - $this->ci->load->model('system/Attachment_model', 'AttachmentModel'); + $this->_ci->load->model('system/Message_model', 'MessageModel'); + $this->_ci->load->model('system/MsgStatus_model', 'MsgStatusModel'); + $this->_ci->load->model('system/Recipient_model', 'RecipientModel'); + $this->_ci->load->model('system/Attachment_model', 'AttachmentModel'); // Loads phrases - $this->ci->lang->load('message'); + $this->_ci->lang->load('message'); } //------------------------------------------------------------------------------------------------------------------ @@ -52,7 +54,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - $msg = $this->ci->RecipientModel->getMessage($msg_id, $person_id); + $msg = $this->_ci->RecipientModel->getMessage($msg_id, $person_id); return $msg; } @@ -65,7 +67,7 @@ class MessageLib if (isEmptyString($uid)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); + $msg = $this->_ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); return $msg; } @@ -78,7 +80,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); + $msg = $this->_ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); return $msg; } @@ -91,7 +93,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); + $msg = $this->_ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); return $msg; } @@ -104,7 +106,7 @@ class MessageLib if (isEmptyString($token)) return $this->_error('', MSG_ERR_INVALID_TOKEN); - $result = $this->ci->RecipientModel->getMessageByToken($token); + $result = $this->_ci->RecipientModel->getMessageByToken($token); if (hasData($result)) { // Searches for a status that is different from unread @@ -127,7 +129,7 @@ class MessageLib 'status' => MSG_STATUS_READ ); - $resultIns = $this->ci->MsgStatusModel->insert($statusKey); + $resultIns = $this->_ci->MsgStatusModel->insert($statusKey); // If an error occured while writing on data base, then return it if (isError($resultIns)) { @@ -147,7 +149,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - $msg = $this->ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); + $msg = $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); return $msg; } @@ -175,7 +177,7 @@ class MessageLib } // Searches if the status is already present - $result = $this->ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); if (hasData($result)) { // status already present @@ -189,7 +191,7 @@ class MessageLib 'status' => $status ); - $result = $this->ci->MsgStatusModel->insert($statusKey); + $result = $this->_ci->MsgStatusModel->insert($statusKey); } return $result; @@ -202,7 +204,7 @@ class MessageLib { if (!is_numeric($sender_id)) { - $sender_id = $this->ci->config->item('system_person_id'); + $sender_id = $this->_ci->config->item('system_person_id'); } $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); @@ -233,7 +235,7 @@ class MessageLib if (isSuccess($result)) { // If the system is configured to send messages immediately - if ($this->ci->config->item('send_immediately') === true) + if ($this->_ci->config->item('send_immediately') === true) { // Send message by email! $resultSendEmail = $this->sendOne($result->retval, $subject, $body, $multiPartMime); @@ -277,7 +279,7 @@ class MessageLib { if (!is_numeric($sender_id)) { - $sender_id = $this->ci->config->item('system_person_id'); + $sender_id = $this->_ci->config->item('system_person_id'); } $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); @@ -293,7 +295,7 @@ class MessageLib else { // Load reveiver data to get its relative language - $this->ci->load->model('person/Person_model', 'PersonModel'); + $this->_ci->load->model('person/Person_model', 'PersonModel'); } // Looping on receivers @@ -302,14 +304,14 @@ class MessageLib $receiver_id = $receivers->retval[$i]->person_id; // Checks if the receiver exists - $result = $this->ci->PersonModel->load($receiver_id); + $result = $this->_ci->PersonModel->load($receiver_id); if (hasData($result)) { // Retrives the language of the logged user $sprache = getUserLanguage(); // Loads template data - $result = $this->ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache); + $result = $this->_ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache); if (isSuccess($result)) { // If the text and the subject of the template are not empty @@ -317,9 +319,9 @@ class MessageLib !isEmptyString($result->retval[0]->text) && !isEmptyString($result->retval[0]->subject)) { // Parses template text - $parsedText = $this->ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data); + $parsedText = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data); // Parses subject - $subject = $this->ci->vorlagelib->parseVorlagetext($result->retval[0]->subject, $data); + $subject = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->subject, $data); // Save message $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $parsedText, $relationmessage_id, $oe_kurzbz); @@ -327,7 +329,7 @@ class MessageLib if (isSuccess($result)) { // If the system is configured to send messages immediately - if ($this->ci->config->item('send_immediately') === true) + if ($this->_ci->config->item('send_immediately') === true) { // Send message by email! $resultSendEmail = $this->sendOne($result->retval, $subject, $parsedText, $multiPartMime); @@ -392,21 +394,21 @@ class MessageLib $sent = true; // optimistic expectation // Gets standard configs - $cfg = $this->ci->maillib->getConfigs(); + $cfg = $this->_ci->maillib->getConfigs(); $cfg->email_number_to_sent = $numberToSent; $cfg->email_number_per_time_range = $numberPerTimeRange; $cfg->email_time_range = $email_time_range; $cfg->email_from_system = $email_from_system; // Overrides configs with the parameters - $this->ci->maillib->overrideConfigs($cfg); + $this->_ci->maillib->overrideConfigs($cfg); - // Gets a number ($this->ci->maillib->getMaxEmailToSent()) of unsent messages from DB + // Gets a number ($this->_ci->maillib->getMaxEmailToSent()) of unsent messages from DB // having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->ci->RecipientModel->getMessages( + $result = $this->_ci->RecipientModel->getMessages( EMAIL_KONTAKT_TYPE, null, - $this->ci->maillib->getConfigs()->email_number_to_sent + $this->_ci->maillib->getConfigs()->email_number_to_sent ); // Checks if errors were occurred if (isSuccess($result)) @@ -421,14 +423,14 @@ class MessageLib if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) { - $href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[$i]->token; + $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[$i]->token; - $vorlage = $this->ci->vorlagelib->loadVorlagetext('MessageMailHTML'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); if(hasData($vorlage)) { // Using a template for the html email body - $body = $this->ci->parser->parse_string( + $body = $this->_ci->parser->parse_string( $vorlage->retval[0]->text, array( 'href' => $href, @@ -441,7 +443,7 @@ class MessageLib else { // Using a template for the html email body - $body = $this->ci->parser->parse( + $body = $this->_ci->parser->parse( 'templates/mailHTML', array( 'href' => $href, @@ -453,14 +455,14 @@ class MessageLib } if (is_null($body) || $body == '') { - $this->ci->loglib->logError('Error while parsing the mail template'); + $this->_ci->loglib->logError('Error while parsing the mail template'); } - $vorlage = $this->ci->vorlagelib->loadVorlagetext('MessageMailTXT'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); if(hasData($vorlage)) { // Using a template for the plain text email body - $altBody = $this->ci->parser->parse_string( + $altBody = $this->_ci->parser->parse_string( $vorlage->retval[0]->text, array( 'href' => $href, @@ -473,7 +475,7 @@ class MessageLib else { // Using a template for the plain text email body - $altBody = $this->ci->parser->parse( + $altBody = $this->_ci->parser->parse( 'templates/mailTXT', array( 'href' => $href, @@ -485,7 +487,7 @@ class MessageLib } if (is_null($altBody) || $altBody == '') { - $this->ci->loglib->logError('Error while parsing the mail template'); + $this->_ci->loglib->logError('Error while parsing the mail template'); } // If the sender is not an employee, then system-sender is used if empty @@ -502,7 +504,7 @@ class MessageLib } // Sending email - $sent = $this->ci->maillib->send( + $sent = $this->_ci->maillib->send( $sender, $receiverContact, $result->retval[$i]->subject, @@ -515,7 +517,7 @@ class MessageLib // If errors were occurred while sending the email if (!$sent) { - $this->ci->loglib->logError('Error while sending an email'); + $this->_ci->loglib->logError('Error while sending an email'); // Writing errors in tbl_msg_recipient $sme = $this->setMessageError( $result->retval[$i]->message_id, @@ -525,7 +527,7 @@ class MessageLib ); if (!$sme) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } } else @@ -535,13 +537,13 @@ class MessageLib // If some errors occurred if (!$sent) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } } } else { - $this->ci->loglib->logError('This person does not have an email account'); + $this->_ci->loglib->logError('This person does not have an email account'); // Writing errors in tbl_msg_recipient $sme = $this->setMessageError( $result->retval[$i]->message_id, @@ -551,7 +553,7 @@ class MessageLib ); if (!$sme) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } $sent = true; // Non blocking error } @@ -559,13 +561,13 @@ class MessageLib } else { - $this->ci->loglib->logInfo('There are no email to be sent'); + $this->_ci->loglib->logInfo('There are no email to be sent'); $sent = false; } } else { - $this->ci->loglib->logError('Something went wrong while getting data from DB'); + $this->_ci->loglib->logError('Something went wrong while getting data from DB'); $sent = false; } @@ -580,7 +582,7 @@ class MessageLib $sent = true; // optimistic expectation // Get a specific message from DB having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->ci->RecipientModel->getMessages( + $result = $this->_ci->RecipientModel->getMessages( EMAIL_KONTAKT_TYPE, null, null, @@ -601,12 +603,12 @@ class MessageLib if ($multiPartMime === true) { // Using a template for the html email body - $href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[0]->token; + $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[0]->token; - $vorlage = $this->ci->vorlagelib->loadVorlagetext('MessageMailHTML'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); if(hasData($vorlage)) { - $bodyMsg = $this->ci->parser->parse_string( + $bodyMsg = $this->_ci->parser->parse_string( $vorlage->retval[0]->text, array( 'href' => $href, @@ -618,7 +620,7 @@ class MessageLib } else { - $bodyMsg = $this->ci->parser->parse( + $bodyMsg = $this->_ci->parser->parse( 'templates/mailHTML', array( 'href' => $href, @@ -631,14 +633,14 @@ class MessageLib if (is_null($bodyMsg) || $bodyMsg == '') { // $body = $result->retval[0]->body; - $this->ci->loglib->logError('Error while parsing the html mail template'); + $this->_ci->loglib->logError('Error while parsing the html mail template'); } // Using a template for the plain text email body - $vorlage = $this->ci->vorlagelib->loadVorlagetext('MessageMailTXT'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); if(hasData($vorlage)) { - $altBody = $this->ci->parser->parse_string( + $altBody = $this->_ci->parser->parse_string( $vorlage->retval[0]->text, array( 'href' => $href, @@ -650,7 +652,7 @@ class MessageLib } else { - $altBody = $this->ci->parser->parse( + $altBody = $this->_ci->parser->parse( 'templates/mailTXT', array( 'href' => $href, @@ -662,7 +664,7 @@ class MessageLib } if (is_null($altBody) || $altBody == '') { - $this->ci->loglib->logError('Error while parsing the plain text mail template'); + $this->_ci->loglib->logError('Error while parsing the plain text mail template'); } } else @@ -684,7 +686,7 @@ class MessageLib } // Sending email - $sent = $this->ci->maillib->send( + $sent = $this->_ci->maillib->send( null, $receiverContact, is_null($subject) ? $result->retval[0]->subject : $subject, // if parameter subject is not null, use it! @@ -697,7 +699,7 @@ class MessageLib // If errors were occurred while sending the email if (!$sent) { - $this->ci->loglib->logError('Error while sending an email'); + $this->_ci->loglib->logError('Error while sending an email'); // Writing errors in tbl_msg_recipient $sme = $this->setMessageError( $result->retval[0]->message_id, @@ -707,7 +709,7 @@ class MessageLib ); if (!$sme) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } } else @@ -717,13 +719,13 @@ class MessageLib // If the email has been sent and the DB updated if (!$sent) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } } } else { - $this->ci->loglib->logError('This person does not have an email account'); + $this->_ci->loglib->logError('This person does not have an email account'); // Writing errors in tbl_msg_recipient $sme = $this->setMessageError( $result->retval[0]->message_id, @@ -733,20 +735,20 @@ class MessageLib ); if (!$sme) { - $this->ci->loglib->logError('Error while updating DB'); + $this->_ci->loglib->logError('Error while updating DB'); } $sent = true; // Non blocking error } } else { - $this->ci->loglib->logInfo('There are no email to be sent'); + $this->_ci->loglib->logInfo('There are no email to be sent'); $sent = false; } } else { - $this->ci->loglib->logError('Something went wrong while getting data from DB'); + $this->_ci->loglib->logError('Something went wrong while getting data from DB'); $sent = false; } @@ -758,7 +760,7 @@ class MessageLib */ public function parseMessageText($text, $data = array()) { - return $this->ci->parser->parse_string($text, $data, true); + return $this->_ci->parser->parse_string($text, $data, true); } /** @@ -768,7 +770,7 @@ class MessageLib public function getMessageVarsPerson() { $variablesArray = array(); - $variables = $this->ci->MessageModel->getMessageVarsPerson(); + $variables = $this->_ci->MessageModel->getMessageVarsPerson(); if (hasData($variables)) { @@ -783,6 +785,46 @@ class MessageLib return $variablesArray; } + /** + * A person may belongs to more organisation units + */ + public function getOeKurzbz($sender_id) + { + $oe_kurzbz = array(); + + $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $benutzerResult = $this->_ci->BenutzerfunktionModel->getByPersonId($sender_id); + if (isError($benutzerResult)) + { + show_error($benutzerResult->retval); + } + elseif (hasData($benutzerResult)) + { + foreach ($benutzerResult->retval as $val) + { + $oe_kurzbz[] = $val->oe_kurzbz; + } + } + + return $oe_kurzbz; + } + + /** + * Admin or commoner? + */ + public function getIsAdmin($sender_id) + { + $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $isAdmin = $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); + + if (isError($isAdmin)) + { + show_error($isAdmin->retval); + } + + return $isAdmin->retval; + } + //------------------------------------------------------------------------------------------------------------------ // Private methods @@ -794,7 +836,7 @@ class MessageLib $updated = false; // Updates table tbl_msg_recipient - $resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); + $resultUpdate = $this->_ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); // Checks if errors were occurred if (isSuccess($resultUpdate) && is_array($resultUpdate->retval)) { @@ -835,13 +877,13 @@ class MessageLib private function _getReceiversByOekurzbz($oe_kurzbz) { // Load Benutzerfunktion_model - $this->ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); // Join with table public.tbl_benutzer on field uid - $this->ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid'); + $this->_ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid'); // Get all the valid receivers id using the oe_kurzbz - $receivers = $this->ci->BenutzerfunktionModel->loadWhere( - 'oe_kurzbz = '.$this->ci->db->escape($oe_kurzbz). - ' AND funktion_kurzbz = '.$this->ci->db->escape($this->ci->config->item('assistent_function')). + $receivers = $this->_ci->BenutzerfunktionModel->loadWhere( + 'oe_kurzbz = '.$this->_ci->db->escape($oe_kurzbz). + ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item('assistent_function')). ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' ); @@ -884,8 +926,8 @@ class MessageLib private function _checkReceiverId($receiver_id) { // Load Person_model - $this->ci->load->model('person/Person_model', 'PersonModel'); - $result = $this->ci->PersonModel->load($receiver_id); + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $result = $this->_ci->PersonModel->load($receiver_id); if (hasData($result)) { return true; @@ -900,7 +942,7 @@ class MessageLib private function _saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz) { // Starts db transaction - $this->ci->db->trans_start(false); + $this->_ci->db->trans_start(false); // Save Message $msgData = array( @@ -911,7 +953,7 @@ class MessageLib 'relationmessage_id' => $relationmessage_id, 'oe_kurzbz' => $oe_kurzbz ); - $result = $this->ci->MessageModel->insert($msgData); + $result = $this->_ci->MessageModel->insert($msgData); if (isSuccess($result)) { // Link the message with the receiver @@ -921,7 +963,7 @@ class MessageLib 'message_id' => $msg_id, 'token' => generateToken() ); - $result = $this->ci->RecipientModel->insert($recipientData); + $result = $this->_ci->RecipientModel->insert($recipientData); if (isSuccess($result)) { // Save message status @@ -930,20 +972,20 @@ class MessageLib 'person_id' => $receiver_id, 'status' => MSG_STATUS_UNREAD ); - $result = $this->ci->MsgStatusModel->insert($statusData); + $result = $this->_ci->MsgStatusModel->insert($statusData); } } - $this->ci->db->trans_complete(); + $this->_ci->db->trans_complete(); - if ($this->ci->db->trans_status() === false || isError($result)) + if ($this->_ci->db->trans_status() === false || isError($result)) { - $this->ci->db->trans_rollback(); + $this->_ci->db->trans_rollback(); $result = $this->_error($result->msg, EXIT_ERROR); } else { - $this->ci->db->trans_commit(); + $this->_ci->db->trans_commit(); $result = $this->_success($msg_id); } diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index ef41b24bd..af83ad9a2 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -19,27 +19,27 @@ $this->load->view(
- +
- +
1 && $i % 10 == 0) + for ($i = 0; $i < count($recipients); $i++) { - echo '
'; + $receiver = $recipients[$i]; + // Every 10 recipients a new line + if ($i > 1 && $i % 10 == 0) + { + echo '
'; + } + echo $receiver->Vorname." ".$receiver->Nachname."; "; } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } ?>
@@ -47,123 +47,130 @@ $this->load->view(
- +
  subject; - } + $subject = ''; + if (isset($message)) + { + $subject = 'Re: '.$message->subject; + } ?>
- +

- + body; - } + $body = ''; + if (isset($message)) + { + $body = $message->body; + } ?>
-
-
- - - + foreach ($variables as $key => $val) + { + ?> + + + +
-
- +

widgetlib->widget( - 'Vorlage_widget', - array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); + echo $this->widgetlib->widget( + 'Vorlage_widget', + array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), + array('name' => 'vorlage', 'id' => 'vorlageDnD') + ); ?>
- +
- 0): ?> -
-
-
- -
-
-
+ 0) + { + ?> +
-
-
- - - -   - Refresh + if (count($recipients) > 1) + echo ''; + + foreach ($recipients as $receiver) + { + ?> + + + +   + Refresh +
+
+
+
-
- -
+
+
-
- -
- person_id.'">'."\n"; - } + for ($i = 0; $i < count($recipients); $i++) + { + echo ''."\n"; + } ?> - - + + diff --git a/content/messages.js.php b/content/messages.js.php index e98985c0c..fae1db4ba 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -1,191 +1,191 @@ - - */ -require_once('../config/vilesci.config.inc.php'); -?> -// ********** FUNKTIONEN ********** // -var MessagePersonID=null; -var MessagesTreeDatasource=''; // Datasource des Adressen Trees -var MessagesSelectID=''; -var MessageSenderPersonID=''; -var MessageIFrameIsInitialized=false; - -var MessagesTreeSinkObserver = -{ - onBeginLoad : function(pSink) {}, - onInterrupt : function(pSink) {}, - onResume : function(pSink) {}, - onError : function(pSink, pStatus, pError) {}, - onEndLoad : function(pSink) - { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - document.getElementById('messages-tree').builder.rebuild(); - } -}; - -var MessagesTreeListener = -{ - willRebuild : function(builder) { }, - didRebuild : function(builder) - { - //timeout nur bei Mozilla notwendig da sonst die rows - //noch keine values haben. Ab Seamonkey funktionierts auch - //ohne dem setTimeout - //window.setTimeout(KontaktAdressenTreeSelectID,10); - } -}; - -// **** -// * Laedt die Trees -// **** -function loadMessages(person_id, fas_person_id) -{ - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - MessagePersonID = person_id; - MessageSenderPersonID=fas_person_id; - - //Adressen laden - url = "rdf/messages.rdf.php?person_id="+person_id+"&"+gettimestamp(); - var tree=document.getElementById('messages-tree'); - try - { - MessagesTreeDatasource.removeXMLSinkObserver(MessagesTreeSinkObserver); - tree.builder.removeListener(MessagesTreeListener); - } - catch(e) - {} - - //Alte DS entfernen - var oldDatasources = tree.database.GetDataSources(); - while(oldDatasources.hasMoreElements()) - { - tree.database.RemoveDataSource(oldDatasources.getNext()); - } - - var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); - MessagesTreeDatasource = rdfService.GetDataSource(url); - MessagesTreeDatasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource); - MessagesTreeDatasource.QueryInterface(Components.interfaces.nsIRDFXMLSink); - tree.database.AddDataSource(MessagesTreeDatasource); - MessagesTreeDatasource.addXMLSinkObserver(MessagesTreeSinkObserver); - tree.builder.addListener(MessagesTreeListener); - -} - - -// **** -// * Zeigt HTML Seite zum Erstellen neuer Nachrichten -// **** -function MessagesNewMessage() -{ - var tree = parent.document.getElementById('student-tree'); - - if (tree.currentIndex == -1) - { - alert("Bitte markieren Sie zuerst eine Person"); - } - else - { - var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - - var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID; - - openWindowPostArray(action, 'prestudent_id', prestudentIdArray); - } -} - -/** - * Oeffnet Nachrichtenseite um eine Antwort auf eine Nachricht zu schicken - */ -function MessagesSendAnswer() -{ - var messagesTree = document.getElementById('messages-tree'); - var studentsTree = parent.document.getElementById('student-tree'); - - if (messagesTree.currentIndex == -1) - { - alert("Bitte markieren Sie zuerst eine Nachricht"); - } - else - { - var MessageId = getTreeCellText(messagesTree, 'messages-tree-message_id', messagesTree.currentIndex); - var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); - var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); - - var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; - - openWindowPostArray(action, 'prestudent_id', prestudentIdArray); - } -} - -function MessageAuswahl() -{ - var tree=document.getElementById('messages-tree'); - if(tree.currentIndex==-1) - { - alert("Bitte markieren Sie zuerst eine Nachricht"); - } - else - { - var text = getTreeCellText(tree, 'messages-tree-body', tree.currentIndex); - var recipient_id = getTreeCellText(tree, 'messages-tree-recipient_id', tree.currentIndex); - // Antworten ist nur moeglich wenn die Message vom User kommt - if(recipient_id==MessagePersonID) - { - document.getElementById('messages-tree-popup-answer').disabled=true; - document.getElementById('messages-button-answer').disabled=true; - } - else - { - document.getElementById('messages-tree-popup-answer').disabled=false; - document.getElementById('messages-button-answer').disabled=false; - } - } - - MessagesIFrameSetHTML(text); -} - -function MessagesIFrameSetHTML(val) -{ - MessageIFrameInit(); - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - editor = document.getElementById('message-wysiwyg'); - - if(editor.contentWindow.document.body.innerHTML!='') - { - //Inhalt leeren - editor.contentDocument.execCommand("selectall", false, null); - editor.contentDocument.execCommand("delete", false, null); - } - //Value setzen - if(val!='') - editor.contentDocument.execCommand("inserthtml", false, val); -} - -function MessageIFrameInit() -{ - if(!MessageIFrameIsInitialized) - { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - editor = document.getElementById('message-wysiwyg'); - editor.contentDocument.designMode = 'on'; - editor.style.backgroundColor="#FFFFFF"; - MessageIFrameIsInitialized=true; - } -} + + */ +require_once('../config/vilesci.config.inc.php'); +?> +// ********** FUNKTIONEN ********** // +var MessagePersonID=null; +var MessagesTreeDatasource=''; // Datasource des Adressen Trees +var MessagesSelectID=''; +var MessageSenderPersonID=''; +var MessageIFrameIsInitialized=false; + +var MessagesTreeSinkObserver = +{ + onBeginLoad : function(pSink) {}, + onInterrupt : function(pSink) {}, + onResume : function(pSink) {}, + onError : function(pSink, pStatus, pError) {}, + onEndLoad : function(pSink) + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + document.getElementById('messages-tree').builder.rebuild(); + } +}; + +var MessagesTreeListener = +{ + willRebuild : function(builder) { }, + didRebuild : function(builder) + { + //timeout nur bei Mozilla notwendig da sonst die rows + //noch keine values haben. Ab Seamonkey funktionierts auch + //ohne dem setTimeout + //window.setTimeout(KontaktAdressenTreeSelectID,10); + } +}; + +// **** +// * Laedt die Trees +// **** +function loadMessages(person_id, fas_person_id) +{ + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + MessagePersonID = person_id; + MessageSenderPersonID=fas_person_id; + + //Adressen laden + url = "rdf/messages.rdf.php?person_id="+person_id+"&"+gettimestamp(); + var tree=document.getElementById('messages-tree'); + try + { + MessagesTreeDatasource.removeXMLSinkObserver(MessagesTreeSinkObserver); + tree.builder.removeListener(MessagesTreeListener); + } + catch(e) + {} + + //Alte DS entfernen + var oldDatasources = tree.database.GetDataSources(); + while(oldDatasources.hasMoreElements()) + { + tree.database.RemoveDataSource(oldDatasources.getNext()); + } + + var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); + MessagesTreeDatasource = rdfService.GetDataSource(url); + MessagesTreeDatasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource); + MessagesTreeDatasource.QueryInterface(Components.interfaces.nsIRDFXMLSink); + tree.database.AddDataSource(MessagesTreeDatasource); + MessagesTreeDatasource.addXMLSinkObserver(MessagesTreeSinkObserver); + tree.builder.addListener(MessagesTreeListener); + +} + + +// **** +// * Zeigt HTML Seite zum Erstellen neuer Nachrichten +// **** +function MessagesNewMessage() +{ + var tree = parent.document.getElementById('student-tree'); + + if (tree.currentIndex == -1) + { + alert("Bitte markieren Sie zuerst eine Person"); + } + else + { + var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); + + var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID; + + openWindowPostArray(action, 'prestudent_id', prestudentIdArray); + } +} + +/** + * Oeffnet Nachrichtenseite um eine Antwort auf eine Nachricht zu schicken + */ +function MessagesSendAnswer() +{ + var messagesTree = document.getElementById('messages-tree'); + var studentsTree = parent.document.getElementById('student-tree'); + + if (messagesTree.currentIndex == -1) + { + alert("Bitte markieren Sie zuerst eine Nachricht"); + } + else + { + var MessageId = getTreeCellText(messagesTree, 'messages-tree-message_id', messagesTree.currentIndex); + var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); + var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); + + var action = 'index.ci.php/system/FASMessages/writeReply/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + + openWindowPostArray(action, 'prestudent_id', prestudentIdArray); + } +} + +function MessageAuswahl() +{ + var tree=document.getElementById('messages-tree'); + if (tree.currentIndex == -1) + { + alert("Bitte markieren Sie zuerst eine Nachricht"); + } + else + { + var text = getTreeCellText(tree, 'messages-tree-body', tree.currentIndex); + var recipient_id = getTreeCellText(tree, 'messages-tree-recipient_id', tree.currentIndex); + // Antworten ist nur moeglich wenn die Message vom User kommt + if (recipient_id == MessagePersonID) + { + document.getElementById('messages-tree-popup-answer').disabled=true; + document.getElementById('messages-button-answer').disabled=true; + } + else + { + document.getElementById('messages-tree-popup-answer').disabled=false; + document.getElementById('messages-button-answer').disabled=false; + } + } + + MessagesIFrameSetHTML(text); +} + +function MessagesIFrameSetHTML(val) +{ + MessageIFrameInit(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + editor = document.getElementById('message-wysiwyg'); + + if(editor.contentWindow.document.body.innerHTML!='') + { + //Inhalt leeren + editor.contentDocument.execCommand("selectall", false, null); + editor.contentDocument.execCommand("delete", false, null); + } + //Value setzen + if(val!='') + editor.contentDocument.execCommand("inserthtml", false, val); +} + +function MessageIFrameInit() +{ + if(!MessageIFrameIsInitialized) + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + editor = document.getElementById('message-wysiwyg'); + editor.contentDocument.designMode = 'on'; + editor.style.backgroundColor="#FFFFFF"; + MessageIFrameIsInitialized=true; + } +} From ee4e7c503815479bf1d9b4d1787105711c2181dd Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 1 Feb 2019 17:28:01 +0100 Subject: [PATCH 03/19] Work in progress on Messages controller and messageWrite --- application/controllers/system/Messages.php | 230 ++++++-------------- application/views/system/messageWrite.php | 7 +- 2 files changed, 70 insertions(+), 167 deletions(-) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 27c029d20..94c0eb756 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -27,7 +27,6 @@ class Messages extends Auth_Controller $this->load->library('WidgetLib'); $this->load->model('system/Message_model', 'MessageModel'); - $this->load->model('person/Person_model', 'PersonModel'); $this->loadPhrases( array( @@ -41,86 +40,41 @@ class Messages extends Auth_Controller // Public methods /** - * Write + * Write a new message */ public function write() { - $sender_id = null; - $recipients = $this->input->post('person_id'); + $person_id = $this->input->post('person_id'); - $authUser = $this->PersonModel->getByUid(getAuthUID()); - if (isError($authUser)) - { - show_error($authUser->retval); - } - elseif (hasData($authUser)) - { - $sender_id = $authUser->retval[0]->person_id; - } + $sender_id = $this->_getAuthPersonId(); - $msg = null; + $msgVarsData = $this->_getMsgVarsData($person_id); - // Get message data if possible - if (is_numeric($msg_id) && is_numeric($receiver_id)) - { - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - if ($msg->error) - { - show_error($msg->retval); - } - else - { - $msg = $msg->retval[0]; - } - } + // Retrieves message vars for a person from view view vw_msg_vars_person + $variablesArray = $this->messagelib->getMessageVarsPerson(); - $variablesArray = array(); - $msgVarsData = array(); + // Organisation units used to get the templates + $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - // Get variables - $this->load->model('system/Message_model', 'MessageModel'); - - $this->getPersonMsgData($person_id, $variablesArray, $msgVarsData); - - // Organisation units used to get the templates - $oe_kurzbz = array(); // A person can have more organisation units - $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); - $benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id); - if (hasData($benutzerResult)) - { - foreach ($benutzerResult->retval as $val) - { - $oe_kurzbz[] = $val->oe_kurzbz; - } - } - - // Admin or commoner? - $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); - $isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id); - if (isError($isAdmin)) - { - show_error($isAdmin->retval); - } + // Admin or commoner? + $isAdmin = $this->messagelib->getIsAdmin($sender_id); $data = array ( - 'sender_id' => $sender_id, - 'receivers' => isset($msgVarsData->retval) ? $msgVarsData->retval : $msgVarsData, - 'message' => $msg, + 'recipients' => $msgVarsData->retval, 'variables' => $variablesArray, 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin->retval, - 'personOnly' => $personOnly//indicates if sent only to persons + 'isAdmin' => $isAdmin ); $this->load->view('system/messageWrite', $data); } /** - * send + * Send message */ - public function send($sender_id = null) + public function send() { - $result = $this->_execSend($sender_id); + $result = $this->_execSend(); if (isSuccess($result)) { @@ -136,9 +90,9 @@ class Messages extends Auth_Controller * Send message, response is in JSON format * @param $sender_id */ - public function sendJson($sender_id = null) + public function sendJson() { - $result = $this->_execSend($sender_id); + $result = $this->_execSend(); $this->output ->set_content_type('application/json') @@ -150,29 +104,25 @@ class Messages extends Auth_Controller * @param $sender_id * @return array wether execution was successfull - error or success */ - private function _execSend($sender_id) + private function _execSend() { - if ($sender_id === null) - { - $user_person = $this->PersonModel->getByUid(getAuthUID()); - - if (!hasData($user_person)) - { - return error('no sender'); - } - $sender_id = $user_person->retval[0]->person_id; - } + $sender_id = $this->_getAuthPersonId(); $subject = $this->input->post('subject'); $body = $this->input->post('body'); + $prestudents = $this->input->post('prestudents'); + // OR $persons = $this->input->post('persons'); + $relationmessage_id = $this->input->post('relationmessage_id'); + + // From infocenterDetails $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $oe_kurzbz = $this->input->post('oe_kurzbz'); $msgvars = $this->input->post('msgvars'); - if (!isset($relationmessage_id) || $relationmessage_id == '') + if (!is_numeric($relationmessage_id)) { $relationmessage_id = null; } @@ -275,9 +225,7 @@ class Messages extends Auth_Controller $this->VorlagestudiengangModel->addOrder('version','DESC'); $result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); - $this->output - ->set_content_type('application/json') - ->set_output(json_encode($result)); + $this->outputJsonSuccess($result); } } @@ -289,32 +237,34 @@ class Messages extends Auth_Controller $prestudent_id = $this->input->get('prestudent_id'); $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - + $parsedText = ''; $data = null; - if (isset($person_id) && !isset($prestudent_id)) - $data = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - elseif (isset($prestudent_id)) - $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - - if (isset($data)) + if (is_numeric($person_id)) { - $parsedText = ""; - if (hasData($data)) - { - $dataArray = (array)$data->retval[0]; - foreach ($dataArray as $key => $val) - { - $newKey = str_replace(" ", "_", strtolower($key)); - $dataArray[$newKey] = $dataArray[$key]; - } + $data = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + } + elseif (is_numeric($prestudent_id)) + { + $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + } - $parsedText = $this->messagelib->parseMessageText($text, $dataArray); + if (is_error($data) || !hasData($data)) + { + $this->outputJsonError($data->retval); + } + else + { + $dataArray = (array)$data->retval[0]; + foreach ($dataArray as $key => $val) + { + $newKey = str_replace(" ", "_", strtolower($key)); + $dataArray[$newKey] = $dataArray[$key]; } - $this->output - ->set_content_type('application/json') - ->set_output(json_encode($parsedText)); + $parsedText = $this->messagelib->parseMessageText($text, $dataArray); + + $this->outputJsonSuccess($parsedText); } } @@ -338,88 +288,42 @@ class Messages extends Auth_Controller // Private methods /** - * gets Message Variables and their data for Prestudent - * @param $prestudent_id - * @param $variablesArray to be filled with variable names - * @param $msgVarsData to be filled with variable data + * Retrieves message vars from view vw_msg_vars */ - private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData) - { - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - if ($msgVarsData->error) - { - show_error($msgVarsData->retval); - } - - if (!hasData($variables = $this->MessageModel->getMessageVars())) - { - unset($variables); - } - else - { - $variablesArray = array(); - // Skip person_id and prestudent_id - for ($i = 2; $i < count($variables->retval); $i++) - { - $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; - } - } - - array_shift($variables->retval); // Remove person_id - array_shift($variables->retval); // Remove prestudent_id - } - - /** - * gets Message Variables and their data for Person - * @param $person_id - * @param $variablesArray to be filled with variable names - * @param $msgVarsData to be filled with variable data - */ - private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData) + private function _getMsgVarsData($person_id) { $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - if ($msgVarsData->error) + + if (isError($msgVarsData)) { show_error($msgVarsData->retval); } - if (!hasData($variables = $this->MessageModel->getMessageVarsPerson())) - { - unset($variables); - } - else - { - $variablesArray = array(); - // Skip person_id - for ($i = 1; $i < count($variables->retval); $i++) - { - $variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i]; - } - array_shift($variables->retval); // Remove person_id - } + return $msgVarsData; } /** - * getPersonId + * */ - private function getPersonId() + private function _getAuthPersonId() { - $person_id = null; + $sender_id = null; - if ($this->input->get('person_id') !== null) + $this->load->model('person/Person_model', 'PersonModel'); + $authUser = $this->PersonModel->getByUid(getAuthUID()); + if (isError($authUser)) { - $person_id = $this->input->get('person_id'); + show_error($authUser->retval); } - elseif ($this->input->post('person_id') !== null) + elseif (!hasData($authUser)) { - $person_id = $this->input->get('person_id'); + show_error('The current logged user person_id is not defined'); + } + else + { + $sender_id = $authUser->retval[0]->person_id; } - if (!is_numeric($person_id)) - { - show_error('Person_id is not numeric'); - } - - return $person_id; + return $sender_id; } } diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index af83ad9a2..5d17f85b3 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageReply', + 'title' => 'Write a message', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, @@ -129,8 +129,7 @@ $this->load->view( '."\n"; + } + ?> + + + + + + + +
-
- load->view('system/messages/messageForm.php'); ?> - person_id; - $fieldname = 'persons[]'; - - echo ''."\n"; - } - ?> - - - - - - - -
-
- + load->view("templates/FHC-Footer"); ?> diff --git a/public/js/messaging/messageWriteReply.js b/public/js/messaging/messageWriteReply.js new file mode 100644 index 000000000..6343701d7 --- /dev/null +++ b/public/js/messaging/messageWriteReply.js @@ -0,0 +1,30 @@ +/** + * JS used by view system/messages/messageWriteReply + */ + +$(document).ready(function () +{ + tinymce.init({ + selector: "#bodyTextArea", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10, + auto_focus: "bodyTextArea" + }); + + if ($("#sendButton") && $("#sendForm")) + { + $("#sendButton").click(function () { + + if ($("#subject") && $("#subject").val() != '' && tinyMCE.get("bodyTextArea").getContent() != '') + { + $("#sendForm").submit(); + } + else + { + alert("Subject and text are required fields!"); + } + }); + } +}); From 9729036e26e672e07f677667ad477c33c7d1caf0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 8 Feb 2019 17:19:56 +0100 Subject: [PATCH 06/19] Added new function getData to helper hlp_message_helper.php --- application/helpers/hlp_message_helper.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/helpers/hlp_message_helper.php b/application/helpers/hlp_message_helper.php index 1197a02ac..c8bbcaf87 100644 --- a/application/helpers/hlp_message_helper.php +++ b/application/helpers/hlp_message_helper.php @@ -82,6 +82,21 @@ function hasData($result) return false; } +/** + * Returns the property retval if $result contains data + */ +function getData($result) +{ + $data = null; + + if (hasData($result)) + { + $data = $result->retval; + } + + return $data; +} + /** * Checks if the result represents an error * Wrapper function of isSuccess, more readable code From fad7894ec8ffbc5fe667cceefdfef29a51495992 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 8 Feb 2019 17:20:36 +0100 Subject: [PATCH 07/19] Halfway commit --- application/controllers/system/Messages.php | 166 ++++++++++---------- application/libraries/MessageLib.php | 35 +++-- 2 files changed, 98 insertions(+), 103 deletions(-) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 8f6225ff8..2c1890625 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -45,8 +45,17 @@ class Messages extends Auth_Controller public function write() { $person_id = $this->input->post('person_id'); + $sender_id = null; - $sender_id = $this->_getAuthPersonId(); + $authUser = $this->_getAuthUser(); + if (isError($authUser)) + { + show_error($authUser->retval); + } + else + { + $sender_id = getData($authUser)[0]->person_id; + } $msgVarsData = $this->_getMsgVarsData($person_id); @@ -74,119 +83,115 @@ class Messages extends Auth_Controller */ public function send() { - $result = $this->_execSend(); + $persons = $this->input->post('persons'); + $relationmessage_id = $this->input->post('relationmessage_id'); - $this->load->view('system/messages/messageSent', array('success' => isSuccess($result))); + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + + $send = $this->_send($msgVarsData, $relationmessage_id); + + $this->load->view('system/messages/messageSent', array('success' => isSuccess($send))); } /** * Send message, response is in JSON format - * @param $sender_id */ public function sendJson() { - $result = $this->_execSend(); + $prestudents = $this->input->post('prestudents'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $msgVars = $this->input->post('msgvars'); - $this->output - ->set_content_type('application/json') - ->set_output(json_encode($result)); + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + + if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) + { + for ($i = 0; $i < count($msgVarsData->retval); $i++) + { + for ($p = 0; $p < count($prestudentsData->retval); $p++) + { + if ($prestudentsData->retval[$p]->prestudent_id == $msgVarsData->retval[$i]->prestudent_id) + { + $msgVarsData->retval[$i]->oe_kurzbz = $prestudentsData->retval[$p]->oe_kurzbz; + break; + } + } + } + } + + $send = $this->_send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + if (isError($send)) + { + $this->outputJsonError($send->retval); + } + else + { + $this->outputJsonSuccess($send->retval); + } } + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + /** * Executes message sending * @param $sender_id * @return array wether execution was successfull - error or success */ - private function _execSend() + private function _send($msgVarsData, $relationmessage_id = null, $oe_kurzbz = null, $vorlage_kurzbz = null, $msgVars = null) { - $sender_id = $this->_getAuthPersonId(); - $subject = $this->input->post('subject'); $body = $this->input->post('body'); - $prestudents = $this->input->post('prestudents'); - // OR - $persons = $this->input->post('persons'); + $authUser = $this->_getAuthUser(); + if (isError($authUser)) return $authUser; - $relationmessage_id = $this->input->post('relationmessage_id'); - - // From infocenterDetails - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); - $oe_kurzbz = $this->input->post('oe_kurzbz'); - $msgvars = $this->input->post('msgvars'); - - if (!is_numeric($relationmessage_id)) - { - $relationmessage_id = null; - } - - // get message data of prestudents or persons - $prestudentsData = array(); - if ($prestudents !== null) - { - $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - // - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - } - else - $data = $this->MessageModel->getMsgVarsDataByPersonId($persons); + $sender_id = getData($authUser)[0]->person_id; // send message(s) - if (hasData($data)) + if (hasData($msgVarsData)) { - for ($i = 0; $i < count($data->retval); $i++) + // Loads the person log library + $this->load->library('PersonLogLib'); + + for ($i = 0; $i < count($msgVarsData->retval); $i++) { $parsedText = ""; - $dataArray = (array)$data->retval[$i]; + $msgVarsDataArray = (array)$msgVarsData->retval[$i]; - // if oe not given, get from prestudent - if (isEmptyString($oe_kurzbz) && hasData($prestudentsData)) - { - for ($p = 0; $p < count($prestudentsData->retval); $p++) - { - if ($prestudentsData->retval[$p]->prestudent_id == $data->retval[$i]->prestudent_id) - { - $oe_kurzbz = $prestudentsData->retval[$p]->oe_kurzbz; - } - } - } - - // send without vorlage + // Send without vorlage if (isEmptyString($vorlage_kurzbz)) { - $parsedText = $this->messagelib->parseMessageText($body, $dataArray); - $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); + $parsedText = $this->messagelib->parseMessageText($body, $msgVarsDataArray); + $msg = $this->messagelib->sendMessage($sender_id, $msgVarsDataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); } - // send with vorlage + // Send with vorlage else { - if (isset($msgvars) && is_array($msgvars)) + if (isset($msgVars) && is_array($msgVars)) { - // additional message variables - foreach ($msgvars as $key => $msgvar) + // Additional message variables + foreach ($msgVars as $key => $msgvar) { - $dataArray[$key] = $msgvar; + $msgVarsDataArray[$key] = $msgvar; } } - $msg = $this->messagelib->sendMessageVorlage($sender_id, $dataArray['person_id'], $vorlage_kurzbz, $oe_kurzbz, $dataArray); + $msg = $this->messagelib->sendMessageVorlage($sender_id, $msgVarsDataArray['person_id'], $vorlage_kurzbz, $oe_kurzbz, $msgVarsDataArray); } - if ($msg->error) - { - return error($msg->msg); - } - - // Loads the person log library - $this->load->library('PersonLogLib'); + if (isError($msg)) return $msg; //write log entry $this->personloglib->log( - $dataArray['person_id'], + $msgVarsDataArray['person_id'], 'Action', array( 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$dataArray['person_id'].', messageid '.$msg->retval, + 'message' => 'Message sent from person '.$sender_id.' to '.$msgVarsDataArray['person_id'].', messageid '.$msg->retval, 'success' => 'true' ), 'kommunikation', @@ -194,7 +199,6 @@ class Messages extends Auth_Controller null, getAuthUID() ); - } return success('success'); @@ -271,6 +275,7 @@ class Messages extends Auth_Controller { $msg_id = $this->input->get('msg_id'); $receiver_id = $this->input->get('receiver_id'); + $msg = $this->messagelib->getMessage($msg_id, $receiver_id); $this->output @@ -287,7 +292,6 @@ class Messages extends Auth_Controller private function _getMsgVarsData($person_id) { $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - if (isError($msgVarsData)) { show_error($msgVarsData->retval); @@ -299,25 +303,15 @@ class Messages extends Auth_Controller /** * */ - private function _getAuthPersonId() + private function _getAuthUser() { $sender_id = null; $this->load->model('person/Person_model', 'PersonModel'); $authUser = $this->PersonModel->getByUid(getAuthUID()); - if (isError($authUser)) - { - show_error($authUser->retval); - } - elseif (!hasData($authUser)) - { - show_error('The current logged user person_id is not defined'); - } - else - { - $sender_id = $authUser->retval[0]->person_id; - } - return $sender_id; + if (!hasData($authUser)) $authUser = error('The current logged user person_id is not defined'); + + return $authUser; } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 035c93eb8..29b4d09ae 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -54,9 +54,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - $msg = $this->_ci->RecipientModel->getMessage($msg_id, $person_id); - - return $msg; + return $this->_ci->RecipientModel->getMessage($msg_id, $person_id); } /** @@ -67,9 +65,7 @@ class MessageLib if (isEmptyString($uid)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->_ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); - - return $msg; + return $this->_ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); } /** @@ -80,9 +76,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->_ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - - return $msg; + return $this->_ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); } /** @@ -93,9 +87,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_MSG_ID); - $msg = $this->_ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - - return $msg; + return $this->_ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); } /** @@ -149,9 +141,7 @@ class MessageLib if (!is_numeric($person_id)) return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - $msg = $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); - - return $msg; + return $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); } /** @@ -780,7 +770,11 @@ class MessageLib $variablesArray = array(); $variables = $this->_ci->MessageModel->getMessageVarsPerson(); - if (hasData($variables)) + if (isError($variables)) + { + show_error($variables->retval); + } + elseif (hasData($variables)) { // Skip person_id for ($i = 1; $i < count($variables->retval); $i++) @@ -824,7 +818,6 @@ class MessageLib { $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); $isAdmin = $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); - if (isError($isAdmin)) { show_error($isAdmin->retval); @@ -833,6 +826,14 @@ class MessageLib return $isAdmin->retval; } + /** + * + */ + public function send() + { + + } + //------------------------------------------------------------------------------------------------------------------ // Private methods From 37c4ad85b853f72c4803ff722c84303c70017942 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 14 Feb 2019 17:20:50 +0100 Subject: [PATCH 08/19] changed Name "getActiveKostenstellenForGeschaeftsjahr" to "getKostenstellenForGeschaeftsjahr" in Kostenstelle_model to avoid confusion (kostenstelle has active field in db, but meant is active as "valid in a Geschaeftsjahr") --- application/models/accounting/Kostenstelle_model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/models/accounting/Kostenstelle_model.php b/application/models/accounting/Kostenstelle_model.php index f338b69d5..719d08835 100644 --- a/application/models/accounting/Kostenstelle_model.php +++ b/application/models/accounting/Kostenstelle_model.php @@ -13,12 +13,12 @@ class Kostenstelle_model extends DB_Model } /** - * Gets all active Kostenstellen for a geschaeftsjahr, as determined by the geschaeftsjahrvon and bis fields + * Gets Kostenstellen for a geschaeftsjahr, as determined by the geschaeftsjahrvon and bis fields * Gets Kostenstellen of current Geschaeftsjahr if Geschaeftsjahr not specified * @param $geschaeftsjahr * @return array|null Kostenstellen or empty array if no geschaeftsjahr found */ - public function getActiveKostenstellenForGeschaeftsjahr($geschaeftsjahr = null) + public function getKostenstellenForGeschaeftsjahr($geschaeftsjahr = null) { $this->load->model('organisation/geschaeftsjahr_model', 'GeschaeftsjahrModel'); @@ -47,12 +47,12 @@ class Kostenstelle_model extends DB_Model } /** - * Gets all active Kostenstellen for a geschaeftsjahr, as determined by the geschaeftsjahrvon and bis fields, together with their oe, + * Gets Kostenstellen for a geschaeftsjahr, as determined by the geschaeftsjahrvon and bis fields, together with their oe, * hierarchally sorted, gets Kostenstellen of current Geschaeftsjahr if Geschaeftsjahr not specified * @param null $geschaeftsjahr * @return array|null */ - public function getActiveKostenstellenForGeschaeftsjahrWithOe($geschaeftsjahr = null) + public function getKostenstellenForGegitschaeftsjahrWithOe($geschaeftsjahr = null) { $this->load->model('organisation/geschaeftsjahr_model', 'GeschaeftsjahrModel'); From c3d4cb4bfcb44cd29b09229eca10f5c5a9d2fda4 Mon Sep 17 00:00:00 2001 From: Andreas Oesterreicher Date: Thu, 14 Feb 2019 17:56:58 +0100 Subject: [PATCH 09/19] =?UTF-8?q?Spezielle=20Vorlage=20f=C3=BCr=20ESA=20/?= =?UTF-8?q?=20EIF=20da=20dort=20der=20Stundensatz=20immer=20angedruckt=20w?= =?UTF-8?q?erden=20soll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/xsl/Lehrauftrag_ESA_EIF.xsl | 529 +++++++++++++++++++++++++++++ 1 file changed, 529 insertions(+) create mode 100644 system/xsl/Lehrauftrag_ESA_EIF.xsl diff --git a/system/xsl/Lehrauftrag_ESA_EIF.xsl b/system/xsl/Lehrauftrag_ESA_EIF.xsl new file mode 100644 index 000000000..fa743924f --- /dev/null +++ b/system/xsl/Lehrauftrag_ESA_EIF.xsl @@ -0,0 +1,529 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Abs.: Technikum Wien GmbH, Höchstädtplatz 6, 1200 Wien + + + + Lehrauftrag Lehrgang + + + + SV.Nr.: + Personalnummer: + + + Wir beauftragen Sie, im folgende Lehrveranstaltungen abzuhalten: + + + + + + + + + + + + ID + + + Lehrveranstaltung + + + Institut + + + Gruppe(n) + + + + Std. + + + Satz + + + Brutto + + + + + + + + + + + + + + + + + Summe: + + + + + + + + + + + + + + + + Die angeführten Stundensätze sind Bruttobeträge, von denen gegebenenfalls die DienstnehmerInnenanteile für Steuern und Sozialversicherung abgezogen werden. + Die angeführte Stundenzahl ist die maximal vorgesehene; abgerechnet werden jedoch nur die tatsächlich gehaltenen Stunden laut Anwesenheitslisten. + Außerdem besteht die Verpflichtung zur Teilnahme an LektorInnenkonferenzen. + + + + + + + + + + Wien, am + + + + + + + + + + + + Ort, Datum + + + + + + + Lehrgangsleitung + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f3bc7649305fe3979282bb840daf037df6c3d186 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 15 Feb 2019 14:37:14 +0100 Subject: [PATCH 10/19] - Better code - Better errors handling - Fixed include path for view messageList.php --- application/controllers/ViewMessage.php | 28 ++++++------------- application/controllers/system/Messages.php | 12 ++++++-- .../system/infocenter/InfoCenter.php | 2 +- .../system/infocenter/infocenterDetails.php | 2 +- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index 6794cb2bc..35f5a5b4b 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -134,8 +134,6 @@ class ViewMessage extends FHC_Controller $this->load->model('system/Message_model', 'MessageModel'); $this->load->library('MessageLib'); - $error = false; - $subject = $this->input->post('subject'); $body = $this->input->post('body'); $persons = $this->input->post('persons'); @@ -145,7 +143,6 @@ class ViewMessage extends FHC_Controller if (!isset($relationmessage_id) || $relationmessage_id == '' || !isset($token) || $token == '') { show_error('Error while sending reply'); - $error = true; } $relationmsg = $this->MessageTokenModel->getMessageByToken($token); @@ -154,7 +151,6 @@ class ViewMessage extends FHC_Controller if (!hasData($relationmsg) || $relationmessage_id !== $relationmsg->retval[0]->message_id) { show_error('Error while sending reply'); - $error = true; } // get sender (receiver of previous msg) @@ -166,20 +162,16 @@ class ViewMessage extends FHC_Controller // send message(s) if (hasData($data)) { + // Loads the person log library + $this->load->library('PersonLogLib'); + for ($i = 0; $i < count($data->retval); $i++) { $dataArray = (array)$data->retval[$i]; $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $body, PRIORITY_NORMAL, $relationmessage_id, null); - if ($msg->error) - { - show_error($msg->retval); - $error = true; - break; - } - // Loads the person log library - $this->load->library('PersonLogLib'); + if ($msg->error) show_error($msg->retval); // Write log entry for sender $logtype_kurzbz = 'Action'; @@ -193,7 +185,8 @@ class ViewMessage extends FHC_Controller $oe_kurzbz = null; $insertvon = 'online'; - $this->personloglib->log( + // Logs person data + $personLog = $this->personloglib->log( $sender_id, $logtype_kurzbz, $logdata, @@ -203,14 +196,11 @@ class ViewMessage extends FHC_Controller $insertvon ); - //unpark bewerber after he sends message - $this->personloglib->unPark($sender_id); + // Unpark bewerber after he sends message + $personLog = $this->personloglib->unPark($sender_id); } } - if (!$error) - { - $this->load->view('system/messages/messageReplySent'); - } + $this->load->view('system/messages/messageReplySent'); } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 2c1890625..3f407147b 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -124,6 +124,7 @@ class Messages extends Auth_Controller } $send = $this->_send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + if (isError($send)) { $this->outputJsonError($send->retval); @@ -148,6 +149,7 @@ class Messages extends Auth_Controller $body = $this->input->post('body'); $authUser = $this->_getAuthUser(); + if (isError($authUser)) return $authUser; $sender_id = getData($authUser)[0]->person_id; @@ -172,7 +174,7 @@ class Messages extends Auth_Controller // Send with vorlage else { - if (isset($msgVars) && is_array($msgVars)) + if (is_array($msgVars)) { // Additional message variables foreach ($msgVars as $key => $msgvar) @@ -186,7 +188,7 @@ class Messages extends Auth_Controller if (isError($msg)) return $msg; //write log entry - $this->personloglib->log( + $personLog = $this->personloglib->log( $msgVarsDataArray['person_id'], 'Action', array( @@ -201,7 +203,11 @@ class Messages extends Auth_Controller ); } - return success('success'); + return success('Messages sent successfully'); + } + else + { + return $msgVarsData; } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 65e81a201..431d0ecd8 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -631,7 +631,7 @@ class InfoCenter extends Auth_Controller public function reloadMessages($person_id) { $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); - $this->load->view('system/messageList.php', array('messages' => $messages->retval)); + $this->load->view('system/messages/messageList.php', array('messages' => $messages->retval)); } /** diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index c59702a65..f29be7127 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -143,7 +143,7 @@
load->view('system/messageList.php', $messages); + $this->load->view('system/messages/messageList.php', $messages); ?>
From a913482ef4cc8408a5d403b4f46a0d39664e7abf Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 15 Feb 2019 15:30:04 +0100 Subject: [PATCH 11/19] - Added private method _replaceKeys to controller system/Messages.php - Fixed replacement of keys in the message vars array --- application/controllers/system/Messages.php | 26 +++++++++++++++++---- application/libraries/MessageLib.php | 10 +------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 3f407147b..ed6d12044 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -108,6 +108,7 @@ class Messages extends Auth_Controller $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)) { for ($i = 0; $i < count($msgVarsData->retval); $i++) @@ -124,7 +125,6 @@ class Messages extends Auth_Controller } $send = $this->_send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - if (isError($send)) { $this->outputJsonError($send->retval); @@ -154,7 +154,7 @@ class Messages extends Auth_Controller $sender_id = getData($authUser)[0]->person_id; - // send message(s) + // Send message(s) if (hasData($msgVarsData)) { // Loads the person log library @@ -163,7 +163,7 @@ class Messages extends Auth_Controller for ($i = 0; $i < count($msgVarsData->retval); $i++) { $parsedText = ""; - $msgVarsDataArray = (array)$msgVarsData->retval[$i]; + $msgVarsDataArray = $this->_replaceKeys((array)$msgVarsData->retval[$i]); // replaces array keys // Send without vorlage if (isEmptyString($vorlage_kurzbz)) @@ -187,7 +187,7 @@ class Messages extends Auth_Controller if (isError($msg)) return $msg; - //write log entry + // Write log entry $personLog = $this->personloglib->log( $msgVarsDataArray['person_id'], 'Action', @@ -266,7 +266,7 @@ class Messages extends Auth_Controller } else { - $parsedText = $this->messagelib->parseMessageText($text, (array)$data->retval[0]); + $parsedText = $this->messagelib->parseMessageText($text, $this->_replaceKeys((array)$data->retval[0])); $this->outputJsonSuccess($parsedText); } @@ -320,4 +320,20 @@ class Messages extends Auth_Controller return $authUser; } + + /** + * + */ + private function _replaceKeys($data) + { + $tmpData = array(); + + // Replaces data array keys to a lowercase without spaces string + foreach ($data as $key => $val) + { + $tmpData[str_replace(' ', '_', strtolower($key))] = $val; + } + + return $tmpData; + } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 29b4d09ae..eadf54500 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -750,15 +750,7 @@ class MessageLib */ public function parseMessageText($text, $data = array()) { - $tmpData = array(); - - // Replaces data array keys to a lowercase without spaces string - foreach ($data as $key => $val) - { - $tmpData[str_replace(' ', '_', strtolower($key))] = $data[$key]; - } - - return $this->_ci->parser->parse_string($text, $tmpData, true); + return $this->_ci->parser->parse_string($text, $data, true); } /** From e93ee714662f2c252ab616481f751472d4b90ae3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 15 Feb 2019 15:34:48 +0100 Subject: [PATCH 12/19] Removed not implemented method --- application/libraries/MessageLib.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index eadf54500..c539a0bc7 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -818,14 +818,6 @@ class MessageLib return $isAdmin->retval; } - /** - * - */ - public function send() - { - - } - //------------------------------------------------------------------------------------------------------------------ // Private methods From ae29f9e93a99f9196247d809e28aa44ffc789dab Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 18 Feb 2019 16:55:58 +0100 Subject: [PATCH 13/19] Function getStudiensemesterOnlinebewerbung with optional "art" --- include/studiensemester.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/studiensemester.class.php b/include/studiensemester.class.php index 358aa3170..98b94a33d 100644 --- a/include/studiensemester.class.php +++ b/include/studiensemester.class.php @@ -849,13 +849,21 @@ class studiensemester extends basis_db /** * Laedt die Studiensemester die fuer die Onlinebewerbung aktiviert sind - * + * @param string $art Optional. + * Wenn art=WS dann wird das naechste Wintersemester geliefert. + * Wenn art=SS dann wird das naechste Sommersemester geliefert. * @return true wenn ok, sonst false */ - public function getStudiensemesterOnlinebewerbung() + public function getStudiensemesterOnlinebewerbung($art = '') { - $qry = "SELECT * FROM public.tbl_studiensemester WHERE onlinebewerbung=true - ORDER BY start"; + $qry = "SELECT * FROM public.tbl_studiensemester WHERE onlinebewerbung=true"; + + if($art == 'WS' || $art == 'SS' ) + { + $qry .= " AND substring(studiensemester_kurzbz from 1 for 2)=" . $this->db_add_param($art); + } + + $qry.= " ORDER BY start"; if($this->db_query($qry)) { From 0645095af0a85ecba3a575d181cdb6a29c1abfb4 Mon Sep 17 00:00:00 2001 From: raab Date: Tue, 19 Feb 2019 15:31:58 +0100 Subject: [PATCH 14/19] Unterscheidung ob intern / extern bei MitarbeiterInnen ind Suche und Profil --- cis/private/profile/index.php | 4 +++- cis/private/tools/suche.php | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cis/private/profile/index.php b/cis/private/profile/index.php index 6f2848bdf..3af22ac35 100644 --- a/cis/private/profile/index.php +++ b/cis/private/profile/index.php @@ -205,8 +205,10 @@ echo ' //Foto anzeigen $benutzer = new benutzer(); $benutzer->load($uid); + $person = new person(); $person->load($benutzer->person_id); +//var_dump($person); if ($person->foto != '') { if (!($ansicht && $user->foto_sperre)) @@ -238,7 +240,7 @@ if (!$ansicht) echo ''; echo ' - '.($type == "student"?$p->t("profil/student"):$p->t('profil/mitarbeiter')).'

+ '.($type == "student"?$p->t("profil/student") : ($user->fixangestellt ? $p->t('profil/mitarbeiter') : $p->t('personensuche/mitarbeiterInExtern'))).'

'.$p->t('global/username').': '.$user->uid.'
'; if ($type == 'student' && $person->matr_nr) echo $p->t('global/matrikelnummer'). ": ". $person->matr_nr. "
"; diff --git a/cis/private/tools/suche.php b/cis/private/tools/suche.php index 517f3bde0..2261a4e66 100644 --- a/cis/private/tools/suche.php +++ b/cis/private/tools/suche.php @@ -158,7 +158,7 @@ function searchPerson($searchItems) { $bisverwendung = new bisverwendung(); $bisverwendung->getLastAktVerwendung($row->uid); - + echo ''; //echo '',$row->titelpre,''; echo '',$row->anrede,''; @@ -171,7 +171,7 @@ function searchPerson($searchItems) echo ''; //echo '',$row->titelpost,''; echo '',($row->studiengang!=''?$row->studiengang:'-'),''; - echo '',($row->mitarbeiter_uid==NULL?'StudentIn':'MitarbeiterIn'),''; + echo '',($row->mitarbeiter_uid==NULL ? $p->t('personensuche/studentIn') : ($row->fixangestellt=='t' ? $p->t('personensuche/mitarbeiterIn') : $p->t('personensuche/mitarbeiterInExtern'))),''; // Display phone number echo ''; // * if user has telefonklappe, display it @@ -197,7 +197,7 @@ function searchPerson($searchItems) { echo $kontakt->kontakt. "
"; $is_zugestellt = true; - } + } } // if zustellung is false display '-' if (!$is_zugestellt) @@ -211,7 +211,7 @@ function searchPerson($searchItems) echo '-'; } } - echo ''; + echo ''; echo '',($row->raum!=''?$row->raum:'-'),''; if($row->alias!='' && !in_array($row->studiengang_kz, $noalias)) $mail = $row->alias.'@'.DOMAIN; @@ -311,7 +311,7 @@ function searchOE($searchItems) if($bisverwendung->beschausmasscode=='5') echo ' (karenziert)'; echo ''; - + // Display phone number echo ''; // * if user has telefonklappe, display it @@ -323,7 +323,7 @@ function searchOE($searchItems) else { $person_id = $person->person_id; - + if ($kontakt->load_persKontakttyp($person_id, 'firmenhandy')) { $is_zugestellt = false; @@ -334,13 +334,13 @@ function searchOE($searchItems) { echo $kontakt->kontakt. "
"; $is_zugestellt = true; - } + } } // if zustellung is false display '-' if (!$is_zugestellt) { echo '-'; - } + } } // * if neither telefonklappe nor business handy, display '-' else @@ -348,8 +348,8 @@ function searchOE($searchItems) echo '-'; } } - echo ''; - + echo ''; + echo '',($mitarbeiter->ort_kurzbz!=''?$mitarbeiter->ort_kurzbz:'-'),''; //if($row->alias!='' && !in_array($row->studiengang_kz, $noalias)) ??? Was macht $noalias? if($person->alias!='') From a2d0ae6da8c8f00c52b7c3502372e22fd1429d0e Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 Feb 2019 16:50:20 +0100 Subject: [PATCH 15/19] =?UTF-8?q?Infocenter:=20=20-=20FIT=20Programme=20St?= =?UTF-8?q?udieng=C3=A4nge=2010021,10027=20can=20be=20freigegeben=20an=20S?= =?UTF-8?q?tudiengang=20=20-=20earlier=20check=20for=20existing=20prestude?= =?UTF-8?q?ntid=20in=20prestudentmodel=20in=20getPrestudentWithZgv=20metho?= =?UTF-8?q?d=20=20-=20reduced=20Sprache=20attributed=20to=20sprache,=20loc?= =?UTF-8?q?ale,=20bezeichnung=20in=20prestudentmodel=20in=20getPrestudentW?= =?UTF-8?q?ithZgv=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/models/crm/Prestudent_model.php | 6 ++- .../views/system/infocenter/zgvpruefungen.php | 52 +++++++++++++++---- public/js/infocenter/infocenterDetails.js | 25 ++++++--- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 89ab2623d..4a9b23ec9 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -204,8 +204,8 @@ class Prestudent_model extends DB_Model $this->addJoin('bis.tbl_nation zgvmanat', 'zgvmanation = zgvmanat.nation_code', 'LEFT'); $prestudent = $this->load($prestudent_id); - if($prestudent->error) - return error($prestudent->retval); + if (!hasData($prestudent)) + return error('prestudent could not be loaded'); //Prestudentstatus $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); @@ -225,6 +225,7 @@ class Prestudent_model extends DB_Model if (count($studienordnung->retval) > 0) { + $lastStatus->retval[0]->studiengang_kz = $studienordnung->retval[0]->studiengang_kz; $lastStatus->retval[0]->studiengangkurzbzlang = $studienordnung->retval[0]->studiengangkurzbzlang; $lastStatus->retval[0]->studiengangbezeichnung = $studienordnung->retval[0]->studiengangbezeichnung; $lastStatus->retval[0]->studiengangbezeichnung_englisch = $studienordnung->retval[0]->studiengangbezeichnung_englisch; @@ -233,6 +234,7 @@ class Prestudent_model extends DB_Model //get Sprache $this->load->model('system/sprache_model', 'SpracheModel'); + $this->SpracheModel->addSelect('sprache, locale, bezeichnung'); $language = $this->SpracheModel->load($lastStatus->retval[0]->sprache); if ($language->error) diff --git a/application/views/system/infocenter/zgvpruefungen.php b/application/views/system/infocenter/zgvpruefungen.php index 4f4037f43..806f87410 100644 --- a/application/views/system/infocenter/zgvpruefungen.php +++ b/application/views/system/infocenter/zgvpruefungen.php @@ -2,11 +2,34 @@ infoonly; + $studiengangkurzbz = $studiengangbezeichnung = $studiengangtyp = ''; + $studiensemester = isset($zgvpruefung->prestudentstatus->studiensemester_kurzbz) ? $zgvpruefung->prestudentstatus->studiensemester_kurzbz : ''; - $studiengangkurzbz = empty($zgvpruefung->prestudentstatus->studiengangkurzbzlang) ? $zgvpruefung->studiengang : $zgvpruefung->prestudentstatus->studiengangkurzbzlang; - $studiengangbezeichnung = empty($zgvpruefung->prestudentstatus->studiengangbezeichnung) ? $zgvpruefung->studiengangbezeichnung : $zgvpruefung->prestudentstatus->studiengangbezeichnung; + $studiengang_kz = isset($zgvpruefung->studiengang_kz) ? $zgvpruefung->studiengang_kz : ''; + $studiengangtyp = isset($zgvpruefung->studiengangtyp) ? $zgvpruefung->studiengangtyp : ''; + + if (empty($zgvpruefung->prestudentstatus->studiengangkurzbzlang)) + { + if (!empty($zgvpruefung->studiengang)) + $studiengangkurzbz = $zgvpruefung->studiengang; + } + else + { + $studiengangkurzbz = $zgvpruefung->prestudentstatus->studiengangkurzbzlang; + } + + if (empty($zgvpruefung->prestudentstatus->studiengangbezeichnung)) + { + if (!empty($zgvpruefung->studiengangbezeichnung)) + $studiengangbezeichnung = $zgvpruefung->studiengangbezeichnung; + } + else + { + $studiengangbezeichnung = $zgvpruefung->prestudentstatus->studiengangbezeichnung; + } //set bootstrap columns for zgv form $columns = array(3, 3, 3, 3); @@ -219,7 +242,7 @@
- studiengangtyp === 'm') : ?> +
@@ -360,17 +383,24 @@
prestudentstatus->bewerbung_abgeschicktamum)) { - $disabled = 'disabled'; - $disabledTxt = 'Die Bewerbung muss erst abgeschickt worden sein.'; + $disabled = $disabledStg = 'disabled'; + $disabledTxt = $disabledStgTxt = 'Die Bewerbung muss erst abgeschickt worden sein.'; } - if ($zgvpruefung->studiengangtyp !== 'b') + if ($studiengangtyp !== 'b') { $disabled = 'disabled'; - $disabledTxt = 'Nur Bachelorstudiengänge können freigegeben werden.';; + $disabledTxt = 'Nur Bachelorstudiengänge können freigegeben werden.'; + + // FIT-Lehrgänge: exceptions, can be freigegeben in Infocenter + if (!in_array($studiengang_kz, $fit_programme_studiengaenge)) + { + $disabledStg = 'disabled'; + $disabledStgTxt = 'Nur Bachelorstudiengänge können freigegeben werden.'; + } } ?>
@@ -378,7 +408,7 @@
- diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 27a6e9497..16179117d 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -7,6 +7,8 @@ const RTFREIGABE_MESSAGE_VORLAGE_QUER = "InfocenterRTfreigegQuer"; const RTFREIGABE_MESSAGE_VORLAGE_QUER_KURZ = "InfocenterRTfreigegQuerKurz"; const STGFREIGABE_MESSAGE_VORLAGE = "InfocenterSTGfreigegeben"; +const FIT_PROGRAMM_STUDIENGAENGE = [10021, 10027]; + /** * javascript file for infocenterDetails page */ @@ -507,17 +509,26 @@ var InfocenterDetails = { if (id !== prestudentid) { if (receiverPrestudentstatus.studiensemester_kurzbz === prestudentstatus.studiensemester_kurzbz - && prestudentstatus.bestaetigtam !== null && prestudentstatus.status_kurzbz === "Interessent" - && prestudent.studiengangtyp === "b") + && prestudentstatus.bestaetigtam !== null && prestudentstatus.status_kurzbz === "Interessent") { - if (prestudentstatus.statusgrund_id === null) + if (prestudent.studiengangtyp === "b") { - rtFreigegeben = true; - break; + if (prestudentstatus.statusgrund_id === null) + { + rtFreigegeben = true; + } + else if ($.isNumeric(prestudentstatus.statusgrund_id)) + { + stgFreigegeben = true; + } } - else if($.isNumeric(prestudentstatus.statusgrund_id)) + // special case FIT programme Freigabe (stgtyp not bachelor) - STG Freigabe possible + else if ($.inArray(parseInt(prestudent.studiengang_kz), FIT_PROGRAMM_STUDIENGAENGE) >= 0) { - stgFreigegeben = true; + if ($.isNumeric(prestudentstatus.statusgrund_id)) + { + stgFreigegeben = true; + } } } } From 5fe28e4904ec1be64b67f83eda986fa4311cf2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 21 Feb 2019 10:37:32 +0100 Subject: [PATCH 16/19] Removed Header Styling from default Header --- application/views/person/gradelist/gradelist.php | 3 ++- application/views/templates/FHC-Header.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/application/views/person/gradelist/gradelist.php b/application/views/person/gradelist/gradelist.php index f00978294..c6aaaa2f8 100644 --- a/application/views/person/gradelist/gradelist.php +++ b/application/views/person/gradelist/gradelist.php @@ -9,7 +9,8 @@ 'fontawesome' => true, 'ajaxlib' => true, 'customCSSs' => array( - 'public/css/tools/gradelist.css' + 'public/css/tools/gradelist.css', + 'public/css/fhcomplete.css' ), 'customJSs' => array( 'public/js/bootstrapper.js' diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 6a96eb6f9..2c9768a50 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -93,8 +93,6 @@ // NavigationWidget CSS if ($navigationwidget === true) generateCSSsInclude('public/css/NavigationWidget.css'); - generateCSSsInclude('public/css/fhcomplete.css'); - // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS From 1474400a3c1f1b2c46956acd1a58f4e627e2e672 Mon Sep 17 00:00:00 2001 From: Andreas Oesterreicher Date: Thu, 21 Feb 2019 11:29:58 +0100 Subject: [PATCH 17/19] =?UTF-8?q?Zusatztext=20f=C3=BCr=20Lehrg=C3=A4nge=20?= =?UTF-8?q?wird=20jetzt=20auch=20erstellt=20wenn=20der=20Lehrgang=20mit=20?= =?UTF-8?q?Typ=20E=20erfasst=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rdf/diplomasupplement.xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdf/diplomasupplement.xml.php b/rdf/diplomasupplement.xml.php index d40f9afc3..4f2e66a58 100644 --- a/rdf/diplomasupplement.xml.php +++ b/rdf/diplomasupplement.xml.php @@ -291,7 +291,7 @@ if (isset($_REQUEST["xmlformat"]) && $_REQUEST["xmlformat"] == "xml") echo ' Doktoratsstudium (UNESCO ISCED 8)'; echo ' University doctoral studies (UNESCO ISCED 8)'; } - elseif($row->typ=='l' || $row->typ=='k') + elseif($row->typ=='l' || $row->typ=='k' || $row->typ=='e') { echo ' UNESCO ISCED 7'; echo ' Lehrgang zur Weiterbildung nach §9 FHStG idgF.'; From 0cb86f84edec1339f48e5d3e2d8b69e9f6839a27 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 21 Feb 2019 17:18:12 +0100 Subject: [PATCH 18/19] Infocenter: - No Message sent when FIT program Freigabe --- .../system/infocenter/InfoCenter.php | 2 +- public/js/infocenter/infocenterDetails.js | 70 ++++++++++--------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 431d0ecd8..ef282b73b 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -527,7 +527,7 @@ class InfoCenter extends Auth_Controller $logparams = array($prestudent_id, $logdata['studiengang_kurzbz'], ''); - if (isset($statusgrund_id)) + if (isset($statusgrund_id) && is_numeric($statusgrund_id)) { $this->StatusgrundModel->addSelect('bezeichnung_mehrsprachig'); $statusgrund_kurzbz = $this->StatusgrundModel->load($statusgrund_id); diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 16179117d..d4d0d5cb9 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -7,7 +7,9 @@ const RTFREIGABE_MESSAGE_VORLAGE_QUER = "InfocenterRTfreigegQuer"; const RTFREIGABE_MESSAGE_VORLAGE_QUER_KURZ = "InfocenterRTfreigegQuerKurz"; const STGFREIGABE_MESSAGE_VORLAGE = "InfocenterSTGfreigegeben"; +//Statusgründe for which no Studiengang Freigabe Message should be sent const FIT_PROGRAMM_STUDIENGAENGE = [10021, 10027]; +const STGFREIGABE_MESSAGESEND_EXCEPTIONS = ["FIT Programm", "FIT program", "FIT programme"]; /** * javascript file for infocenterDetails page @@ -265,23 +267,23 @@ var InfocenterDetails = { } ); }, - saveFreigabe: function(data, rtfreigabe) + saveFreigabe: function(freigabeData) { FHC_AjaxClient.ajaxCallPost( CALLED_PATH + '/saveFreigabe', - data, + {"prestudent_id": freigabeData.prestudent_id, "statusgrund_id": freigabeData.statusgrund_id}, { - successCallback: function(data, textStatus, jqXHR) { + successCallback: function(freigabeResponseData, textStatus, jqXHR) { - if (FHC_AjaxClient.hasData(data)) + if (FHC_AjaxClient.hasData(freigabeResponseData)) { FHC_AjaxClient.showVeil(); - InfocenterDetails.initFrgMessageSend(data.retval.prestudent_id, rtfreigabe); + InfocenterDetails.initFrgMessageSend(freigabeData); InfocenterDetails._refreshZgv(); FHC_AjaxClient.hideVeil(); InfocenterDetails._refreshLog(); } - else if (data.error === 2 && parseInt(data.retval.prestudent_id, 10)) + else if (freigabeResponseData.error === 2 && parseInt(freigabeResponseData.retval.prestudent_id, 10)) { FHC_DialogLib.alertError("error when setting accepted documents"); InfocenterDetails._refreshZgv(); @@ -474,13 +476,17 @@ var InfocenterDetails = { } ); }, - initFrgMessageSend: function(prestudentid, rtfreigabe) + initFrgMessageSend: function(freigabedata) { var callback = function (data) { if (data == null) return; + var prestudent_id = freigabedata.prestudent_id; + var statusgrund_id = freigabedata.statusgrund_id; + var rtfreigabe = !$.isNumeric(statusgrund_id); + // check if a prestudent in same semester is already freigegeben - then not send message again var rtFreigegeben = false; var stgFreigegeben = false; @@ -489,7 +495,7 @@ var InfocenterDetails = { //get prestudentstatus of message receiver for(var i = 0; i < data.length; i++) { - if (data[i].prestudentstatus.prestudent_id === prestudentid) + if (data[i].prestudentstatus.prestudent_id === prestudent_id) { receiverPrestudentstatus = data[i].prestudentstatus; break; @@ -506,29 +512,21 @@ var InfocenterDetails = { var prestudentstatus = prestudent.prestudentstatus; var id = prestudentstatus.prestudent_id; - if (id !== prestudentid) + if (id !== prestudent_id) { + var fitfreigegeben = $.inArray(prestudentstatus.bezeichnung_statusgrund[0], STGFREIGABE_MESSAGESEND_EXCEPTIONS) >= 0; + if (receiverPrestudentstatus.studiensemester_kurzbz === prestudentstatus.studiensemester_kurzbz - && prestudentstatus.bestaetigtam !== null && prestudentstatus.status_kurzbz === "Interessent") + && prestudentstatus.bestaetigtam !== null && prestudentstatus.status_kurzbz === "Interessent" + && (prestudent.studiengangtyp === "b")) { - if (prestudent.studiengangtyp === "b") + if (prestudentstatus.statusgrund_id === null) { - if (prestudentstatus.statusgrund_id === null) - { - rtFreigegeben = true; - } - else if ($.isNumeric(prestudentstatus.statusgrund_id)) - { - stgFreigegeben = true; - } + rtFreigegeben = true; } - // special case FIT programme Freigabe (stgtyp not bachelor) - STG Freigabe possible - else if ($.inArray(parseInt(prestudent.studiengang_kz), FIT_PROGRAMM_STUDIENGAENGE) >= 0) + else if ($.isNumeric(prestudentstatus.statusgrund_id) && !fitfreigegeben) { - if ($.isNumeric(prestudentstatus.statusgrund_id)) - { - stgFreigegeben = true; - } + stgFreigegeben = true; } } } @@ -552,7 +550,7 @@ var InfocenterDetails = { 'studiengangbezeichnung_englisch': studiengangbezeichnung_englisch }; - InfocenterDetails.sendFreigabeMessage(prestudentid, RTFREIGABE_MESSAGE_VORLAGE_QUER_KURZ, msgvars); + InfocenterDetails.sendFreigabeMessage(prestudent_id, RTFREIGABE_MESSAGE_VORLAGE_QUER_KURZ, msgvars); } } else //not already for RT freigegeben - send RTfreigabe message @@ -574,15 +572,17 @@ var InfocenterDetails = { vorlage = RTFREIGABE_MESSAGE_VORLAGE } - InfocenterDetails.sendFreigabeMessage(prestudentid, vorlage, msgvars); + InfocenterDetails.sendFreigabeMessage(prestudent_id, vorlage, msgvars); } } else if (rtfreigabe === false) { + var statusgrundbez = freigabedata.statusgrundbezeichnung ? freigabedata.statusgrundbezeichnung : ""; + // if Freigabe to Studiengang, send StgFreigabe Message if not already sent - if (!stgFreigegeben) + if (!stgFreigegeben && $.inArray(statusgrundbez, STGFREIGABE_MESSAGESEND_EXCEPTIONS) < 0) { - InfocenterDetails.sendFreigabeMessage(prestudentid, STGFREIGABE_MESSAGE_VORLAGE, msgvars); + InfocenterDetails.sendFreigabeMessage(prestudent_id, STGFREIGABE_MESSAGE_VORLAGE, msgvars); } } }; @@ -740,8 +740,8 @@ var InfocenterDetails = { { $(".freigabeModal").modal("hide"); var prestudent_id = this.id.substr(this.id.indexOf("_") + 1); - var data = {"prestudent_id": prestudent_id}; - InfocenterDetails.saveFreigabe(data, true);//Reihungstestfreigabe + var data = {"prestudent_id": prestudent_id, "statusgrund_id": null}; + InfocenterDetails.saveFreigabe(data);//Reihungstestfreigabe } ); @@ -749,9 +749,11 @@ var InfocenterDetails = { { $(".freigabeModal").modal("hide"); var prestudent_id = this.id.substr(this.id.indexOf("_") + 1); - var statusgrund_id = $("#frgstatusgrselect_" + prestudent_id + " select[name=frgstatusgrund]").val(); - var data = {"prestudent_id": prestudent_id, "statusgrund_id": statusgrund_id}; - InfocenterDetails.saveFreigabe(data, false);//Studiengangfreigabe + var statusgrundel = $("#frgstatusgrselect_" + prestudent_id + " select[name=frgstatusgrund]"); + var statusgrund_id = statusgrundel.val(); + var statusgrundbezeichnung = statusgrundel.find("option[value="+statusgrund_id+"]").text(); + var data = {"prestudent_id": prestudent_id, "statusgrund_id": statusgrund_id, "statusgrundbezeichnung": statusgrundbezeichnung}; + InfocenterDetails.saveFreigabe(data);//Studiengangfreigabe } ) }, From 8fdf91b4bb83b4910e79fe98da38d34ce19e41e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 21 Feb 2019 18:10:25 +0100 Subject: [PATCH 19/19] CI Dashboard can now be injected by Addons Cleaned Up CI Navigation --- application/config/navigation.php | 92 +++++++++-------------------- application/views/home.php | 97 +------------------------------ 2 files changed, 30 insertions(+), 159 deletions(-) diff --git a/application/config/navigation.php b/application/config/navigation.php index 827aaa154..d6f4b8452 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -1,6 +1,4 @@ '', 'description' => 'Vilesci', 'expand' => true, - 'sort' => 1, - 'requiredPermissions' => 'basis/vilesci:r' - ), - 'reihungstest' => array( - 'link' => site_url('organisation/Reihungstest'), - 'icon' => 'list-ol', - 'description' => 'Reihungstests', - 'expand' => true, 'sort' => 10, - 'requiredPermissions' => 'infocenter:r' + 'requiredPermissions' => 'basis/vilesci:r' ) ) ), @@ -47,14 +37,20 @@ $config['navigation_header'] = array( 'description' => 'CIS', 'sort' => 10 ), - 'infocenter' => array( - 'link' => site_url('system/infocenter/InfoCenter'), - 'icon' => 'info', - 'description' => 'Infocenter', + 'reihungstest' => array( + 'link' => site_url('organisation/Reihungstest'), + 'description' => 'Reihungstests', 'expand' => true, 'sort' => 20, 'requiredPermissions' => 'infocenter:r' ), + 'infocenter' => array( + 'link' => site_url('system/infocenter/InfoCenter'), + 'description' => 'Infocenter', + 'expand' => true, + 'sort' => 30, + 'requiredPermissions' => 'infocenter:r' + ), ) ), 'Personen' => array( @@ -71,6 +67,23 @@ $config['navigation_header'] = array( 'requiredPermissions' => 'admin:r' ) ) + ), + 'Administration' => array( + 'link' => '#', + 'icon' => 'gear', + 'description' => 'Administration', + 'expand' => false, + 'sort' => 50, + 'requiredPermissions' => 'admin:r', + 'children'=> array( + 'extensions' => array( + 'link' => site_url('system/extensions/Manager'), + 'description' => 'Extensions Manager', + 'expand' => true, + 'sort' => 10, + 'requiredPermissions' => 'admin:r' + ) + ) ) ) ); @@ -86,55 +99,6 @@ $config['navigation_menu']['Vilesci/index'] = array( 'description' => 'Dashboard', 'icon' => 'dashboard', 'sort' => 1 - ), - 'lehre' => array( - 'link' => '#', - 'icon' => 'graduation-cap', - 'description' => 'Lehre', - 'expand' => true, - 'sort' => 2, - 'children'=> array( - 'cis' => array( - 'link' => CIS_ROOT, - 'icon' => '', - 'description' => 'CIS', - 'expand' => true, - 'sort' => 1 - ), - 'infocenter' => array( - 'link' => site_url('system/infocenter/InfoCenter'), - 'icon' => 'info', - 'description' => 'Infocenter', - 'expand' => true, - 'sort' => 2, - 'requiredPermissions' => 'infocenter:r' - ), - ) - ), - 'administration' => array( - 'link' => '#', - 'icon' => 'gear', - 'description' => 'Administration', - 'expand' => false, - 'sort' => 3, - 'children'=> array( - 'vilesci' => array( - 'link' => base_url('vilesci'), - 'icon' => '', - 'description' => 'Vilesci', - 'expand' => true, - 'sort' => 1, - 'requiredPermissions' => 'basis/vilesci:r' - ), - 'extensions' => array( - 'link' => site_url('system/extensions/Manager'), - 'icon' => 'cubes', - 'description' => 'Extensions Manager', - 'expand' => true, - 'sort' => 2, - 'requiredPermissions' => 'admin:r' - ) - ) ) ); diff --git a/application/views/home.php b/application/views/home.php index 598413c32..d00b98f81 100644 --- a/application/views/home.php +++ b/application/views/home.php @@ -7,6 +7,7 @@ $this->load->view('templates/FHC-Header', 'fontawesome' => true, 'sbadmintemplate' => true, 'ajaxlib' => true, + 'addons' => true, 'navigationwidget' => true ) ); @@ -23,102 +24,8 @@ $this->load->view('templates/FHC-Header',
-
-
-
-
-
-
- -
-
-
26
-
neue Messages
-
-
-
- - - -
-
-
-
-
-
-
- -
-
-
12
-
neue Interessenten
-
-
-
- - - -
-
-
-
-
-
-
- -
-
-
124
-
inaktive Interessenten
-
-
-
- - - -
-
-
-
-
-
-
- -
-
-
13
-
Support Tickets!
-
-
-
- - - -
-
-
- - - load->view('system/infocenter/infocenterData.php'); - ?> +