From de0ed58ba63c6578e0fa833f10f10a938f38082c Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 11 Apr 2017 12:03:15 +0200 Subject: [PATCH] - Removed method index, inbox, view and outbox from controller system/Messages - Removed views messageReply, messageView, messages, messagesInbox and messagesOutbox - Removed menu item "Nachrichten" from VileSci->Admin - Controller system/Messages: method write also works for replying to a message - View system/messageWrite also worki for replying to a message - Updated content/messages.js.php to call the system/Messages controller with the new parameters --- application/controllers/system/Messages.php | 139 ++++++-------------- application/models/system/Message_model.php | 2 +- application/views/system/messageReply.php | 65 --------- application/views/system/messageView.php | 34 ----- application/views/system/messageWrite.php | 28 +++- application/views/system/messages.php | 20 --- application/views/system/messagesInbox.php | 57 -------- application/views/system/messagesOutbox.php | 57 -------- content/messages.js.php | 16 ++- include/tw/vilesci_menu_main.inc.php | 1 - 10 files changed, 79 insertions(+), 340 deletions(-) delete mode 100644 application/views/system/messageReply.php delete mode 100644 application/views/system/messageView.php delete mode 100644 application/views/system/messages.php delete mode 100644 application/views/system/messagesInbox.php delete mode 100644 application/views/system/messagesOutbox.php diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index d11eed4e1..26a9b65ca 100755 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -16,105 +16,32 @@ class Messages extends VileSci_Controller $this->load->model('person/Person_model', 'PersonModel'); } - - public function index() - { - $this->load->view('system/messages.php', array('person_id' => $this->getPersonId())); - } - - public function inbox($person_id) - { - $msg = $this->messagelib->getMessagesByPerson($person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $person = $this->PersonModel->load($person_id); - if ($person->error) - { - show_error($person->retval); - } - - $data = array ( - 'messages' => $msg->retval, - 'person' => $person->retval[0] - ); - - $this->load->view('system/messagesInbox.php', $data); - } - - public function outbox($person_id) - { - $msg = $this->messagelib->getSentMessagesByPerson($person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $person = $this->PersonModel->load($person_id); - if ($person->error) - { - show_error($person->retval); - } - - $data = array ( - 'messages' => $msg->retval, - 'person' => $person->retval[0] - ); - - $this->load->view('system/messagesOutbox.php', $data); - } - public function view($msg_id, $person_id) - { - $msg = $this->messagelib->getMessage($msg_id, $person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $v = $this->load->view('system/messageView', array('message' => $msg->retval[0])); - } - - public function reply($msg_id, $person_id) - { - $msg = $this->messagelib->getMessage($msg_id, $person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $v = $this->load->view('system/messageReply', array('message' => $msg->retval[0])); - } - - public function sendReply($msg_id, $person_id) - { - $subject = $this->input->post('subject'); - $body = $this->input->post('body'); - - $this->load->model('system/Message_model', 'MessageModel'); - $originMsg = $this->MessageModel->load($msg_id); - if ($originMsg->error) - { - show_error($originMsg->retval); - } - - $msg = $this->messagelib->sendMessage($person_id, $originMsg->retval[0]->person_id, $subject, $body, PRIORITY_NORMAL, $msg_id); - if ($msg->error) - { - show_error($msg->retval); - } - - redirect('/system/Messages/view/' . $msg->retval . '/' . $originMsg->retval[0]->person_id); - } - - public function write($sender_id) + /** + * + */ + public function write($sender_id, $msg_id = null, $receiver_id = null) { $prestudent_id = $this->input->post('prestudent_id'); + $msg = null; + // 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]; + } + } + + // Get variables $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudent = $this->MessageModel->getMsgVarsData($prestudent_id); + $prestudent = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); if ($prestudent->error) { show_error($prestudent->retval); @@ -141,12 +68,16 @@ class Messages extends VileSci_Controller $data = array ( 'sender_id' => $sender_id, 'receivers' => $prestudent->retval, + 'message' => $msg, 'variables' => $variablesArray ); $v = $this->load->view('system/messageWrite', $data); } + /** + * + */ public function send($sender_id) { $error = false; @@ -154,7 +85,14 @@ class Messages extends VileSci_Controller $subject = $this->input->post('subject'); $body = $this->input->post('body'); $prestudents = $this->input->post('prestudents'); - $data = $this->MessageModel->getMsgVarsData($prestudents); + $relationmessage_id = $this->input->post('relationmessage_id'); + + if (!isset($relationmessage_id) || $relationmessage_id == '') + { + $relationmessage_id = null; + } + + $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); if (hasData($data)) { for ($i = 0; $i < count($data->retval); $i++) @@ -185,6 +123,9 @@ class Messages extends VileSci_Controller } } + /** + * + */ private function getPersonId() { $person_id = null; @@ -206,6 +147,9 @@ class Messages extends VileSci_Controller return $person_id; } + /** + * + */ public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); @@ -221,6 +165,9 @@ class Messages extends VileSci_Controller } } + /** + * + */ public function parseMessageText() { $prestudent_id = $this->input->get('prestudent_id'); @@ -228,7 +175,7 @@ class Messages extends VileSci_Controller if (isset($prestudent_id)) { - $data = $this->MessageModel->getMsgVarsData($prestudent_id); + $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); $parsedText = ""; if (hasData($data)) diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index bc59bb24a..0cb3162c2 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -87,7 +87,7 @@ class Message_model extends DB_Model /** * */ - public function getMsgVarsData($prestudent_id) + public function getMsgVarsDataByPrestudentId($prestudent_id) { $query = 'SELECT * FROM public.vw_msg_vars WHERE prestudent_id %s ?'; diff --git a/application/views/system/messageReply.php b/application/views/system/messageReply.php deleted file mode 100644 index ea98f56fd..000000000 --- a/application/views/system/messageReply.php +++ /dev/null @@ -1,65 +0,0 @@ -load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?> - - - -
- -
-
- To: uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?>
- Subject:
- -
-
- -
-
- -            - widgetlib->widget( - 'Vorlage_widget', - null, - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); - ?> -
-
- -
- - - - diff --git a/application/views/system/messageView.php b/application/views/system/messageView.php deleted file mode 100644 index ea5411a20..000000000 --- a/application/views/system/messageView.php +++ /dev/null @@ -1,34 +0,0 @@ -load->view('templates/header'); ?> - - - - -
-
-

- From: uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?>
- Subject: subject; ?>
-

- -
-
- -
-
- -
-
- - - - diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index 193403e88..56d2f33ed 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -1,10 +1,13 @@ load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?> + +
+
@@ -33,15 +36,30 @@ Subject:  - + subject; + } + ?> +
+
Message:
- + body; + } + ?> +
  @@ -143,7 +161,6 @@ ?> - - \ No newline at end of file + + + +load->view("templates/footer"); ?> \ No newline at end of file diff --git a/application/views/system/messages.php b/application/views/system/messages.php deleted file mode 100644 index 1ba29c04a..000000000 --- a/application/views/system/messages.php +++ /dev/null @@ -1,20 +0,0 @@ - - - - - VileSci - Messages - - - - - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - <a href="MessagesList">Use without frames</a> - </body> - - - - diff --git a/application/views/system/messagesInbox.php b/application/views/system/messagesInbox.php deleted file mode 100644 index 88a1b595d..000000000 --- a/application/views/system/messagesInbox.php +++ /dev/null @@ -1,57 +0,0 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> - -
-
-

- Inbox vorname . " " . $person->nachname; ?> -
-
- -
-
-

-
- Person - -
- - - - - - - - - - - - - - - - - message_id . "/" . $person->person_id; - ?> - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- - diff --git a/application/views/system/messagesOutbox.php b/application/views/system/messagesOutbox.php deleted file mode 100644 index a4bcad7dc..000000000 --- a/application/views/system/messagesOutbox.php +++ /dev/null @@ -1,57 +0,0 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> - -
-
-

- Outbox vorname . " " . $person->nachname; ?> -
-
- -
-
-

-
- Person - -
- - - - - - - - - - - - - - - - - message_id . "/" . $person->person_id; - ?> - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- - diff --git a/content/messages.js.php b/content/messages.js.php index be39d3a73..014c331c5 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -114,16 +114,22 @@ function MessagesNewMessage() */ function MessagesSendAnswer() { - var tree=document.getElementById('messages-tree'); - if(tree.currentIndex==-1) + 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(tree, 'messages-tree-message_id', tree.currentIndex); - var RecipientID = getTreeCellText(tree, 'messages-tree-recipient_id', tree.currentIndex); - window.open('index.ci.php/system/Messages/reply/'+MessageId+'/'+RecipientID,'Reply',''); + 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/Messages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + + openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } } diff --git a/include/tw/vilesci_menu_main.inc.php b/include/tw/vilesci_menu_main.inc.php index 1cd2d2da8..895cb2cef 100755 --- a/include/tw/vilesci_menu_main.inc.php +++ b/include/tw/vilesci_menu_main.inc.php @@ -230,7 +230,6 @@ $menu=array 'link'=>'left.php?categorie=Admin', 'target'=>'nav', 'Cronjobs'=>array('name'=>'Cronjobs', 'link'=>'stammdaten/cronjobverwaltung.php', 'target'=>'main','permissions'=>array('basis/cronjob')), 'Vorlagen'=>array('name'=>'Vorlagen', 'link'=>'../index.ci.php/system/Vorlage', 'target'=>'main','permissions'=>array('basis/cronjob')), - 'Messages'=>array('name'=>'Nachrichten', 'link'=>'../index.ci.php/system/Messages', 'target'=>'main','permissions'=>array('basis/cronjob')), 'Phrasen'=>array('name'=>'Phrasen', 'link'=>'../index.ci.php/system/Phrases', 'target'=>'main','permissions'=>array('basis/cronjob')) ), 'SD-Tools'=> array