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()