mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Added the ability to choose a template (Vorlage) as email text
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class Message extends APIv1_Controller
|
||||
{
|
||||
@@ -23,7 +23,7 @@ class Message extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load library MessageLib
|
||||
$this->load->library('MessageLib');
|
||||
$this->load->library("MessageLib");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +31,8 @@ class Message extends APIv1_Controller
|
||||
*/
|
||||
public function getMessagesByPersonID()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
$all = $this->get('all');
|
||||
$person_id = $this->get("person_id");
|
||||
$all = $this->get("all");
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
@@ -51,8 +51,8 @@ class Message extends APIv1_Controller
|
||||
*/
|
||||
public function getMessagesByUID()
|
||||
{
|
||||
$uid = $this->get('uid');
|
||||
$all = $this->get('all');
|
||||
$uid = $this->get("uid");
|
||||
$all = $this->get("all");
|
||||
|
||||
if (isset($uid))
|
||||
{
|
||||
@@ -71,7 +71,7 @@ class Message extends APIv1_Controller
|
||||
*/
|
||||
public function getMessagesByToken()
|
||||
{
|
||||
$token = $this->get('token');
|
||||
$token = $this->get("token");
|
||||
|
||||
if (isset($token))
|
||||
{
|
||||
@@ -85,6 +85,23 @@ class Message extends APIv1_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getRedirectByToken()
|
||||
{
|
||||
$token = $this->get("token");
|
||||
|
||||
if (isset($token))
|
||||
{
|
||||
redirect(CIS_ROOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
@@ -95,13 +112,13 @@ class Message extends APIv1_Controller
|
||||
if (is_object($validation) && $validation->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->messagelib->sendMessage(
|
||||
$this->post()['person_id'],
|
||||
$this->post()['receiver_id'],
|
||||
$this->post()['subject'],
|
||||
$this->post()['body'],
|
||||
$this->post()["person_id"],
|
||||
$this->post()["receiver_id"],
|
||||
$this->post()["subject"],
|
||||
$this->post()["body"],
|
||||
PRIORITY_NORMAL,
|
||||
$this->post()['relationmessage_id'],
|
||||
$this->post()['oe_kurzbz']
|
||||
$this->post()["relationmessage_id"],
|
||||
$this->post()["oe_kurzbz"]
|
||||
);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
@@ -122,13 +139,13 @@ class Message extends APIv1_Controller
|
||||
if (is_object($validation) && $validation->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->messagelib->sendMessageVorlage(
|
||||
$this->post()['sender_id'],
|
||||
$this->post()['receiver_id'],
|
||||
$this->post()['vorlage_kurzbz'],
|
||||
$this->post()['oe_kurzbz'],
|
||||
$this->post()['data'],
|
||||
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null,
|
||||
isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null
|
||||
$this->post()["sender_id"],
|
||||
$this->post()["receiver_id"],
|
||||
$this->post()["vorlage_kurzbz"],
|
||||
$this->post()["oe_kurzbz"],
|
||||
$this->post()["data"],
|
||||
isset($this->post()["relationmessage_id"]) ? $this->post()["relationmessage_id"] : null,
|
||||
isset($this->post()["orgform_kurzbz"]) ? $this->post()["orgform_kurzbz"] : null
|
||||
);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
@@ -144,9 +161,9 @@ class Message extends APIv1_Controller
|
||||
*/
|
||||
public function postChangeStatus()
|
||||
{
|
||||
$person_id = $this->post()['person_id'];
|
||||
$message_id = $this->post()['message_id'];
|
||||
$status = $this->post()['status'];
|
||||
$person_id = $this->post()["person_id"];
|
||||
$message_id = $this->post()["message_id"];
|
||||
$status = $this->post()["status"];
|
||||
|
||||
if (isset($person_id) && isset($message_id) && isset($status) &&
|
||||
in_array($status, array(MSG_STATUS_UNREAD, MSG_STATUS_READ, MSG_STATUS_ARCHIVED, MSG_STATUS_DELETED)))
|
||||
@@ -165,55 +182,55 @@ class Message extends APIv1_Controller
|
||||
{
|
||||
if (!isset($message))
|
||||
{
|
||||
return $this->_error('Parameter is null');
|
||||
return $this->_error("Parameter is null");
|
||||
}
|
||||
if (!isset($message['person_id']))
|
||||
if (!isset($message["person_id"]))
|
||||
{
|
||||
return $this->_error('person_id is not set');
|
||||
return $this->_error("person_id is not set");
|
||||
}
|
||||
if (!isset($message['subject']))
|
||||
if (!isset($message["subject"]))
|
||||
{
|
||||
return $this->_error('subject is not set');
|
||||
return $this->_error("subject is not set");
|
||||
}
|
||||
if( !isset($message['body']))
|
||||
if( !isset($message["body"]))
|
||||
{
|
||||
return $this->_error('body is not set');
|
||||
return $this->_error("body is not set");
|
||||
}
|
||||
if (!isset($message['oe_kurzbz']))
|
||||
if (!isset($message["oe_kurzbz"]))
|
||||
{
|
||||
return $this->_error('oe_kurzbz is not set');
|
||||
return $this->_error("oe_kurzbz is not set");
|
||||
}
|
||||
|
||||
return $this->_success('Input data are valid');
|
||||
return $this->_success("Input data are valid");
|
||||
}
|
||||
|
||||
private function _validatePostMessageVorlage($message = null)
|
||||
{
|
||||
if (!isset($message))
|
||||
{
|
||||
return $this->_error('Parameter is null');
|
||||
return $this->_error("Parameter is null");
|
||||
}
|
||||
if (!isset($message['sender_id']))
|
||||
if (!isset($message["sender_id"]))
|
||||
{
|
||||
return $this->_error('person_id of sender is not set');
|
||||
return $this->_error("person_id of sender is not set");
|
||||
}
|
||||
if (!isset($message['receiver_id']))
|
||||
if (!isset($message["receiver_id"]))
|
||||
{
|
||||
return $this->_error('person_id of receiver is not set');
|
||||
return $this->_error("person_id of receiver is not set");
|
||||
}
|
||||
if (!isset($message['vorlage_kurzbz']))
|
||||
if (!isset($message["vorlage_kurzbz"]))
|
||||
{
|
||||
return $this->_error('vorlage_kurzbz is not set');
|
||||
return $this->_error("vorlage_kurzbz is not set");
|
||||
}
|
||||
if( !isset($message['oe_kurzbz']))
|
||||
if( !isset($message["oe_kurzbz"]))
|
||||
{
|
||||
return $this->_error('oe_kurzbz is not set');
|
||||
return $this->_error("oe_kurzbz is not set");
|
||||
}
|
||||
if (!isset($message['data']))
|
||||
if (!isset($message["data"]))
|
||||
{
|
||||
return $this->_error('data is not set');
|
||||
return $this->_error("data is not set");
|
||||
}
|
||||
|
||||
return $this->_success('Input data are valid');
|
||||
return $this->_success("Input data are valid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,4 +161,19 @@ class Messages extends VileSci_Controller
|
||||
|
||||
return $person_id;
|
||||
}
|
||||
|
||||
public function getVorlage()
|
||||
{
|
||||
$vorlage_kurzbz = $this->input->get("vorlage_kurzbz");
|
||||
|
||||
if (isset($vorlage_kurzbz))
|
||||
{
|
||||
$this->load->model("system/Vorlagestudiengang_model", "VorlagestudiengangModel");
|
||||
$result = $this->VorlagestudiengangModel->loadWhere(array("vorlage_kurzbz" => $vorlage_kurzbz));
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,52 @@
|
||||
<?php $this->load->view('templates/header'); ?>
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
|
||||
<?php $this->load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?>
|
||||
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<?php
|
||||
$href = str_replace("/system/Messages/reply", "/system/Messages/sendReply", $_SERVER["REQUEST_URI"]);
|
||||
?>
|
||||
<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>
|
||||
<?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>
|
||||
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: '#bodyTextArea'
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<button type="submit">Send</button>
|
||||
|
||||
<?php echo $this->templatelib->widget("Vorlage_widget", array("title" => "Vorlage")); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: "#bodyTextArea"
|
||||
});
|
||||
|
||||
<?php
|
||||
$url = str_replace("/system/Messages/reply", "/system/Messages/getVorlage", $_SERVER["REQUEST_URI"]);
|
||||
?>
|
||||
|
||||
function getVorlageText(vorlage_kurzbz)
|
||||
{
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: "<?php echo $url; ?>",
|
||||
data: {"vorlage_kurzbz": vorlage_kurzbz},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
tinyMCE.activeEditor.setContent(data.retval[0].text);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
alert(textStatus + " - " + errorThrown);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -1,28 +1,52 @@
|
||||
<?php $this->load->view('templates/header'); ?>
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url('vendor/tinymce/tinymce/tinymce.min.js');?>"></script>
|
||||
<?php $this->load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?>
|
||||
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<?php
|
||||
$href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER["REQUEST_URI"]);
|
||||
?>
|
||||
<form id="sendForm" method="post" action="<?php echo $href; ?>">
|
||||
<div class="span4">
|
||||
To: <?php echo $receiver->vorname . " " . $receiver->nachname; ?><br/>
|
||||
Subject: <input type="text" value="" name="subject"><br/>
|
||||
<textarea id="bodyTextArea" name="body"></textarea>
|
||||
</div>
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
<?php
|
||||
$href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER["REQUEST_URI"]);
|
||||
?>
|
||||
<form id="sendForm" method="post" action="<?php echo $href; ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
To: <?php echo $receiver->vorname . " " . $receiver->nachname; ?><br/>
|
||||
Subject: <input type="text" value="" name="subject"><br/>
|
||||
<textarea id="bodyTextArea" name="body"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: '#bodyTextArea'
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<button type="submit">Send</button>
|
||||
|
||||
<?php echo $this->templatelib->widget("Vorlage_widget", array("title" => "Vorlage")); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: "#bodyTextArea"
|
||||
});
|
||||
|
||||
<?php
|
||||
$url = str_replace("/system/Messages/write", "/system/Messages/getVorlage", $_SERVER["REQUEST_URI"]);
|
||||
?>
|
||||
|
||||
function getVorlageText(vorlage_kurzbz)
|
||||
{
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: "<?php echo $url; ?>",
|
||||
data: {"vorlage_kurzbz": vorlage_kurzbz},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
tinyMCE.activeEditor.setContent(data.retval[0].text);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
alert(textStatus + " - " + errorThrown);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<select name="vorlage">
|
||||
<?php foreach($vorlage as $v): ?>
|
||||
<option value="<?php echo $v->vorlage_kurzbz; ?>" onClick="getVorlageText(this.value)">
|
||||
<?php echo $v->vorlage_kurzbz . (isset($v->bezeichnung) ? " - " . $v->bezeichnung : ""); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class Vorlage_widget extends Widget
|
||||
{
|
||||
public function display($data)
|
||||
{
|
||||
$this->load->model("system/Vorlage_model", "VorlageModel");
|
||||
$this->VorlageModel->addOrder("vorlage_kurzbz");
|
||||
$result = $this->VorlageModel->load();
|
||||
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$data = array("vorlage" => $result->retval);
|
||||
$this->view("widgets/vorlage", $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user