From fe5e5cc3134e2a89434f43f52469b85592babd4a Mon Sep 17 00:00:00 2001
From: alex
Date: Fri, 9 Feb 2018 17:00:16 +0100
Subject: [PATCH] added lines with actions for multiple persons in infocenter
uebersicht (send message, select all, number of rows), message with no sender
sends from logged user, layout tweaks writemessage page
---
application/controllers/system/Messages.php | 54 +++++++++---
.../views/system/infocenter/infocenter.php | 9 +-
.../system/infocenter/infocenterDetails.php | 15 +---
.../views/system/infocenter/stammdaten.php | 18 ++--
application/views/system/messageWrite.php | 35 +++++---
application/views/widgets/filter/filter.php | 16 ++--
include/js/bootstrapper.js | 3 +-
include/js/infocenterPersonDataset.js | 82 +++++++++++++++++++
8 files changed, 174 insertions(+), 58 deletions(-)
create mode 100644 include/js/infocenterPersonDataset.js
diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php
index e0642ca02..2c2474a1e 100644
--- a/application/controllers/system/Messages.php
+++ b/application/controllers/system/Messages.php
@@ -27,8 +27,19 @@ class Messages extends VileSci_Controller
/**
* write
*/
- public function write($sender_id, $msg_id = null, $receiver_id = null)
+ public function write($sender_id = null, $msg_id = null, $receiver_id = null)
{
+ if ($sender_id === null)
+ {
+ $user_person = $this->PersonModel->getByUid($this->uid);
+
+ if (isError($user_person))
+ {
+ show_error($user_person->retval);
+ }
+ $sender_id = $user_person->retval[0]->person_id;
+ }
+
$prestudent_id = $this->input->post('prestudent_id');
$person_id = $this->input->post('person_id');
$personOnly = false;
@@ -68,7 +79,7 @@ class Messages extends VileSci_Controller
$benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id);
if (hasData($benutzerResult))
{
- foreach($benutzerResult->retval as $val)
+ foreach ($benutzerResult->retval as $val)
{
$oe_kurzbz[] = $val->oe_kurzbz;
}
@@ -95,6 +106,12 @@ class Messages extends VileSci_Controller
$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);
@@ -111,7 +128,7 @@ class Messages extends VileSci_Controller
{
$variablesArray = array();
// Skip person_id and prestudent_id
- for($i = 2; $i < count($variables->retval); $i++)
+ for ($i = 2; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
@@ -121,6 +138,12 @@ class Messages extends VileSci_Controller
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);
@@ -137,7 +160,7 @@ class Messages extends VileSci_Controller
{
$variablesArray = array();
// Skip person_id
- for($i = 1; $i < count($variables->retval); $i++)
+ for ($i = 1; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
@@ -148,8 +171,19 @@ class Messages extends VileSci_Controller
/**
* send
*/
- public function send($sender_id)
+ public function send($sender_id = null)
{
+ if ($sender_id === null)
+ {
+ $user_person = $this->PersonModel->getByUid($this->uid);
+
+ if (isError($user_person))
+ {
+ show_error($user_person->retval);
+ }
+ $sender_id = $user_person->retval[0]->person_id;
+ }
+
$error = false;
$subject = $this->input->post('subject');
@@ -165,7 +199,7 @@ class Messages extends VileSci_Controller
// get message data of prestudents or persons
$prestudentsData = array();
- if($prestudents !== null)
+ if ($prestudents !== null)
{
$data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
//
@@ -182,7 +216,7 @@ class Messages extends VileSci_Controller
{
$parsedText = "";
$dataArray = (array)$data->retval[$i];
- foreach($dataArray as $key => $val)
+ foreach ($dataArray as $key => $val)
{
$newKey = str_replace(" ", "_", strtolower($key));
$dataArray[$newKey] = $dataArray[$key];
@@ -191,7 +225,7 @@ class Messages extends VileSci_Controller
$parsedText = $this->messagelib->parseMessageText($body, $dataArray);
$oe_kurzbz = null;
- if(hasData($prestudentsData))
+ if (hasData($prestudentsData))
{
for ($p = 0; $p < count($prestudentsData->retval); $p++)
{
@@ -247,7 +281,7 @@ class Messages extends VileSci_Controller
{
$person_id = $this->input->get('person_id');
}
- else if ($this->input->post('person_id') !== null)
+ elseif ($this->input->post('person_id') !== null)
{
$person_id = $this->input->get('person_id');
}
@@ -310,7 +344,7 @@ class Messages extends VileSci_Controller
if (hasData($data))
{
$dataArray = (array)$data->retval[0];
- foreach($dataArray as $key => $val)
+ foreach ($dataArray as $key => $val)
{
$newKey = str_replace(" ", "_", strtolower($key));
$dataArray[$newKey] = $dataArray[$key];
diff --git a/application/views/system/infocenter/infocenter.php b/application/views/system/infocenter/infocenter.php
index 3b598203b..8244e8c67 100644
--- a/application/views/system/infocenter/infocenter.php
+++ b/application/views/system/infocenter/infocenter.php
@@ -8,7 +8,8 @@
'fontawesome' => true,
'sbadmintemplate' => true,
'tablesorter' => true,
- 'customCSSs' => 'skin/tablesort_bootstrap.css'
+ 'customCSSs' => 'skin/tablesort_bootstrap.css',
+ 'customJSs' => array('include/js/infocenterPersonDataset.js', 'include/js/bootstrapper.js')
)
);
?>
@@ -40,11 +41,7 @@
">