Task #404: GUI zum Schreiben von Nachrichten im FAS: 2nd part

This commit is contained in:
bison-paolo
2016-09-26 12:10:31 +02:00
parent 1fe6ec5ccc
commit 3009a03eac
10 changed files with 400 additions and 281 deletions
@@ -75,7 +75,7 @@ class Message extends APIv1_Controller
if (isset($token))
{
$result = $this->messagelib->getMessagesByToken($token);
$result = $this->messagelib->getMessageByToken($token);
$this->response($result, REST_Controller::HTTP_OK);
}
@@ -96,6 +96,7 @@ class Message extends APIv1_Controller
{
$result = $this->messagelib->sendMessage(
$this->post()['person_id'],
$this->post()['receiver_id'],
$this->post()['subject'],
$this->post()['body'],
PRIORITY_NORMAL,
@@ -215,4 +216,4 @@ class Message extends APIv1_Controller
return $this->_success('Input data are valid');
}
}
}
@@ -1,78 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class message_old extends APIv1_Controller
{
/**
* message_old API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model message_oldModel
$this->load->model('system/message_old_model', 'message_oldModel');
}
/**
* @return void
*/
public function getmessage_old()
{
$message_oldID = $this->get('message_old_id');
if (isset($message_oldID))
{
$result = $this->message_oldModel->load($message_oldID);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function postmessage_old()
{
if ($this->_validate($this->post()))
{
if (isset($this->post()['message_old_id']))
{
$result = $this->message_oldModel->update($this->post()['message_old_id'], $this->post());
}
else
{
$result = $this->message_oldModel->insert($this->post());
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
private function _validate($message_old = NULL)
{
return true;
}
}
+25 -17
View File
@@ -40,7 +40,7 @@ class Messages extends VileSci_Controller
public function outbox($person_id)
{
$msg = $this->messagelib->getMessagesByPerson($person_id);
$msg = $this->messagelib->getSentMessagesByPerson($person_id);
if ($msg->error)
{
show_error($msg->retval);
@@ -71,28 +71,36 @@ class Messages extends VileSci_Controller
$v = $this->load->view("system/messageView", array("message" => $msg->retval[0]));
}
public function write($vorlage_kurzbz = null)
public function write($msg_id, $person_id)
{
$data = array
(
"subject" => "TestSubject",
"body" => "TestDevelopmentBodyText"
);
$v = $this->load->view("system/messageWrite", $data);
$msg = $this->messagelib->getMessage($msg_id, $person_id);
if ($msg->error)
{
show_error($msg->retval);
}
$v = $this->load->view("system/messageWrite", array("message" => $msg->retval[0]));
}
public function send()
public function send($msg_id, $person_id)
{
$body = $this->input->post("body", TRUE);
$subject = $this->input->post("subject", TRUE);
if (! $this->messagelib->addRecipient(1))
show_error("Error: AddRecipient");
$msg = $this->messagelib->sendMessage(1,$body ,$subject);
$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);
$msg_id = $msg->retval;
redirect("/system/Message/view/".$msg_id);
}
redirect("/system/Messages/view/" . $msg->retval . "/" . $originMsg->retval[0]->person_id);
}
private function getPersonId()
+100 -52
View File
@@ -37,7 +37,7 @@ class MessageLib
}
/**
* getMessage() - returns the spicified message for a specified person
* getMessage() - returns the spicified received message for a specified person
*
* @param string $msg_id REQUIRED
* @param string $person_id REQUIRED
@@ -50,12 +50,11 @@ class MessageLib
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));
$msg = $this->ci->RecipientModel->getMessage($msg_id, $person_id);
return $msg;
}
/**
* getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
*
@@ -67,7 +66,7 @@ class MessageLib
if (empty($uid))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$msg = $this->ci->MessageModel->getMessagesByUID($uid, $all);
$msg = $this->ci->RecipientModel->getMessagesByUID($uid, $all);
return $msg;
}
@@ -83,23 +82,39 @@ class MessageLib
if (empty($person_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$msg = $this->ci->RecipientModel->getMessagesByPerson($person_id, $all);
return $msg;
}
/**
* getSentMessagesByPerson() - Get all sent messages from a person identified by person_id
*
* @param bigint $person_id REQUIRED
* @return array
*/
public function getSentMessagesByPerson($person_id, $all = false)
{
if (empty($person_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all);
return $msg;
}
/**
* getMessagesByToken
* getMessageByToken
*
* @param token string
* @return array
*/
public function getMessagesByToken($token)
public function getMessageByToken($token)
{
if (empty($token))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
$result = $this->ci->MessageModel->getMessagesByToken($token);
$result = $this->ci->RecipientModel->getMessageByToken($token);
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
// Searches for a status that is different from unread
@@ -179,61 +194,94 @@ class MessageLib
/**
* sendMessage() - sends new internal message. This function will create a new thread
*
* @param integer $sender_id REQUIRED
* @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
* @param string $subject
* @param string $body
* @param integer $priority
* @return array
*/
public function sendMessage($sender_id, $subject = "", $body = "", $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null)
public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null)
{
if (!is_numeric($sender_id))
if (!is_numeric($sender_id) || !is_numeric($receiver_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
// Start sending Message
$this->ci->db->trans_start(false);
//save Message
$data = array(
"person_id" => $sender_id,
"subject" => $subject,
"body" => $body,
"priority" => $priority,
"relationmessage_id" => $relationmessage_id,
"oe_kurzbz" => $oe_kurzbz
);
$result = $this->ci->MessageModel->insert($data);
if (is_object($result) && $result->error == EXIT_SUCCESS)
// Checks if the receiver exists
$this->ci->load->model("person/Person_model", "PersonModel");
$result = $this->ci->PersonModel->load($receiver_id);
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
/**
* @TODO: sender_id must be a receiver_id
*/
$msg_id = $result->retval;
$statusData = array(
"message_id" => $msg_id,
"person_id" => $sender_id,
"status" => MSG_STATUS_UNREAD
);
$result = $this->ci->MsgStatusModel->insert($statusData);
}
$this->ci->db->trans_complete();
if ($this->ci->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
{
$this->ci->db->trans_rollback();
return $this->_error($result->msg, EXIT_ERROR);
// If the text and the subject of the template are not empty
if (!empty($subject) && !empty($body))
{
$this->ci->db->trans_start(false);
// Save Message
$msgData = array(
"person_id" => $sender_id,
"subject" => $subject,
"body" => $body,
"priority" => PRIORITY_NORMAL,
"relationmessage_id" => $relationmessage_id,
"oe_kurzbz" => $oe_kurzbz
);
$result = $this->ci->MessageModel->insert($msgData);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// Link the message with the receiver
$msg_id = $result->retval;
$recipientData = array(
"person_id" => $receiver_id,
"message_id" => $msg_id
);
$result = $this->ci->RecipientModel->insert($recipientData);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// Save message status
$statusData = array(
"message_id" => $msg_id,
"person_id" => $receiver_id,
"status" => MSG_STATUS_UNREAD
);
$result = $this->ci->MsgStatusModel->insert($statusData);
// If no errors were occurred
/**
* TODO: different config item???
*/
/*if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// If the system is configured to send messages immediately
if ($this->ci->config->item("send_immediately") === true)
{
// Send message by email!
$resultSendEmail = $this->sendOne($msg_id, $subject, $parsedText);
}
}*/
}
}
$this->ci->db->trans_complete();
if ($this->ci->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
{
$this->ci->db->trans_rollback();
return $this->_error($result->msg, EXIT_ERROR);
}
else
{
$this->ci->db->trans_commit();
return $this->_success($msg_id);
}
}
else
{
$result = $this->_error("Subject or body empty", EXIT_ERROR);
}
}
else
{
$this->ci->db->trans_commit();
return $this->_success($msg_id);
$result = $this->_error("Receiver not present", EXIT_ERROR);
}
return $result;
}
/**
* sendMessage() - sends new internal message. This function will create a new thread
* sendMessageVorlage() - sends new internal message using a template
*
* @param integer $sender_id REQUIRED
* @param mixed $recipients REQUIRED - a single integer or an array of integers, representing user_ids
@@ -484,7 +532,7 @@ class MessageLib
}
/**
* One messages from DB and sends it via email
* Gets one message from DB and sends it via email
*/
public function sendOne($message_id, $subject = null, $body = null)
{
+7 -95
View File
@@ -14,60 +14,9 @@ class Message_model extends DB_Model
$this->pk = "message_id";
}
public function getMessagesByUID($uid, $all)
{
// Check wrights
// @ToDo: Define the special wright for reading own messages "basis/message:own"
// if same user
if ($uid === getAuthUID())
{
if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s"))
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)." -> basis/message:all", FHC_MODEL_ERROR);
}
// get Data
$sql = "SELECT b.uid,
m.person_id,
m.message_id,
m.subject,
m.body,
m.priority,
m.relationmessage_id,
m.oe_kurzbz,
m.insertamum,
p.anrede,
p.titelpost,
p.titelpre,
p.nachname,
p.vorname,
p.vornamen,
s.status,
s.statusinfo,
s.insertamum AS statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (r.person_id = p.person_id)
JOIN public.tbl_benutzer b ON (r.person_id = b.person_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE b.uid = ?";
if (! $all)
$sql .= " AND (status < 3 OR status IS NULL)";
$result = $this->db->query($sql, array($uid));
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
/**
* Get all sent messages from a person identified by person_id
*/
public function getMessagesByPerson($person_id, $all)
{
// Check wrights
@@ -80,7 +29,7 @@ class Message_model extends DB_Model
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = "SELECT r.message_id,
$sql = "SELECT m.message_id,
m.person_id,
m.subject,
m.body,
@@ -99,13 +48,13 @@ class Message_model extends DB_Model
s.insertamum AS statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (p.person_id = m.person_id)
JOIN (
LEFT JOIN (
SELECT message_id, person_id, status, statusinfo, insertamum
FROM public.tbl_msg_status
%s
ORDER BY insertamum DESC
) s ON (m.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.person_id = ?";
WHERE m.person_id = ?";
$parametersArray = array($person_id);
@@ -115,8 +64,7 @@ class Message_model extends DB_Model
}
else
{
array_push($parametersArray, $person_id, $person_id);
$sql = sprintf($sql, "WHERE person_id = ? AND message_id NOT IN (SELECT message_id FROM public.tbl_msg_status WHERE status >= 3 AND person_id = ?)");
$sql = sprintf($sql, "WHERE status >= 3");
}
$result = $this->db->query($sql, $parametersArray);
@@ -125,40 +73,4 @@ class Message_model extends DB_Model
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
public function getMessagesByToken($token)
{
// Check wrights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = "SELECT r.message_id,
r.person_id as receiver_id,
m.person_id as sender_id,
m.subject,
m.body,
m.insertamum,
m.relationmessage_id,
m.oe_kurzbz,
s.status,
s.statusinfo,
s.insertamum as statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.token = ?
AND status < ?
ORDER BY s.insertamum DESC";
$result = $this->db->query($sql, array($token, MSG_STATUS_DELETED));
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
}
+201 -3
View File
@@ -1,18 +1,216 @@
<?php
class Recipient_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_msg_recipient';
$this->pk = array('person_id', 'message_id');
$this->dbTable = "public.tbl_msg_recipient";
$this->pk = array("person_id", "message_id");
$this->hasSequence = false;
}
/**
* Get data for a received message
*/
public function getMessage($message_id, $person_id)
{
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_person"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_person"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_kontakt"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_kontakt"), FHC_MODEL_ERROR);
$query = "SELECT mr.message_id,
mr.person_id,
mm.subject,
mm.body,
ks.kontakt,
p.nachname,
p.vorname,
b.uid
FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id)
INNER JOIN public.tbl_person p ON (mr.person_id = p.person_id)
LEFT JOIN public.tbl_benutzer b ON (mr.person_id = b.person_id)
LEFT JOIN (
SELECT person_id, kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email'
) ks ON (ks.person_id = mr.person_id)
WHERE mr.message_id = ? AND mr.person_id = ?";
$parametersArray = array($message_id, $person_id);
// Get data of the messages to sent
$result = $this->db->query($query, $parametersArray);
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
/**
* Get a received message identified by token
*/
public function getMessageByToken($token)
{
// Check wrights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = "SELECT r.message_id,
r.person_id as receiver_id,
m.person_id as sender_id,
m.subject,
m.body,
m.insertamum,
m.relationmessage_id,
m.oe_kurzbz,
s.status,
s.statusinfo,
s.insertamum as statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.token = ?
AND status < ?
ORDER BY s.insertamum DESC";
$result = $this->db->query($sql, array($token, MSG_STATUS_DELETED));
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
/**
* Get all received messages for a person identified by person_id
*/
public function getMessagesByPerson($person_id, $all)
{
// Check wrights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_person"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_person"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = "SELECT r.message_id,
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
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (p.person_id = m.person_id)
JOIN (
SELECT message_id, person_id, status, statusinfo, insertamum
FROM public.tbl_msg_status
%s
ORDER BY insertamum DESC
) s ON (m.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.person_id = ?";
$parametersArray = array($person_id);
if ($all == "true")
{
$sql = sprintf($sql, "");
}
else
{
array_push($parametersArray, $person_id, $person_id);
$sql = sprintf($sql, "WHERE person_id = ? AND message_id NOT IN (SELECT message_id FROM public.tbl_msg_status WHERE status >= 3 AND person_id = ?)");
}
$result = $this->db->query($sql, $parametersArray);
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
/**
* Get all received messages for a person identified by uid
*/
public function getMessagesByUID($uid, $all)
{
// Check wrights
// @ToDo: Define the special wright for reading own messages "basis/message:own"
// if same user
if ($uid === getAuthUID())
{
if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s"))
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)." -> basis/message:all", FHC_MODEL_ERROR);
}
// get Data
$sql = "SELECT b.uid,
m.person_id,
m.message_id,
m.subject,
m.body,
m.priority,
m.relationmessage_id,
m.oe_kurzbz,
m.insertamum,
p.anrede,
p.titelpost,
p.titelpre,
p.nachname,
p.vorname,
p.vornamen,
s.status,
s.statusinfo,
s.insertamum AS statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (r.person_id = p.person_id)
JOIN public.tbl_benutzer b ON (r.person_id = b.person_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE b.uid = ?";
if (! $all)
$sql .= " AND (status < 3 OR status IS NULL)";
$result = $this->db->query($sql, array($uid));
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
/**
* getMessages
*
+32 -12
View File
@@ -1,14 +1,34 @@
<?php $this->load->view('templates/header'); ?>
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<div class="row">
<div class="span4">
<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>
<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/write/<?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>
+30 -20
View File
@@ -1,21 +1,31 @@
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<?php $this->load->view('templates/header'); ?>
<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>
</div>
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
<body>
<div class="row">
<div class="span4">
<?php
$href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER["REQUEST_URI"]);
/*$href = substr($href, 0, strrpos($href, "/") - strlen($href));
$href = substr($href, 0, strrpos($href, "/") - strlen($href));*/
/*$href .= "/" . $m->message_id . "/" . $person->person_id;*/
?>
<form id="sendForm" method="post" action="<?php echo $href; ?>">
<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>
<button type="submit">Send</button>
</form>
</div>
</div>
<script>
tinymce.init({
selector: '#bodyTextArea'
});
</script>
</body>
</html>
+1 -1
View File
@@ -6,7 +6,7 @@
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; ?>'">
<button type="button" onClick="parent.document.getElementById('MessagesTop').src = 'Messages/outbox/<?php echo $person->person_id; ?>'">
Outbox
</button>
<br />
+1 -1
View File
@@ -6,7 +6,7 @@
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; ?>'">
<button type="button" onClick="parent.document.getElementById('MessagesTop').src = 'Messages/inbox/<?php echo $person->person_id; ?>'">
Inbox
</button>
<br />