From 4f14e7fa921695b414001216858c3c77424facfd Mon Sep 17 00:00:00 2001 From: Paminger Date: Thu, 23 Jun 2016 10:28:26 +0200 Subject: [PATCH] Messages Inbox Outbox --- application/controllers/system/Messages.php | 40 +++++++++++++-- application/controllers/system/Templates.php | 4 ++ application/core/DB_Model.php | 8 ++- application/core/FHC_Controller.php | 2 +- application/migrations/010_vorlage.php | 4 +- application/models/system/Message_model.php | 6 +-- application/views/system/messages.php | 2 +- application/views/system/messagesInbox.php | 51 +++++++++++++++++++ .../{messagesList.php => messagesOutbox.php} | 17 +++++-- application/views/system/templatetextEdit.php | 1 + .../views/widgets/organisationseinheit.php | 2 +- application/views/widgets/orgform.php | 7 +++ application/views/widgets/tinymce.php | 1 + .../widgets/organisationseinheit_widget.php | 22 ++++++-- application/widgets/orgform_widget.php | 49 ++++++++++++++++++ application/widgets/tinymce_widget.php | 4 +- include/studiengang.class.php | 2 +- 17 files changed, 196 insertions(+), 26 deletions(-) create mode 100644 application/views/system/messagesInbox.php rename application/views/system/{messagesList.php => messagesOutbox.php} (73%) create mode 100644 application/views/widgets/orgform.php create mode 100644 application/widgets/orgform_widget.php diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index ba3c79aee..e9f80e8c1 100755 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -8,8 +8,7 @@ class Messages extends VileSci_Controller { parent::__construct(); $this->load->library('MessageLib'); - //$this->load->model('person/Person_model'); - //$this->load->model('system/Message_model'); + $this->load->model('person/Person_model', 'PersonModel'); } public function index($person_id = null) @@ -18,7 +17,7 @@ class Messages extends VileSci_Controller $this->load->view('system/messages.php', $data); } - public function table($person_id = null) + public function inbox($person_id = null) { if (empty($person_id)) $person_id = $this->input->post('person_id', TRUE); @@ -31,12 +30,43 @@ class Messages extends VileSci_Controller $data = array ( + 'uid' => $this->getUID(), 'messages' => $msg->retval ); - //var_dump ($data); - $this->load->view('system/messagesList.php', $data); + if (!empty($person_id)) + { + $person = $this->PersonModel->load($person_id); + $data['person'] = $person->retval[0]; + } + // var_dump ($data); + $this->load->view('system/messagesInbox.php', $data); } + public function outbox($person_id = null) + { + if (empty($person_id)) + $person_id = $this->input->post('person_id', TRUE); + if (empty($person_id)) + $msg = $this->messagelib->getMessagesByUID($this->getUID()); + else + $msg = $this->messagelib->getMessagesByPerson($person_id); + if ($msg->error) + show_error($msg->retval); + + $data = array + ( + 'uid' => $this->getUID(), + 'messages' => $msg->retval + ); + if (!empty($person_id)) + { + $person = $this->PersonModel->load($person_id); + $data['person'] = $person->retval[0]; + } + //var_dump ($data); + $this->load->view('system/messagesOutbox.php', $data); + } + public function view($msg_id) { $msg = $this->messagelib->getMessage($msg_id); diff --git a/application/controllers/system/Templates.php b/application/controllers/system/Templates.php index e5806508c..796c50c02 100755 --- a/application/controllers/system/Templates.php +++ b/application/controllers/system/Templates.php @@ -134,6 +134,10 @@ class Templates extends FHC_Controller $data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE); $data['version'] = $this->input->post('version', TRUE); $data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE); + if ($this->input->post('orgform_kurzbz') == '') + $data['orgform_kurzbz'] = null; + else + $data['orgform_kurzbz'] = $this->input->post('orgform_kurzbz', TRUE); $data['text'] = $this->input->post('text', TRUE); $data['aktiv'] = $this->input->post('aktiv', TRUE); $vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data); diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 4e5f2474d..a5bc4d298 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -128,7 +128,7 @@ class DB_Model extends FHC_Model * @param string $id ID (Primary Key) for SELECT ... WHERE * @return array */ - public function load($id) + public function load($id = null) { // Check Class-Attributes if (is_null($this->dbTable)) @@ -150,6 +150,8 @@ class DB_Model extends FHC_Model else $result = $this->db->get_where($this->dbTable, $id); } + elseif (empty($id)) + $result = $this->db->get($this->dbTable); else $result = $this->db->get_where($this->dbTable, array($this->pk => $id)); @@ -185,6 +187,8 @@ class DB_Model extends FHC_Model return $this->_error($this->db->error(), FHC_DB_ERROR); } + + /** --------------------------------------------------------------- * Load single data from DB-Table * @@ -212,7 +216,7 @@ class DB_Model extends FHC_Model else return $this->_error($this->db->error(), FHC_DB_ERROR); } - + /** --------------------------------------------------------------- * Add a table to join with * diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 3216bbb63..66bc0c64f 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -3,7 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class FHC_Controller extends CI_Controller { - protected $_uid; // needs to be changed to protected $_uid + protected $_uid; public function __construct() { diff --git a/application/migrations/010_vorlage.php b/application/migrations/010_vorlage.php index 0fda6823c..110200fd2 100755 --- a/application/migrations/010_vorlage.php +++ b/application/migrations/010_vorlage.php @@ -29,7 +29,8 @@ class Migration_Vorlage extends CI_Migration { else echo "Error adding public.tbl_vorlage.attribute!"; } - + + // tbl_vorlagestudiengang->Subject if (! @$this->db->simple_query('SELECT subject FROM public.tbl_vorlagestudiengang')) { $this->db->insert('system.tbl_berechtigung', array( @@ -48,6 +49,7 @@ class Migration_Vorlage extends CI_Migration { echo "Error adding public.tbl_vorlagestudiengang.subject!"; } + // tbl_vorlagestudiengang->OrgForm if (! @$this->db->simple_query('SELECT orgform_kurzbz FROM public.tbl_vorlagestudiengang')) { $query= "ALTER TABLE public.tbl_vorlagestudiengang diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 5117b742d..b84fff1c3 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -23,13 +23,13 @@ class Message_model extends DB_Model if ($uid === $this->getUID()) { if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> system/message', FHC_MODEL_ERROR); + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message', FHC_MODEL_ERROR); } // if different user, for reading messages from other users else { if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> system/message:all', FHC_MODEL_ERROR); + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message:all', FHC_MODEL_ERROR); } // get Data @@ -120,4 +120,4 @@ public function getMessagesByPerson($person_id, $all) else return $this->_error($this->db->error(), FHC_DB_ERROR); } -} \ No newline at end of file +} diff --git a/application/views/system/messages.php b/application/views/system/messages.php index 4b583edb4..7bada1a87 100644 --- a/application/views/system/messages.php +++ b/application/views/system/messages.php @@ -7,7 +7,7 @@ - + <body bgcolor="#FFFFFF"> diff --git a/application/views/system/messagesInbox.php b/application/views/system/messagesInbox.php new file mode 100644 index 000000000..3288cafef --- /dev/null +++ b/application/views/system/messagesInbox.php @@ -0,0 +1,51 @@ +<?php + $this->load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); +?> +<div class="row"> + <div class="span4"> + <h2>Inbox <?php if (empty($person)) + echo $uid; + else + echo ' -> Person '.$person->person_id.' ('.$person->vorname.')'; + ?><br /><br /> + <form method="post" action="outbox"> + <button type="submit">Outbox</button> + </form></h2> + + <form method="post" action=""> + Person <input name="person_id"></input> + <button type="submit">show Mails</button> + </form> + +<table id="t1" class="tablesorter"> + <thead> + <tr><th>MessageID</th> + <th class='table-sortable:default'>Sender</th> + <th>Erstellt</th> + <th>Priorität</th> + <th>Status</th> + <th>StatusInfo</th> + <th>OE</th> + <th>Relation</th> + <th></th> + </tr> + </thead> + <tbody> + <?php foreach ($messages as $m): ?> + <tr><td><a href="view/<?php echo $m->message_id; ?>" target="MessagesBottom"><?php echo $m->message_id; ?></a></td> + <td><?php echo $m->titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?></td> + <td><?php echo $m->insertamum; ?></td> + <td><?php echo $m->priority; ?></td> + <td><?php echo $m->status; ?></td> + <td><?php echo $m->statusinfo; ?></td> + <td><?php echo $m->oe_kurzbz; ?></td> + <td><?php echo $m->relationmessage_id; ?></td> + <td><a href="view/<?php echo $m->message_id; ?>">View</a></td> + </tr> + <?php endforeach ?> + </tbody> +</table> +</div> +</div> +</body> +</html> diff --git a/application/views/system/messagesList.php b/application/views/system/messagesOutbox.php similarity index 73% rename from application/views/system/messagesList.php rename to application/views/system/messagesOutbox.php index f9343af83..53388e8c6 100644 --- a/application/views/system/messagesList.php +++ b/application/views/system/messagesOutbox.php @@ -2,12 +2,19 @@ $this->load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> <div class="row"> - <div class="span4"> - <h2>Vorlagen</h2> + <div class="span4"> + <h2>Outbox <?php if (empty($person)) + echo $uid; + else + echo ' -> Person '.$person->person_id.' ('.$person->vorname.')'; + ?><br /><br /> + <form method="post" action="inbox"> + <button type="submit">Inbox</button> + </form></h2> + <form method="post" action=""> -Person -<input name="person_id"></input> - <button type="submit">Filter</button> + Person <input name="person_id"></input> + <button type="submit">show Mails</button> </form> <table id="t1" class="tablesorter"> diff --git a/application/views/system/templatetextEdit.php b/application/views/system/templatetextEdit.php index 573768de3..e2d339eca 100644 --- a/application/views/system/templatetextEdit.php +++ b/application/views/system/templatetextEdit.php @@ -10,6 +10,7 @@ StudiengangKZ: <?=$studiengang_kz?> Version: <input type="text" name="version" value="<?php echo $version; ?>" /> Aktiv: <input type="text" name="aktiv" value="<?php echo $aktiv; ?>" /> OE:<?php echo $this->templatelib->widget("organisationseinheit_widget", array('oe_kurzbz' => $oe_kurzbz)); ?> + OrgForm:<?php echo $this->templatelib->widget("orgform_widget", array('orgform' => $orgform_kurzbz)); ?> <input type="hidden" name="vorlagestudiengang_id" value="<?php echo $vorlagestudiengang_id; ?>" /> <input type="hidden" name="studiengang_kz" value="<?php echo $studiengang_kz; ?>" /> <?php diff --git a/application/views/widgets/organisationseinheit.php b/application/views/widgets/organisationseinheit.php index 2f2c738c6..500e4c590 100644 --- a/application/views/widgets/organisationseinheit.php +++ b/application/views/widgets/organisationseinheit.php @@ -1,4 +1,4 @@ -<select name="<?php echo $name; ?>"> +<select name="<?php echo $htmltagname; ?>"> <?php foreach($items as $item): ?> <option value="<?php echo $item['value']; ?>" <?php if ($item['selected']) echo 'selected'?>> <?php echo $item['name']; ?> diff --git a/application/views/widgets/orgform.php b/application/views/widgets/orgform.php new file mode 100644 index 000000000..500e4c590 --- /dev/null +++ b/application/views/widgets/orgform.php @@ -0,0 +1,7 @@ +<select name="<?php echo $htmltagname; ?>"> + <?php foreach($items as $item): ?> + <option value="<?php echo $item['value']; ?>" <?php if ($item['selected']) echo 'selected'?>> + <?php echo $item['name']; ?> + </option> + <?php endforeach; ?> +</select> diff --git a/application/views/widgets/tinymce.php b/application/views/widgets/tinymce.php index 600831fd2..3e2093e55 100644 --- a/application/views/widgets/tinymce.php +++ b/application/views/widgets/tinymce.php @@ -1,5 +1,6 @@ <script type="text/javascript"> tinymce.init({ + menubar: <?php echo $menubar; ?>, selector: "<?php echo $selector; ?>", plugins: [<?php echo $plugins; ?>], toolbar: "<?php echo $toolbar; ?>" diff --git a/application/widgets/organisationseinheit_widget.php b/application/widgets/organisationseinheit_widget.php index d07681860..24fbb85ce 100644 --- a/application/widgets/organisationseinheit_widget.php +++ b/application/widgets/organisationseinheit_widget.php @@ -5,22 +5,34 @@ */ class organisationseinheit_widget extends Widget { + + protected $_htmltagname = 'oe_kurzbz'; + public function display($data) { $this->load->model('organisation/Organisationseinheit_model'); $res = $this->Organisationseinheit_model->getRecursiveList(); - var_dump($res); + + // *** set data *** + if (isset($data['htmltagname'])) + $this->_htmltagname = $data['htmltagname']; + + // items from db foreach ($res->retval->result() as $obj) { - $item = array('name' => $obj->name, 'value' => $obj->value); - if (isset($data['oe_kurzbz']) && $obj->value == $data['oe_kurzbz']) + $item = array + ( + 'name' => $obj->name, + 'value' => $obj->value + ); + if (isset($data['oe_kurzbz']) && $data['oe_kurzbz'] == $obj->value) $item['selected'] = true; else $item['selected'] = false; $data['items'][] = $item; } - if (! isset($data['name'])) - $data['name'] = 'oe_kurzbz'; + $data['htmltagname'] = $this->_htmltagname; + $this->view('widgets/organisationseinheit', $data); } diff --git a/application/widgets/orgform_widget.php b/application/widgets/orgform_widget.php new file mode 100644 index 000000000..13ab67013 --- /dev/null +++ b/application/widgets/orgform_widget.php @@ -0,0 +1,49 @@ +<?php + +/* + * OrgForm widget + */ +class orgform_widget extends Widget +{ + protected $_htmltagname = 'orgform_kurzbz'; + + public function display($data) + { + $this->load->model('codex/Orgform_model', 'OrgFormModel'); + $res = $this->OrgFormModel->load(); + + // set data + if (isset($data['htmltagname'])) + $this->_htmltagname = $data['htmltagname']; + + // empty item for null values + $item = array + ( + 'name' => ' - ', + 'value' => '' + ); + if (empty($data['oe_kurzbz'])) + $item['selected'] = true; + else + $item['selected'] = false; + $data['items'][] = $item; + + // items from db + foreach ($res->retval as $obj) + { + $item = array + ( + 'name' => $obj->orgform_kurzbz.' ('.$obj->bezeichnung.')', + 'value' => $obj->orgform_kurzbz + ); + if (isset($data['orgform']) && $obj->orgform_kurzbz == $data['orgform']) + $item['selected'] = true; + else + $item['selected'] = false; + $data['items'][] = $item; + } + $data['htmltagname'] = $this->_htmltagname; + + $this->view('widgets/orgform', $data); + } +} diff --git a/application/widgets/tinymce_widget.php b/application/widgets/tinymce_widget.php index 860b26332..7f776c9d2 100644 --- a/application/widgets/tinymce_widget.php +++ b/application/widgets/tinymce_widget.php @@ -15,13 +15,15 @@ class tinymce_widget extends Widget $data['text'] = ''; if (! isset($data['style'])) $data['style'] = 'width:100%'; + if (! isset($data['menubar'])) + $data['menubar'] = 'false'; if (! isset($data['plugins'])) $data['plugins'] = ' "advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"'; if (! isset($data['toolbar'])) - $data['toolbar'] = 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image'; + $data['toolbar'] = 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code'; $this->view('widgets/tinymce', $data); } diff --git a/include/studiengang.class.php b/include/studiengang.class.php index dfc433110..1f8a40fad 100755 --- a/include/studiengang.class.php +++ b/include/studiengang.class.php @@ -117,7 +117,7 @@ class studiengang extends Studiengang_model * @param studiengang_kz KZ des Studienganges der zu Laden ist * @return true wenn ok, false im Fehlerfall */ - public function load($studiengang_kz) + public function load($studiengang_kz = null) { if(!is_numeric($studiengang_kz)) {