From 1fe6ec5cccc47fdc87ce19766706f12db764dcd8 Mon Sep 17 00:00:00 2001 From: bison-paolo Date: Fri, 23 Sep 2016 17:38:02 +0200 Subject: [PATCH] Task #404: GUI zum Schreiben von Nachrichten im FAS --- application/controllers/system/Messages.php | 136 +++++++++++--------- application/core/VileSci_Controller.php | 6 +- application/libraries/MessageLib.php | 24 +++- application/migrations/008_message.php | 6 +- application/models/system/Message_model.php | 9 +- application/views/system/messageView.php | 20 +-- application/views/system/messageWrite.php | 33 ++--- application/views/system/messages.php | 28 ++-- application/views/system/messagesInbox.php | 104 ++++++++------- application/views/system/messagesOutbox.php | 104 ++++++++------- 10 files changed, 258 insertions(+), 212 deletions(-) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 191af6623..37ed57323 100755 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -1,110 +1,118 @@ load->library('MessageLib'); - $this->load->model('person/Person_model', 'PersonModel'); + $this->load->library("MessageLib"); + $this->load->model("person/Person_model", "PersonModel"); } - public function index($person_id = null) + public function index() { - $data = array('person_id' => $person_id); - $this->load->view('system/messages.php', $data); + $this->load->view("system/messages.php", array("person_id" => $this->getPersonId())); } - public function inbox($person_id = null) + public function inbox($person_id) { - if (empty($person_id)) - $person_id = $this->input->post('person_id', TRUE); - if (empty($person_id)) - $msg = $this->messagelib->getMessagesByUID(getAuthUID()); - else - $msg = $this->messagelib->getMessagesByPerson($person_id); + $msg = $this->messagelib->getMessagesByPerson($person_id); if ($msg->error) - show_error($msg->retval); - - $data = array - ( - 'uid' => getAuthUID(), - 'messages' => $msg->retval - ); - if (!empty($person_id)) { - $person = $this->PersonModel->load($person_id); - $data['person'] = $person->retval[0]; + show_error($msg->retval); } - // var_dump ($data); - $this->load->view('system/messagesInbox.php', $data); + + $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 = null) + public function outbox($person_id) { - if (empty($person_id)) - $person_id = $this->input->post('person_id', TRUE); - if (empty($person_id)) - $msg = $this->messagelib->getMessagesByUID(getAuthUID()); - else - $msg = $this->messagelib->getMessagesByPerson($person_id); + $msg = $this->messagelib->getMessagesByPerson($person_id); if ($msg->error) - show_error($msg->retval); - - $data = array - ( - 'uid' => getAuthUID(), - 'messages' => $msg->retval - ); - if (!empty($person_id)) { - $person = $this->PersonModel->load($person_id); - $data['person'] = $person->retval[0]; + show_error($msg->retval); } - //var_dump ($data); - $this->load->view('system/messagesOutbox.php', $data); + + $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) + public function view($msg_id, $person_id) { - $msg = $this->messagelib->getMessage($msg_id); - //var_dump($msg); + $msg = $this->messagelib->getMessage($msg_id, $person_id); if ($msg->error) + { show_error($msg->retval); - if (count($msg->retval) != 1) - show_error('Nachricht nicht vorhanden! ID: '.$msg_id); - - $data = array - ( - 'message' => $msg->retval[0] - ); - //var_dump($data['message']); - $v = $this->load->view('system/messageView', $data); + } + + $v = $this->load->view("system/messageView", array("message" => $msg->retval[0])); } public function write($vorlage_kurzbz = null) { $data = array ( - 'subject' => 'TestSubject', - 'body' => 'TestDevelopmentBodyText' + "subject" => "TestSubject", + "body" => "TestDevelopmentBodyText" ); - $v = $this->load->view('system/messageWrite', $data); + $v = $this->load->view("system/messageWrite", $data); } public function send() { - $body = $this->input->post('body', TRUE); - $subject = $this->input->post('subject', TRUE); + $body = $this->input->post("body", TRUE); + $subject = $this->input->post("subject", TRUE); if (! $this->messagelib->addRecipient(1)) - show_error('Error: AddRecipient'); + show_error("Error: AddRecipient"); $msg = $this->messagelib->sendMessage(1,$body ,$subject); if ($msg->error) show_error($msg->retval); $msg_id = $msg->retval; - redirect('/system/Message/view/'.$msg_id); + redirect("/system/Message/view/".$msg_id); + } + + private function getPersonId() + { + $person_id = null; + + if ($this->input->get("person_id") !== null) + { + $person_id = $this->input->get("person_id"); + } + else if ($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/core/VileSci_Controller.php b/application/core/VileSci_Controller.php index f3dcd1aee..4eaa733a1 100644 --- a/application/core/VileSci_Controller.php +++ b/application/core/VileSci_Controller.php @@ -1,13 +1,11 @@ getUID() && strncmp(uri_string(), 'system/Login', 11) !== 0) - redirect(site_url('system/Login/'.uri_string()));*/ } - } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 3e239b1a5..c382c1d77 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -35,6 +35,26 @@ class MessageLib //$this->ci->load->helper('language'); $this->ci->lang->load("message"); } + + /** + * getMessage() - returns the spicified message for a specified person + * + * @param string $msg_id REQUIRED + * @param string $person_id REQUIRED + * @return object + */ + public function getMessage($msg_id, $person_id) + { + if (empty($msg_id)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + if (empty($person_id)) + return $this->_error(MSG_ERR_INVALID_RECIPIENTS); + + $this->ci->RecipientModel->addJoin("public.tbl_msg_message m", "message_id"); + $msg = $this->ci->RecipientModel->loadWhere(array("message_id" => $msg_id, "public.tbl_msg_recipient.person_id" => $person_id)); + + return $msg; + } /** * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. @@ -63,8 +83,8 @@ class MessageLib if (empty($person_id)) return $this->_error(MSG_ERR_INVALID_MSG_ID); - $msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all); - + $msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all); + return $msg; } diff --git a/application/migrations/008_message.php b/application/migrations/008_message.php index 5f3e65f33..3d102aa6b 100644 --- a/application/migrations/008_message.php +++ b/application/migrations/008_message.php @@ -100,11 +100,11 @@ class Migration_Message extends MigrationLib // Create table public.tbl_msg_recipient $fields = array( - "person_id" => array( + "message_id" => array( "type" => "bigint", "null" => false ), - "message_id" => array( + "person_id" => array( "type" => "bigint", "null" => false ), @@ -291,4 +291,4 @@ class Migration_Message extends MigrationLib $this->endDown(); } -} \ No newline at end of file +} diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 966927d34..8bb73108b 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -84,9 +84,16 @@ class Message_model extends DB_Model m.person_id, m.subject, m.body, + m.priority, m.insertamum, m.relationmessage_id, m.oe_kurzbz, + p.anrede, + p.titelpost, + p.titelpre, + p.nachname, + p.vorname, + p.vornamen, s.status, s.statusinfo, s.insertamum AS statusamum @@ -154,4 +161,4 @@ class Message_model extends DB_Model else return $this->_error($this->db->error(), FHC_DB_ERROR); } -} \ No newline at end of file +} diff --git a/application/views/system/messageView.php b/application/views/system/messageView.php index e6275752f..37bdc1341 100644 --- a/application/views/system/messageView.php +++ b/application/views/system/messageView.php @@ -1,14 +1,14 @@ +
-

