- Removed messagelink from controller system/infocenter/InfoCenter.php

- Improved MessageLib
- Added method getMessageVarsPerson to MessageLib
- Moved JS from views/system/messageWrite.php to public/js/messaging/messageWrite.js
- Added new controller controllers/system/FASMessages.php
- Adapted content/fasoverlay.js.php and content/messages.js.php to use FASMessages
This commit is contained in:
Paolo
2019-01-25 17:16:57 +01:00
parent d3803a848f
commit 306da46c80
10 changed files with 530 additions and 427 deletions
@@ -0,0 +1,117 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class FASMessages extends Auth_Controller
{
/**
*
*/
public function __construct()
{
parent::__construct(
array(
'write' => 'basis/message:rw'
)
);
// Loads the message library
$this->load->library('MessageLib');
// Loads the widget library
$this->load->library('WidgetLib');
$this->load->model('system/Message_model', 'MessageModel');
$this->load->model('person/Person_model', 'PersonModel');
$this->loadPhrases(
array(
'global',
'ui'
)
);
}
/**
* Write
*/
public function write($sender_id = null, $msg_id = null, $receiver_id = null)
{
$prestudent_id = $this->input->post('prestudent_id');
$oe_kurzbz = array(); // a person may belongs to more organisation units
$msg = null;
if (!is_numeric($sender_id))
{
$personByUID = $this->PersonModel->getByUid(getAuthUID());
if (isError($personByUID) || !hasData($personByUID))
{
show_error($personByUID->retval);
}
else
{
$sender_id = $personByUID->retval[0]->person_id;
}
}
// Get message data if possible
if (is_numeric($msg_id) && is_numeric($receiver_id))
{
$msg = $this->messagelib->getMessage($msg_id, $receiver_id);
if (isError($msg) || !hasData($msg))
{
show_error($msg->retval);
}
else
{
$msg = $msg->retval[0];
}
}
// Retrieves message vars from view vw_msg_vars
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if (isError($msgVarsData))
{
show_error($msgVarsData->retval);
}
// Retrieves message vars for a person from view view vw_msg_vars_person
$variablesArray = $this->messagelib->getMessageVarsPerson();
// Organisation units used to get the templates
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id);
if (isError($benutzerResult))
{
show_error($benutzerResult->retval);
}
elseif (hasData($benutzerResult))
{
foreach ($benutzerResult->retval as $val)
{
$oe_kurzbz[] = $val->oe_kurzbz;
}
}
// Admin or commoner?
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
$isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id);
if (isError($isAdmin))
{
show_error($isAdmin->retval);
}
$data = array (
'sender_id' => $sender_id,
'receivers' => $msgVarsData->retval,
'message' => $msg,
'variables' => $variablesArray,
'oe_kurzbz' => $oe_kurzbz, // used to get the templates
'isAdmin' => $isAdmin->retval,
'personOnly' => false // indicates if sent only to persons
);
$this->load->view('system/messageWrite', $data);
}
}
+110 -128
View File
@@ -4,8 +4,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class Messages extends Auth_Controller
{
private $uid; // contains the UID of the logged user
/**
*
*/
@@ -28,43 +26,37 @@ class Messages extends Auth_Controller
// Loads the widget library
$this->load->library('WidgetLib');
$this->load->model('system/Message_model', 'MessageModel');
$this->load->model('person/Person_model', 'PersonModel');
$this->loadPhrases(
array(
'global',
'person',
'lehre',
'ui',
'infocenter'
'ui'
)
);
$this->_setAuthUID(); // sets property uid
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* write
* Write
*/
public function write($sender_id = null, $msg_id = null, $receiver_id = null)
public function write()
{
if ($sender_id === null)
$sender_id = null;
$recipients = $this->input->post('person_id');
$authUser = $this->PersonModel->getByUid(getAuthUID());
if (isError($authUser))
{
$user_person = $this->PersonModel->getByUid($this->uid);
if (isError($user_person))
{
show_error($user_person->retval);
}
$sender_id = $user_person->retval[0]->person_id;
show_error($authUser->retval);
}
elseif (hasData($authUser))
{
$sender_id = $authUser->retval[0]->person_id;
}
$prestudent_id = $this->input->post('prestudent_id');
$person_id = $this->input->post('person_id');
$personOnly = false;
if (isset($person_id) && !isset($prestudent_id))
$personOnly = true;
$msg = null;
@@ -87,10 +79,8 @@ class Messages extends Auth_Controller
// Get variables
$this->load->model('system/Message_model', 'MessageModel');
if ($personOnly === true)
$this->getPersonMsgData($person_id, $variablesArray, $msgVarsData);
else
$this->getPrestudentMsgData($prestudent_id, $variablesArray, $msgVarsData);
$this->getPersonMsgData($person_id, $variablesArray, $msgVarsData);
// Organisation units used to get the templates
$oe_kurzbz = array(); // A person can have more organisation units
@@ -122,69 +112,7 @@ class Messages extends Auth_Controller
'personOnly' => $personOnly//indicates if sent only to persons
);
$v = $this->load->view('system/messageWrite', $data);
}
/**
* gets Message Variables and their data for Prestudent
* @param $prestudent_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if ($msgVarsData->error)
{
show_error($msgVarsData->retval);
}
if (!hasData($variables = $this->MessageModel->getMessageVars()))
{
unset($variables);
}
else
{
$variablesArray = array();
// Skip person_id and prestudent_id
for ($i = 2; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
}
array_shift($variables->retval); // Remove person_id
array_shift($variables->retval); // Remove prestudent_id
}
/**
* gets Message Variables and their data for Person
* @param $person_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
if ($msgVarsData->error)
{
show_error($msgVarsData->retval);
}
if (!hasData($variables = $this->MessageModel->getMessageVarsPerson()))
{
unset($variables);
}
else
{
$variablesArray = array();
// Skip person_id
for ($i = 1; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
array_shift($variables->retval); // Remove person_id
}
$this->load->view('system/messageWrite', $data);
}
/**
@@ -226,7 +154,7 @@ class Messages extends Auth_Controller
{
if ($sender_id === null)
{
$user_person = $this->PersonModel->getByUid($this->uid);
$user_person = $this->PersonModel->getByUid(getAuthUID());
if (!hasData($user_person))
{
@@ -326,7 +254,7 @@ class Messages extends Auth_Controller
'kommunikation',
'core',
null,
$this->uid
getAuthUID()
);
}
@@ -334,40 +262,6 @@ class Messages extends Auth_Controller
}
}
/**
* getPersonId
*/
private function getPersonId()
{
$person_id = null;
if ($this->input->get('person_id') !== null)
{
$person_id = $this->input->get('person_id');
}
elseif ($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;
}
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->uid = getAuthUID();
if (!$this->uid) show_error('User authentification failed');
}
/**
* getVorlage
*/
@@ -440,4 +334,92 @@ class Messages extends Auth_Controller
->set_output(json_encode(array($msg->retval[0])));
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* gets Message Variables and their data for Prestudent
* @param $prestudent_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if ($msgVarsData->error)
{
show_error($msgVarsData->retval);
}
if (!hasData($variables = $this->MessageModel->getMessageVars()))
{
unset($variables);
}
else
{
$variablesArray = array();
// Skip person_id and prestudent_id
for ($i = 2; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
}
array_shift($variables->retval); // Remove person_id
array_shift($variables->retval); // Remove prestudent_id
}
/**
* gets Message Variables and their data for Person
* @param $person_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
if ($msgVarsData->error)
{
show_error($msgVarsData->retval);
}
if (!hasData($variables = $this->MessageModel->getMessageVarsPerson()))
{
unset($variables);
}
else
{
$variablesArray = array();
// Skip person_id
for ($i = 1; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
array_shift($variables->retval); // Remove person_id
}
}
/**
* getPersonId
*/
private function getPersonId()
{
$person_id = null;
if ($this->input->get('person_id') !== null)
{
$person_id = $this->input->get('person_id');
}
elseif ($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;
}
}
@@ -1154,8 +1154,6 @@ class InfoCenter extends Auth_Controller
show_error($user_person->retval);
}
$messagelink = site_url('/system/Messages/write/'.$user_person->retval[0]->person_id);
$data = array (
'lockedby' => $lockedby,
'lockedbyother' => $lockedbyother,
@@ -1165,8 +1163,7 @@ class InfoCenter extends Auth_Controller
'messages' => $messages->retval,
'logs' => $logs,
'notizen' => $notizen->retval,
'notizenbewerbung' => $notizen_bewerbung->retval,
'messagelink' => $messagelink
'notizenbewerbung' => $notizen_bewerbung->retval
);
return $data;
+34 -9
View File
@@ -39,6 +39,9 @@ class MessageLib
$this->ci->lang->load('message');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* getMessage() - returns the specified received message for a specified person
*/
@@ -750,7 +753,37 @@ class MessageLib
return $sent;
}
// ------------------------------------------------------------------------
/**
* parseMessageText
*/
public function parseMessageText($text, $data = array())
{
return $this->ci->parser->parse_string($text, $data, true);
}
/**
* Gets data for Person from view vw_msg_vars_person
* @param $person_id
*/
public function getMessageVarsPerson()
{
$variablesArray = array();
$variables = $this->ci->MessageModel->getMessageVarsPerson();
if (hasData($variables))
{
// Skip person_id
for ($i = 1; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(' ', '_', strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
array_shift($variables->retval); // Remove person_id
}
return $variablesArray;
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
@@ -932,12 +965,4 @@ class MessageLib
{
return success($retval, $code, MessageLib::MSG_INDX_PREFIX);
}
/**
*
*/
public function parseMessageText($text, $data = array())
{
return $this->ci->parser->parse_string($text, $data, true);
}
}
@@ -66,7 +66,7 @@
</tr>
</thead>
<tbody>
<?php
<?php
$lastMailAdress = '';
foreach ($stammdaten->kontakte as $kontakt): ?>
<tr>
@@ -113,12 +113,11 @@
</table>
<div class="row">
<div class="col-xs-6">
<form id="sendmsgform" method="post" action="<?php echo $messagelink ?>"
target="_blank">
<input type="hidden" name="person_id"
value="<?php echo $stammdaten->person_id ?>">
<a id="sendmsglink" href="javascript:void(0);"><i
class="fa fa-envelope"></i>&nbsp;<?php echo $this->p->t('ui','nachrichtSenden') ?></a>
<form id="sendmsgform" method="post" action="<?php echo site_url('/system/Messages/write'); ?>" target="_blank">
<input type="hidden" name="person_id" value="<?php echo $stammdaten->person_id ?>">
<a id="sendmsglink" href="javascript:void(0);">
<i class="fa fa-envelope"></i>&nbsp;<?php echo $this->p->t('ui','nachrichtSenden'); ?>
</a>
</form>
</div>
<?php if (isset($stammdaten->zugangscode)): ?>
+130 -274
View File
@@ -9,311 +9,167 @@ $this->load->view(
'tinymce' => true,
'sbadmintemplate' => true,
'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'),
'customJSs' => array('public/js/bootstrapper.js')
'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js')
)
);
?>
<body>
<?php
$href = site_url().'/system/Messages/send/';
?>
<div id="wrapper">
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h3 class="page-header"><?php echo ucfirst($this->p->t('ui', 'nachrichtSenden')) ?></h3>
</div>
</div>
<form id="sendForm" method="post" action="<?php echo $href; ?>">
<div id="wrapper">
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="form-group">
<div class="col-lg-1 msgfieldcol-left">
<label><?php echo ucfirst($this->p->t('global', 'empfaenger')) . ':'?></label>
</div>
<div class="col-lg-11 msgfieldcol-right">
<?php
for ($i = 0; $i < count($receivers); $i++)
{
$receiver = $receivers[$i];
// Every 10 recipients a new line
if ($i > 1 && $i % 10 == 0)
<div class="col-lg-12">
<h3 class="page-header"><?php echo ucfirst($this->p->t('ui', 'nachrichtSenden')) ?></h3>
</div>
</div>
<form id="sendForm" method="post" action="<?php echo site_url('/system/Messages/send'); ?>">
<div class="row">
<div class="form-group">
<div class="col-lg-1 msgfieldcol-left">
<label><?php echo ucfirst($this->p->t('global', 'empfaenger')) . ':'?></label>
</div>
<div class="col-lg-11 msgfieldcol-right">
<?php
for ($i = 0; $i < count($receivers); $i++)
{
echo '<br>';
}
echo $receiver->Vorname." ".$receiver->Nachname."; ";
}
?>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-lg-1 msgfield msgfieldcol-left">
<label><?php echo ucfirst($this->p->t('global', 'betreff')) . ':'?></label>
</div>&nbsp;
<?php
$subject = '';
if (isset($message))
{
$subject = 'Re: '.$message->subject;
}
?>
<div class="col-lg-7">
<input id="subject" class="form-control" type="text" value="<?php echo $subject; ?>"
name="subject">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-10">
<label><?php echo ucfirst($this->p->t('global', 'nachricht')) . ':'?></label>
<?php
$body = '';
if (isset($message))
{
$body = $message->body;
}
?>
<textarea id="bodyTextArea" name="body"><?php echo $body; ?></textarea>
</div>
<?php
if (isset($variables)):
?>
<div class="col-lg-2">
<div class="form-group">
<label><?php echo ucfirst($this->p->t('ui', 'felder')) . ':'?></label>
<select id="variables" class="form-control" size="14" multiple="multiple">
<?php
foreach ($variables as $key => $val)
$receiver = $receivers[$i];
// Every 10 recipients a new line
if ($i > 1 && $i % 10 == 0)
{
?>
<option value="<?php echo $key; ?>"><?php echo $val; ?></option>
<?php
echo '<br>';
}
?>
</select>
echo $receiver->Vorname." ".$receiver->Nachname."; ";
}
?>
</div>
</div>
<?php endif; ?>
</div>
<br>
<div class="row">
<div class="col-xs-3">
<?php
echo $this->widgetlib->widget(
'Vorlage_widget',
array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin),
array('name' => 'vorlage', 'id' => 'vorlageDnD')
);
?>
</div>
<div class="col-lg-7 col-xs-9 text-right">
<button id="sendButton" class="btn btn-default" type="button"><?php echo $this->p->t('ui', 'senden')?></button>
</div>
</div>
<?php if (isset($receivers) && count($receivers) > 0): ?>
<hr>
<div class="row">
<div class="col-lg-12">
<label><?php echo ucfirst($this->p->t('global', 'vorschau')) . ':'?></label>
<div class="form-group">
<div class="col-lg-1 msgfield msgfieldcol-left">
<label><?php echo ucfirst($this->p->t('global', 'betreff')) . ':'?></label>
</div>&nbsp;
<?php
$subject = '';
if (isset($message))
{
$subject = 'Re: '.$message->subject;
}
?>
<div class="col-lg-7">
<input id="subject" class="form-control" type="text" value="<?php echo $subject; ?>"
name="subject">
</div>
</div>
</div>
<div class="well">
<div class="row">
<div class="col-lg-5">
<div class="form-grop form-inline">
<label><?php echo ucfirst($this->p->t('global', 'empfaenger')) . ': ' ?></label>
<select id="recipients">
<br>
<div class="row">
<div class="col-lg-10">
<label><?php echo ucfirst($this->p->t('global', 'nachricht')) . ':'?></label>
<?php
$body = '';
if (isset($message))
{
$body = $message->body;
}
?>
<textarea id="bodyTextArea" name="body"><?php echo $body; ?></textarea>
</div>
<?php
if (isset($variables)):
?>
<div class="col-lg-2">
<div class="form-group">
<label><?php echo ucfirst($this->p->t('ui', 'felder')) . ':'?></label>
<select id="variables" class="form-control" size="14" multiple="multiple">
<?php
if (count($receivers) > 1)
echo '<option value="-1">Select...</option>';
$idtype = $personOnly === true ? 'person_id' : 'prestudent_id';
foreach ($receivers as $receiver)
foreach ($variables as $key => $val)
{
?>
<option value="<?php echo $receiver->{$idtype}; ?>"><?php echo $receiver->Vorname." ".$receiver->Nachname; ?></option>
<option value="<?php echo $key; ?>"><?php echo $val; ?></option>
<?php
}
?>
</select>
&nbsp;
<strong><a href="#" id="refresh">Refresh</a></strong>
</div>
</div>
<div class="col-lg-2">
<?php endif; ?>
</div>
<br>
<div class="row">
<div class="col-xs-3">
<?php
echo $this->widgetlib->widget(
'Vorlage_widget',
array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin),
array('name' => 'vorlage', 'id' => 'vorlageDnD')
);
?>
</div>
<div class="col-lg-7 col-xs-9 text-right">
<button id="sendButton" class="btn btn-default" type="button"><?php echo $this->p->t('ui', 'senden')?></button>
</div>
</div>
<?php if (isset($receivers) && count($receivers) > 0): ?>
<hr>
<div class="row">
<div class="col-lg-12">
<label><?php echo ucfirst($this->p->t('global', 'vorschau')) . ':'?></label>
</div>
</div>
<br>
<textarea id="tinymcePreview"></textarea>
</div>
<?php
endif;
?>
<div class="well">
<div class="row">
<div class="col-lg-5">
<div class="form-grop form-inline">
<label><?php echo ucfirst($this->p->t('global', 'empfaenger')) . ': ' ?></label>
<select id="recipients">
<?php
if (count($receivers) > 1)
echo '<option value="-1">Select...</option>';
<?php
for ($i = 0; $i < count($receivers); $i++)
{
$receiver = $receivers[$i];
if ($personOnly === true)
{
$receiverid = $receiver->person_id;
$fieldname = 'persons[]';
}
else
{
$receiverid = $receiver->prestudent_id;
$fieldname = 'prestudents[]';
}
echo '<input type="hidden" name="'.$fieldname.'" value="'.$receiverid.'">'."\n";
}
?>
foreach ($receivers as $receiver)
{
?>
<option value="<?php echo $receiver->person_id; ?>"><?php echo $receiver->Vorname." ".$receiver->Nachname; ?></option>
<?php
}
?>
</select>
&nbsp;
<strong><a href="#" id="refresh">Refresh</a></strong>
</div>
</div>
<div class="col-lg-2">
<?php
if (isset($message))
{
</div>
</div>
<br>
<textarea id="tinymcePreview"></textarea>
</div>
<?php
endif;
?>
<input type="hidden" name="relationmessage_id" value="<?php echo $message->message_id; ?>">
<?php
}
?>
</form>
<?php
for ($i = 0; $i < count($receivers); $i++)
{
echo '<input type="hidden" name="persons[]" value="'.$receiver->person_id.'">'."\n";
}
?>
<?php
if (isset($message))
{
?>
<input type="hidden" name="relationmessage_id" value="<?php echo $message->message_id; ?>">
<?php
}
?>
</form>
</div>
</div>
</div>
</div>
<script>
const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/"+FHC_JS_DATA_STORAGE_OBJECT.called_path;
tinymce.init({
selector: "#bodyTextArea",
plugins: "autoresize",
autoresize_min_height: 150,
autoresize_max_height: 600,
autoresize_bottom_margin: 10
});
tinymce.init({
menubar: false,
toolbar: false,
statusbar: false,
readonly: 1,
selector: "#tinymcePreview",
plugins: "autoresize",
autoresize_min_height: 150,
autoresize_bottom_margin: 10
});
$(document).ready(function ()
{
if ($("#variables"))
{
$("#variables").dblclick(function ()
{
if ($("#bodyTextArea"))
{
//if editor active add at cursor position, otherwise at end
if (tinymce.activeEditor.id === "bodyTextArea")
tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).children(":selected").val());
else
tinyMCE.get("bodyTextArea").setContent(tinyMCE.get("bodyTextArea").getContent() + $(this).children(":selected").val());
}
});
}
if ($("#recipients"))
{
$("#recipients").change(tinymcePreviewSetContent);
}
if ($("#refresh"))
{
$("#refresh").click(tinymcePreviewSetContent);
}
if ($("#sendButton") && $("#sendForm"))
{
$("#sendButton").click(function ()
{
if ($("#subject") && $("#subject").val() != '' && tinyMCE.get("bodyTextArea").getContent() != '')
{
$("#sendForm").submit();
}
else
{
alert("Subject and text are required fields!");
}
});
}
if ($("#vorlageDnD"))
{
$("#vorlageDnD").change(function ()
{
if (this.value != '')
{
$.ajax({
dataType: "json",
url: CONTROLLER_URL+"/getVorlage",
data: {"vorlage_kurzbz": this.value},
success: function (data, textStatus, jqXHR)
{
tinyMCE.get("bodyTextArea").setContent(data.retval[0].text);
$("#subject").val(data.retval[0].subject);
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown);
}
});
}
});
}
$("#subject").focus();
});
function tinymcePreviewSetContent()
{
if ($("#tinymcePreview"))
{
if ($("#recipients").children(":selected").val() > -1)
{
parseMessageText($("#recipients").children(":selected").val(), tinyMCE.get("bodyTextArea").getContent());
}
else
{
tinyMCE.get("tinymcePreview").setContent("");
}
}
}
function parseMessageText(receiver_id, text)
{
<?php
$idtype = $personOnly === true ? 'person_id' : 'prestudent_id';
?>
$.ajax({
dataType: "json",
url: CONTROLLER_URL+"/parseMessageText",
data: {"<?php echo $idtype ?>": receiver_id, "text": text},
success: function (data, textStatus, jqXHR)
{
tinyMCE.get("tinymcePreview").setContent(data);
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
</script>
</body>
<?php $this->load->view("templates/FHC-Footer"); ?>
+1 -1
View File
@@ -1230,7 +1230,7 @@ function MessageNew()
{
var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id');
var action = '<?php echo APP_ROOT ?>index.ci.php/system/Messages/write/' + <?php echo $benutzer->person_id; ?>;
var action = '<?php echo APP_ROOT ?>index.ci.php/system/FASMessages/write/' + <?php echo $benutzer->person_id; ?>;
openWindowPostArray(action, 'prestudent_id', prestudentIdArray);
}
+3 -3
View File
@@ -104,7 +104,7 @@ function MessagesNewMessage()
{
var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id');
var action = '<?php echo APP_ROOT ?>index.ci.php/system/Messages/write/' + MessageSenderPersonID;
var action = '<?php echo APP_ROOT ?>index.ci.php/system/FASMessages/write/' + MessageSenderPersonID;
openWindowPostArray(action, 'prestudent_id', prestudentIdArray);
}
@@ -128,7 +128,7 @@ function MessagesSendAnswer()
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;
var action = '<?php echo APP_ROOT ?>index.ci.php/system/FASMessages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID;
openWindowPostArray(action, 'prestudent_id', prestudentIdArray);
}
@@ -188,4 +188,4 @@ function MessageIFrameInit()
editor.style.backgroundColor="#FFFFFF";
MessageIFrameIsInitialized=true;
}
}
}
@@ -27,7 +27,7 @@ var InfocenterPersonDataset = {
appendTableActionsHtml: function()
{
var currurl = window.location.href;
var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write");
var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/write";
var formHtml = '<form id="sendMsgsForm" method="post" action="'+ url +'" target="_blank"></form>';
$("#datasetActionsTop").before(formHtml);
+127
View File
@@ -0,0 +1,127 @@
const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages";
function tinymcePreviewSetContent()
{
if ($("#tinymcePreview"))
{
if ($("#recipients").children(":selected").val() > -1)
{
parseMessageText($("#recipients").children(":selected").val(), tinyMCE.get("bodyTextArea").getContent());
}
else
{
tinyMCE.get("tinymcePreview").setContent("");
}
}
}
function parseMessageText(receiver_id, text)
{
$.ajax({
dataType: "json",
url: CONTROLLER_URL + "/parseMessageText",
data: {
"person_id": receiver_id,
"text": text
},
success: function(data, textStatus, jqXHR)
{
tinyMCE.get("tinymcePreview").setContent(data);
},
error: function(jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
$(document).ready(function ()
{
tinymce.init({
selector: "#bodyTextArea",
plugins: "autoresize",
autoresize_min_height: 150,
autoresize_max_height: 600,
autoresize_bottom_margin: 10
});
tinymce.init({
menubar: false,
toolbar: false,
statusbar: false,
readonly: 1,
selector: "#tinymcePreview",
plugins: "autoresize",
autoresize_min_height: 150,
autoresize_bottom_margin: 10
});
if ($("#variables"))
{
$("#variables").dblclick(function ()
{
if ($("#bodyTextArea"))
{
//if editor active add at cursor position, otherwise at end
if (tinymce.activeEditor.id === "bodyTextArea")
tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).children(":selected").val());
else
tinyMCE.get("bodyTextArea").setContent(tinyMCE.get("bodyTextArea").getContent() + $(this).children(":selected").val());
}
});
}
if ($("#recipients"))
{
$("#recipients").change(tinymcePreviewSetContent);
}
if ($("#refresh"))
{
$("#refresh").click(tinymcePreviewSetContent);
}
if ($("#sendButton") && $("#sendForm"))
{
$("#sendButton").click(function ()
{
if ($("#subject") && $("#subject").val() != '' && tinyMCE.get("bodyTextArea").getContent() != '')
{
$("#sendForm").submit();
}
else
{
alert("Subject and text are required fields!");
}
});
}
if ($("#vorlageDnD"))
{
$("#vorlageDnD").change(function ()
{
if (this.value != '')
{
$.ajax({
dataType: "json",
url: CONTROLLER_URL + "/getVorlage",
data: {
"vorlage_kurzbz": this.value
},
success: function(data, textStatus, jqXHR)
{
tinyMCE.get("bodyTextArea").setContent(data.retval[0].text);
$("#subject").val(data.retval[0].subject);
},
error: function(jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown);
}
});
}
});
}
$("#subject").focus();
});