- 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
This commit is contained in:
Paolo
2017-04-11 12:03:15 +02:00
parent 7d4486d34a
commit de0ed58ba6
10 changed files with 79 additions and 340 deletions
+43 -96
View File
@@ -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))
+1 -1
View File
@@ -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 ?';
-65
View File
@@ -1,65 +0,0 @@
<?php $this->load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?>
<body>
<?php
$href = str_replace("/system/Messages/reply", "/system/Messages/sendReply", $_SERVER["REQUEST_URI"]);
?>
<form id="sendForm" method="post" action="<?php echo $href; ?>">
<div class="row">
<div class="span4">
To: <?php echo $message->uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?><br/>
Subject: <input type="text" value="Re: <?php echo $message->subject; ?>" name="subject"><br/>
<textarea id="bodyTextArea" name="body"><?php echo $message->body; ?></textarea>
</div>
</div>
<div class="row">
<div class="span4">
<button type="submit">Send</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
echo $this->widgetlib->widget(
'Vorlage_widget',
null,
array('name' => 'vorlage', 'id' => 'vorlageDnD')
);
?>
</div>
</div>
</form>
</body>
<script>
tinymce.init({
selector: "#bodyTextArea"
});
<?php
$url = str_replace("/system/Messages/reply", "/system/Messages/getVorlage", $_SERVER["REQUEST_URI"]);
?>
$(document).ready(function() {
if ($("#vorlageDnD"))
{
$("#vorlageDnD").change(function() {
if (this.value != '')
{
$.ajax({
dataType: "json",
url: "<?php echo $url; ?>",
data: {"vorlage_kurzbz": this.value},
success: function(data, textStatus, jqXHR) {
tinyMCE.activeEditor.setContent(data.retval[0].text + "<?php echo $message->body; ?>");
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus + " - " + errorThrown);
}
});
}
});
}
});
</script>
</html>
-34
View File
@@ -1,34 +0,0 @@
<?php $this->load->view('templates/header'); ?>
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<body>
<div class="row">
<div class="span4">
<h2>
From: <?php echo $message->uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?><br/>
Subject: <?php echo $message->subject; ?><br/>
</h2>
<textarea id="bodyTextArea"><?php echo $message->body; ?></textarea>
</div>
</div>
<div class="row">
<div class="span4">
<button type="submit" onClick="parent.document.getElementById('MessagesBottom').src = 'Messages/reply/<?php echo $message->message_id; ?>/<?php echo $message->person_id; ?>'">
Reply
</button>
</div>
</div>
<script>
tinymce.init({
selector: '#bodyTextArea',
readonly : 1,
statusbar: false,
toolbar: false,
menubar: false
});
</script>
</body>
</html>
+24 -4
View File
@@ -1,10 +1,13 @@
<?php $this->load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?>
<body>
<?php
$href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER["REQUEST_URI"]);
?>
<form id="sendForm" method="post" action="<?php echo $href; ?>">
<table>
<tr>
<td>
@@ -33,15 +36,30 @@
<strong>Subject:</strong>&nbsp;
</td>
<td>
<input id="subject" type="text" value="" name="subject" size="70">
<?php
$subject = '';
if (isset($message))
{
$subject = 'Re: '.$message->subject;
}
?>
<input id="subject" type="text" value="<?php echo $subject; ?>" name="subject" size="70">
</td>
</tr>
</table>
<table width="100%">
<tr>
<td width="80%">
<strong>Message:</strong><br>
<textarea id="bodyTextArea" name="body"></textarea>
<?php
$body = '';
if (isset($message))
{
$body = $message->body;
}
?>
<textarea id="bodyTextArea" name="body"><?php echo $body; ?></textarea>
</td>
<td width="3%">&nbsp;</td>
<td width="17%">
@@ -143,7 +161,6 @@
?>
</form>
</body>
<script>
tinymce.init({
@@ -254,4 +271,7 @@
});
}
</script>
</html>
</body>
<?php $this->load->view("templates/footer"); ?>
-20
View File
@@ -1,20 +0,0 @@
<!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>
<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>
@@ -1,57 +0,0 @@
<?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 echo $person->vorname . " " . $person->nachname; ?>
<br />
<br />
<button type="button" 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>
@@ -1,57 +0,0 @@
<?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 echo $person->vorname . " " . $person->nachname; ?>
<br />
<br />
<button type="button" 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>
+11 -5
View File
@@ -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('<?php echo APP_ROOT ?>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 = '<?php echo APP_ROOT ?>index.ci.php/system/Messages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID;
openWindowPostArray(action, 'prestudent_id', prestudentIdArray);
}
}
-1
View File
@@ -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