Nachricht message_id,': ',$message->subject; ?>

- -Absender: person_id; ?>
-Betreff: subject; ?>
-Text: body; ?>
-templatelib->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz)); -?> - +

+ Subject: subject; ?> +

+ Sender: person_id; ?>
+ Body: body; ?>
+ templatelib->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz)); + ?> +
diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index 76fea0a3d..d063de729 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -1,20 +1,21 @@ +
-

Neue Nachricht

-
- Absender: person_id; ?>
- template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz)); - ?> - Betreff: - template->widget("tinymce_widget", array()); - ?> - - -
-
+

Neue Nachricht

+
+ Absender: person_id; ?>
+ template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz)); + ?> + Betreff: + template->widget("tinymce_widget", array()); + ?> + + +
+
diff --git a/application/views/system/messages.php b/application/views/system/messages.php index 7bada1a87..1ba29c04a 100644 --- a/application/views/system/messages.php +++ b/application/views/system/messages.php @@ -1,20 +1,20 @@ - - VileSci - Messages - - + + VileSci - Messages + + - - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - <a href="MessagesList">Use without frames</a> - </body> - - + + + + + <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 index 3288cafef..920b4d7b5 100644 --- a/application/views/system/messagesInbox.php +++ b/application/views/system/messagesInbox.php @@ -1,51 +1,57 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); -?> -
-
-

Inbox Person '.$person->person_id.' ('.$person->vorname.')'; - ?>

-
- -

+load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> -
- Person - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- +
+
+

+ 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 index 53388e8c6..ad1fc52dd 100644 --- a/application/views/system/messagesOutbox.php +++ b/application/views/system/messagesOutbox.php @@ -1,51 +1,57 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); -?> -
-
-

Outbox Person '.$person->person_id.' ('.$person->vorname.')'; - ?>

-
- -

+load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> -
- Person - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- +
+
+

+ 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
+
+
+