Task #404: GUI zum Schreiben von Nachrichten im FAS

This commit is contained in:
bison-paolo
2016-09-23 17:38:02 +02:00
parent 0ae8b4d8fa
commit 1fe6ec5ccc
10 changed files with 258 additions and 212 deletions
+72 -64
View File
@@ -1,110 +1,118 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
if (! defined("BASEPATH")) exit("No direct script access allowed");
class Messages extends VileSci_Controller
{
public function __construct()
{
parent::__construct();
$this->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;
}
}
+2 -4
View File
@@ -1,13 +1,11 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
if (! defined("BASEPATH")) exit("No direct script access allowed");
class VileSci_Controller extends FHC_Controller
{
function __construct()
{
parent::__construct();
/*if (! $this->getUID() && strncmp(uri_string(), 'system/Login', 11) !== 0)
redirect(site_url('system/Login/'.uri_string()));*/
}
}
+22 -2
View File
@@ -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;
}
+3 -3
View File
@@ -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();
}
}
}
+8 -1
View File
@@ -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);
}
}
}
+10 -10
View File
@@ -1,14 +1,14 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<h2>Nachricht <?php echo $message->message_id,': ',$message->subject; ?></h2>
Absender: <?php echo $message->person_id; ?><br/>
Betreff: <?php echo $message->subject; ?><br/>
Text: <?php echo $message->body; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->templatelib->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
<h2>
Subject: <?php echo $message->subject; ?>
</h2>
Sender: <?php echo $message->person_id; ?><br/>
Body: <?php echo $message->body; ?><br/>
<?php
echo $this->templatelib->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
</div>
</div>
+17 -16
View File
@@ -1,20 +1,21 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<h2>Neue Nachricht</h2>
<form method="post" action="send">
Absender: <?php //echo $message->person_id; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
//echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
Betreff: <input type="text" name="subject" value="<?php echo $subject; ?>" /></input>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("tinymce_widget", array());
?>
<textarea name="body" style="width:100%"><?php echo $body; ?></textarea>
<button type="submit">send Message!</button>
</form>
</div>
<h2>Neue Nachricht</h2>
<form method="post" action="send">
Absender: <?php //echo $message->person_id; ?><br/>
<?php
// This is an example to show that you can load stuff from inside the template file
//echo $this->template->widget("organisationseinheit_widget", array('title' => 'Organisationseinheit', 'oe_kurzbz' => $message->oe_kurzbz));
?>
Betreff: <input type="text" name="subject" value="<?php echo $subject; ?>" /></input>
<?php
// This is an example to show that you can load stuff from inside the template file
echo $this->template->widget("tinymce_widget", array());
?>
<textarea name="body" style="width:100%"><?php echo $body; ?></textarea>
<button type="submit">send Message!</button>
</form>
</div>
</div>
+14 -14
View File
@@ -1,20 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<html lang="de_AT">
<head>
<title>VileSci - Messages</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<head>
<title>VileSci - Messages</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<frameset rows="30%,*">
<frame src="Messages/inbox<?php if (! empty($person_id)) echo '/'.$person_id; ?>" id="MessagesTop" name="MessagesTop" frameborder="0" />
<frame src="Messages/edit" id="MessagesBottom" name="MessagesBottom" frameborder="0" />
<noframes>
<body bgcolor="#FFFFFF">
This application works only with a frames-enabled browser.<br />
<a href="MessagesList">Use without frames</a>
</body>
</noframes>
</frameset>
<frameset rows="30%,*">
<frame src="Messages/inbox/<?php echo $person_id; ?>" id="MessagesTop" name="MessagesTop" frameborder="0" />
<frame src="" id="MessagesBottom" name="MessagesBottom" frameborder="0" />
<noframes>
<body bgcolor="#FFFFFF">
This application works only with a frames-enabled browser.<br />
<a href="MessagesList">Use without frames</a>
</body>
</noframes>
</frameset>
</html>
+55 -49
View File
@@ -1,51 +1,57 @@
<?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>
<?php $this->load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?>
<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>
<div class="row">
<div class="span4">
<h2>
Inbox <?php echo $person->vorname . " " . $person->nachname; ?>
<br />
<br />
<button type="submit" onClick="parent.document.getElementById('MessagesTop').src = 'Messages/outbox/<?php echo $person->person_id; ?>'">
Outbox
</button>
<br />
<br />
</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): ?>
<?php
$href = str_replace("/system/Messages/inbox", "/system/Messages/view", $_SERVER["REQUEST_URI"]);
$href = substr($href, 0, strrpos($href, "/") - strlen($href));
$href .= "/" . $m->message_id . "/" . $person->person_id;
?>
<tr>
<td><a href="<?php echo $href; ?>" 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="<?php echo $href; ?>" target="MessagesBottom">View</a></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
+55 -49
View File
@@ -1,51 +1,57 @@
<?php
$this->load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}'));
?>
<div class="row">
<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>
<?php $this->load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?>
<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>
<div class="row">
<div class="span4">
<h2>
Outbox <?php echo $person->vorname . " " . $person->nachname; ?>
<br />
<br />
<button type="submit" onClick="parent.document.getElementById('MessagesTop').src = 'Messages/inbox/<?php echo $person->person_id; ?>'">
Inbox
</button>
<br />
<br />
</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): ?>
<?php
$href = str_replace("/system/Messages/outbox", "/system/Messages/view", $_SERVER["REQUEST_URI"]);
$href = substr($href, 0, strrpos($href, "/") - strlen($href));
$href .= "/" . $m->message_id . "/" . $person->person_id;
?>
<tr>
<td><a href="<?php echo $href; ?>" 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="<?php echo $href; ?>" target="MessagesBottom">View</a></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
</body>
</html>