From 2ef386c34e7cd1352f7cb2df211e438bcc627b40 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Jun 2019 17:27:35 +0200 Subject: [PATCH 001/157] - Changed system/dbupdate_3.3.php to add oe_kurzbz to table public.tbl_msg_recipient and foreign key fk_tbl_msg_recipient_oe_kurzbz - Removed not used constants for messaging from config/constants.php - Renamed config entry assistent_function to ou_receivers and converted from string to array - Moved controllers/MailJob.php to controllers/jobs/MailJob.php - Controller MailJob now extends CLI_Controller - Added new function parseText to helpers/hlp_common_helper.php - Improved code function generateToken in helpers/hlp_common_helper.php - helpers/hlp_sancho_helper.php now uses parseText function from hlp_common_helper - Removed method parseVorlagetext from PhrasesLib.php - PhrasesLib.php now uses parseText function from hlp_common_helper - Removed method parseVorlagetext from VorlageLib - Improved code of controller controllers/system/Messages.php (uses parseText too) - Controller controllers/system/Vorlage.php now uses parseText --- application/config/constants.php | 37 +++--- application/config/message.php | 2 +- .../controllers/{ => jobs}/MailJob.php | 11 +- application/controllers/system/Messages.php | 121 +++++++++--------- application/controllers/system/Vorlage.php | 2 +- application/helpers/hlp_common_helper.php | 73 +++++++---- application/helpers/hlp_sancho_helper.php | 4 +- application/libraries/PhrasesLib.php | 12 +- application/libraries/VorlageLib.php | 14 -- system/dbupdate_3.3.php | 27 +++- 10 files changed, 161 insertions(+), 142 deletions(-) rename application/controllers/{ => jobs}/MailJob.php (68%) diff --git a/application/config/constants.php b/application/config/constants.php index ac2ecc649..e1c5906c3 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -136,26 +136,19 @@ define('MSG_STATUS_READ', 1); define('MSG_STATUS_ARCHIVED', 2); define('MSG_STATUS_DELETED', 3); -// Priority -define('PRIORITY_LOW', 1); -define('PRIORITY_NORMAL', 2); -define('PRIORITY_HIGH', 3); -define('PRIORITY_URGENT', 4); +// Message priorities +define('MSG_PRIORITY_LOW', 1); +define('MSG_PRIORITY_NORMAL', 2); +define('MSG_PRIORITY_HIGH', 3); +define('MSG_PRIORITY_URGENT', 4); -define('MSG_ERR_SUBJECT_EMPTY', 40); -define('MSG_ERR_BODY_EMPTY', 41); -define('MSG_ERR_TEMPLATE_NOT_FOUND', 42); -define('MSG_ERR_DELIVERY_MESSAGE', 43); -define('MSG_ERR_CONTACT_NOT_FOUND', 44); -define('MSG_ERR_OU_CONTACTS_NOT_FOUND', 45); - -define('MSG_ERR_INVALID_USER_ID', 100); -define('MSG_ERR_INVALID_MSG_ID', 101); -define('MSG_ERR_INVALID_THREAD_ID', 102); -define('MSG_ERR_INVALID_STATUS_ID', 103); -define('MSG_ERR_INVALID_SENDER_ID', 104); -define('MSG_ERR_INVALID_RECIPIENTS', 105); -define('MSG_ERR_INVALID_RECEIVER_ID', 106); -define('MSG_ERR_INVALID_OU', 107); -define('MSG_ERR_INVALID_TEMPLATE', 108); -define('MSG_ERR_INVALID_TOKEN', 109); +// Message error status +define('MSG_ERR_INVALID_SUBJECT', 40); +define('MSG_ERR_INVALID_BODY', 41); +define('MSG_ERR_INVALID_TEMPLATE', 42); +define('MSG_ERR_INVALID_MSG_ID', 43); +define('MSG_ERR_INVALID_STATUS_ID', 44); +define('MSG_ERR_INVALID_SENDER', 45); +define('MSG_ERR_INVALID_RECIPIENTS', 46); +define('MSG_ERR_INVALID_OU', 47); +define('MSG_ERR_INVALID_TOKEN', 48); diff --git a/application/config/message.php b/application/config/message.php index 40d15a07e..30444b0ef 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -12,7 +12,7 @@ $config['message_html_view_url'] = '/ViewMessage/toHTML/'; // Change this to CIS Server (https://cis.example.com/index.ci.php) if you are sending Messages from Vilesci $config['message_server'] = site_url(); -$config['assistent_function'] = 'ass'; +$config['ou_receivers'] = array('ass'); $config['message_redirect_url'] = array(); $config['message_redirect_url']['fallback'] = site_url('ViewMessage/writeReply'); diff --git a/application/controllers/MailJob.php b/application/controllers/jobs/MailJob.php similarity index 68% rename from application/controllers/MailJob.php rename to application/controllers/jobs/MailJob.php index 2f8b5b92d..cb5ffc032 100644 --- a/application/controllers/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -14,22 +14,25 @@ if (!defined("BASEPATH")) exit("No direct script access allowed"); -class MailJob extends Auth_Controller +class MailJob extends CLI_Controller { /** * API constructor */ public function __construct() { - // An empty array as parameter will ensure that this controller is ONLY callable from command line - parent::__construct(array()); + parent::__construct(); // Loads MessageLib $this->load->library('MessageLib'); } + /** + * Send all not sent messages + * Parameters are used to overrride messages and mail configuration + */ public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) { - $this->messagelib->sendAll($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); + $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index ec630da1e..744eb880e 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends Auth_Controller { /** - * + * MessageLib is loaded by CLMessagesModel */ public function __construct() { @@ -20,9 +20,6 @@ class Messages extends Auth_Controller ) ); - // Loads the message library - $this->load->library('MessageLib'); - // Loads the widget library $this->load->library('WidgetLib'); @@ -38,30 +35,26 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods + // Public methods - HTML output /** - * Write a new message + * Initialize all the parameters used by view system/messages/messageWrite + * to build a GUI used to write a messate to user/s */ public function write() { - $person_id = $this->input->post('person_id'); - $sender_id = null; + $persons = $this->input->post('person_id'); $authUser = $this->CLMessagesModel->getAuthUser(); - if (isError($authUser)) - { - show_error(getData($authUser)); - } - else - { - $sender_id = getData($authUser)[0]->person_id; - } + if (isError($authUser)) show_error(getData($authUser)); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $sender_id = getData($authUser)[0]->person_id; + + // Retrieves person information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); if (isError($msgVarsData)) show_error(getData($msgVarsData)); - // Retrieves message vars for a person from view view vw_msg_vars_person + // Retrieves message vars from view vw_msg_vars_person $variables = $this->messagelib->getMessageVarsPerson(); if (isError($variables)) show_error(getData($variables)); @@ -73,33 +66,43 @@ class Messages extends Auth_Controller $isAdmin = $this->messagelib->getIsAdmin($sender_id); if (isError($isAdmin)) show_error(getData($isAdmin)); - $data = array ( - 'recipients' => getData($msgVarsData), - 'variables' => getData($variables), - 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates - 'isAdmin' => getData($isAdmin) + $this->load->view( + 'system/messages/messageWrite', + array ( + 'recipients' => getData($msgVarsData), // recipients data + 'variables' => getData($variables), // message vars + 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates + 'isAdmin' => getData($isAdmin) // is admin? + ) ); - - $this->load->view('system/messages/messageWrite', $data); } /** - * Send message + * Send a new message or reply to user/s + * If a relationmessage_id this message is a reply to another one */ public function send() { $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); + // Retrieves message vars data for the fiven user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + // Send the message $send = $this->CLMessagesModel->send($msgVarsData, $relationmessage_id); $this->load->view('system/messages/messageSent', array('success' => isSuccess($send))); } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods - JSON output + /** - * Send message, response is in JSON format + * Send a new message + * - The recipients are prestudents + * - An email template with message var may be provided + * - A global organisation unit may be provided, otherwise is used the prestudent one */ public function sendJson() { @@ -120,23 +123,19 @@ class Messages extends Auth_Controller } $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - if (isError($send)) - { - $this->outputJsonError(getData($send)); - } - else - { - $this->outputJsonSuccess(getData($send)); - } + + $this->outputJson(getData($send)); } /** - * getVorlage + * Returns an object that represent a template store in database + * If no templates are found with the given parameter or the given parameter is an empty string, + * then an error is returned */ public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); - $result = null; + $result = error('The given vorlage_kurzbz is not valid'); if (!isEmptyString($vorlage_kurzbz)) { @@ -145,10 +144,6 @@ class Messages extends Auth_Controller $result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); } - else - { - $result = error('The given vorlage_kurzbz is not valid'); - } if (isError($result) || !hasData($result)) { @@ -161,40 +156,37 @@ class Messages extends Auth_Controller } /** - * parseMessageText + * Parse the given given text using data from the given user + * Use the CI parser which performs simple text substitution for pseudo-variable */ public function parseMessageText() { $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - $parsedText = ''; - $data = null; + $msgVarsData = error('The given person_id is not a valid number'); if (is_numeric($person_id)) { - $data = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + } + + if (isError($msgVarsData) || !hasData($msgVarsData)) + { + $this->outputJsonError(getData($msgVarsData)); } else { - $data = error('The given person_id is not a valid number'); - } - - if (isError($data) || !hasData($data)) - { - $this->outputJsonError(getData($data)); - } - else - { - $parsedText = $this->messagelib->parseMessageText($text, $this->CLMessagesModel->replaceKeys((array)getData($data)[0])); - - $this->outputJsonSuccess($parsedText); + $this->outputJsonSuccess( + parseText( + $text, + $this->CLMessagesModel->replaceKeys((array)getData($msgVarsData)[0]) + ) + ); } } /** * Outputs message data for a message (identified my msg id and receiver id) in JSON format - * @param $msg_id - * @param $receiver_id */ public function getMessageFromIds() { @@ -203,8 +195,13 @@ class Messages extends Auth_Controller $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - $this->output - ->set_content_type('application/json') - ->set_output(json_encode(array(getData($msg)[0]))); + if (isError($msg) || !hasData($msg)) + { + $this->outputJson(array()); + } + else + { + $this->outputJson(array(getData($msg)[0])); + } } } diff --git a/application/controllers/system/Vorlage.php b/application/controllers/system/Vorlage.php index 4712d0e68..22513970e 100644 --- a/application/controllers/system/Vorlage.php +++ b/application/controllers/system/Vorlage.php @@ -269,7 +269,7 @@ class Vorlage extends Auth_Controller show_error($vorlagetext->retval); $data = array( - 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm) + 'text' => parseText($vorlagetext->retval[0]->text, $jsonDecodedForm) ); $this->load->view('system/vorlage/templatetextPreview', $data); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index bc09cd32c..45a36914c 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -24,39 +24,54 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); // ------------------------------------------------------------------------ /** - * generateToken() - generates a new token for diffent use - * - reading Messages from external - * - forgotten Password - * - * @return string + * Generates a new token for diffent use cases. Default token length is 64 + * - Reading messages + * - Forgotten password + * - etc + * Returns null on failure */ function generateToken($length = 64) { + $token = null; + $firstGeneratedToken = null; + // For PHP 7 you can use random_bytes() if (function_exists('random_bytes')) { - $token = base64_encode(random_bytes($length)); - //base64 is about 33% longer, so we need to truncate the result - return strtr(substr($token, 0, $length), '+/=', '-_,'); + try + { + $firstGeneratedToken = random_bytes($length); // try to generates cryptographically secure pseudo-random bytes... + } + catch (Exception $e) { $firstGeneratedToken = null; } // if fails $firstGeneratedToken is set to null } - - // for PHP >=5.3 and <7 - if (function_exists('openssl_random_pseudo_bytes')) + // For PHP >= 5.3 and < 7 and openssl is available + elseif (function_exists('openssl_random_pseudo_bytes')) { - $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); - // is the token strong enough? - if($strong == true) - return strtr(substr($token, 0, $length), '+/=', '-_,'); + $firstGeneratedToken = openssl_random_pseudo_bytes($length, $strong); + // If the token generation ended with errors OR the generated token is NOT strong enough + if ($firstGeneratedToken == false || $strong == false) $firstGeneratedToken = null; // $firstGeneratedToken is set to null } - //fallback to mt_rand if php < 5.3 or no openssl available - $characters = '0123456789'; - $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; - $charactersLength = strlen($characters)-1; - $token = ''; - //select some random characters - for ($i = 0; $i < $length; $i++) - $token .= $characters[mt_rand(0, $charactersLength)]; + if ($firstGeneratedToken != null) // If everything was fine + { + // base64 is about 33% longer, so we need to truncate the result + $token = strtr(substr(base64_encode($firstGeneratedToken), 0, $length), '+/=', '-_,'); + } + + // Fallback to mt_rand if: + // php < 5.3 + // OR no openssl is available + // OR openssl_random_pseudo_bytes used an algorithm that is cryptographically NOT strong + // OR one of the previous methods failed + if ($token == null) + { + $token = ''; // set $token as an empty string + $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+'; + $charactersLength = strlen($characters) - 1; + + // Select some random characters + for ($i = 0; $i < $length; $i++) $token .= $characters[mt_rand(0, $charactersLength)]; + } return $token; } @@ -224,3 +239,15 @@ function isDateWorkingDay($date, $days = null) return true; } } + +/** + * Parse the given given text using the given data parameter + * Use the CI parser which performs simple text substitution for pseudo-variable + */ +function parseText($text, $data) +{ + $ci =& get_instance(); // get CI instance + $ci->load->library('parser'); // Loads CI parser library + + return $ci->parser->parse_string($text, $data, true); +} diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index 6f5ef8c24..5d2d9f1f1 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -98,9 +98,7 @@ function _parseMailContent($vorlage_kurzbz, $vorlage_data) !isEmptyString($result->retval[0]->text)) { // Parses template text - $parsedText = $ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $vorlage_data); - - return $parsedText; + return parseText($result->retval[0]->text, $vorlage_data); } } } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index af642fe9e..7d0d6859f 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -165,16 +165,6 @@ class PhrasesLib } /** - * parseVorlagetext() - will parse a Vorlagetext. - */ - public function parseVorlagetext($text, $data = array()) - { - if (isEmptyString($text)) return error('Not a valid text'); - - return $this->_ci->parser->parse_string($text, $data, true); - } - - /** * Retrieves a phrases from the the property _phrases with the given parameters * It also replace parameters inside the phrase if they are provided * @param string $category Category name which is used to categorize the phrase. @@ -201,7 +191,7 @@ class PhrasesLib { if (!is_array($parameters)) $parameters = array(); // if params is not an array - return $this->_ci->parser->parse_string($_phrase->text, $parameters, true); // parsing + return parseText($_phrase->text, $parameters); // parsing } } } diff --git a/application/libraries/VorlageLib.php b/application/libraries/VorlageLib.php index d6c9d6a98..9679dff1c 100644 --- a/application/libraries/VorlageLib.php +++ b/application/libraries/VorlageLib.php @@ -188,18 +188,4 @@ class VorlageLib $vorlagetext = $this->ci->VorlageStudiengangModel->update($vorlagestudiengang_id, $data); return $vorlagetext; } - - /** - * parseVorlagetext() - will parse a Vorlagetext. - * - * @param string $text REQUIRED - * @param array $data REQUIRED - * @return string - */ - public function parseVorlagetext($text, $data = array()) - { - if (isEmptyString($text)) return error('Not a valid text'); - - return $this->ci->parser->parse_string($text, $data, true); - } } diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index ac5f5fdba..b76d994ee 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -2938,6 +2938,31 @@ if(!$result = @$db->db_query("SELECT bezeichnung_mehrsprachig FROM bis.tbl_orgfo } } +// Add column oe_kurzbz to public.tbl_msg_recipient +if(!$result = @$db->db_query("SELECT oe_kurzbz FROM public.tbl_msg_recipient LIMIT 1")) +{ + $qry = 'ALTER TABLE public.tbl_msg_recipient ADD COLUMN oe_kurzbz character varying(32);'; + if(!$db->db_query($qry)) + echo 'public.tbl_msg_recipient: '.$db->db_last_error().'
'; + else + echo '
Added column oe_kurzbz to table public.tbl_msg_recipient'; + + // FOREIGN KEY fk_tbl_msg_recipient_oe_kurzbz: public.tbl_msg_recipient.oe_kurzbz references public.tbl_organisationseinheit.oe_kurzbz + if ($result = @$db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'fk_tbl_msg_recipient_oe_kurzbz'")) + { + if ($db->db_num_rows($result) == 0) + { + $qry = "ALTER TABLE public.tbl_msg_recipient ADD CONSTRAINT fk_tbl_msg_recipient_oe_kurzbz FOREIGN KEY (oe_kurzbz) + REFERENCES public.tbl_organisationseinheit(oe_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT;"; + + if (!$db->db_query($qry)) + echo 'public.tbl_msg_recipient: '.$db->db_last_error().'
'; + else + echo '
public.tbl_msg_recipient: added foreign key on column oe_kurzbz referenced to public.tbl_organisationseinheit(oe_kurzbz)'; + } + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -3121,7 +3146,7 @@ $tabellen=array( "public.tbl_mitarbeiter" => array("mitarbeiter_uid","personalnummer","telefonklappe","kurzbz","lektor","fixangestellt","bismelden","stundensatz","ausbildungcode","ort_kurzbz","standort_id","anmerkung","insertamum","insertvon","updateamum","updatevon","ext_id","kleriker"), "public.tbl_msg_attachment" => array("attachment_id","message_id","name","filename"), "public.tbl_msg_message" => array("message_id","person_id","subject","body","priority","relationmessage_id","oe_kurzbz","insertamum","insertvon"), - "public.tbl_msg_recipient" => array("message_id","person_id","token","sent","sentinfo","insertamum","insertvon"), + "public.tbl_msg_recipient" => array("message_id","person_id","token","sent","sentinfo","insertamum","insertvon","oe_kurzbz"), "public.tbl_msg_status" => array("message_id","person_id","status","statusinfo","insertamum","insertvon","updateamum","updatevon"), "public.tbl_notiz" => array("notiz_id","titel","text","verfasser_uid","bearbeiter_uid","start","ende","erledigt","insertamum","insertvon","updateamum","updatevon","ext_id"), "public.tbl_notizzuordnung" => array("notizzuordnung_id","notiz_id","projekt_kurzbz","projektphase_id","projekttask_id","uid","person_id","prestudent_id","bestellung_id","lehreinheit_id","ext_id","anrechnung_id"), From a5b3f0ed88219ea817c8aa496ac334384a810bc9 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 14:09:56 +0200 Subject: [PATCH 002/157] - Moved constants EMAIL_KONTAKT_TYPE and SENT_INFO_NEWLINE from config/constants.php to MessageLib - Added function parseTemplate to helper helpers/hlp_common_helper.php - Changed method getMessages of model models/system/Recipient_model.php - Changed views/templates/mailHTML.php and views/templates/mailTXT.php --- application/config/constants.php | 5 ----- application/helpers/hlp_common_helper.php | 14 +++++++++++++- application/models/system/Recipient_model.php | 16 +++------------- application/views/templates/mailHTML.php | 6 +++--- application/views/templates/mailTXT.php | 8 ++++++-- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index e1c5906c3..ce917b5a3 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -125,11 +125,6 @@ define('EMAIL_CONFIG_INDEX', 'mail'); | Messaging system constants |-------------------------------------------------------------------------- */ -// Email kontakt type -define('EMAIL_KONTAKT_TYPE', 'email'); -// tbl_msg_recipient->sentInfo separator -define('SENT_INFO_NEWLINE', '\n'); - // Message statuses define('MSG_STATUS_UNREAD', 0); define('MSG_STATUS_READ', 1); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 45a36914c..025834ed2 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -241,7 +241,7 @@ function isDateWorkingDay($date, $days = null) } /** - * Parse the given given text using the given data parameter + * Parse the given text using the given data parameter * Use the CI parser which performs simple text substitution for pseudo-variable */ function parseText($text, $data) @@ -251,3 +251,15 @@ function parseText($text, $data) return $ci->parser->parse_string($text, $data, true); } + +/** + * Parse the given template using the given data parameter + * Use the CI parser which performs simple text substitution for pseudo-variable + */ +function parseTemplate($template, $data) +{ + $ci =& get_instance(); // get CI instance + $ci->load->library('parser'); // Loads CI parser library + + return $ci->parser->parse($template, $data, true); +} diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 654a9a883..74a1c3256 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,7 +205,7 @@ class Recipient_model extends DB_Model * @param limit specifies the number of messages to get * @param message_id specifies a single message */ - public function getMessages($kontaktType, $sent, $limit = null, $message_id = null) + public function getMessages($kontaktType, $limit = 1, $message_id = null) { $query = 'SELECT mm.message_id, ks.kontakt as sender, @@ -239,17 +239,7 @@ class Recipient_model extends DB_Model $parametersArray = array($kontaktType, $kontaktType); - if (is_null($sent) || $sent == '') - { - $query .= ' WHERE mr.sent IS NULL'; - } - else - { - array_push($parametersArray, $sent); - $query .= ' WHERE mr.sent = ?'; - } - - if (!is_null($message_id)) + if (is_numeric($message_id)) { array_push($parametersArray, $message_id); $query .= ' AND mm.message_id = ?'; @@ -257,7 +247,7 @@ class Recipient_model extends DB_Model $query .= ' ORDER BY mr.insertamum ASC'; - if (!is_null($limit)) + if (is_numeric($limit)) { $query .= ' LIMIT ?'; array_push($parametersArray, $limit); diff --git a/application/views/templates/mailHTML.php b/application/views/templates/mailHTML.php index c2e072f68..32d544c5a 100644 --- a/application/views/templates/mailHTML.php +++ b/application/views/templates/mailHTML.php @@ -1,12 +1,12 @@ - This is not the email template, this is a tribute + Notification of personal message reception
-

Neue Nachricht vorhanden

+

A new message is available

diff --git a/application/views/templates/mailTXT.php b/application/views/templates/mailTXT.php index cd55aeb06..09634e6ae 100644 --- a/application/views/templates/mailTXT.php +++ b/application/views/templates/mailTXT.php @@ -1,3 +1,7 @@ -Follow the following link to read the message. +Notification of personal message reception -{href} \ No newline at end of file +A new message is available + +Click here to view the message + +{href} From 8135c6275e991b34b8cc98a41c355ef600a8affc Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 15:57:45 +0200 Subject: [PATCH 003/157] - Fixed query building in method getMessages of model models/system/Recipient_model.php - Better code in controller api/v1/system/Message.php - Adapted controller api/v1/system/Message.php to use sendMessageUser and sendMessageUserTemplate methods from MessageLib - Adapted model models/CL/Messages_model.php to use sendMessageUser and sendMessageUserTemplate methods from MessageLib - Adapted model models/CL/Messages_model.php to use function parseText - Removed constant MSG_INDX_PREFIX from MessageLib - Added constants to MessageLib: CFG_SYSTEM_PERSON_ID, CFG_SEND_IMMEDIATELY, CFG_MESSAGE_SERVER, CFG_MESSAGE_HTML_VIEW_URL, CFG_OU_RECEIVERS, NOTICE_TEMPLATE_HTML, NOTICE_TEMPLATE_TXT, NOTICE_TEMPLATE_FALLBACK_HTML, NOTICE_TEMPLATE_FALLBACK_TXT, EMAIL_KONTAKT_TYPE and SENT_INFO_NEWLINE - MessageLib does not load anymore library parser - Improved MessageLib code - Added private methodis _sendMessage, _getSender, _getNoticeBody, _getNoticeHTMLBody, _getNoticeTXTBody and _ouExists to MessageLib - Added public methods sendMessageUser, sendMessageUserTemplate and sendMessageOU to MessageLib - Renamed method sendAll to sendAllNotices in MessageLib - Renamed method sendOne to _sendNotice and changed it from public to private - Renamed method _checkReceiverId to _getReceiversByPersonId --- .../controllers/api/v1/system/Message.php | 63 +- application/libraries/MessageLib.php | 1145 ++++++++--------- application/models/CL/Messages_model.php | 39 +- application/models/system/Recipient_model.php | 2 +- 4 files changed, 574 insertions(+), 675 deletions(-) diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index be87526ed..5c663e832 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -144,26 +144,26 @@ class Message extends APIv1_Controller */ public function postMessage() { - $validation = $this->_validatePostMessage($this->post()); + $postMessage = $this->_validatePostMessage($this->post()); - if (isSuccess($validation)) + if (isSuccess($postMessage)) { - $result = $this->messagelib->sendMessage( - isset($this->post()['person_id']) ? $this->post()['person_id'] : null, - isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, - $this->post()['subject'], - $this->post()['body'], - PRIORITY_NORMAL, - isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, - isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit - isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true + $result = $this->messagelib->sendMessageUser( + $this->post()['receiver_id']), // receiverPersonId + $this->post()['subject'], // subject + $this->post()['body'], // body + $this->post()['person_id']) ? $this->post()['person_id'] : null, // sender_id + isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU + isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id + MSG_PRIORITY_NORMAL, // priority + isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime ); $this->response($result, REST_Controller::HTTP_OK); } else { - $this->response($validation, REST_Controller::HTTP_OK); + $this->response($postMessage, REST_Controller::HTTP_OK); } } @@ -172,26 +172,27 @@ class Message extends APIv1_Controller */ public function postMessageVorlage() { - $validation = $this->_validatePostMessageVorlage($this->post()); + $postMessage = $this->_validatePostMessageVorlage($this->post()); - if (isSuccess($validation)) + if (isSuccess($postMessage)) { - $result = $this->messagelib->sendMessageVorlage( - isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null, - isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, - $this->post()['vorlage_kurzbz'], - isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit - $this->post()['data'], - isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, - isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null, - isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true + $result = $this->messagelib->sendMessageUserTemplate( + isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null, // receiversPersonId + $this->post()['vorlage_kurzbz'], // vorlage + $this->post()['data'], // parseData + isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null, // orgform + isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null, // sender_id + isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // senderOU + isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null, // relationmessage_id + MSG_PRIORITY_NORMAL, // priority + isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true // multiPartMime ); $this->response($result, REST_Controller::HTTP_OK); } else { - $this->response($validation, REST_Controller::HTTP_OK); + $this->response($postMessage, REST_Controller::HTTP_OK); } } @@ -220,26 +221,26 @@ class Message extends APIv1_Controller /** * _validatePostMessage */ - private function _validatePostMessage($message = null) + private function _validatePostMessage($post = null) { - if (!isset($message)) + if (!isset($post)) { return error('Parameter is null'); } - if (!isset($message['subject'])) + if (!isset($post['subject'])) { return error('subject is not set'); } - if( !isset($message['body'])) + if (!isset($post['body'])) { return error('body is not set'); } - if (!isset($message['receiver_id']) && !isset($message['oe_kurzbz'])) + if (!isset($post['receiver_id'])) { - return error('If a receiver_id is not given a oe_kurzbz must be specified'); + return error('receiver_id is not set'); } - return success('Input data are valid'); + return success(); } /** diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index feba96473..7911d4b2d 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -7,7 +7,21 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class MessageLib { - const MSG_INDX_PREFIX = 'message_'; + // Config entries + const CFG_SYSTEM_PERSON_ID = 'system_person_id'; + const CFG_SEND_IMMEDIATELY = 'send_immediately'; + const CFG_MESSAGE_SERVER = 'message_server'; + const CFG_MESSAGE_HTML_VIEW_URL = 'message_html_view_url'; + const CFG_OU_RECEIVERS = 'ou_receivers'; + + // Templates names + const NOTICE_TEMPLATE_HTML = 'MessageMailHTML'; + const NOTICE_TEMPLATE_TXT = 'MessageMailTXT'; + const NOTICE_TEMPLATE_FALLBACK_HTML = 'templates/mailHTML'; + const NOTICE_TEMPLATE_FALLBACK_TXT = 'templates/mailTXT'; + + const EMAIL_KONTAKT_TYPE = 'email'; // Email kontakt type + const SENT_INFO_NEWLINE = '\n'; // tbl_msg_recipient->sentInfo separator private $_ci; @@ -22,8 +36,6 @@ class MessageLib // Loads message configuration $this->_ci->config->load('message'); - // CI Parser library - $this->_ci->load->library('parser'); // Loads LogLib $this->_ci->load->library('LogLib'); // Loads VorlageLib @@ -31,352 +43,106 @@ class MessageLib // Loads Mail library $this->_ci->load->library('MailLib'); - // Loading models + // Loads message models $this->_ci->load->model('system/Message_model', 'MessageModel'); $this->_ci->load->model('system/MsgStatus_model', 'MsgStatusModel'); $this->_ci->load->model('system/Recipient_model', 'RecipientModel'); $this->_ci->load->model('system/Attachment_model', 'AttachmentModel'); + + // Loads extra models + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); } //------------------------------------------------------------------------------------------------------------------ // Public methods /** - * getMessage() - returns the specified received message for a specified person + * Returns the specified message for a specified person */ public function getMessage($msg_id, $person_id) { - if (!is_numeric($msg_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); + if (!is_numeric($msg_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); return $this->_ci->RecipientModel->getMessage($msg_id, $person_id); } /** - * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * Sends a message to persons ($receiversPersonId) */ - public function getMessagesByUID($uid, $oe_kurzbz = null, $all = false) + public function sendMessageUser( + $receiversPersonId, $subject, $body, // Required parameters + $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (isEmptyString($uid)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); + // Retrieves receiver id and checks that is valid + $receivers = $this->_getReceiversByPersonId($receiversPersonId); + if (isError($receivers)) return $receivers; - return $this->_ci->RecipientModel->getMessagesByUID($uid, $oe_kurzbz, $all); + // Send the message and return the result + return $this->_sendMessage($receivers, null, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); } /** - * getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * Sends a message to persons ($receiversPersonId) */ - public function getMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) + public function sendMessageUserTemplate( + $receiversPersonId, $vorlage, $parseData, // Required parameters + $orgform = null, $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - - return $this->_ci->RecipientModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - } - - /** - * getSentMessagesByPerson() - Get all sent messages from a person identified by person_id - */ - public function getSentMessagesByPerson($person_id, $oe_kurzbz = null, $all = false) - { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - - return $this->_ci->MessageModel->getMessagesByPerson($person_id, $oe_kurzbz, $all); - } - - /** - * getMessageByToken - */ - public function getMessageByToken($token) - { - if (isEmptyString($token)) - return $this->_error('', MSG_ERR_INVALID_TOKEN); - - $result = $this->_ci->RecipientModel->getMessageByToken($token); - if (hasData($result)) + // Loads template data + $templateResult = $this->_ci->vorlagelib->loadVorlagetext($vorlage, $senderOU, $orgform, getUserLanguage()); + if (hasData($templateResult)) // if a template is found { - // Searches for a status that is different from unread - $found = -1; - for ($i = 0; $i < count($result->retval); $i++) - { - if ($result->retval[$i]->status > MSG_STATUS_UNREAD) - { - $found = $i; - break; - } - } + $template = getData($templateResult)[0]; // template object - // If not found then insert the read status - if ($found == -1) - { - $statusKey = array( - 'message_id' => $result->retval[0]->message_id, - 'person_id' => $result->retval[0]->receiver_id, - 'status' => MSG_STATUS_READ - ); + // Parses template subject + $subject = parseText($template->subject, $parseData); + // Parses template text + $body = parseText($template->text, $parseData); - $resultIns = $this->_ci->MsgStatusModel->insert($statusKey); - // If an error occured while writing on data base, then return it - if (isError($resultIns)) - { - $result = $resultIns; - } - } - } - - return $result; - } - - /** - * getCountUnreadMessages - */ - public function getCountUnreadMessages($person_id, $oe_kurzbz = null) - { - if (!is_numeric($person_id)) - return $this->_error('', MSG_ERR_INVALID_RECIPIENTS); - - return $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $oe_kurzbz); - } - - /** - * updateMessageStatus() - will change status on message for particular user - * NOTE: it performs an insert, NOT an update - */ - public function updateMessageStatus($message_id, $person_id, $status) - { - if (!is_numeric($message_id)) - { - return $this->_error('', MSG_ERR_INVALID_MSG_ID); - } - - if (!is_numeric($person_id)) - { - return $this->_error('', MSG_ERR_INVALID_USER_ID); - } - - // NOTE: Not use empty otherwise if status is 0 it returns an error - if (!isset($status)) - { - return $this->_error('', MSG_ERR_INVALID_STATUS_ID); - } - - // Searches if the status is already present - $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); - if (hasData($result)) - { - // status already present - } - else - { - // Insert the new status - $statusKey = array( - 'message_id' => $message_id, - 'person_id' => $person_id, - 'status' => $status + return $this->sendMessageUser( + $receiversPersonId, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime ); - - $result = $this->_ci->MsgStatusModel->insert($statusKey); } - - return $result; + elseif (isError($templateResult)) // if an error occured + { + return $templateResult; // return it + } + else // if a template was not found + { + return error('Template was not found', MSG_ERR_INVALID_TEMPLATE); + } } /** - * sendMessage() - sends new internal message. This function will create a new thread + * Sends a message to all the persons that are enabled to read messages for the given organisation unit ($receiversOU) */ - public function sendMessage($sender_id, $receiver_id, $subject, $body, $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null, $multiPartMime = true) + public function sendMessageOU( + $receiversOU, $subject, $body, // Required parameters + $sender_id = null, $senderOU = null, $relationmessage_id = null, $priority = MSG_PRIORITY_NORMAL, $multiPartMime = true + ) { - if (!is_numeric($sender_id)) - { - $sender_id = $this->_ci->config->item('system_person_id'); - } + // If the recipient is an organisation unit that would be possible to send the same message (same message id) + // to the entire organisation unit (one to many functionality) + // In this case the receiver id is a the one present in message configuration + $receivers = success(array($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID))); - $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); - - // If everything went ok - if (isSuccess($receivers) && is_array($receivers->retval)) - { - // If no receivers were found for this organization unit - if (count($receivers->retval) == 0) - { - $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); - } - - // Looping on receivers - for ($i = 0; $i < count($receivers->retval); $i++) - { - $receiver_id = $receivers->retval[$i]->person_id; - - // Checks if the receiver exists - if ($this->_checkReceiverId($receiver_id)) - { - // If the text and the subject of the template are not empty - if (!isEmptyString($subject) && !isEmptyString($body)) - { - $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz); - // If no errors were occurred - // Leave the code commented - if (isSuccess($result)) - { - // If the system is configured to send messages immediately - if ($this->_ci->config->item('send_immediately') === true) - { - // Send message by email! - $resultSendEmail = $this->sendOne($result->retval, $subject, $body, $multiPartMime); - } - } - } - else - { - if (isEmptyString($subject)) - { - $result = $this->_error('', MSG_ERR_SUBJECT_EMPTY); - break; - } - elseif (isEmptyString($body)) - { - $result = $this->_error('', MSG_ERR_BODY_EMPTY); - break; - } - } - } - else - { - $result = $this->_error('', MSG_ERR_INVALID_RECEIVER_ID); - break; - } - } - } - // If there was some errors then copy them into the returning variable - else - { - $result = $receivers; - } - - return $result; + // Send the message and return the result + return $this->_sendMessage($receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); } - /** - * Sends new internal message using a template - */ - public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null, $multiPartMime = true) - { - if (!is_numeric($sender_id)) - { - $sender_id = $this->_ci->config->item('system_person_id'); - } - - $receivers = $this->_getReceivers($receiver_id, $oe_kurzbz); - - // If everything went ok - if (isSuccess($receivers) && is_array($receivers->retval)) - { - // If no receivers were found for this organization unit - if (count($receivers->retval) == 0) - { - $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); - } - else - { - // Load reveiver data to get its relative language - $this->_ci->load->model('person/Person_model', 'PersonModel'); - } - - // Looping on receivers - for ($i = 0; $i < count($receivers->retval); $i++) - { - $receiver_id = $receivers->retval[$i]->person_id; - - // Checks if the receiver exists - $result = $this->_ci->PersonModel->load($receiver_id); - if (hasData($result)) - { - // Retrieves the language of the logged user - $sprache = getUserLanguage(); - - // Loads template data - $result = $this->_ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache); - if (isSuccess($result)) - { - // If the text and the subject of the template are not empty - if (is_array($result->retval) && count($result->retval) > 0 && - !isEmptyString($result->retval[0]->text) && !isEmptyString($result->retval[0]->subject)) - { - // Parses template text - $parsedText = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data); - // Parses subject - $subject = $this->_ci->vorlagelib->parseVorlagetext($result->retval[0]->subject, $data); - - // Save message - $result = $this->_saveMessage($sender_id, $receiver_id, $subject, $parsedText, $relationmessage_id, $oe_kurzbz); - // If no errors were occurred - if (isSuccess($result)) - { - // If the system is configured to send messages immediately - if ($this->_ci->config->item('send_immediately') === true) - { - // Send message by email! - $resultSendEmail = $this->sendOne($result->retval, $subject, $parsedText, $multiPartMime); - } - } - } - else - { - // Better message error - if (!is_array($result->retval) || (is_array($result->retval) && count($result->retval) == 0)) - { - $result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND); - break; - } - elseif (is_array($result->retval) && count($result->retval) > 0) - { - if (is_null($result->retval[0]->oe_kurzbz)) - { - $result = $this->_error('', MSG_ERR_TEMPLATE_NOT_FOUND); - break; - } - elseif (isEmptyString($result->retval[0]->text)) - { - $result = $this->_error('', MSG_ERR_INVALID_TEMPLATE); - break; - } - elseif (isEmptyString($result->retval[0]->subject)) - { - $result = $this->_error('', MSG_ERR_INVALID_TEMPLATE); - break; - } - } - } - } - else - { - $result = $this->_error($result->retval, EXIT_ERROR); - break; - } - } - else - { - $result = $this->_error('', MSG_ERR_INVALID_RECEIVER_ID); - break; - } - } - } - // If there was some errors then copy them into the returning variable - else - { - $result = $receivers; - } - - return $result; - } + //------------------------------------------------------------------------------------------------------------------ + // Public methods called by a job /** * Gets all the messages from DB and sends them via email */ - public function sendAll($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendAllNotices($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) { $sent = true; // optimistic expectation @@ -393,8 +159,7 @@ class MessageLib // Gets a number ($this->_ci->maillib->getMaxEmailToSent()) of unsent messages from DB // having EMAIL_KONTAKT_TYPE as relative contact type $result = $this->_ci->RecipientModel->getMessages( - EMAIL_KONTAKT_TYPE, - null, + self::EMAIL_KONTAKT_TYPE, $this->_ci->maillib->getConfigs()->email_number_to_sent ); // Checks if errors were occurred @@ -410,21 +175,20 @@ class MessageLib if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) { - $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[$i]->token; + $href = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL).$result->retval[$i]->token; - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_HTML); if(hasData($vorlage)) { // Using a template for the html email body - $body = $this->_ci->parser->parse_string( + $body = parseText( $vorlage->retval[0]->text, array( 'href' => $href, 'subject' => $result->retval[$i]->subject, 'body' => $result->retval[$i]->body - ), - true + ) ); } else @@ -445,18 +209,17 @@ class MessageLib $this->_ci->loglib->logError('Error while parsing the mail template'); } - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); + $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_TXT); if(hasData($vorlage)) { // Using a template for the plain text email body - $altBody = $this->_ci->parser->parse_string( + $altBody = parseText( $vorlage->retval[0]->text, array( 'href' => $href, 'subject' => $result->retval[$i]->subject, 'body' => $result->retval[$i]->body - ), - true + ) ); } else @@ -506,7 +269,7 @@ class MessageLib { $this->_ci->loglib->logError('Error while sending an email'); // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( + $sme = $this->_setSentError( $result->retval[$i]->message_id, $result->retval[$i]->receiver_id, 'Error while sending an email', @@ -520,7 +283,7 @@ class MessageLib else { // Setting the message as sent in DB - $sent = $this->setMessageSent($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); + $sent = $this->_setSentSuccess($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); // If some errors occurred if (!$sent) { @@ -532,7 +295,7 @@ class MessageLib { $this->_ci->loglib->logError('This person does not have an email account'); // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( + $sme = $this->_setSentError( $result->retval[$i]->message_id, $result->retval[$i]->receiver_id, 'This person does not have an email account', @@ -561,244 +324,51 @@ class MessageLib return $sent; } - /** - * Gets one message from DB and sends it via email - */ - public function sendOne($message_id, $subject = null, $body = null, $multiPartMime = true) - { - $sent = true; // optimistic expectation - - // Get a specific message from DB having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->_ci->RecipientModel->getMessages( - EMAIL_KONTAKT_TYPE, - null, - null, - $message_id - ); - - // Checks if errors were occurred - if (isSuccess($result)) - { - // If data are present - if (is_array($result->retval) && count($result->retval) > 0) - { - // If the person has an email account - if ((!is_null($result->retval[0]->receiver) && $result->retval[0]->receiver != '') - || (!is_null($result->retval[0]->employeecontact) && $result->retval[0]->employeecontact != '')) - { - // If it is required use a multi-part message in MIME format - if ($multiPartMime === true) - { - // Using a template for the html email body - $href = $this->_ci->config->item('message_server').$this->_ci->config->item('message_html_view_url').$result->retval[0]->token; - - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailHTML'); - if(hasData($vorlage)) - { - $bodyMsg = $this->_ci->parser->parse_string( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - else - { - $bodyMsg = $this->_ci->parser->parse( - 'templates/mailHTML', - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - if (is_null($bodyMsg) || $bodyMsg == '') - { - // $body = $result->retval[0]->body; - $this->_ci->loglib->logError('Error while parsing the html mail template'); - } - - // Using a template for the plain text email body - $vorlage = $this->_ci->vorlagelib->loadVorlagetext('MessageMailTXT'); - if(hasData($vorlage)) - { - $altBody = $this->_ci->parser->parse_string( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - else - { - $altBody = $this->_ci->parser->parse( - 'templates/mailTXT', - array( - 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body - ), - true - ); - } - if (is_null($altBody) || $altBody == '') - { - $this->_ci->loglib->logError('Error while parsing the plain text mail template'); - } - } - else - { - $bodyMsg = $altBody = $body; - } - - // If the sender is not an employee, then system-sender is used if empty - $sender = ''; - if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') - { - $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; - } - - $receiverContact = $result->retval[0]->receiver; - if (!is_null($result->retval[0]->employeecontact) && $result->retval[0]->employeecontact != '') - { - $receiverContact = $result->retval[0]->employeecontact.'@'.DOMAIN; - } - - // Sending email - $sent = $this->_ci->maillib->send( - null, - $receiverContact, - is_null($subject) ? $result->retval[0]->subject : $subject, // if parameter subject is not null, use it! - $bodyMsg, - null, - null, - null, - $altBody - ); - // If errors were occurred while sending the email - if (!$sent) - { - $this->_ci->loglib->logError('Error while sending an email'); - // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( - $result->retval[0]->message_id, - $result->retval[0]->receiver_id, - 'Error while sending an email', - $result->retval[0]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - else - { - // Setting the message as sent in DB - $sent = $this->setMessageSent($result->retval[0]->message_id, $result->retval[0]->receiver_id); - // If the email has been sent and the DB updated - if (!$sent) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - } - else - { - $this->_ci->loglib->logError('This person does not have an email account'); - // Writing errors in tbl_msg_recipient - $sme = $this->setMessageError( - $result->retval[0]->message_id, - $result->retval[0]->receiver_id, - 'This person does not have an email account', - $result->retval[0]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - $sent = true; // Non blocking error - } - } - else - { - $this->_ci->loglib->logInfo('There are no email to be sent'); - $sent = false; - } - } - else - { - $this->_ci->loglib->logError('Something went wrong while getting data from DB'); - $sent = false; - } - - return $sent; - } + //------------------------------------------------------------------------------------------------------------------ + // Public methods used by to build the GUI to write messages to user/s /** - * 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 + * Retrieves message vars from view vw_msg_vars_person */ public function getMessageVarsPerson() { - $variablesArray = array(); + // Retrieves message vars from view vw_msg_vars_person + $messageVarsPerson = $this->_ci->MessageModel->getMessageVarsPerson(); + if (isSuccess($messageVarsPerson)) // if everything is ok + { + $variablesArray = array(); + $tmpVariablesArray = getData($messageVarsPerson); - $variables = $this->_ci->MessageModel->getMessageVarsPerson(); - if (isError($variables)) - { - return $variables; - } - elseif (hasData($variables)) - { - $tmpVariablesArray = getData($variables); - // Skip person_id + // Starts from 1 to skip the first element which is person_id for ($i = 1; $i < count($tmpVariablesArray); $i++) { $variablesArray['{'.str_replace(' ', '_', strtolower($tmpVariablesArray[$i])).'}'] = $tmpVariablesArray[$i]; } + + return success($variablesArray); } - return success($variablesArray); + return $messageVarsPerson; // otherwise returns the error } /** - * A person may belongs to more organisation units + * Retrieves organisation units for each role that a user plays inside that organisation unit */ public function getOeKurzbz($sender_id) { - $oe_kurzbz = array(); - - $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); - + // Retrieves organisation units for a user from database $benutzer = $this->_ci->BenutzerfunktionModel->getByPersonId($sender_id); - if (isError($benutzer)) - { - return $benutzer; - } - elseif (hasData($benutzer)) + if (isSuccess($benutzer)) // if everything is ok { - foreach (getData($benutzer) as $val) - { - $oe_kurzbz[] = $val->oe_kurzbz; - } + $ouArray = array(); + + // Copies organisation units in $ouArray array + foreach (getData($benutzer) as $val) $ouArray[] = $val->oe_kurzbz; + + return success($ouArray); } - return success($oe_kurzbz); + return $benutzer; // otherwise returns the error } /** @@ -806,55 +376,172 @@ class MessageLib */ public function getIsAdmin($sender_id) { - $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); - return $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); } + //------------------------------------------------------------------------------------------------------------------ + // Public methods used by REST API + + /** + * Return all messages, including the latest status for specified user. It don´t returns Attachments. + * The sender organisation unit may be specified to filter messages + */ + public function getMessagesByUID($uid, $senderOU = null, $all = false) + { + if (isEmptyString($uid)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->RecipientModel->getMessagesByUID($uid, $senderOU, $all); + } + + /** + * Return all messages, including the latest status for specified user. It does not return attachments + * The sender organisation unit may be specified to filter messages + */ + public function getMessagesByPerson($person_id, $senderOU = null, $all = false) + { + if (!is_numeric($person_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->RecipientModel->getMessagesByPerson($person_id, $senderOU, $all); + } + + /** + * Get all sent messages from a person identified by person_id + * The sender organisation unit may be specified to filter messages + */ + public function getSentMessagesByPerson($person_id, $senderOU = null, $all = false) + { + if (!is_numeric($person_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + + return $this->_ci->MessageModel->getMessagesByPerson($person_id, $senderOU, $all); + } + + /** + * Retrieves a message by its token + * If a message is found with the given token then this message is set as read + */ + public function getMessageByToken($token) + { + if (isEmptyString($token)) return error('The given token is not valid', MSG_ERR_INVALID_TOKEN); + + $result = $this->_ci->RecipientModel->getMessageByToken($token); + if (hasData($result)) + { + // Searches for a status that is NOT unread + $found = false; + + foreach (getData($result) as $message) + { + if ($message->status > MSG_STATUS_UNREAD) + { + $found = true; + break; + } + } + + // If NOT found then insert the read status + if (!$found) + { + $statusData = array( + 'message_id' => getData($result)[0]->message_id, + 'person_id' => getData($result)[0]->receiver_id, + 'status' => MSG_STATUS_READ + ); + + $resultIns = $this->_ci->MsgStatusModel->insert($statusData); + // If an error occured while writing on data base, then return it + if (isError($resultIns)) $result = $resultIns; + } + } + + return $result; + } + + /** + * Counts the unread messages for the given user + * The sender organisation unit may be specified to filter messages + */ + public function getCountUnreadMessages($person_id, $senderOU = null) + { + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); + + return $this->_ci->RecipientModel->getCountUnreadMessages($person_id, $senderOU); + } + + /** + * Change the message status of the given message specified by message_id and person_id, using the given status + * NOTE: it performs an insert NOT an update + */ + public function updateMessageStatus($message_id, $person_id, $status) + { + if (!is_numeric($message_id)) return error('The given message id is not valid', MSG_ERR_INVALID_MSG_ID); + if (!is_numeric($person_id)) return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); + if (!is_numeric($status)) return error('The given status is not valid', MSG_ERR_INVALID_STATUS_ID); + + $this->_ci->MsgStatusModel->resetQuery(); // Reset an eventually already buit query + + // Searches if the status is already present + $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + if (!hasData($result)) // if not found + { + // Insert the new status + $statusKey = array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => $status + ); + $result = $this->_ci->MsgStatusModel->insert($statusKey); + } + + return $result; + } + //------------------------------------------------------------------------------------------------------------------ // Private methods /** - * Update the table tbl_msg_recipient + * */ - private function _updateMessageRecipient($message_id, $receiver_id, $parameters) + private function _getSender($sender_id) { - $updated = false; - - // Updates table tbl_msg_recipient - $resultUpdate = $this->_ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); - // Checks if errors were occurred - if (isSuccess($resultUpdate) && is_array($resultUpdate->retval)) + // By default the sender is defined in message configuration + $sender = success($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)); + if ($sender_id != null) // if it was given as parameter { - $updated = true; + if (is_numeric($sender_id)) // if it valid -> it is a number + { + $sender = success($sender_id); // return it as a success object + } + else + { + // Otherwise returns an error + $sender = error('The given sender is not valid', MSG_ERR_INVALID_SENDER); + } } - return $updated; + return $sender; } /** - * Changes the status of the message from unsent to sent + * Checks if the given receiver ids belong to persons in database */ - private function setMessageSent($message_id, $receiver_id) + private function _getReceiversByPersonId($receiver_id) { - $parameters = array('sent' => 'NOW()', 'sentinfo' => null); + // Reset an eventually already buit query + $this->_ci->PersonModel->resetQuery(); - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); - } + // Get only this columns + $this->_ci->PersonModel->addSelect('person_id'); - /** - * Sets the sentInfo with the error - */ - private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null) - { - if (!is_null($prevSentInfo) && $prevSentInfo != '') + // Loads from database the person by its person_id + $personResult = $this->_ci->PersonModel->load($receiver_id); + if (hasData($personResult)) // if data are retrieved { - $sentInfo = $prevSentInfo.SENT_INFO_NEWLINE.$sentInfo; + return $personResult; // return them + } + else // otherwise an error occurred (blocking error or data not found) + { + return error('The given person id is not valid', MSG_ERR_INVALID_RECIPIENTS); } - - $parameters = array('sent' => null, 'sentinfo' => $sentInfo); - - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); } /** @@ -869,92 +556,49 @@ class MessageLib // Get all the valid receivers id using the oe_kurzbz $receivers = $this->_ci->BenutzerfunktionModel->loadWhere( 'oe_kurzbz = '.$this->_ci->db->escape($oe_kurzbz). - ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item('assistent_function')). + ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item(self::CFG_OU_RECEIVERS)). ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' ); - return $receivers; } /** - * Gets the receivers id + * Save a new message in DB */ - private function _getReceivers($receiver_id, $oe_kurzbz = null) + private function _saveMessage($sender_id, $senderOU, $receiver_id, $receiverOU, $subject, $body, $priority, $relationmessage_id) { - $receivers = null; - - // If no receiver_id is given... - if (is_null($receiver_id)) - { - // ...a oe_kurzbz must be specified - if (is_null($oe_kurzbz)) - { - $receivers = $this->_error('', MSG_ERR_INVALID_OU); - } - else - { - $receivers = $this->_getReceiversByOekurzbz($oe_kurzbz); - } - } - // Else if the receiver id is given - else - { - $receivers = $this->_success(array(new stdClass())); - $receivers->retval[0]->person_id = $receiver_id; - } - - return $receivers; - } - - /** - * Checks if the given receiver id is a valid person - */ - private function _checkReceiverId($receiver_id) - { - // Load Person_model - $this->_ci->load->model('person/Person_model', 'PersonModel'); - $result = $this->_ci->PersonModel->load($receiver_id); - if (hasData($result)) - { - return true; - } - - return false; - } - - /** - * Save a message in DB - **/ - private function _saveMessage($sender_id, $receiver_id, $subject, $body, $relationmessage_id, $oe_kurzbz) - { - // Starts db transaction + // Starts database transaction $this->_ci->db->trans_start(false); - // Save Message - $msgData = array( + // Store message information in tbl_msg_message + $messageData = array( 'person_id' => $sender_id, 'subject' => $subject, 'body' => $body, - 'priority' => PRIORITY_NORMAL, + 'priority' => $priority, 'relationmessage_id' => $relationmessage_id, - 'oe_kurzbz' => $oe_kurzbz + 'oe_kurzbz' => $senderOU ); - $result = $this->_ci->MessageModel->insert($msgData); + + $result = $this->_ci->MessageModel->insert($messageData); if (isSuccess($result)) { - // Link the message with the receiver - $msg_id = $result->retval; + $messageId = getData($result); // Gets the message id generated by database + + // Store message information in tbl_msg_recipient $recipientData = array( 'person_id' => $receiver_id, - 'message_id' => $msg_id, - 'token' => generateToken() + 'message_id' => $messageId, + 'token' => generateToken(), + 'oe_kurzbz' => $receiverOU ); + $result = $this->_ci->RecipientModel->insert($recipientData); if (isSuccess($result)) { - // Save message status + // Store message information in tbl_msg_status $statusData = array( - 'message_id' => $msg_id, + 'message_id' => $messageId, 'person_id' => $receiver_id, 'status' => MSG_STATUS_UNREAD ); @@ -962,35 +606,262 @@ class MessageLib } } - $this->_ci->db->trans_complete(); + $this->_ci->db->trans_complete(); // Ends database transaction + // If the transaction failed... if ($this->_ci->db->trans_status() === false || isError($result)) { - $this->_ci->db->trans_rollback(); - $result = $this->_error('An error occurred while saving a message', EXIT_ERROR); + $this->_ci->db->trans_rollback(); // ...then rollback } - else + else // otherwise commit... { $this->_ci->db->trans_commit(); - $result = $this->_success($msg_id); + $result = success($messageId); // ...and returns the message id } return $result; } /** - * Wrapper for function error + * Set the message as sent successfully by setting columns 'sent' and 'sentinfo' of table tbl_msg_recipient + * sent column is set with date of delivery + * sentinfo is set to null */ - private function _error($retval, $code) + private function _setSentSuccess($message_id, $receiver_id) { - return error($retval, $code); + return $this->_ci->RecipientModel->update(array($receiver_id, $message_id), array('sent' => 'NOW()', 'sentinfo' => null)); } /** - * Wrapper for function success + * Set the message as sent with error by setting columns 'sent' and 'sentinfo' of table tbl_msg_recipient + * Stores the type of error in 'sentinfo' column keeping en eventual previous error + * sent column is set to null */ - private function _success($retval, $code = null) + private function _setSentError($message_id, $receiver_id, $sentInfo, $prevSentInfo) { - return success($retval, $code); + if (!isEmptyString($prevSentInfo)) + { + $sentInfo .= self::SENT_INFO_NEWLINE.$prevSentInfo; + } + + return $this->_ci->RecipientModel->update(array($receiver_id, $message_id), array('sent' => null, 'sentinfo' => $sentInfo)); + } + + /** + * Returns the notice body. Tries to use the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeBody($viewMessageLink, $subject, $body, $dbTemplateName, $fsTemplateName) + { + $noticeBody = null; + + $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); + + if (isError($vorlageResult)) return $vorlageResult; + + if (hasData($vorlageResult)) + { + $vorlage = getData($vorlageResult)[0]; + + $noticeBody = parseText( + $vorlage->text, + array( + 'href' => $viewMessageLink, + 'subject' => $subject, + 'body' => $body + ) + ); + } + else + { + $noticeBody = parseTemplate( + $fsTemplateName, + array( + 'href' => $viewMessageLink, + 'subject' => $subject, + 'body' => $body + ) + ); + } + + if (isEmptyString($noticeBody)) return error('An error occurred while generating the notice body'); + + return success($noticeBody); + } + + /** + * Returns the notice HTML body try to using the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeHTMLBody($viewMessageLink, $subject, $body) + { + return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_HTML, self::NOTICE_TEMPLATE_FALLBACK_HTML); + } + + /** + * Returns the notice TXT body try to using the template present in database and then falling back + * on the one present in filesystem. If both fail then an error is returned + */ + private function _getNoticeTXTBody($viewMessageLink, $subject, $body) + { + return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_TXT, self::NOTICE_TEMPLATE_FALLBACK_TXT); + } + + /** + * Sends a notice email that notices to a user about a new received message + */ + private function _sendNotice($message_id) + { + // Get the message and related data (sender, recipient, etc...) + $messageResult = $this->_ci->RecipientModel->getMessages( + self::EMAIL_KONTAKT_TYPE, + 1, + $message_id + ); + + if (isError($messageResult)) return $messageResult; // if an error occured then return it + if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error + + $messageData = getData($messageResult)[0]; // Message data from database + + // Checks if this person has a valid email address where to send the notice email + if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $message_id, + $messageData->receiver_id, + 'This person does not have an email account', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('This person does not have an email account'); + } + + // Create a link to the controller to view the message using a token + $viewMessageLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER). + $this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL). + $messageData->token; + + // Generates notice email body in HTML and plain text version. + // If an error occured during the generation then the error itself is returned + $noticeHTMLBody = $this->_getNoticeHTMLBody($viewMessageLink, $messageData->subject, $messageData->body); + if (isError($noticeHTMLBody)) return $noticeHTMLBody; + $noticeTXTBody = $this->_getNoticeTXTBody($viewMessageLink, $messageData->subject, $messageData->body); + if (isError($noticeTXTBody)) return $noticeTXTBody; + + // If an employeecontact contact is present then use it, otherwise use the personal contacts + $receiverContact = $messageData->receiver; + if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; + + // Sending email + $sent = $this->_ci->maillib->send( + null, + $receiverContact, + $messageData->subject, + getData($noticeHTMLBody), + null, + null, + null, + getData($noticeTXTBody) + ); + + // If errors occurred while sending the email + if (!$sent) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $message_id, + $messageData->receiver_id, + 'An error occurred while sending the email', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('An error occurred while sending the email'); + } + else // success! + { + // Set in database that the notice email was succesfully sent + $sss = $this->_setSentSuccess($message_id, $messageData->receiver_id); + if (isError($sss)) return $sss; // If database error occurred then return it + } + + return success('Notice email sent successfully'); + } + + /** + * Sends new message core method, may be wrapped by other methods. + */ + private function _sendMessage( + $receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime + ) + { + // Checks if sender is fine + $sender = $this->_getSender($sender_id); + if (!hasData($sender)) return $sender; + // Checks if the sender and receiver organisation unit are valid + if (($receiversOU != null && !$this->_ouExists($receiversOU)) || ($senderOU != null && !$this->_ouExists($senderOU))) + { + return error('The given organisation unit is not valid', MSG_ERR_INVALID_OU); + } + // Checks subjects + if (isEmptyString($subject)) return error('The given subject is an empty string', MSG_ERR_INVALID_SUBJECT); + // Checks body + if (isEmptyString($body)) return error('The given body is an empty string', MSG_ERR_INVALID_BODY); + + $savedMessages = array(); // This array contains all the message ids of the saved messages + + // Looping on receivers + foreach (getData($receivers) as $receiver) + { + // Save message in database + $saveMessageResult = $this->_saveMessage( + getData($sender), $senderOU, $receiver->person_id, $receiversOU, $subject, $body, $priority, $relationmessage_id + ); + if (isSuccess($saveMessageResult)) // If successfully saved + { + // If the system is configured to send messages immediately + if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) + { + $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message + } + } + else + { + return $saveMessageResult; // If an error occured while saving + } + } + + // If the system is configured to send messages immediately + if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) + { + // Looping through saved messages ids + foreach ($savedMessages as $message_id) + { + // Send message notice via email! + $sendNotice = $this->_sendNotice($message_id); + // If an error occurred then return it + if (isError($sendNotice)) return $sendNotice; + } + } + + return success('Message sent successfully'); + } + + /** + * Checks if the given organisation unit exists in database + */ + private function _ouExists($ou) + { + // Reset an eventually already buit query + $this->_ci->OrganisationseinheitModel->resetQuery(); + // Get only this columns + $this->_ci->OrganisationseinheitModel->addSelect('oe_kurzbz'); + // Retrieves the given organisation unit from database + $ouResults = $this->_ci->OrganisationseinheitModel->loadWhere(array('oe_kurzbz' => $ou)); + + return hasData($ouResults); } } diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 5f3f40e6d..c17d608c7 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -38,19 +38,29 @@ class Messages_model extends CI_Model $sender_id = getData($authUser)[0]->person_id; + // Send message(s) if (hasData($msgVarsData)) { for ($i = 0; $i < count(getData($msgVarsData)); $i++) { - $parsedText = ""; + $parsedText = ''; $msgVarsDataArray = $this->replaceKeys((array)getData($msgVarsData)[$i]); // replaces array keys // Send without vorlage if (isEmptyString($vorlage_kurzbz)) { - $parsedText = $this->messagelib->parseMessageText($body, $msgVarsDataArray); - $msg = $this->messagelib->sendMessage($sender_id, $msgVarsDataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz); + $parsedText = parseText($body, $msgVarsDataArray); + + $msg = $this->messagelib->sendMessageUser( + $msgVarsDataArray['person_id'], // receiverPersonId + $subject, // subject + $parsedText, // body + $sender_id, // sender_id + $oe_kurzbz, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); } // Send with vorlage else @@ -63,7 +73,15 @@ class Messages_model extends CI_Model $msgVarsDataArray[$key] = $msgvar; } } - $msg = $this->messagelib->sendMessageVorlage($sender_id, $msgVarsDataArray['person_id'], $vorlage_kurzbz, $oe_kurzbz, $msgVarsDataArray); + + $msg = $this->messagelib->sendMessageUserTemplate( + $msgVarsDataArray['person_id'], // receiversPersonId + $vorlage_kurzbz, // vorlage + $msgVarsDataArray, // parseData + null, // orgform + $sender_id, // sender_id + $oe_kurzbz // senderOU + ); } if (isError($msg)) return $msg; @@ -95,7 +113,7 @@ class Messages_model extends CI_Model } /** - * Send a reply + * Send a reply to a message accessed using a token */ public function sendReply($subject, $body, $persons, $relationmessage_id, $token) { @@ -116,7 +134,16 @@ class Messages_model extends CI_Model { $dataArray = (array)getData($data)[$i]; - $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $body, PRIORITY_NORMAL, $relationmessage_id, null); + $msg = $this->messagelib->sendMessageUser( + $dataArray['person_id'], // receiverPersonId + $subject, // subject + $body, // body + $sender_id, // sender_id + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); + if (isError($msg)) return $msg; // Logs person data diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 74a1c3256..49fc21fc4 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -242,7 +242,7 @@ class Recipient_model extends DB_Model if (is_numeric($message_id)) { array_push($parametersArray, $message_id); - $query .= ' AND mm.message_id = ?'; + $query .= ' WHERE mm.message_id = ?'; } $query .= ' ORDER BY mr.insertamum ASC'; From 0ef94aacdad9545edc20a160d36d70753e8852f4 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 18:23:24 +0200 Subject: [PATCH 004/157] - Fixed query method getMessages in model models/system/Recipient_model.php - Changed interface method sendMessages of job jobs/MailJob.php - Added function terminateWithError to helper helpers/hlp_common_helper.php - Changed method overrideConfigs of library MailLib - Removed method getConfigs from library MailLib - Added public method getEmailNumberToSent to library MailLib - Changed method sendAllNotices of library MessageLib - Renamed private method _sendNotice to _sendOneNotice in library MessageLib - Added new private methods _loadDbNoticeEmailTemplate, _loadFsNoticeEmailTemplate and _sendNotice to library MessageLib - Changed method _getNoticeBody in library MessageLib - Removed methods _getNoticeHTMLBody and _getNoticeTXTBody from in library MessageLib --- application/controllers/jobs/MailJob.php | 4 +- application/helpers/hlp_common_helper.php | 22 + application/libraries/MailLib.php | 47 +- application/libraries/MessageLib.php | 444 ++++++------------ application/models/system/Recipient_model.php | 11 +- 5 files changed, 202 insertions(+), 326 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index cb5ffc032..721db0068 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -31,8 +31,8 @@ class MailJob extends CLI_Controller * Send all not sent messages * Parameters are used to overrride messages and mail configuration */ - public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendMessages($numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) { - $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $email_time_range, $email_from_system); + $this->messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); } } diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 025834ed2..dbd8eb905 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -263,3 +263,25 @@ function parseTemplate($template, $data) return $ci->parser->parse($template, $data, true); } + +/** + * Terminate immediately the execution of the current script. + * If message parameter is given then: + * - logs the given message in CI logs + * - prints the given message to standard output + * Otherwise terminate with the generic error + */ +function terminateWithError($message = null) +{ + if (!isEmptyString($message)) + { + $ci =& get_instance(); // get CI instance + $ci->load->library('LogLib'); // Loads LogLib + + $ci->loglib->logError($message); + + exit($message); + } + + exit(EXIT_ERROR); +} diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php index 6d0a48f73..e9e571f6c 100644 --- a/application/libraries/MailLib.php +++ b/application/libraries/MailLib.php @@ -110,43 +110,34 @@ class MailLib } /** - * To ovveride the configurations + * Overrides configuration parameters + * If the given parameters are not null or empty strings then they are used to override + * the following properties of this object: + * - email_number_to_sent + * - email_number_per_time_range + * - email_time_range + * - email_from_system */ - public function overrideConfigs($cfg) + public function overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { - if (!is_null($cfg)) + if (is_numeric($numberToSent)) $this->email_number_to_sent = $numberToSent; + + if (is_numeric($numberPerTimeRange)) $this->email_number_per_time_range = $numberPerTimeRange; + + if (is_numeric($emailTimeRange)) $this->email_time_range = $emailTimeRange; + + if (!isEmptyString($emailFromSystem) && filter_var($emailFromSystem, FILTER_VALIDATE_EMAIL)) { - if (isset($cfg->email_number_to_sent) && is_numeric($cfg->email_number_to_sent)) - { - $this->email_number_to_sent = $cfg->email_number_to_sent; - } - if (isset($cfg->email_number_per_time_range) && is_numeric($cfg->email_number_per_time_range)) - { - $this->email_number_per_time_range = $cfg->email_number_per_time_range; - } - if (isset($cfg->email_time_range) && is_numeric($cfg->email_time_range)) - { - $this->email_time_range = $cfg->email_time_range; - } - if (isset($cfg->email_from_system) && filter_var($cfg->email_from_system, FILTER_VALIDATE_EMAIL)) - { - $this->email_from_system = $cfg->email_from_system; - } + $this->email_from_system = $emailFromSystem; } } /** - * Returns the current configuration + * Returns value of property email_number_to_sent */ - public function getConfigs() + public function getEmailNumberToSent() { - $cfg = new stdClass(); - $cfg->email_number_to_sent = $this->email_number_to_sent; - $cfg->email_number_per_time_range = $this->email_number_per_time_range; - $cfg->email_time_range = $this->email_time_range; - $cfg->email_from_system = $this->email_from_system; - - return $cfg; + return $this->email_number_to_sent; } /** diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 7911d4b2d..c3c1169d4 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -36,8 +36,6 @@ class MessageLib // Loads message configuration $this->_ci->config->load('message'); - // Loads LogLib - $this->_ci->load->library('LogLib'); // Loads VorlageLib $this->_ci->load->library('VorlageLib'); // Loads Mail library @@ -140,188 +138,27 @@ class MessageLib // Public methods called by a job /** - * Gets all the messages from DB and sends them via email + * Gets all NOT sent messages from DB and sends for each of them the notice email + * Does not return anything, it logs info and errors on CI logs and in tbl_msg_recipient table + * Wrapper for _sendNotice. */ - public function sendAllNotices($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null) + public function sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { - $sent = true; // optimistic expectation + // Overrides MailLib configs with the given parameters + $this->_ci->maillib->overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); - // Gets standard configs - $cfg = $this->_ci->maillib->getConfigs(); - $cfg->email_number_to_sent = $numberToSent; - $cfg->email_number_per_time_range = $numberPerTimeRange; - $cfg->email_time_range = $email_time_range; - $cfg->email_from_system = $email_from_system; - - // Overrides configs with the parameters - $this->_ci->maillib->overrideConfigs($cfg); - - // Gets a number ($this->_ci->maillib->getMaxEmailToSent()) of unsent messages from DB - // having EMAIL_KONTAKT_TYPE as relative contact type - $result = $this->_ci->RecipientModel->getMessages( + // Retrieves a certain amount of NOT sent messages, the amount is given by maillib->email_number_to_sent + $messagesResult = $this->_ci->RecipientModel->getMessages( self::EMAIL_KONTAKT_TYPE, - $this->_ci->maillib->getConfigs()->email_number_to_sent + null, + $this->_ci->maillib->getEmailNumberToSent() ); - // Checks if errors were occurred - if (isSuccess($result)) - { - // If data are present - if (is_array($result->retval) && count($result->retval) > 0) - { - // Iterating through the result set, if no errors occurred in the previous iteration - for ($i = 0; $i < count($result->retval) && $sent; $i++) - { - // If the person has an email account - if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') - || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) - { - $href = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL).$result->retval[$i]->token; - $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_HTML); + if (isError($messagesResult)) terminateWithError(getData($messagesResult)); // If an error occurred then log it and terminate - if(hasData($vorlage)) - { - // Using a template for the html email body - $body = parseText( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ) - ); - } - else - { - // Using a template for the html email body - $body = $this->_ci->parser->parse( - 'templates/mailHTML', - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ), - true - ); - } - if (is_null($body) || $body == '') - { - $this->_ci->loglib->logError('Error while parsing the mail template'); - } + $sendNotice = $this->_sendNotice(getData($messagesResult)); - $vorlage = $this->_ci->vorlagelib->loadVorlagetext(self::NOTICE_TEMPLATE_TXT); - if(hasData($vorlage)) - { - // Using a template for the plain text email body - $altBody = parseText( - $vorlage->retval[0]->text, - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ) - ); - } - else - { - // Using a template for the plain text email body - $altBody = $this->_ci->parser->parse( - 'templates/mailTXT', - array( - 'href' => $href, - 'subject' => $result->retval[$i]->subject, - 'body' => $result->retval[$i]->body - ), - true - ); - } - if (is_null($altBody) || $altBody == '') - { - $this->_ci->loglib->logError('Error while parsing the mail template'); - } - - // If the sender is not an employee, then system-sender is used if empty - $sender = ''; - if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') - { - $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; - } - - $receiverContact = $result->retval[$i]->receiver; - if (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '') - { - $receiverContact = $result->retval[$i]->employeecontact.'@'.DOMAIN; - } - - // Sending email - $sent = $this->_ci->maillib->send( - $sender, - $receiverContact, - $result->retval[$i]->subject, - $body, - null, - null, - null, - $altBody - ); - // If errors were occurred while sending the email - if (!$sent) - { - $this->_ci->loglib->logError('Error while sending an email'); - // Writing errors in tbl_msg_recipient - $sme = $this->_setSentError( - $result->retval[$i]->message_id, - $result->retval[$i]->receiver_id, - 'Error while sending an email', - $result->retval[$i]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - else - { - // Setting the message as sent in DB - $sent = $this->_setSentSuccess($result->retval[$i]->message_id, $result->retval[$i]->receiver_id); - // If some errors occurred - if (!$sent) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - } - } - else - { - $this->_ci->loglib->logError('This person does not have an email account'); - // Writing errors in tbl_msg_recipient - $sme = $this->_setSentError( - $result->retval[$i]->message_id, - $result->retval[$i]->receiver_id, - 'This person does not have an email account', - $result->retval[$i]->sentinfo - ); - if (!$sme) - { - $this->_ci->loglib->logError('Error while updating DB'); - } - $sent = true; // Non blocking error - } - } - } - else - { - $this->_ci->loglib->logInfo('There are no email to be sent'); - $sent = false; - } - } - else - { - $this->_ci->loglib->logError('Something went wrong while getting data from DB'); - $sent = false; - } - - return $sent; + if (isError($sendNotice)) terminateWithError(getData($sendNotice)); // If an error occurred then log it and terminate } //------------------------------------------------------------------------------------------------------------------ @@ -423,13 +260,13 @@ class MessageLib { if (isEmptyString($token)) return error('The given token is not valid', MSG_ERR_INVALID_TOKEN); - $result = $this->_ci->RecipientModel->getMessageByToken($token); - if (hasData($result)) + $messageTokenResult = $this->_ci->RecipientModel->getMessageByToken($token); + if (hasData($messageTokenResult)) { // Searches for a status that is NOT unread $found = false; - foreach (getData($result) as $message) + foreach (getData($messageTokenResult) as $message) { if ($message->status > MSG_STATUS_UNREAD) { @@ -442,18 +279,18 @@ class MessageLib if (!$found) { $statusData = array( - 'message_id' => getData($result)[0]->message_id, - 'person_id' => getData($result)[0]->receiver_id, + 'message_id' => getData($messageTokenResult)[0]->message_id, + 'person_id' => getData($messageTokenResult)[0]->receiver_id, 'status' => MSG_STATUS_READ ); - $resultIns = $this->_ci->MsgStatusModel->insert($statusData); + $messageTokenResultIns = $this->_ci->MsgStatusModel->insert($statusData); // If an error occured while writing on data base, then return it - if (isError($resultIns)) $result = $resultIns; + if (isError($messageTokenResultIns)) $messageTokenResult = $messageTokenResultIns; } } - return $result; + return $messageTokenResult; } /** @@ -480,8 +317,8 @@ class MessageLib $this->_ci->MsgStatusModel->resetQuery(); // Reset an eventually already buit query // Searches if the status is already present - $result = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); - if (!hasData($result)) // if not found + $updMessageStatusResult = $this->_ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + if (!hasData($updMessageStatusResult)) // if not found { // Insert the new status $statusKey = array( @@ -489,10 +326,10 @@ class MessageLib 'person_id' => $person_id, 'status' => $status ); - $result = $this->_ci->MsgStatusModel->insert($statusKey); + $updMessageStatusResult = $this->_ci->MsgStatusModel->insert($statusKey); } - return $result; + return $updMessageStatusResult; } //------------------------------------------------------------------------------------------------------------------ @@ -580,10 +417,10 @@ class MessageLib 'oe_kurzbz' => $senderOU ); - $result = $this->_ci->MessageModel->insert($messageData); - if (isSuccess($result)) + $saveMessageResult = $this->_ci->MessageModel->insert($messageData); + if (isSuccess($saveMessageResult)) { - $messageId = getData($result); // Gets the message id generated by database + $messageId = getData($saveMessageResult); // Gets the message id generated by database // Store message information in tbl_msg_recipient $recipientData = array( @@ -593,8 +430,8 @@ class MessageLib 'oe_kurzbz' => $receiverOU ); - $result = $this->_ci->RecipientModel->insert($recipientData); - if (isSuccess($result)) + $saveMessageResult = $this->_ci->RecipientModel->insert($recipientData); + if (isSuccess($saveMessageResult)) { // Store message information in tbl_msg_status $statusData = array( @@ -602,24 +439,24 @@ class MessageLib 'person_id' => $receiver_id, 'status' => MSG_STATUS_UNREAD ); - $result = $this->_ci->MsgStatusModel->insert($statusData); + $saveMessageResult = $this->_ci->MsgStatusModel->insert($statusData); } } $this->_ci->db->trans_complete(); // Ends database transaction // If the transaction failed... - if ($this->_ci->db->trans_status() === false || isError($result)) + if ($this->_ci->db->trans_status() === false || isError($saveMessageResult)) { $this->_ci->db->trans_rollback(); // ...then rollback } else // otherwise commit... { $this->_ci->db->trans_commit(); - $result = success($messageId); // ...and returns the message id + $saveMessageResult = success($messageId); // ...and returns the message id } - return $result; + return $saveMessageResult; } /** @@ -651,20 +488,14 @@ class MessageLib * Returns the notice body. Tries to use the template present in database and then falling back * on the one present in filesystem. If both fail then an error is returned */ - private function _getNoticeBody($viewMessageLink, $subject, $body, $dbTemplateName, $fsTemplateName) + private function _getNoticeBody($dbEmailNoticeTemplate, $fsEmailNoticeTemplate, $viewMessageLink, $subject, $body) { - $noticeBody = null; + $noticeBody = null; // pessimistic expectation - $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); - - if (isError($vorlageResult)) return $vorlageResult; - - if (hasData($vorlageResult)) + if (!isEmptyString($dbEmailNoticeTemplate)) { - $vorlage = getData($vorlageResult)[0]; - $noticeBody = parseText( - $vorlage->text, + $dbEmailNoticeTemplate, array( 'href' => $viewMessageLink, 'subject' => $subject, @@ -674,8 +505,8 @@ class MessageLib } else { - $noticeBody = parseTemplate( - $fsTemplateName, + $noticeBody = parseText( + $fsEmailNoticeTemplate, array( 'href' => $viewMessageLink, 'subject' => $subject, @@ -689,106 +520,111 @@ class MessageLib return success($noticeBody); } - /** - * Returns the notice HTML body try to using the template present in database and then falling back - * on the one present in filesystem. If both fail then an error is returned - */ - private function _getNoticeHTMLBody($viewMessageLink, $subject, $body) - { - return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_HTML, self::NOTICE_TEMPLATE_FALLBACK_HTML); - } - - /** - * Returns the notice TXT body try to using the template present in database and then falling back - * on the one present in filesystem. If both fail then an error is returned - */ - private function _getNoticeTXTBody($viewMessageLink, $subject, $body) - { - return $this->_getNoticeBody($viewMessageLink, $subject, $body, self::NOTICE_TEMPLATE_TXT, self::NOTICE_TEMPLATE_FALLBACK_TXT); - } - /** * Sends a notice email that notices to a user about a new received message + * It gets just one message. Wrapper for _sendNotice. */ - private function _sendNotice($message_id) + private function _sendOneNotice($message_id) { // Get the message and related data (sender, recipient, etc...) $messageResult = $this->_ci->RecipientModel->getMessages( self::EMAIL_KONTAKT_TYPE, - 1, $message_id ); if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error - $messageData = getData($messageResult)[0]; // Message data from database + return $this->_sendNotice(getData($messageResult)); + } - // Checks if this person has a valid email address where to send the notice email - if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + /** + * Core method to send one or more email notices for one or more messages + */ + private function _sendNotice($messagesResult) + { + // Prefix for all links that will be subsequently generated + $prefixLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER).$this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL); + + // Loads all the needed templates for HTML and plain text. Main templates from database, fallback templates from file system + $dbEmailNoticeTemplateHTML = $this->_loadDbNoticeEmailTemplate(self::NOTICE_TEMPLATE_HTML); + $dbEmailNoticeTemplateTXT = $this->_loadDbNoticeEmailTemplate(self::NOTICE_TEMPLATE_TXT); + $fsEmailNoticeTemplateHTML = $this->_loadFsNoticeEmailTemplate(self::NOTICE_TEMPLATE_FALLBACK_HTML); + $fsEmailNoticeTemplateTXT = $this->_loadFsNoticeEmailTemplate(self::NOTICE_TEMPLATE_FALLBACK_TXT); + + // Loops through all the messages to be sent + foreach ($messagesResult as $messageData) { - // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( - $message_id, - $messageData->receiver_id, - 'This person does not have an email account', - $messageData->sentinfo + // Checks if this person has a valid email address where to send the notice email + if (isEmptyString($messageData->receiver) && isEmptyString($messageData->employeecontact)) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $messageData->message_id, + $messageData->receiver_id, + 'This person does not have an email account', + $messageData->sentinfo + ); + + // If database error occurred then return it + if (isError($sse)) return $sse; + + continue; // Skip the rest, continue with the next one + } + + // Create a link to the controller to view the message using a token + $viewMessageLink = $prefixLink.$messageData->token; + + // Generates notice email body in HTML and plain text version. + // If an error occured during the generation then the error itself is returned + $noticeHTMLBody = $this->_getNoticeBody( + $dbEmailNoticeTemplateHTML, $fsEmailNoticeTemplateHTML, $viewMessageLink, $messageData->subject, $messageData->body + ); + if (isError($noticeHTMLBody)) return $noticeHTMLBody; + $noticeTXTBody = $this->_getNoticeBody( + $dbEmailNoticeTemplateTXT, $fsEmailNoticeTemplateTXT, $viewMessageLink, $messageData->subject, $messageData->body + ); + if (isError($noticeTXTBody)) return $noticeTXTBody; + + // If an employeecontact contact is present then use it, otherwise use the personal contacts + $receiverContact = $messageData->receiver; + if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; + + // Sending email + $sent = $this->_ci->maillib->send( + null, + $receiverContact, + $messageData->subject, + getData($noticeHTMLBody), + null, + null, + null, + getData($noticeTXTBody) ); - // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('This person does not have an email account'); + // If errors occurred while sending the email + if (!$sent) + { + // Set in database why this email is NOT going to be send + $sse = $this->_setSentError( + $messageData->message_id, + $messageData->receiver_id, + 'An error occurred while sending the email', + $messageData->sentinfo + ); + + // If database error occurred then return it, otherwise return a logic error + return isError($sse) ? $sse : error('An error occurred while sending the email'); + } + else // success! + { + // Set in database that the notice email was succesfully sent + $sss = $this->_setSentSuccess($messageData->message_id, $messageData->receiver_id); + if (isError($sss)) return $sss; // If database error occurred then return it + } } - // Create a link to the controller to view the message using a token - $viewMessageLink = $this->_ci->config->item(self::CFG_MESSAGE_SERVER). - $this->_ci->config->item(self::CFG_MESSAGE_HTML_VIEW_URL). - $messageData->token; - - // Generates notice email body in HTML and plain text version. - // If an error occured during the generation then the error itself is returned - $noticeHTMLBody = $this->_getNoticeHTMLBody($viewMessageLink, $messageData->subject, $messageData->body); - if (isError($noticeHTMLBody)) return $noticeHTMLBody; - $noticeTXTBody = $this->_getNoticeTXTBody($viewMessageLink, $messageData->subject, $messageData->body); - if (isError($noticeTXTBody)) return $noticeTXTBody; - - // If an employeecontact contact is present then use it, otherwise use the personal contacts - $receiverContact = $messageData->receiver; - if (!isEmptyString($messageData->employeecontact)) $receiverContact = $messageData->employeecontact.'@'.DOMAIN; - - // Sending email - $sent = $this->_ci->maillib->send( - null, - $receiverContact, - $messageData->subject, - getData($noticeHTMLBody), - null, - null, - null, - getData($noticeTXTBody) - ); - - // If errors occurred while sending the email - if (!$sent) - { - // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( - $message_id, - $messageData->receiver_id, - 'An error occurred while sending the email', - $messageData->sentinfo - ); - - // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('An error occurred while sending the email'); - } - else // success! - { - // Set in database that the notice email was succesfully sent - $sss = $this->_setSentSuccess($message_id, $messageData->receiver_id); - if (isError($sss)) return $sss; // If database error occurred then return it - } - - return success('Notice email sent successfully'); + return success('Notice emails sent successfully'); } /** @@ -841,7 +677,7 @@ class MessageLib foreach ($savedMessages as $message_id) { // Send message notice via email! - $sendNotice = $this->_sendNotice($message_id); + $sendNotice = $this->_sendOneNotice($message_id); // If an error occurred then return it if (isError($sendNotice)) return $sendNotice; } @@ -864,4 +700,30 @@ class MessageLib return hasData($ouResults); } + + /** + * Loads a the specified template from database + * Returns null if not found or on failure + */ + private function _loadDbNoticeEmailTemplate($dbTemplateName) + { + $emailNoticeTemplate = null; + + $vorlageResult = $this->_ci->vorlagelib->loadVorlagetext($dbTemplateName); + + if (hasData($vorlageResult)) + { + $emailNoticeTemplate = getData($vorlageResult)[0]->text; + } + + return $emailNoticeTemplate; + } + + /** + * Loads a the specified template from database + */ + private function _loadFsNoticeEmailTemplate($fsTemplateName) + { + return $this->_ci->load->view($fsTemplateName, null, true); + } } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 49fc21fc4..3a30bba1f 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,7 +205,7 @@ class Recipient_model extends DB_Model * @param limit specifies the number of messages to get * @param message_id specifies a single message */ - public function getMessages($kontaktType, $limit = 1, $message_id = null) + public function getMessages($kontaktType, $message_id = null, $limit = 1) { $query = 'SELECT mm.message_id, ks.kontakt as sender, @@ -219,10 +219,10 @@ class Recipient_model extends DB_Model mr.sentinfo FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE kontakttyp = ? + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? ) ks ON (ks.person_id = mm.person_id) LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE kontakttyp = ? + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? ) kr ON (kr.person_id = mr.person_id) LEFT JOIN ( SELECT b.person_id, @@ -235,14 +235,15 @@ class Recipient_model extends DB_Model m.mitarbeiter_uid FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE b.aktiv = TRUE - ) ms ON (ms.person_id = mm.person_id)'; + ) ms ON (ms.person_id = mm.person_id) + WHERE mr.sent IS NULL'; $parametersArray = array($kontaktType, $kontaktType); if (is_numeric($message_id)) { array_push($parametersArray, $message_id); - $query .= ' WHERE mm.message_id = ?'; + $query .= ' AND mm.message_id = ?'; } $query .= ' ORDER BY mr.insertamum ASC'; From 5bda5eb966a21ac612e9b6716c297bde5532d629 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 14 Jun 2019 15:40:15 +0200 Subject: [PATCH 005/157] - Moved view system/messages/messageList.php -> system/infocenter/messageList.php - Moved js public/js/messaging/messageList.js -> public/js/infocenter/messageList.js - Updated includes in controller system/infocenter/InfoCenter.php and view system/infocenter/infocenterDetails.php --- application/controllers/system/Messages.php | 63 ++++++++++--------- .../system/infocenter/InfoCenter.php | 2 +- .../system/infocenter/infocenterDetails.php | 4 +- .../{messages => infocenter}/messageList.php | 0 .../{messaging => infocenter}/messageList.js | 0 5 files changed, 36 insertions(+), 33 deletions(-) rename application/views/system/{messages => infocenter}/messageList.php (100%) rename public/js/{messaging => infocenter}/messageList.js (100%) diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 744eb880e..a7709a702 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -96,36 +96,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - - /** - * Send a new message - * - The recipients are prestudents - * - An email template with message var may be provided - * - A global organisation unit may be provided, otherwise is used the prestudent one - */ - public function sendJson() - { - $prestudents = $this->input->post('prestudents'); - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); - $oe_kurzbz = $this->input->post('oe_kurzbz'); - $msgVars = $this->input->post('msgvars'); - - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - - // Adds the organisation unit to each prestudent - if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) - { - $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); - } - - $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - - $this->outputJson(getData($send)); - } + // Public methods - JSON output - called by this controller and FASMessages (view system/messages/messageWrite) /** * Returns an object that represent a template store in database @@ -185,6 +156,9 @@ class Messages extends Auth_Controller } } + // ----------------------------------------------------------------------------------------------------------------- + // Public methods - JSON output - called by infocenter + /** * Outputs message data for a message (identified my msg id and receiver id) in JSON format */ @@ -204,4 +178,33 @@ class Messages extends Auth_Controller $this->outputJson(array(getData($msg)[0])); } } + + /** + * Send a new message + * - The recipients are prestudents + * - An email template with message var may be provided + * - A global organisation unit may be provided, otherwise is used the prestudent one + */ + public function sendJson() + { + $prestudents = $this->input->post('prestudents'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $msgVars = $this->input->post('msgvars'); + + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + + // Adds the organisation unit to each prestudent + if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) + { + $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); + } + + $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + + $this->outputJson(getData($send)); + } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d59c058cf..b83d6e48b 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -646,7 +646,7 @@ class InfoCenter extends Auth_Controller public function reloadMessages($person_id) { $messages = $this->MessageModel->getMessagesOfPerson($person_id, 1); - $this->load->view('system/messages/messageList.php', array('messages' => $messages->retval)); + $this->load->view('system/infocenter/messageList.php', array('messages' => $messages->retval)); } /** diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 9e708d076..86493134c 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -22,7 +22,7 @@ 'customJSs' => array( 'public/js/bootstrapper.js', 'public/js/tablesort/tablesort.js', - 'public/js/messaging/messageList.js', + 'public/js/infocenter/messageList.js', 'public/js/infocenter/infocenterDetails.js' ), 'phrases' => array( @@ -147,7 +147,7 @@
load->view('system/messages/messageList.php', $messages); + $this->load->view('system/infocenter/messageList.php', $messages); ?>
diff --git a/application/views/system/messages/messageList.php b/application/views/system/infocenter/messageList.php similarity index 100% rename from application/views/system/messages/messageList.php rename to application/views/system/infocenter/messageList.php diff --git a/public/js/messaging/messageList.js b/public/js/infocenter/messageList.js similarity index 100% rename from public/js/messaging/messageList.js rename to public/js/infocenter/messageList.js From f6e0f58b3dbe9031d2520fbb1c350c1ff7bf0be3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 18 Jun 2019 18:25:26 +0200 Subject: [PATCH 006/157] - Renamed view system/messages/messageSent.php to system/messages/htmlSuccess.php - Added new view system/messages/htmlError.php - Renamed view system/messages/messageWrite.php to system/messages/htmlWriteTemplate.php - Added new widget views: widgets/Dropdown_widget.php and widgets/MultipleDropdown_widget.php - Added new CSS public/css/Widgets.css - Controller system/FASMessages: - Renamed method write to writeTemplate and method writeReply to writeReplyTemplate - Removed all the private methods and moved all the logic to model CL/Messages_model - Methods writeTemplate and writeReplyTemplate do not need anymore the sender id as parameter - Controller system/Messages: - Renamed method write to writeTemplate - Renamed method send to sendImplicitTemplate - Renamed method sendJson to sendExplicitTemplateJson - Moved all the logic to model CL/Messages_model - Adapted php and JS code to use these new methods names and interfaces - Removed public method getIsAdmin from MessageLib - Method _sendMessage of MessageLib now returns the saved message ids - Added new package olifolkerd/tabulator to composer - Added new parameter widgets to view templates/FHC-Header.php - Added new HTML widget widgets/Dropdown_widget and widgets/MultipleDropdown_widget - Added constants REPLY_SUBJECT_PREFIX and REPLY_BODY_PREFIX to model CL/Messages_model - Added new public methods prepareHtmlWriteTemplatePersons, prepareHtmlWriteTemplatePrestudents, sendImplicitTemplate, sendExplicitTemplate, getVorlage, parseMessageText and getMessageFromIds to model CL/Messages_model - Added new private methods _getAuthUser, _lowerReplaceSpaceArrayKeys, _addOeToPrestudents, _personLog and _prepareHtmlWriteTemplate to model CL/Messages_model --- .../controllers/system/FASMessages.php | 177 +------- application/controllers/system/Messages.php | 147 ++----- application/libraries/MessageLib.php | 18 +- application/models/CL/Messages_model.php | 409 ++++++++++++++---- .../views/system/infocenter/stammdaten.php | 2 +- .../views/system/messages/htmlError.php | 82 ++++ .../{messageSent.php => htmlSuccess.php} | 12 +- .../system/messages/htmlWriteTemplate.php | 167 +++++++ .../views/system/messages/messageWrite.php | 183 -------- application/views/templates/FHC-Header.php | 4 + application/views/widgets/dropdown.php | 6 +- application/widgets/Dropdown_widget.php | 19 + .../widgets/MultipleDropdown_widget.php | 20 + application/widgets/html/DropdownWidget.php | 42 +- composer.json | 13 + composer.lock | 49 ++- content/fasoverlay.js.php | 2 +- content/messages.js.php | 4 +- public/css/Widgets.css | 46 ++ public/css/messaging/messageWrite.css | 7 +- public/js/infocenter/infocenterDetails.js | 2 +- .../js/infocenter/infocenterPersonDataset.js | 2 +- public/js/messaging/messageWrite.js | 2 +- 23 files changed, 802 insertions(+), 613 deletions(-) create mode 100644 application/views/system/messages/htmlError.php rename application/views/system/messages/{messageSent.php => htmlSuccess.php} (95%) create mode 100644 application/views/system/messages/htmlWriteTemplate.php delete mode 100644 application/views/system/messages/messageWrite.php create mode 100644 application/widgets/Dropdown_widget.php create mode 100644 application/widgets/MultipleDropdown_widget.php create mode 100644 public/css/Widgets.css diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/FASMessages.php index 6928a919d..55d1da25f 100644 --- a/application/controllers/system/FASMessages.php +++ b/application/controllers/system/FASMessages.php @@ -11,17 +11,15 @@ class FASMessages extends Auth_Controller { parent::__construct( array( - 'write' => 'basis/message:rw', - 'writeReply' => 'basis/message:rw' + 'writeTemplate' => 'basis/message:rw', + 'writeReplyTemplate' => 'basis/message:rw' ) ); - // Loads the message library - $this->load->library('MessageLib'); - - // Loads the widget library - $this->load->library('WidgetLib'); + // Loads model CLMessagesModel which contains the GUI logic + $this->load->model('CL/Messages_model', 'CLMessagesModel'); + // Phrases used in loaded views $this->loadPhrases( array( 'global', @@ -30,162 +28,33 @@ class FASMessages extends Auth_Controller ); } - // ----------------------------------------------------------------------------------------------------------------- - // Public methods - /** - * Write a new message + * Writes a new message to a prestudent using templates */ - public function write($sender_id) + public function writeTemplate() { - $prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s) + $prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s) - if (!is_numeric($sender_id)) - { - show_error('The current logged user person_id is not defined'); - } - - $msgVarsData = $this->_getMsgVarsData($prestudent_id); - - // Retrieves message vars for a person from view view vw_msg_vars_person - $variablesArray = $this->_getMessageVarsPerson(); - - // Organisation units used to get the templates - $oe_kurzbz = $this->_getOeKurzbz($sender_id); - - // Admin or commoner? - $isAdmin = $this->_getIsAdmin($sender_id); - - $data = array( - 'recipients' => getData($msgVarsData), - 'variables' => $variablesArray, - 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin - ); - - $this->load->view('system/messages/messageWrite', $data); + // Loads the view to write a new message with a template + $this->load->view( + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents) + ); } /** - * Write a reply + * Writes a reply to a message identified by parameters $message_id and $recipient_id + * The recipient is a prestudent + * Uses templates */ - public function writeReply($sender_id, $msg_id, $receiver_id) + public function writeReplyTemplate($message_id, $recipient_id) { - $prestudent_id = $this->input->post('prestudent_id'); // recipients prestudend_id(s) + $prestudents = $this->input->post('prestudent_id'); // recipients prestudend_id(s) - if (!is_numeric($sender_id)) - { - show_error('The current logged user person_id is not defined'); - } - - if (!is_numeric($msg_id)) - { - show_error('The msg_id must be a number'); - } - - if (!is_numeric($receiver_id)) - { - show_error('The receiver_id must be a number'); - } - - $msg = $this->_getMessage($msg_id, $receiver_id); - - $msgVarsData = $this->_getMsgVarsData($prestudent_id); - - // Retrieves message vars for a person from view view vw_msg_vars_person - $variablesArray = $this->_getMessageVarsPerson(); - - // Organisation units used to get the templates - $oe_kurzbz = $this->_getOeKurzbz($sender_id); - - // Admin or commoner? - $isAdmin = $this->_getIsAdmin($sender_id); - - $data = array( - 'recipients' => getData($msgVarsData), - 'message' => $msg, - 'variables' => $variablesArray, - 'oe_kurzbz' => $oe_kurzbz, // used to get the templates - 'isAdmin' => $isAdmin - ); - - $this->load->view('system/messages/messageWrite', $data); + // Loads the view to write a new message with a template + $this->load->view( + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePrestudents($prestudents, $message_id, $recipient_id) + ); } - - // ----------------------------------------------------------------------------------------------------------------- - // Private methods - - /** - * - */ - private function _getMessage($msg_id, $receiver_id) - { - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - if (isError($msg)) - { - show_error(getData($msg)); - } - elseif (!hasData($msg)) - { - show_error('The selected message does not exist'); - } - else - { - $msg = getData($msg)[0]; - } - - return $msg; - } - - /** - * Retrieves message vars from view vw_msg_vars - */ - private function _getMsgVarsData($prestudent_id) - { - $this->load->model('system/Message_model', 'MessageModel'); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - - if (isError($msgVarsData)) - { - show_error(getData($msgVarsData)); - } - - return $msgVarsData; - } - - /** - * Wrapper method to call messagelib->getMessageVarsPerson - */ - private function _getMessageVarsPerson() - { - $variables = $this->messagelib->getMessageVarsPerson(); - - if (isError($variables)) show_error(getData($variables)); - - return getData($variables); - } - - /** - * Wrapper method to call messagelib->getOeKurzbz - */ - private function _getOeKurzbz($sender_id) - { - $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); - - return getData($oe_kurzbz); - } - - /** - * Wrapper method to call messagelib->getIsAdmin - */ - private function _getIsAdmin($sender_id) - { - $isAdmin = $this->messagelib->getIsAdmin($sender_id); - - if (isError($isAdmin)) show_error(getData($isAdmin)); - - return getData($isAdmin); - } } diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index a7709a702..20fed38ad 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -4,28 +4,23 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends Auth_Controller { - /** - * MessageLib is loaded by CLMessagesModel - */ public function __construct() { parent::__construct( array( - 'write' => array('basis/message:rw', 'infocenter:rw'), - 'send' => array('basis/message:rw', 'infocenter:rw'), - 'sendJson' => array('basis/message:rw', 'infocenter:rw'), + 'writeTemplate' => array('basis/message:rw', 'infocenter:rw'), + 'sendImplicitTemplate' => array('basis/message:rw', 'infocenter:rw'), + 'sendExplicitTemplateJson' => array('basis/message:rw', 'infocenter:rw'), 'getVorlage' => array('basis/message:r', 'infocenter:r'), 'parseMessageText' => array('basis/message:r', 'infocenter:r'), 'getMessageFromIds' => array('basis/message:r', 'infocenter:r') ) ); - // Loads the widget library - $this->load->library('WidgetLib'); - - $this->load->model('system/Message_model', 'MessageModel'); + // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); + // Phrases used in loaded views $this->loadPhrases( array( 'global', @@ -38,65 +33,45 @@ class Messages extends Auth_Controller // Public methods - HTML output /** - * Initialize all the parameters used by view system/messages/messageWrite - * to build a GUI used to write a messate to user/s + * Initialize all the parameters used by view system/messages/htmlWriteTemplate + * to build a GUI used to write a messate to user/s using a template */ - public function write() + public function writeTemplate() { $persons = $this->input->post('person_id'); - $authUser = $this->CLMessagesModel->getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - - $sender_id = getData($authUser)[0]->person_id; - - // Retrieves person information - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); - if (isError($msgVarsData)) show_error(getData($msgVarsData)); - - // Retrieves message vars from view vw_msg_vars_person - $variables = $this->messagelib->getMessageVarsPerson(); - if (isError($variables)) show_error(getData($variables)); - - // Organisation units used to get the templates - $oe_kurzbz = $this->messagelib->getOeKurzbz($sender_id); - if (isError($oe_kurzbz)) show_error(getData($oe_kurzbz)); - - // Admin or commoner? - $isAdmin = $this->messagelib->getIsAdmin($sender_id); - if (isError($isAdmin)) show_error(getData($isAdmin)); - + // Loads the view to write a new message with a template $this->load->view( - 'system/messages/messageWrite', - array ( - 'recipients' => getData($msgVarsData), // recipients data - 'variables' => getData($variables), // message vars - 'oe_kurzbz' => getData($oe_kurzbz), // used to get the templates - 'isAdmin' => getData($isAdmin) // is admin? - ) + 'system/messages/htmlWriteTemplate', + $this->CLMessagesModel->prepareHtmlWriteTemplatePersons($persons) ); } /** * Send a new message or reply to user/s * If a relationmessage_id this message is a reply to another one + * Body is a template and will be parsed using information present in persons parameter */ - public function send() + public function sendImplicitTemplate() { + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); $persons = $this->input->post('persons'); $relationmessage_id = $this->input->post('relationmessage_id'); - // Retrieves message vars data for the fiven user/s - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); - - // Send the message - $send = $this->CLMessagesModel->send($msgVarsData, $relationmessage_id); - - $this->load->view('system/messages/messageSent', array('success' => isSuccess($send))); + $sendImplicitTemplate = $this->CLMessagesModel->sendImplicitTemplate($persons, $subject, $body, $relationmessage_id); + if (isSuccess($sendImplicitTemplate)) + { + $this->load->view('system/messages/htmlSuccess'); + } + else + { + $this->load->view('system/messages/htmlError'); + } } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by this controller and FASMessages (view system/messages/messageWrite) + // Public methods - JSON output - called by this controller and FASMessages (view system/messages/htmlWriteTemplate) /** * Returns an object that represent a template store in database @@ -106,24 +81,8 @@ class Messages extends Auth_Controller public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); - $result = error('The given vorlage_kurzbz is not valid'); - if (!isEmptyString($vorlage_kurzbz)) - { - $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); - $this->VorlagestudiengangModel->addOrder('version','DESC'); - - $result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); - } - - if (isError($result) || !hasData($result)) - { - $this->outputJsonError(getData($result)); - } - else - { - $this->outputJsonSuccess(getData($result)); - } + $this->outputJson($this->CLMessagesModel->getVorlage($vorlage_kurzbz)); } /** @@ -134,26 +93,8 @@ class Messages extends Auth_Controller { $person_id = $this->input->get('person_id'); $text = $this->input->get('text'); - $msgVarsData = error('The given person_id is not a valid number'); - if (is_numeric($person_id)) - { - $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - } - - if (isError($msgVarsData) || !hasData($msgVarsData)) - { - $this->outputJsonError(getData($msgVarsData)); - } - else - { - $this->outputJsonSuccess( - parseText( - $text, - $this->CLMessagesModel->replaceKeys((array)getData($msgVarsData)[0]) - ) - ); - } + $this->outputJson($this->CLMessagesModel->parseMessageText($person_id, $text)); } // ----------------------------------------------------------------------------------------------------------------- @@ -164,19 +105,10 @@ class Messages extends Auth_Controller */ public function getMessageFromIds() { - $msg_id = $this->input->get('msg_id'); + $message_id = $this->input->get('msg_id'); $receiver_id = $this->input->get('receiver_id'); - $msg = $this->messagelib->getMessage($msg_id, $receiver_id); - - if (isError($msg) || !hasData($msg)) - { - $this->outputJson(array()); - } - else - { - $this->outputJson(array(getData($msg)[0])); - } + $this->outputJson($this->CLMessagesModel->getMessageFromIds($message_id, $receiver_id)); } /** @@ -184,27 +116,16 @@ class Messages extends Auth_Controller * - The recipients are prestudents * - An email template with message var may be provided * - A global organisation unit may be provided, otherwise is used the prestudent one + * - A template is explicitly specified */ - public function sendJson() + public function sendExplicitTemplateJson() { $prestudents = $this->input->post('prestudents'); - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $oe_kurzbz = $this->input->post('oe_kurzbz'); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $msgVars = $this->input->post('msgvars'); - $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); - - // Adds the organisation unit to each prestudent - if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) - { - $this->CLMessagesModel->addOeToPrestudents($msgVarsData, $prestudentsData); - } - - $send = $this->CLMessagesModel->send($msgVarsData, null, $oe_kurzbz, $vorlage_kurzbz, $msgVars); - - $this->outputJson(getData($send)); + $sendExplicitTemplate = $this->CLMessagesModel->sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars); + $this->outputJson(getData($sendExplicitTemplate)); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index c3c1169d4..7bf6b7518 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -49,7 +49,6 @@ class MessageLib // Loads extra models $this->_ci->load->model('person/Person_model', 'PersonModel'); - $this->_ci->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); } @@ -208,14 +207,6 @@ class MessageLib return $benutzer; // otherwise returns the error } - /** - * Admin or commoner? - */ - public function getIsAdmin($sender_id) - { - return $this->_ci->BenutzerrolleModel->isAdminByPersonId($sender_id); - } - //------------------------------------------------------------------------------------------------------------------ // Public methods used by REST API @@ -629,6 +620,7 @@ class MessageLib /** * Sends new message core method, may be wrapped by other methods. + * If success then returns an array of successfully saved message ids */ private function _sendMessage( $receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime @@ -658,11 +650,7 @@ class MessageLib ); if (isSuccess($saveMessageResult)) // If successfully saved { - // If the system is configured to send messages immediately - if ($this->_ci->config->item(self::CFG_SEND_IMMEDIATELY) === true) - { - $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message - } + $savedMessages[] = getData($saveMessageResult); // store the message id of the saved message } else { @@ -683,7 +671,7 @@ class MessageLib } } - return success('Message sent successfully'); + return success($savedMessages); } /** diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index c17d608c7..05eaa8b16 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -1,11 +1,15 @@
-------------------------------------------------------------------------------'; + /** * Constructor */ @@ -14,102 +18,143 @@ class Messages_model extends CI_Model parent::__construct(); // Loads the message library - $this->load->library('MessageLib'); - + $this->load->library('MessageLib'); // MessageModel loaded here! // Loads the person log library $this->load->library('PersonLogLib'); + // Loads the widget library + $this->load->library('WidgetLib'); + // Loads model MessageToken_model $this->load->model('system/MessageToken_model', 'MessageTokenModel'); + + // Loads model Benutzerrolle_model + $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Prepares data for the view system/messages/htmlWriteTemplate using person ids as main parameter + * Wrap method to _prepareHtmlWriteTemplate + */ + public function prepareHtmlWriteTemplatePersons($persons, $message_id = null, $recipient_id = null) + { + // Retrieves persons information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + + return $this->_prepareHtmlWriteTemplate($msgVarsData, $message_id, $recipient_id); } /** - * Executes message sending - * @param $sender_id - * @return array wether execution was successfull - error or success + * Prepares data for the view system/messages/htmlWriteTemplate using prestudent ids as main parameter + * Wrap method to _prepareHtmlWriteTemplate */ - public function send($msgVarsData, $relationmessage_id = null, $oe_kurzbz = null, $vorlage_kurzbz = null, $msgVars = null) + public function prepareHtmlWriteTemplatePrestudents($prestudents, $message_id = null, $recipient_id = null) { - $subject = $this->input->post('subject'); - $body = $this->input->post('body'); + // Retrieves prestudents information + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); - $authUser = $this->getAuthUser(); + return $this->_prepareHtmlWriteTemplate($msgVarsData, $message_id, $recipient_id); + } - if (isError($authUser)) return $authUser; + /** + * Sends a new message or a reply to a message (if $relationmessage_id is given) + * using the template stored in the subject and body + */ + public function sendImplicitTemplate($persons, $subject, $body, $relationmessage_id = null) + { + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); $sender_id = getData($authUser)[0]->person_id; + // Retrieves message vars data for the given user/s + $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); + if (isError($msgVarsData)) show_error(getData($msgVarsData)); + if (!hasData($msgVarsData)) show_error('No recipients were given'); - // Send message(s) - if (hasData($msgVarsData)) + foreach (getData($msgVarsData) as $receiver) { - for ($i = 0; $i < count(getData($msgVarsData)); $i++) - { - $parsedText = ''; - $msgVarsDataArray = $this->replaceKeys((array)getData($msgVarsData)[$i]); // replaces array keys + $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys - // Send without vorlage - if (isEmptyString($vorlage_kurzbz)) - { - $parsedText = parseText($body, $msgVarsDataArray); + $parsedSubject = parseText($subject, $msgVarsDataArray); + $parsedBody = parseText($body, $msgVarsDataArray); - $msg = $this->messagelib->sendMessageUser( - $msgVarsDataArray['person_id'], // receiverPersonId - $subject, // subject - $parsedText, // body - $sender_id, // sender_id - $oe_kurzbz, // senderOU - $relationmessage_id, // relationmessage_id - MSG_PRIORITY_NORMAL // priority - ); - } - // Send with vorlage - else - { - if (is_array($msgVars)) - { - // Additional message variables - foreach ($msgVars as $key => $msgvar) - { - $msgVarsDataArray[$key] = $msgvar; - } - } + $message = $this->messagelib->sendMessageUser( + $msgVarsDataArray['person_id'], // receiverPersonId + $parsedSubject, // subject + $parsedBody, // body + $sender_id, // sender_id + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); - $msg = $this->messagelib->sendMessageUserTemplate( - $msgVarsDataArray['person_id'], // receiversPersonId - $vorlage_kurzbz, // vorlage - $msgVarsDataArray, // parseData - null, // orgform - $sender_id, // sender_id - $oe_kurzbz // senderOU - ); - } + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); - if (isError($msg)) return $msg; - - // Write log entry - $personLog = $this->personloglib->log( - $msgVarsDataArray['person_id'], - 'Action', - array( - 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$msgVarsDataArray['person_id'].', messageid '.getData($msg), - 'success' => 'true' - ), - 'kommunikation', - 'core', - null, - getAuthUID() - ); - - if (isError($personLog)) return $personLog; - } - - return success('Messages sent successfully'); + // Write log entry + $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); + if (isError($personLog)) return $personLog; } - else + + return success('Messages sent successfully'); + } + + /** + * Sends a new message using the given template and information present in parameter prestudents + * Extra variables can be added using parameter $msgVars + */ + public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars) + { + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); + + $sender_id = getData($authUser)[0]->person_id; + + // Retrieves message vars data for the given user/s + $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); + if (isError($msgVarsData)) show_error(getData($msgVarsData)); + if (!hasData($msgVarsData)) show_error('No recipients were given'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); + + // Adds the organisation unit to each prestudent + if (isEmptyString($oe_kurzbz) && hasData($msgVarsData) && hasData($prestudentsData)) { - return $msgVarsData; + $this->CLMessagesModel->_addOeToPrestudents($msgVarsData, $prestudentsData); } + + foreach (getData($msgVarsData) as $receiver) + { + $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys + + // Additional message variables + if (is_array($msgVars)) $msgVarsDataArray = array_merge($msgVarsDataArray, $msgVars); + + $message = $this->messagelib->sendMessageUserTemplate( + $msgVarsDataArray['person_id'], // receiversPersonId + $vorlage_kurzbz, // vorlage + $msgVarsDataArray, // parseData + null, // orgform + $sender_id, // sender_id + $oe_kurzbz // senderOU + ); + + if (isError($message)) return $message; + + // Write log entry + $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); + if (isError($personLog)) return $personLog; + } + + return success('Messages sent successfully'); } /** @@ -171,29 +216,98 @@ class Messages_model extends CI_Model return success('Reply sent'); } - /** - * - */ - public function getAuthUser() - { - $sender_id = null; + //------------------------------------------------------------------------------------------------------------------ + // Public methods called by controller system/Messages + /** + * Returns an object that represent a template store in database + * If no templates are found with the given parameter or the given parameter is an empty string, + * then an error is returned + */ + public function getVorlage($vorlage_kurzbz) + { + $getVorlage = error('The given vorlage_kurzbz is not valid'); + + if (!isEmptyString($vorlage_kurzbz)) + { + $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); + $this->VorlagestudiengangModel->addOrder('version','DESC'); + + $getVorlage = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); + } + + return $getVorlage; + } + + /** + * Parse the given given text using data from the given user + * Use the CI parser which performs simple text substitution for pseudo-variable + */ + public function parseMessageText($person_id, $text) + { + $parseMessageText = error('The given person_id is not a valid number'); + + if (is_numeric($person_id)) + { + $parseMessageText = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + } + + if (hasData($parseMessageText)) + { + $parseMessageText = success( + parseText( + $text, + $this->_lowerReplaceSpaceArrayKeys((array)getData($parseMessageText)[0]) + ) + ); + } + + return $parseMessageText; + } + + /** + * Outputs message data for a message (identified my msg id and receiver id) in JSON format + */ + public function getMessageFromIds($message_id, $receiver_id) + { + $getMessageFromIds = error('The given message id or receiver id are not valid'); + + if (is_numeric($message_id) && is_numeric($receiver_id)) + { + $getMessageFromIds = $this->messagelib->getMessage($message_id, $receiver_id); + } + + if (isError($getMessageFromIds) || !hasData($getMessageFromIds)) + { + return array(); + } + else + { + return array(getData($getMessageFromIds)[0]); + } + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Returns the current authenticated person object + */ + private function _getAuthUser() + { $this->load->model('person/Person_model', 'PersonModel'); $authUser = $this->PersonModel->getByUid(getAuthUID()); - if (!hasData($authUser)) $authUser = error('The current logged user person_id is not defined'); - return $authUser; } /** - * + * Replaces data array keys to a lowercase string with underscores instead of spaces */ - public function replaceKeys($data) + private function _lowerReplaceSpaceArrayKeys($data) { $tmpData = array(); - // Replaces data array keys to a lowercase without spaces string foreach ($data as $key => $val) { $tmpData[str_replace(' ', '_', strtolower($key))] = $val; @@ -203,9 +317,9 @@ class Messages_model extends CI_Model } /** - * + * Add organisation unit to an array of prestudents (objects) */ - public function addOeToPrestudents(&$msgVarsData, $prestudentsData) + private function _addOeToPrestudents(&$msgVarsData, $prestudentsData) { for ($i = 0; $i < count(getData($msgVarsData)); $i++) { @@ -219,4 +333,127 @@ class Messages_model extends CI_Model } } } + + /** + * Perform a person log after a message is sent + */ + private function _personLog($sender_id, $receiver_id, $message_id) + { + $_personLog = $this->personloglib->log( + $receiver_id, + 'Action', + array( + 'name' => 'Message sent', + 'message' => 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id, + 'success' => 'true' + ), + 'kommunikation', + 'core', + null, + getAuthUID() + ); + + return $_personLog; + } + + /** + * Prepares data for the view system/messages/htmlWriteTemplate using the given parameters + */ + private function _prepareHtmlWriteTemplate($info, $message_id, $recipient_id) + { + // Checks that info parameter is valid + if (isError($info)) show_error(getData($info)); + if (!hasData($info)) show_error('No recipients were given'); + + // If the message id and recipient id are given, then both they must be valid numbers + if ((is_numeric($message_id) && !is_numeric($recipient_id)) + || (!is_numeric($message_id) && is_numeric($recipient_id))) + { + show_error('If given, message id and recipient id both must be valid numbers'); + } + + // --------------------------------------------------------------------------------------- + // Retrieves the recipients information and builds: + // - recipientsArray: an array that contains objects with id (person_id) and description (Vorname + Nachname) of recipient + // - recipientsList: a string that contains all the recipients descriptions (Vorname + Nachname) separated by ; + // - persons: a string that contains HTML input hidden with alla the receivers id (person_id) + $recipientsArray = array(); + $recipientsList = ''; + $persons = ''; + foreach (getData($info) as $receiver) + { + $recipient = new stdClass(); + $recipient->id = $receiver->person_id; + $recipient->description = $receiver->Vorname.' '.$receiver->Nachname; + + $recipientsArray[] = $recipient; + $recipientsList .= $receiver->Vorname.' '.$receiver->Nachname.'; '; + $persons .= ''."\n"; + } + + // --------------------------------------------------------------------------------------- + // Retrieves the message to reply to, if it is specified by parameters $message_id and $recipient_id + $replySubject = ''; // message reply subject + $replyBody = ''; // message reply body + $relationmessage = ''; // input hidden that contains the message id to be replied to + // If both are given and they are valid + if (is_numeric($message_id) && is_numeric($recipient_id)) + { + // Retrieves a received message from tbl_msg_recipient + $messageResult = $this->messagelib->getMessage($message_id, $recipient_id); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('The selected message does not exist'); + + $message = getData($messageResult)[0]; + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = self::REPLY_BODY_PREFIX.$message->body; + $relationmessage = ''; + } + + // --------------------------------------------------------------------------------------- + // Retrieves message vars from database view vw_msg_vars_person + $variablesResult = $this->messagelib->getMessageVarsPerson(); + if (isError($variablesResult)) show_error(getData($variablesResult)); + + // Then builds an array that contains objects with id (person_id) and description (Vorname + Nachname) of recipient + $variables = array(); + foreach (getData($variablesResult) as $id => $description) + { + $tmpVar = new stdClass(); + $tmpVar->id = $id; + $tmpVar->description = $description; + + $variables[] = $tmpVar; + } + + // --------------------------------------------------------------------------------------- + // Retrieves the sender id + $authUser = $this->_getAuthUser(); + if (isError($authUser)) show_error(getData($authUser)); + if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); + + $sender_id = getData($authUser)[0]->person_id; + + // --------------------------------------------------------------------------------------- + // Organisation units and a boolean (true if the sender is administrator) are used to get the templates + $organisationUnits = $this->messagelib->getOeKurzbz($sender_id); + if (isError($organisationUnits)) show_error(getData($organisationUnits)); + $senderIsAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id); + if (isError($senderIsAdmin)) show_error(getData($senderIsAdmin)); + + // --------------------------------------------------------------------------------------- + // Returns data as an array + return array ( + 'recipientsList' => $recipientsList, + 'subject' => $replySubject, + 'body' => $replyBody, + 'variables' => $variables, + 'organisationUnits' => getData($organisationUnits), + 'senderIsAdmin' => getData($senderIsAdmin), + 'recipientsArray' => $recipientsArray, + 'persons' => $persons, + 'relationmessage_id' => $relationmessage + ); + } } diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index 2b481692e..ebd812c6a 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -113,7 +113,7 @@
-
+  p->t('ui','nachrichtSenden'); ?> diff --git a/application/views/system/messages/htmlError.php b/application/views/system/messages/htmlError.php new file mode 100644 index 000000000..7e029b50c --- /dev/null +++ b/application/views/system/messages/htmlError.php @@ -0,0 +1,82 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Message sent failure', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + ) + ); +?> + + + + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageSent.php b/application/views/system/messages/htmlSuccess.php similarity index 95% rename from application/views/system/messages/messageSent.php rename to application/views/system/messages/htmlSuccess.php index 674ccd5a0..0260c9d16 100644 --- a/application/views/system/messages/messageSent.php +++ b/application/views/system/messages/htmlSuccess.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageSent', + 'title' => 'Message sent successfully', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, @@ -17,11 +17,6 @@
- -
@@ -79,11 +74,6 @@
- - -
diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php new file mode 100644 index 000000000..8ce4d670a --- /dev/null +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -0,0 +1,167 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'ajaxlib' => true, + 'fontawesome' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'widgets' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') + ) + ); +?> + + + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageWrite.php b/application/views/system/messages/messageWrite.php deleted file mode 100644 index 93caaf861..000000000 --- a/application/views/system/messages/messageWrite.php +++ /dev/null @@ -1,183 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Write a message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'ajaxlib' => true, - 'fontawesome' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') - ) -); -?> - -
-
-
-
-
- -
-
-
-
-
-
- -
-
- 1 && $i % 10 == 0) - { - echo '
'; - } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } - ?> -
-
-
-
-
-
- -
  - subject; - } - ?> -
- -
-
-
-
-
-
- - body; - } - ?> - -
- -
-
- - -
-
- -
-
-
-
- widgetlib->widget( - 'Vorlage_widget', - array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin), - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); - ?> -
-
- -
-
- 0) - { - ?> -
-
-
- -
-
-
-
-
-
- - -   - Refresh -
-
-
- -
-
-
- -
- - - person_id.'">'."\n"; - } - ?> - - - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 43112dd7b..6b9afd6b9 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -30,6 +30,7 @@ $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; $tablesorter = isset($tablesorter) ? $tablesorter : false; $tinymce = isset($tinymce) ? $tinymce : false; + $widgets = isset($widgets) ? $widgets : false; ?> @@ -94,6 +95,9 @@ // NavigationWidget CSS if ($navigationwidget === true) generateCSSsInclude('public/css/NavigationWidget.css'); + // HTML Widget CSS + if ($widgets === true) generateCSSsInclude('public/css/Widgets.css'); + // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS diff --git a/application/views/widgets/dropdown.php b/application/views/widgets/dropdown.php index c1bdbf5c8..3db602755 100644 --- a/application/views/widgets/dropdown.php +++ b/application/views/widgets/dropdown.php @@ -37,11 +37,11 @@
- \ No newline at end of file + diff --git a/application/widgets/Dropdown_widget.php b/application/widgets/Dropdown_widget.php new file mode 100644 index 000000000..91e41e3ad --- /dev/null +++ b/application/widgets/Dropdown_widget.php @@ -0,0 +1,19 @@ +setElementsArray( + $elements, + true, + $emptyElement, + 'No data present' + ); + + $this->loadDropDownView($widgetData); + } +} diff --git a/application/widgets/MultipleDropdown_widget.php b/application/widgets/MultipleDropdown_widget.php new file mode 100644 index 000000000..a13f62492 --- /dev/null +++ b/application/widgets/MultipleDropdown_widget.php @@ -0,0 +1,20 @@ +setElementsArray( + $elements, + false, + '', + 'No data present' + ); + + $this->setMultiple(); + + $this->loadDropDownView($widgetData); + } +} diff --git a/application/widgets/html/DropdownWidget.php b/application/widgets/html/DropdownWidget.php index ca3e30163..5c28e5a9f 100644 --- a/application/widgets/html/DropdownWidget.php +++ b/application/widgets/html/DropdownWidget.php @@ -17,32 +17,32 @@ class DropdownWidget extends HTMLWidget const SELECTED_ELEMENT = 'selectedElement'; // Default HTML value const HTML_DEFAULT_VALUE = 'null'; - + const SIZE = 'size'; // size of the dropdown const MULTIPLE = 'multiple'; // multiple attribute - + // Alias of $this->_args[HTMLWidget::HTML_ARG_NAME] for a better code readability protected $htmlParameters; - + /** - * + * */ public function __construct($name, $args = array(), $htmlArgs = array()) { parent::__construct($name, $args, $htmlArgs); - + // If the selectd element is not set then set it to HTML_DEFAULT_VALUE if (!isset($this->_args[DropdownWidget::SELECTED_ELEMENT])) { $this->_args[DropdownWidget::SELECTED_ELEMENT] = DropdownWidget::HTML_DEFAULT_VALUE; } - + $this->htmlParameters =& $this->_args[HTMLWidget::HTML_ARG_NAME]; // Reference for a better code readability - + // By default is not a multiple dropdown unset($this->htmlParameters[DropdownWidget::MULTIPLE]); } - + /** * Set this dropdown as multiple: * - Setting the multiple attribute @@ -53,23 +53,23 @@ class DropdownWidget extends HTMLWidget $this->htmlParameters[DropdownWidget::MULTIPLE] = DropdownWidget::MULTIPLE; $this->htmlParameters[HTMLWidget::HTML_NAME] .= '[]'; } - + /** * Checks if this object is a multiple dropdown */ public function isMultipleDropdown() { $isMultipleDropdown = false; - + if (isset($this->htmlParameters[DropdownWidget::MULTIPLE]) && $this->htmlParameters[DropdownWidget::MULTIPLE] == DropdownWidget::MULTIPLE) { $isMultipleDropdown = true; } - + return $isMultipleDropdown; } - + /** * Add the correct select to the model used to load a list of elemets for this dropdown * @param model $model the model used to load elements @@ -88,7 +88,7 @@ class DropdownWidget extends HTMLWidget ) ); } - + /** * Set the array used to populate the dropdown * @param array $elements list used to populate this dropdown @@ -102,7 +102,7 @@ class DropdownWidget extends HTMLWidget ) { $tmpElements = array(); - + if (isError($elements)) { if (is_object($elements) && isset($elements->retval)) @@ -133,11 +133,11 @@ class DropdownWidget extends HTMLWidget { $tmpElements = $elements->retval; } - + $this->_args[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $tmpElements; } } - + /** * Adds an element to the beginning of the array */ @@ -146,17 +146,17 @@ class DropdownWidget extends HTMLWidget $element = new stdClass(); $element->{DropdownWidget::ID_FIELD} = $id; $element->{DropdownWidget::DESCRIPTION_FIELD} = $stdDescription; - + if (!hasData($elements)) { $element->{DropdownWidget::DESCRIPTION_FIELD} = $noDataDescription; } - + array_unshift($elements->retval, $element); - + return $elements->retval; } - + /** * Loads the dropdown view with all the elements to be displayed */ @@ -164,4 +164,4 @@ class DropdownWidget extends HTMLWidget { $this->view('widgets/dropdown', $this->_args); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index d763dc5ad..c6816e075 100644 --- a/composer.json +++ b/composer.json @@ -173,6 +173,17 @@ } } }, + { + "type": "package", + "package": { + "name": "olifolkerd/tabulator", + "version": "4.2.7", + "dist": { + "url": "https://github.com/olifolkerd/tabulator/archive/4.2.7.zip", + "type": "zip" + } + } + }, { "type": "package", "package": { @@ -260,6 +271,8 @@ "netcarver/textile": "^3.5", "nicolaskruchten/pivottable": "^2.15.0", + "olifolkerd/tabulator": "4.2.7", + "phpseclib/phpseclib": "^2.0", "rmariuzzo/jquery-checkboxes": "1.0.7", diff --git a/composer.lock b/composer.lock index 8fc88ce07..f328832e6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ddbbad487c655512e6983408339cb85f", - "content-hash": "b5902c71fe21cd14397101dba5a3080c", + "hash": "df6059a4bee974ecf5447aad8a8b1e15", + "content-hash": "2111c73853dbc47938c3f31dbc349883", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -1198,16 +1198,16 @@ }, { "name": "netcarver/textile", - "version": "v3.7.1", + "version": "v3.7.2", "source": { "type": "git", "url": "https://github.com/textile/php-textile.git", - "reference": "377933125dd30d708804c545bf33da87a3c1b0f4" + "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/textile/php-textile/zipball/377933125dd30d708804c545bf33da87a3c1b0f4", - "reference": "377933125dd30d708804c545bf33da87a3c1b0f4", + "url": "https://api.github.com/repos/textile/php-textile/zipball/c24d68d9f4d099f9c2434e71024f2a6140dc1594", + "reference": "c24d68d9f4d099f9c2434e71024f2a6140dc1594", "shasum": "" }, "require": { @@ -1247,7 +1247,7 @@ "plaintext", "textile" ], - "time": "2019-01-26 17:03:58" + "time": "2019-06-08 17:57:17" }, { "name": "nicolaskruchten/pivottable", @@ -1260,18 +1260,29 @@ }, "type": "library" }, + { + "name": "olifolkerd/tabulator", + "version": "4.2.7", + "dist": { + "type": "zip", + "url": "https://github.com/olifolkerd/tabulator/archive/4.2.7.zip", + "reference": null, + "shasum": null + }, + "type": "library" + }, { "name": "phpseclib/phpseclib", - "version": "2.0.15", + "version": "2.0.18", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0" + "reference": "60519001db8d791215a822efd366d24cafee9e63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/11cf67cf78dc4acb18dc9149a57be4aee5036ce0", - "reference": "11cf67cf78dc4acb18dc9149a57be4aee5036ce0", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/60519001db8d791215a822efd366d24cafee9e63", + "reference": "60519001db8d791215a822efd366d24cafee9e63", "shasum": "" }, "require": { @@ -1350,7 +1361,7 @@ "x.509", "x509" ], - "time": "2019-03-10 16:53:45" + "time": "2019-06-13 06:15:54" }, { "name": "psr/log", @@ -2180,16 +2191,16 @@ }, { "name": "twig/twig", - "version": "v1.41.0", + "version": "v1.42.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9" + "reference": "671347603760a88b1e7288aaa9378f33687d7edf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/575cd5028362da591facde1ef5d7b94553c375c9", - "reference": "575cd5028362da591facde1ef5d7b94553c375c9", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/671347603760a88b1e7288aaa9378f33687d7edf", + "reference": "671347603760a88b1e7288aaa9378f33687d7edf", "shasum": "" }, "require": { @@ -2199,12 +2210,12 @@ "require-dev": { "psr/container": "^1.0", "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.4.19|^4.1.8" + "symfony/phpunit-bridge": "^3.4.19|^4.1.8|^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.41-dev" + "dev-master": "1.42-dev" } }, "autoload": { @@ -2242,7 +2253,7 @@ "keywords": [ "templating" ], - "time": "2019-05-14 11:59:08" + "time": "2019-06-04 11:31:08" }, { "name": "zetacomponents/base", diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index 0c80221e9..3089b6032 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -1250,7 +1250,7 @@ function MessageNew() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/write/' + person_id; ?>; + var action = 'index.ci.php/system/FASMessages/writeTemplate/' + person_id; ?>; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/content/messages.js.php b/content/messages.js.php index fae1db4ba..4094cddb8 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -104,7 +104,7 @@ function MessagesNewMessage() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/write/' + MessageSenderPersonID; + var action = 'index.ci.php/system/FASMessages/writeTemplate'; 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 = 'index.ci.php/system/FASMessages/writeReply/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + var action = 'index.ci.php/system/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/public/css/Widgets.css b/public/css/Widgets.css new file mode 100644 index 000000000..ef98856ea --- /dev/null +++ b/public/css/Widgets.css @@ -0,0 +1,46 @@ +.div-table { + display: table; +} + +.div-row { + display: table-row; +} + +.div-cell { + display: table-cell; +} + +.div-cell-label { + display: table-cell; +} + +label[required-field=true]::after { + content: "*"; +} + +.div-cell-data { + display: table-cell; +} + +.halign-right { + text-align: right; + margin-left: auto; + margin-right: 0; +} + +.valign-middle { + vertical-align: middle; +} + +.valign-top { + vertical-align: top; + padding-top: 1px; +} + +.width-150px { + width: 150px; +} + +.width-30px { + width: 30px; +} diff --git a/public/css/messaging/messageWrite.css b/public/css/messaging/messageWrite.css index 91b20729f..3b5e1fd0e 100644 --- a/public/css/messaging/messageWrite.css +++ b/public/css/messaging/messageWrite.css @@ -21,4 +21,9 @@ input[type=text] { #sendButton { width: 120px; -} \ No newline at end of file +} + +/* Overwrites the Widget.css class */ +div .width-150px { + width: 200px; +} diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index a43b36df8..3edb9d42d 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -629,7 +629,7 @@ var InfocenterDetails = { sendFreigabeMessage: function(prestudentid, vorlage_kurzbz, msgvars) { FHC_AjaxClient.ajaxCallPost( - 'system/Messages/sendJson', + 'system/Messages/sendExplicitTemplateJson', { "prestudents": prestudentid, "vorlage_kurzbz": vorlage_kurzbz, diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index dc6af2284..c5ea99dfc 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -26,7 +26,7 @@ var InfocenterPersonDataset = { appendTableActionsHtml: function() { var currurl = window.location.href; - var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/write"; + var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/writeTemplate"; var formHtml = '
'; $("#datasetActionsTop").before(formHtml); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 9894573ee..c496b269d 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -1,5 +1,5 @@ /** - * JS used by view system/messages/messageWrite + * JS used by view system/messages/htmlWriteTemplate */ function tinymcePreviewSetContent() From 99570978c3676346d42b6becc7a87396a9bd86b6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 14:51:54 +0200 Subject: [PATCH 007/157] - Renamed view system/messages/messageHTML to system/messages/htmlRead - Renamed view system/messages/messageWriteReply to system/messages/htmlWriteReply - Removed views system/messages/messageReplySent and system/messages/messageForm - Moved logic from controller ViewMessage to model CL/Messages_model - Added new constants CFG_REDIRECT_VIEW_MESSAGE_URL to MessageLib - Removed public method getPersonData from model system/MessageToken_model - Changed query in method system/Recipient_model->getMessage to include column tbl_msg_recipient.sent - Added new public method prepareHtmlRead to model CL/Messages_model - Changed constant REPLY_BODY_FORMAT of model CL/Messages_model - Added new constant NO_AUTH_UID to model CL/Messages_model - Added new public method prepareHtmlWriteReply to model CL/Messages_model - Changed public method sendReply of model CL/Messages_model - Added new private method _getReplyBody to model CL/Messages_model - Changed method _personLog of model CL/Messages_model to manage not authenticated users --- application/controllers/ViewMessage.php | 107 ++-------- application/libraries/MessageLib.php | 1 + application/models/CL/Messages_model.php | 183 +++++++++++++----- .../models/system/MessageToken_model.php | 65 +------ application/models/system/Recipient_model.php | 3 +- .../{messageHTML.php => htmlRead.php} | 23 ++- .../views/system/messages/htmlWriteReply.php | 73 +++++++ .../views/system/messages/messageForm.php | 81 -------- .../system/messages/messageReplySent.php | 103 ---------- .../system/messages/messageWriteReply.php | 63 ------ 10 files changed, 242 insertions(+), 460 deletions(-) rename application/views/system/messages/{messageHTML.php => htmlRead.php} (87%) create mode 100644 application/views/system/messages/htmlWriteReply.php delete mode 100644 application/views/system/messages/messageForm.php delete mode 100644 application/views/system/messages/messageReplySent.php delete mode 100644 application/views/system/messages/messageWriteReply.php diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index 3c22c8977..9c6fc4c4e 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -16,14 +16,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); /** * Handles sending messages with token - * NOTE: in this controller is not possible to include/call everything - * that automatically call the authentication system, like the most of models or libraries + * NOTE: it extends FHC_Controller instead of Auth_Controller because authentication is not needed */ class ViewMessage extends FHC_Controller { - /** - * API constructor - */ public function __construct() { parent::__construct(); @@ -32,121 +28,48 @@ class ViewMessage extends FHC_Controller $this->config->load('message'); // Load model MessageToken_model, not calling the authentication system - $this->load->model('system/MessageToken_model', 'MessageTokenModel'); $this->load->model('CL/Messages_model', 'CLMessagesModel'); } /** - * Using the MessageTokenModel instead of MessageLib to allow - * viewing the message without prompting the login + * Display a message in read mode only using the specified token */ public function toHTML($token) { - $msg = $this->MessageTokenModel->getMessageByToken($token); - - if ($msg->error) - { - show_error(getData($msg)); - } - - if (is_array(getData($msg)) && count(getData($msg)) > 0) - { - $setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token); - - if (isError($setReadMessageStatusByToken)) - { - show_error($msg->$setReadMessageStatusByToken); - } - - $sender_id = getData($msg)[0]->sender_id; - $receiver_id = getData($msg)[0]->receiver_id; - $sender = $this->MessageTokenModel->getSenderData($sender_id); - - // To decide how to change the redirection - $isEmployee = $this->MessageTokenModel->isEmployee($receiver_id); - if (!is_bool($isEmployee) && isError($isEmployee)) - { - show_error($isEmployee); - } - - if($this->config->item('redirect_view_message_url') != '') - $href = $this->config->item('message_server').$this->config->item('redirect_view_message_url').$token; - else - $href = ''; - - $data = array ( - 'sender_id' => $sender_id, - 'sender' => getData($sender)[0], - 'message' => getData($msg)[0], - 'isEmployee' => $isEmployee, - 'href' => $href - ); - - $this->load->view('system/messages/messageHTML.php', $data); - } + // Loads the view to read a received message using its token as identifier + $this->load->view('system/messages/htmlRead', $this->CLMessagesModel->prepareHtmlRead($token)); } /** - * write the reply + * Write a reply message to a received one using its token as identifier */ public function writeReply() { - $token = $this->input->get('token'); + $token = $this->input->get('token'); // gets received message token - if (isEmptyString($token)) - { - show_error('No token supplied'); - } - - $msg = null; - - // Get message data if possible - $msg = $this->MessageTokenModel->getMessageByToken($token); - if (!hasData($msg)) - { - show_error('No message found'); - } - - $msg = getData($msg)[0]; - - // Get variables - $receiverData = $this->MessageTokenModel->getPersonData($msg->sender_id); - if (!hasData($receiverData)) - { - show_error('No sender found'); - } - - $data = array ( - 'receivers' => getData($receiverData), - 'message' => $msg, - 'token' => $token - ); - - $this->load->view('system/messages/messageWriteReply', $data); + // Loads the view to write a reply message + $this->load->view('system/messages/htmlWriteReply', $this->CLMessagesModel->prepareHtmlWriteReply($token)); } /** - * Send a reply + * Send a reply message (no templates are used) */ public function sendReply() { $subject = $this->input->post('subject'); $body = $this->input->post('body'); - $persons = $this->input->post('persons'); + $receiver_id = $this->input->post('receiver_id'); $relationmessage_id = $this->input->post('relationmessage_id'); $token = $this->input->post('token'); - if (!isset($relationmessage_id) || $relationmessage_id == '' || !isset($token) || $token == '') + $sendReply = $this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token); + if (isSuccess($sendReply)) { - show_error('Error while sending reply'); + $this->load->view('system/messages/htmlSuccess'); } - - $sendReply = $this->CLMessagesModel->sendReply($subject, $body, $persons, $relationmessage_id, $token); - if (isError($sendReply)) + else { - show_error(getData($sendReply)); + $this->load->view('system/messages/htmlError'); } - - $this->load->view('system/messages/messageReplySent'); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 7bf6b7518..206aeed87 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -13,6 +13,7 @@ class MessageLib const CFG_MESSAGE_SERVER = 'message_server'; const CFG_MESSAGE_HTML_VIEW_URL = 'message_html_view_url'; const CFG_OU_RECEIVERS = 'ou_receivers'; + const CFG_REDIRECT_VIEW_MESSAGE_URL = 'redirect_view_message_url'; // Templates names const NOTICE_TEMPLATE_HTML = 'MessageMailHTML'; diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 05eaa8b16..33bc90e80 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -8,7 +8,9 @@ class Messages_model extends CI_Model { const REPLY_SUBJECT_PREFIX = 'Re: '; - const REPLY_BODY_PREFIX = '

-------------------------------------------------------------------------------'; + const REPLY_BODY_FORMAT = '

On %s %s %s wrote:
%s
'; + + const NO_AUTH_UID = 'online'; // hard coded uid if no authentication is performed /** * Constructor @@ -34,6 +36,87 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Public methods + /** + * Prepares data for the view system/messages/htmlRead using a token that identifies a single message + */ + public function prepareHtmlRead($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('No message found with the given token'); + + $message = getData($messageResult)[0]; // Found message data + + // Set message as read + $srmsbtResult = $this->MessageTokenModel->setReadMessageStatusByToken($token); + if (isError($srmsbtResult)) show_error(getData($srmsbtResult)); + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + // Check if the receiver is an employee + $isEmployee = false; // not by default + $isEmployeeResult = $this->MessageTokenModel->isEmployee($message->receiver_id); + if (isError($isEmployeeResult)) show_error(getData($isEmployeeResult)); + if (hasData($isEmployeeResult)) $isEmployee = true; + + // If the sender is an employee and are present configurations to reply + $hrefReply = ''; + if ($isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) + { + $hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER). + $this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL). + $token; + } + + return array ( + 'sender' => $sender, + 'message' => $message, + 'hrefReply' => $hrefReply + ); + } + + /** + * Prepares data for the view system/messages/htmlWriteReply using a token that identifies a single message + */ + public function prepareHtmlWriteReply($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + if (!hasData($messageResult)) show_error('No message found with the given token'); + + $message = getData($messageResult)[0]; // Found message data + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = $this->_getReplyBody($message->body, $sender->vorname, $sender->nachname, $message->sent); + + return array ( + 'receiver' => $sender->vorname.' '.$sender->nachname, // yep! the sender of the sent message is the receiver of the reply message + 'subject' => $replySubject, + 'body' => $replyBody, + 'receiver_id' => $message->sender_id, + 'relationmessage_id' => $message->message_id, + 'token' => $token + ); + } + /** * Prepares data for the view system/messages/htmlWriteTemplate using person ids as main parameter * Wrap method to _prepareHtmlWriteTemplate @@ -158,62 +241,45 @@ class Messages_model extends CI_Model } /** - * Send a reply to a message accessed using a token + * Send a reply to a single recipient for a message identified by a token (no templates are used) */ - public function sendReply($subject, $body, $persons, $relationmessage_id, $token) + public function sendReply($receiver_id, $subject, $body, $relationmessage_id, $token) { - $relationmsg = $this->MessageTokenModel->getMessageByToken($token); - if (!hasData($relationmsg) || $relationmessage_id !== getData($relationmsg)[0]->message_id) + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($receiver_id); + if (isError($senderResult)) show_error(getData($senderResult)); + if (!hasData($senderResult)) show_error('No sender information found'); + + $sender = getData($senderResult)[0]; // Found sender data + + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error(getData($messageResult)); + // Security check! It is possible to reply only to a received message!! + if (!hasData($messageResult) || $relationmessage_id != getData($messageResult)[0]->message_id) { - show_error('Error while sending reply'); + show_error('An error occurred while sending your message, please contact the site administrator'); } - // Get sender (receiver of previous msg) - $sender_id = getData($relationmsg)[0]->receiver_id; + $sender_id = getData($messageResult)[0]->receiver_id; - // Get message data of persons - $data = $this->MessageTokenModel->getPersonData($persons); - if (hasData($data)) - { - for ($i = 0; $i < count(getData($data)); $i++) - { - $dataArray = (array)getData($data)[$i]; + $message = $this->messagelib->sendMessageUser( + $receiver_id, // receiverPersonId + $subject, // subject + $body, // body + $sender_id, // sender_id, the receiver of the previous message is the sender of the current one + null, // senderOU + $relationmessage_id, // relationmessage_id + MSG_PRIORITY_NORMAL // priority + ); - $msg = $this->messagelib->sendMessageUser( - $dataArray['person_id'], // receiverPersonId - $subject, // subject - $body, // body - $sender_id, // sender_id - null, // senderOU - $relationmessage_id, // relationmessage_id - MSG_PRIORITY_NORMAL // priority - ); + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); - if (isError($msg)) return $msg; + // Write log entry + $personLog = $this->_personLog($sender_id, $receiver_id, getData($message)[0]); + if (isError($personLog)) return $personLog; - // Logs person data - $personLog = $this->personloglib->log( - $sender_id, - 'Action', - array( - 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$dataArray['person_id'].', messageid '.getData($msg), - 'success' => 'true' - ), - 'kommunikation', - 'core', - null, - 'online' - ); - - // Unpark bewerber after he sends message - $personLog = $this->personloglib->unPark($sender_id); - - if (isError($personLog)) return $personLog; - } - } - - return success('Reply sent'); + return success('Messages sent successfully'); } //------------------------------------------------------------------------------------------------------------------ @@ -339,7 +405,11 @@ class Messages_model extends CI_Model */ private function _personLog($sender_id, $receiver_id, $message_id) { - $_personLog = $this->personloglib->log( + // In case the message is accessed via ViewMessage controller -> no authentication + // If no authentication is performed then use a hard coded uid + $loggedUserUID = function_exists('getAuthUID') ? getAuthUID() : self::NO_AUTH_UID; + + return $this->personloglib->log( $receiver_id, 'Action', array( @@ -350,10 +420,19 @@ class Messages_model extends CI_Model 'kommunikation', 'core', null, - getAuthUID() + $loggedUserUID ); + } - return $_personLog; + /** + * + */ + private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate) + { + return sprintf( + self::REPLY_BODY_FORMAT, + date_format(date_create($sentDate), 'd.m.Y H:i'), $receiverName, $receiverSurname, $body + ); } /** @@ -407,7 +486,7 @@ class Messages_model extends CI_Model $message = getData($messageResult)[0]; $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; - $replyBody = self::REPLY_BODY_PREFIX.$message->body; + $replyBody = $this->_getReplyBody($message->body, $receiver->Vorname, $receiver->Nachname, $message->sent); $relationmessage = ''; } diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index 2398bf57a..bdb6136ac 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -152,45 +152,7 @@ class MessageToken_model extends DB_Model LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE p.person_id = ?'; - $result = $this->db->query($sql, array($person_id)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } - } - - /** - * Get data of a person - */ - public function getPersonData($person_id) - { - $sql = 'SELECT person_id, - vorname as "Vorname", - nachname as "Nachname", - anrede as "Anrede", - titelpost as "TitelPost", - titelpre as "TitelPre", - vornamen as "Vornamen" - FROM public.tbl_person - WHERE person_id %s ?'; - - $result = $this->db->query(sprintf($sql, is_array($person_id) ? 'IN' : '='), array($person_id)); - - // If no errors occurred - if ($result) - { - return success($result->result()); - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array($person_id)); } /** @@ -205,30 +167,7 @@ class MessageToken_model extends DB_Model WHERE p.person_id = ? AND b.aktiv = TRUE'; - $result = $this->db->query($sql, array($person_id)); - - // If no errors occurred - if ($result) - { - // If data are present - if (is_array($result->result()) && count($result->result()) > 0) - { - $personresults = $result->result(); - $person = $personresults[0]; - - // If it is an employee - if ($person->mitarbeiter_uid != null) - { - return true; - } - } - - return false; - } - else - { - return error($this->db->error()); - } + return $this->execQuery($sql, array($person_id)); } /** diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 3a30bba1f..65812580e 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -25,7 +25,8 @@ class Recipient_model extends DB_Model ks.kontakt, p.nachname, p.vorname, - b.uid + b.uid, + mr.sent FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) INNER JOIN public.tbl_person p ON (mm.person_id = p.person_id) LEFT JOIN public.tbl_benutzer b ON (mr.person_id = b.person_id) diff --git a/application/views/system/messages/messageHTML.php b/application/views/system/messages/htmlRead.php similarity index 87% rename from application/views/system/messages/messageHTML.php rename to application/views/system/messages/htmlRead.php index 0ae6c3866..97751f96f 100644 --- a/application/views/system/messages/messageHTML.php +++ b/application/views/system/messages/htmlRead.php @@ -1,4 +1,4 @@ - load->view( 'templates/FHC-Header', array( @@ -10,7 +10,7 @@ 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageReply.css') ) ); - ?> +?>
@@ -24,7 +24,9 @@
+ subject; ?> +
@@ -33,7 +35,9 @@ From: @@ -41,7 +45,9 @@ Subject: @@ -49,7 +55,9 @@ Message:
+ vorname.' '.$sender->nachname; ?> +
+ subject; ?> +
+ body; ?> +
@@ -57,11 +65,15 @@ @@ -72,4 +84,5 @@
- load->view("templates/FHC-Footer"); ?> \ No newline at end of file + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php new file mode 100644 index 000000000..fe8145613 --- /dev/null +++ b/application/views/system/messages/htmlWriteReply.php @@ -0,0 +1,73 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'MessageReply', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'tinymce' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ + + + + +
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageForm.php b/application/views/system/messages/messageForm.php deleted file mode 100644 index d1436a492..000000000 --- a/application/views/system/messages/messageForm.php +++ /dev/null @@ -1,81 +0,0 @@ -
-
-
- -
-
- 1 && $i % 10 == 0) - { - echo '
'; - } - echo $receiver->Vorname." ".$receiver->Nachname."; "; - } - ?> -
-
-
-
-
-
- -
  - subject; - } - ?> -
- -
-
-
-
-
-
- -

On '.date_format(date_create($message->sent), 'd.m.Y H:i').' '.$receivers[0]->Vorname.' '.$receivers[0]->Nachname.' wrote:'.'
'; - $body .= '
'; - $body .= $message->body.'
'; - } - ?> - -
- -
-
- - -
-
- -
-
-
-
- -
-
\ No newline at end of file diff --git a/application/views/system/messages/messageReplySent.php b/application/views/system/messages/messageReplySent.php deleted file mode 100644 index 88fc945b0..000000000 --- a/application/views/system/messages/messageReplySent.php +++ /dev/null @@ -1,103 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'MessageSent', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') - ) - ); -?> - - -
-
-
- -
- -
- -
- -
- -
- -
- -
-
-
-
-
-
- Message sent successfully! -
-
- Nachricht erfolgreich versandt! -
-
-
-
-
-
- - Thank you for your message. - - - We will get back to you shortly. - -
-
- - Herzlichen Dank für Ihre Nachricht. - - - Wir werden uns schnellstmöglich um Ihr Anliegen kümmern. - -
-
- -
- -
-
- You can safely close this window. -
-
- Sie können dieses Fenster schließen. -
-
-
-
-
- Your InfoCenter@FHTW Team -
-
- Ihr InfoCenter@FHTW Team -
-
-
-
-
-
-
-

- Fachhochschule Technikum Wien | University of Applied Sciences Technikum Wien -
Hoechstaedtplatz 6, 1200 Wien, AUSTRIA -
www.technikum-wien.at -

-
-
-
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/messageWriteReply.php b/application/views/system/messages/messageWriteReply.php deleted file mode 100644 index 344871b2d..000000000 --- a/application/views/system/messages/messageWriteReply.php +++ /dev/null @@ -1,63 +0,0 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'MessageReply', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'tinymce' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') - ) -); -?> - - -
-
-
-
-
- -
-
-
- load->view('system/messages/messageForm.php'); - - for ($i = 0; $i < count($receivers); $i++) - { - $receiver = $receivers[$i]; - $receiverid = $receiver->person_id; - $fieldname = 'persons[]'; - - echo ''."\n"; - } - ?> - - - - - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> From b364cfae06348790fec1e7b84fd3ba8917e0b65a Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 15:29:17 +0200 Subject: [PATCH 008/157] - Moved controllers FASMessages and Messages to system/messages/ - Adapted code to use the new path --- application/controllers/system/{ => messages}/FASMessages.php | 0 application/controllers/system/{ => messages}/Messages.php | 0 application/models/CL/Messages_model.php | 2 +- application/views/system/infocenter/stammdaten.php | 2 +- application/views/system/messages/htmlWriteTemplate.php | 2 +- content/fasoverlay.js.php | 2 +- content/messages.js.php | 4 ++-- public/js/infocenter/infocenterDetails.js | 2 +- public/js/infocenter/infocenterPersonDataset.js | 2 +- public/js/infocenter/messageList.js | 2 +- public/js/messaging/messageWrite.js | 4 ++-- 11 files changed, 11 insertions(+), 11 deletions(-) rename application/controllers/system/{ => messages}/FASMessages.php (100%) rename application/controllers/system/{ => messages}/Messages.php (100%) diff --git a/application/controllers/system/FASMessages.php b/application/controllers/system/messages/FASMessages.php similarity index 100% rename from application/controllers/system/FASMessages.php rename to application/controllers/system/messages/FASMessages.php diff --git a/application/controllers/system/Messages.php b/application/controllers/system/messages/Messages.php similarity index 100% rename from application/controllers/system/Messages.php rename to application/controllers/system/messages/Messages.php diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 33bc90e80..302e51340 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -283,7 +283,7 @@ class Messages_model extends CI_Model } //------------------------------------------------------------------------------------------------------------------ - // Public methods called by controller system/Messages + // Public methods called by controller system/messages/Messages /** * Returns an object that represent a template store in database diff --git a/application/views/system/infocenter/stammdaten.php b/application/views/system/infocenter/stammdaten.php index ebd812c6a..a80439bfe 100644 --- a/application/views/system/infocenter/stammdaten.php +++ b/application/views/system/infocenter/stammdaten.php @@ -113,7 +113,7 @@ - +
diff --git a/content/fasoverlay.js.php b/content/fasoverlay.js.php index 3089b6032..2fafb5ea8 100644 --- a/content/fasoverlay.js.php +++ b/content/fasoverlay.js.php @@ -1250,7 +1250,7 @@ function MessageNew() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/writeTemplate/' + person_id; ?>; + var action = 'index.ci.php/system/messages/FASMessages/writeTemplate/' + person_id; ?>; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/content/messages.js.php b/content/messages.js.php index 4094cddb8..3e72748ec 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -104,7 +104,7 @@ function MessagesNewMessage() { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - var action = 'index.ci.php/system/FASMessages/writeTemplate'; + var action = 'index.ci.php/system/messages/FASMessages/writeTemplate'; 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 = 'index.ci.php/system/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; + var action = 'index.ci.php/system/messages/FASMessages/writeReplyTemplate/' + MessageId + '/' + RecipientID; openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 3edb9d42d..60da695d2 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -629,7 +629,7 @@ var InfocenterDetails = { sendFreigabeMessage: function(prestudentid, vorlage_kurzbz, msgvars) { FHC_AjaxClient.ajaxCallPost( - 'system/Messages/sendExplicitTemplateJson', + 'system/messages/Messages/sendExplicitTemplateJson', { "prestudents": prestudentid, "vorlage_kurzbz": vorlage_kurzbz, diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index c5ea99dfc..07163ccee 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -26,7 +26,7 @@ var InfocenterPersonDataset = { appendTableActionsHtml: function() { var currurl = window.location.href; - var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/Messages/writeTemplate"; + var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/system/messages/Messages/writeTemplate"; var formHtml = ''; $("#datasetActionsTop").before(formHtml); diff --git a/public/js/infocenter/messageList.js b/public/js/infocenter/messageList.js index 85d5ad603..6146c7639 100644 --- a/public/js/infocenter/messageList.js +++ b/public/js/infocenter/messageList.js @@ -54,7 +54,7 @@ var MessageList = { var recid = id.substr(id.indexOf('_') + 1); FHC_AjaxClient.ajaxCallGet( - 'system/Messages/getMessageFromIds', + 'system/messages/Messages/getMessageFromIds', { "msg_id": msgid, "receiver_id": recid diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index c496b269d..4146b7008 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -20,7 +20,7 @@ function tinymcePreviewSetContent() function parseMessageText(receiver_id, text) { FHC_AjaxClient.ajaxCallGet( - "system/Messages/parseMessageText", + "system/messages/Messages/parseMessageText", { person_id: receiver_id, text: text @@ -111,7 +111,7 @@ $(document).ready(function () if (vorlage_kurzbz != '') { FHC_AjaxClient.ajaxCallGet( - "system/Messages/getVorlage", + "system/messages/Messages/getVorlage", { vorlage_kurzbz: vorlage_kurzbz }, From 1cb9c28f7dfecb35559635188372df7234824879 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 19 Jun 2019 17:53:51 +0200 Subject: [PATCH 009/157] - Added new controller system/messages/MessageClient used to read and write messages using a new GUI based on ajax and tabulator - system/messages/MessageClient currently has only two methods: read and listMessages - Added new view system/messages/ajaxRead.php used for the GUI to read messages - Added new parameters to templates/FHC-Header: tabulator and momentjs - Added new packages to composer: tabulator and momentjs --- .../system/messages/MessageClient.php | 39 +++++++++++++++++++ .../controllers/system/messages/Messages.php | 6 +-- .../views/system/messages/ajaxRead.php | 20 ++++++++++ .../views/system/messages/htmlRead.php | 2 +- .../views/system/messages/htmlWriteReply.php | 2 +- .../system/messages/htmlWriteTemplate.php | 2 +- application/views/templates/FHC-Header.php | 30 ++++++++------ composer.json | 12 ++++++ composer.lock | 25 ++++++++---- 9 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 application/controllers/system/messages/MessageClient.php create mode 100644 application/views/system/messages/ajaxRead.php diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php new file mode 100644 index 000000000..3000e6b91 --- /dev/null +++ b/application/controllers/system/messages/MessageClient.php @@ -0,0 +1,39 @@ + array('basis/message:r'), + 'listMessages' => array('basis/message:r') + ) + ); + + // Loads model CLMessagesModel which contains the GUI logic + $this->load->model('CL/Messages_model', 'CLMessagesModel'); + } + + /** + * Starts the GUI used to read all the personal messages + */ + public function read() + { + // Loads the view to read messages + $this->load->view('system/messages/ajaxRead'); + } + + /** + * Returns JSON that that contains all the received messages by the currently logged user + * This JSON structure is nested data used by tabulator + */ + public function listMessages() + { + $jsonNestedData = $this->CLMessagesModel->prepareAjaxRead(); + + $this->outputJson($jsonNestedData); + } +} diff --git a/application/controllers/system/messages/Messages.php b/application/controllers/system/messages/Messages.php index 20fed38ad..869caec39 100644 --- a/application/controllers/system/messages/Messages.php +++ b/application/controllers/system/messages/Messages.php @@ -30,7 +30,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - HTML output + // Methods with HTML output /** * Initialize all the parameters used by view system/messages/htmlWriteTemplate @@ -71,7 +71,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by this controller and FASMessages (view system/messages/htmlWriteTemplate) + // Methods with JSON output called by this controller and FASMessages (view system/messages/htmlWriteTemplate) /** * Returns an object that represent a template store in database @@ -98,7 +98,7 @@ class Messages extends Auth_Controller } // ----------------------------------------------------------------------------------------------------------------- - // Public methods - JSON output - called by infocenter + // Methods with JSON output called by infocenter /** * Outputs message data for a message (identified my msg id and receiver id) in JSON format diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php new file mode 100644 index 000000000..97f16ce3b --- /dev/null +++ b/application/views/system/messages/ajaxRead.php @@ -0,0 +1,20 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read personal messages', + 'jquery' => true, + 'bootstrap' => true, + 'momentjs' => true, + 'tabulator' => true, + 'ajaxlib' => true, + 'customJSs' => array('public/js/messaging/messageClient.js') + ) + ); +?> + +
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 97751f96f..01a5421ac 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageSent', + 'title' => 'Read a message', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index fe8145613..b9932148b 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'MessageReply', + 'title' => 'Reply to a message', 'jquery' => true, 'bootstrap' => true, 'fontawesome' => true, diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index f46138e28..7132cfb36 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -2,7 +2,7 @@ $this->load->view( 'templates/FHC-Header', array( - 'title' => 'Write a message', + 'title' => 'Write a new message or reply using templates', 'jquery' => true, 'jqueryui' => true, 'bootstrap' => true, diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 6b9afd6b9..7b75e2ad7 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -25,10 +25,12 @@ $jqueryui = isset($jqueryui) ? $jqueryui : false; $jquerycheckboxes = isset($jquerycheckboxes) ? $jquerycheckboxes : false; $jquerytreetable = isset($jquerytreetable) ? $jquerytreetable : false; + $momentjs = isset($momentjs) ? $momentjs : false; $navigationwidget = isset($navigationwidget) ? $navigationwidget : false; $pivotui = isset($pivotui) ? $pivotui : false; $sbadmintemplate = isset($sbadmintemplate) ? $sbadmintemplate : false; $tablesorter = isset($tablesorter) ? $tablesorter : false; + $tabulator = isset($tabulator) ? $tabulator : false; $tinymce = isset($tinymce) ? $tinymce : false; $widgets = isset($widgets) ? $widgets : false; ?> @@ -61,10 +63,7 @@ if ($fontawesome === true) generateCSSsInclude('vendor/components/font-awesome/css/font-awesome.min.css'); // PivotUI CSS - if ($pivotui === true) - { - generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); - } + if ($pivotui === true) generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); // SB Admin 2 template CSS if ($sbadmintemplate === true) @@ -80,6 +79,9 @@ generateCSSsInclude('vendor/mottie/tablesorter/dist/css/jquery.tablesorter.pager.min.css'); } + // Tabulator CSS + if ($tabulator === true) generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + // -------------------------------------------------------------------------------------------------------- // From public folder @@ -101,6 +103,7 @@ // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS + // -------------------------------------------------------------------------------------------------------- // Javascripts @@ -126,10 +129,7 @@ } // jQuery checkboxes - if ($jquerycheckboxes === true) - { - generateJSsInclude('vendor/rmariuzzo/jquery-checkboxes/dist/jquery.checkboxes-1.0.7.min.js'); - } + if ($jquerycheckboxes === true) generateJSsInclude('vendor/rmariuzzo/jquery-checkboxes/dist/jquery.checkboxes-1.0.7.min.js'); // Bootstrap JS if ($bootstrap === true) generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); @@ -138,12 +138,17 @@ // NOTE: keep it after jQuery includes if ($jquerytreetable === true) generateJSsInclude('vendor/ludo/jquery-treetable/jquery.treetable.js'); - // PivotUI CSS - if ($pivotui === true) + // MomentJS + if ($momentjs === true) { - generateJSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.js'); + generateJSsInclude('vendor/moment/momentjs/min/moment.min.js'); + generateJSsInclude('vendor/moment/momentjs/locale/de-at.js'); + generateJSsInclude('vendor/moment/momentjs/locale/en-ie.js'); } + // PivotUI JS + if ($pivotui === true) generateJSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.js'); + // Table sorter JS if ($tablesorter === true) { @@ -152,6 +157,9 @@ generateJSsInclude('vendor/mottie/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js'); } + // Tabulator JS + if ($tabulator === true) generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); diff --git a/composer.json b/composer.json index c6816e075..5003468c2 100644 --- a/composer.json +++ b/composer.json @@ -162,6 +162,17 @@ } } }, + { + "type": "package", + "package": { + "name": "moment/momentjs", + "version": "2.24.0", + "dist": { + "url": "https://github.com/moment/moment/archive/2.24.0.zip", + "type": "zip" + } + } + }, { "type": "package", "package": { @@ -263,6 +274,7 @@ "ludo/jquery-treetable": "^3.2", + "moment/momentjs": "2.24.0", "michelf/php-markdown": "1.5.0", "ml/json-ld": "1.*", "mottie/tablesorter": "^2.29", diff --git a/composer.lock b/composer.lock index f328832e6..85e506cc4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "df6059a4bee974ecf5447aad8a8b1e15", - "content-hash": "2111c73853dbc47938c3f31dbc349883", + "hash": "e3de1eee238160400fb63f68735b4144", + "content-hash": "5b71e8a3c356d52e43d788eb6f018151", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -1095,6 +1095,17 @@ ], "time": "2018-11-18 20:26:18" }, + { + "name": "moment/momentjs", + "version": "2.24.0", + "dist": { + "type": "zip", + "url": "https://github.com/moment/moment/archive/2.24.0.zip", + "reference": null, + "shasum": null + }, + "type": "library" + }, { "name": "mottie/tablesorter", "version": "v2.31.1", @@ -2191,16 +2202,16 @@ }, { "name": "twig/twig", - "version": "v1.42.1", + "version": "v1.42.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "671347603760a88b1e7288aaa9378f33687d7edf" + "reference": "21707d6ebd05476854805e4f91b836531941bcd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/671347603760a88b1e7288aaa9378f33687d7edf", - "reference": "671347603760a88b1e7288aaa9378f33687d7edf", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/21707d6ebd05476854805e4f91b836531941bcd4", + "reference": "21707d6ebd05476854805e4f91b836531941bcd4", "shasum": "" }, "require": { @@ -2253,7 +2264,7 @@ "keywords": [ "templating" ], - "time": "2019-06-04 11:31:08" + "time": "2019-06-18 15:35:16" }, { "name": "zetacomponents/base", From 27ccd086ac18e59513dd91cd713a56203d3ffd5d Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 24 Jun 2019 17:32:31 +0200 Subject: [PATCH 010/157] - Added new functions getAuthFirstname and getAuthSurname to helper hlp_authentication_helper - Added methods getReceivedMessages and getSentMessages to model system/Recipient_model.php - Added jqueryui and dialoglib to view system/messages/ajaxRead - Added method prepareAjaxRead to model CL/Messages_model - Removed private method _getAuthUser from model CL/Messages_model - Adapted code in model CL/Messages_model to use functions isLogged and getAuthPersonId --- .../helpers/hlp_authentication_helper.php | 29 +++++- application/models/CL/Messages_model.php | 95 +++++++++++++------ application/models/system/Recipient_model.php | 59 ++++++++++++ .../views/system/messages/ajaxRead.php | 2 + public/js/messaging/messageClient.js | 53 +++++++++++ 5 files changed, 210 insertions(+), 28 deletions(-) create mode 100644 public/js/messaging/messageClient.js diff --git a/application/helpers/hlp_authentication_helper.php b/application/helpers/hlp_authentication_helper.php index 740823ff9..459c7fb80 100644 --- a/application/helpers/hlp_authentication_helper.php +++ b/application/helpers/hlp_authentication_helper.php @@ -20,7 +20,6 @@ function getAuthPersonId() return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_PERSON_ID} : null; } - /** * If the user is NOT logged then a null value is returned. * If the user is alredy logged, then it is possible to access to the authentication object @@ -34,3 +33,31 @@ function getAuthUID() return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME} : null; } + +/** + * If the user is NOT logged then a null value is returned. + * If the user is alredy logged, then it is possible to access to the authentication object + * that contains the firstname of the logged user + * NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool), + * then it is possible that the firstname is null! + */ +function getAuthFirstname() +{ + $ci =& get_instance(); // get CI instance + + return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_NAME} : null; +} + +/** + * If the user is NOT logged then a null value is returned. + * If the user is alredy logged, then it is possible to access to the authentication object + * that contains the surname of the logged user + * NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool), + * then it is possible that the surname is null! + */ +function getAuthSurname() +{ + $ci =& get_instance(); // get CI instance + + return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_SURNAME} : null; +} diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 302e51340..21cba1d68 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -36,6 +36,67 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Public methods + /** + * + */ + public function prepareAjaxRead() + { + $jsonNestedData = error('Something did not go as it should'); + + $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + + if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + + $receivedMessagesResult = $this->RecipientModel->getReceivedMessages(getAuthPersonId()); + if (isError($receivedMessagesResult)) return $receivedMessagesResult; + + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); + if (isError($sentMessagesResult)) return $sentMessagesResult; + + if (hasData($receivedMessagesResult)) + { + $jsonArray = array(); + + foreach (getData($receivedMessagesResult) as $receivedMessage) + { + $jsonRecord = new stdClass(); + $jsonRecord->subject = $receivedMessage->subject; + $jsonRecord->from = $receivedMessage->vorname.' '.$receivedMessage->nachname; + $sentDate = new DateTime($receivedMessage->sent); + $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonRecord->status = $receivedMessage->status; + + if (hasData($sentMessagesResult)) + { + $jsonChildrenArray = array(); + + foreach (getData($sentMessagesResult) as $sentMessage) + { + if ($receivedMessage->relationmessage_id == $sentMessage->message_id) + { + $jsonChildrenRecord = new stdClass(); + $jsonChildrenRecord->subject = $sentMessage->subject; + $jsonChildrenRecord->from = $loggedUserName; + $sentDate = new DateTime($sentMessage->sent); + $jsonChildrenRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonChildrenRecord->status = $sentMessage->status; + + $jsonChildrenArray[] = $jsonChildrenRecord; + } + } + + if (!isEmptyArray($jsonChildrenArray)) $jsonRecord->_children = $jsonChildrenArray; + } + + $jsonArray[] = $jsonRecord; + } + + $jsonNestedData = success(json_encode($jsonArray)); + } + + return $jsonNestedData; + } + /** * Prepares data for the view system/messages/htmlRead using a token that identifies a single message */ @@ -148,11 +209,8 @@ class Messages_model extends CI_Model public function sendImplicitTemplate($persons, $subject, $body, $relationmessage_id = null) { // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // Retrieves message vars data for the given user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($persons); @@ -194,11 +252,8 @@ class Messages_model extends CI_Model public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars) { // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // Retrieves message vars data for the given user/s $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents); @@ -356,17 +411,6 @@ class Messages_model extends CI_Model //------------------------------------------------------------------------------------------------------------------ // Private methods - /** - * Returns the current authenticated person object - */ - private function _getAuthUser() - { - $this->load->model('person/Person_model', 'PersonModel'); - $authUser = $this->PersonModel->getByUid(getAuthUID()); - - return $authUser; - } - /** * Replaces data array keys to a lowercase string with underscores instead of spaces */ @@ -407,7 +451,7 @@ class Messages_model extends CI_Model { // In case the message is accessed via ViewMessage controller -> no authentication // If no authentication is performed then use a hard coded uid - $loggedUserUID = function_exists('getAuthUID') ? getAuthUID() : self::NO_AUTH_UID; + $loggedUserUID = isLogged() ? getAuthUID() : self::NO_AUTH_UID; return $this->personloglib->log( $receiver_id, @@ -508,11 +552,8 @@ class Messages_model extends CI_Model // --------------------------------------------------------------------------------------- // Retrieves the sender id - $authUser = $this->_getAuthUser(); - if (isError($authUser)) show_error(getData($authUser)); - if (!hasData($authUser)) show_error('The current logged user person_id is not defined'); - - $sender_id = getData($authUser)[0]->person_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined'); // --------------------------------------------------------------------------------------- // Organisation units and a boolean (true if the sender is administrator) are used to get the templates diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 65812580e..8d1162de5 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -299,4 +299,63 @@ class Recipient_model extends DB_Model return $this->execQuery($sql, $parametersArray); } + + /** + * + */ + public function getReceivedMessages($person_id) + { + $sql = 'SELECT mr.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + p.vorname, + p.nachname, + MAX(ms.status) AS status + FROM public.tbl_msg_recipient mr + JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mm.person_id) + WHERE mr.person_id = ? + AND mr.sent IS NOT NULL + AND mr.sentinfo IS NULL + GROUP BY mr.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + p.vorname, + p.nachname + ORDER BY mr.sent DESC'; + + return $this->execQuery($sql, array($person_id)); + } + + /** + * + */ + public function getSentMessages($person_id) + { + $sql = 'SELECT mm.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent, + MAX(ms.status) AS status + FROM public.tbl_msg_message mm + JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + WHERE mm.person_id = ? + AND mr.sent IS NOT NULL + AND mr.sentinfo IS NULL + GROUP BY mm.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mr.sent + ORDER BY mr.sent DESC'; + + return $this->execQuery($sql, array($person_id)); + } } diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 97f16ce3b..e3ff133f0 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -4,10 +4,12 @@ array( 'title' => 'Read personal messages', 'jquery' => true, + 'jqueryui' => true, 'bootstrap' => true, 'momentjs' => true, 'tabulator' => true, 'ajaxlib' => true, + 'dialoglib' => true, 'customJSs' => array('public/js/messaging/messageClient.js') ) ); diff --git a/public/js/messaging/messageClient.js b/public/js/messaging/messageClient.js new file mode 100644 index 000000000..850777ea9 --- /dev/null +++ b/public/js/messaging/messageClient.js @@ -0,0 +1,53 @@ +/** + * + */ +$(document).ready(function () { + + FHC_AjaxClient.ajaxCallGet( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listMessages', + null, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.hasData(data)) + { + try + { + var jsonMessageLst = JSON.parse(FHC_AjaxClient.getData(data)); + + console.log(jsonMessageLst); + + var tableMessageLst = new Tabulator("#lstMessagesPanel", { + height: "400px", + data: jsonMessageLst, + dataTree: true, + dataTreeStartExpanded: true, + dataTreeElementColumn: "subject", + columns: [ + {title: "Subject", field: "subject", width: 700, responsive: 0}, + {title: "From", field: "from", width: 400}, + {title: "Date", field: "sent", sorter: "datetime", width: 150} + ], + rowClick: function(e, row) { + // TODO + } + }); + } + catch (syntaxError) + { + FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); + } + } + else + { + FHC_DialogLib.alertWarning("No message currently available"); + } + }, + errorCallback: function() { + + }, + veilTimeout: 300 + } + ); + +}); From 34dc82766acd3f28fb0e5cd77f6e5c306d7889cf Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 28 Jun 2019 19:01:25 +0200 Subject: [PATCH 011/157] - Renamed public/js/messaging/messageClient.js to public/js/messaging/read.js - Added new JS public/js/messaging/write.js used in view application/views/system/messages/ajaxWrite.php - Added new public method write, listReceivedMessages, listSentMessages and sendMessageToOU to controller system/messages/MessageClient.php - Removed private method _getReceiversByOekurzbz from MessageLib - Fixed method sendMessageOU of MessageLib - Added new public method prepareAjaxWrite to model CL/Messages_model - Fixed method prepareAjaxReadReceived of model CL/Messages_model - Added new public method prepareAjaxReadSent to model CL/Messages_model - Changed method CL/Messages_model->_personLog interface - Added new public method getOrganisationunitsByPersonId to crm/Prestudent_model - Added new public method getReceivedMessages to model system/Recipient_model - Changed getReceivedMessages method of model system/Recipient_model - Changed view system/messages/ajaxRead.php - Added new view system/messages/ajaxWrite.php --- .../system/messages/MessageClient.php | 43 +++++- application/libraries/MessageLib.php | 22 +-- application/models/CL/Messages_model.php | 131 ++++++++++++++---- application/models/crm/Prestudent_model.php | 16 +++ application/models/system/Recipient_model.php | 40 +++++- .../views/system/messages/ajaxRead.php | 15 +- .../views/system/messages/ajaxWrite.php | 71 ++++++++++ public/js/messaging/messageClient.js | 53 ------- public/js/messaging/messageWrite.js | 10 +- public/js/messaging/read.js | 116 ++++++++++++++++ public/js/messaging/write.js | 52 +++++++ 11 files changed, 449 insertions(+), 120 deletions(-) create mode 100644 application/views/system/messages/ajaxWrite.php delete mode 100644 public/js/messaging/messageClient.js create mode 100644 public/js/messaging/read.js create mode 100644 public/js/messaging/write.js diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 3000e6b91..1062202c1 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -8,8 +8,11 @@ class MessageClient extends Auth_Controller { parent::__construct( array( - 'read' => array('basis/message:r'), - 'listMessages' => array('basis/message:r') + 'read' => array('basis/person:r'), + 'write' => array('basis/person:r'), + 'listReceivedMessages' => array('basis/person:r'), + 'listSentMessages' => array('basis/person:r'), + 'sendMessageToOU' => array('basis/person:r') ) ); @@ -27,13 +30,39 @@ class MessageClient extends Auth_Controller } /** - * Returns JSON that that contains all the received messages by the currently logged user - * This JSON structure is nested data used by tabulator + * Starts the GUI used to write a personal message to an organisation unit */ - public function listMessages() + public function write() { - $jsonNestedData = $this->CLMessagesModel->prepareAjaxRead(); + // Loads the view to write a message + $this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite()); + } - $this->outputJson($jsonNestedData); + /** + * Returns JSON that that contains all the received messages by the currently logged user + */ + public function listReceivedMessages() + { + $this->outputJson($this->CLMessagesModel->prepareAjaxReadReceived()); + } + + /** + * Returns JSON that that contains all the sent messages by the currently logged user + */ + public function listSentMessages() + { + $this->outputJson($this->CLMessagesModel->prepareAjaxReadSent()); + } + + /** + * + */ + public function sendMessageToOU() + { + $receiverOU = $this->input->post('receiverOU'); + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); + + $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 206aeed87..18b958e14 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -128,7 +128,9 @@ class MessageLib // If the recipient is an organisation unit that would be possible to send the same message (same message id) // to the entire organisation unit (one to many functionality) // In this case the receiver id is a the one present in message configuration - $receivers = success(array($this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID))); + $receiver = new stdClass(); + $receiver->person_id = $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID); + $receivers = success(array($receiver)); // Send the message and return the result return $this->_sendMessage($receivers, $receiversOU, $subject, $body, $sender_id, $senderOU, $relationmessage_id, $priority, $multiPartMime); @@ -373,24 +375,6 @@ class MessageLib } } - /** - * Gets the receivers id that are enabled to read messages for that oe_kurzbz - */ - private function _getReceiversByOekurzbz($oe_kurzbz) - { - // Load Benutzerfunktion_model - $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); - // Join with table public.tbl_benutzer on field uid - $this->_ci->BenutzerfunktionModel->addJoin('public.tbl_benutzer', 'uid'); - // Get all the valid receivers id using the oe_kurzbz - $receivers = $this->_ci->BenutzerfunktionModel->loadWhere( - 'oe_kurzbz = '.$this->_ci->db->escape($oe_kurzbz). - ' AND funktion_kurzbz = '.$this->_ci->db->escape($this->_ci->config->item(self::CFG_OU_RECEIVERS)). - ' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))' - ); - return $receivers; - } - /** * Save a new message in DB */ diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 21cba1d68..5810487a9 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -28,9 +28,10 @@ class Messages_model extends CI_Model // Loads model MessageToken_model $this->load->model('system/MessageToken_model', 'MessageTokenModel'); - // Loads model Benutzerrolle_model $this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel'); + // Loads model Prestudent_model + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); } //------------------------------------------------------------------------------------------------------------------ @@ -39,20 +40,42 @@ class Messages_model extends CI_Model /** * */ - public function prepareAjaxRead() + public function prepareAjaxWrite() { - $jsonNestedData = error('Something did not go as it should'); + $ouResult = $this->PrestudentModel->getOrganisationunitsByPersonId(getAuthPersonId()); + + if (isError($ouResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + $ouOptions = ''; + + if (hasData($ouResult)) + { + foreach (getData($ouResult) as $ou) + { + $ouOptions .= sprintf("\n".'', $ou->oe_kurzbz, $ou->bezeichnung); + } + } + + return array('organisationUnitOptions' => $ouOptions); + } + + /** + * + */ + public function prepareAjaxReadReceived() + { + $jsonResult = error('Something did not go as it should'); $loggedUserName = getAuthFirstname().' '.getAuthSurname(); if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - $receivedMessagesResult = $this->RecipientModel->getReceivedMessages(getAuthPersonId()); + $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( + getAuthPersonId(), + $this->config->item(MessageLib::CFG_OU_RECEIVERS) + ); if (isError($receivedMessagesResult)) return $receivedMessagesResult; - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); - if (isError($sentMessagesResult)) return $sentMessagesResult; - if (hasData($receivedMessagesResult)) { $jsonArray = array(); @@ -60,41 +83,59 @@ class Messages_model extends CI_Model foreach (getData($receivedMessagesResult) as $receivedMessage) { $jsonRecord = new stdClass(); + $jsonRecord->message_id = $receivedMessage->message_id; $jsonRecord->subject = $receivedMessage->subject; + $jsonRecord->body = $receivedMessage->body; $jsonRecord->from = $receivedMessage->vorname.' '.$receivedMessage->nachname; $sentDate = new DateTime($receivedMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; - if (hasData($sentMessagesResult)) - { - $jsonChildrenArray = array(); + $jsonArray[] = $jsonRecord; + } - foreach (getData($sentMessagesResult) as $sentMessage) - { - if ($receivedMessage->relationmessage_id == $sentMessage->message_id) - { - $jsonChildrenRecord = new stdClass(); - $jsonChildrenRecord->subject = $sentMessage->subject; - $jsonChildrenRecord->from = $loggedUserName; - $sentDate = new DateTime($sentMessage->sent); - $jsonChildrenRecord->sent = $sentDate->format('d/m/Y H:i:s'); - $jsonChildrenRecord->status = $sentMessage->status; + $jsonResult = success(json_encode($jsonArray)); + } - $jsonChildrenArray[] = $jsonChildrenRecord; - } - } + return $jsonResult; + } - if (!isEmptyArray($jsonChildrenArray)) $jsonRecord->_children = $jsonChildrenArray; - } + /** + * + */ + public function prepareAjaxReadSent() + { + $jsonResult = error('Something did not go as it should'); + + $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + + if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); + if (isError($sentMessagesResult)) return $sentMessagesResult; + + if (hasData($sentMessagesResult)) + { + $jsonArray = array(); + + foreach (getData($sentMessagesResult) as $sentMessage) + { + $jsonRecord = new stdClass(); + $jsonRecord->message_id = $sentMessage->message_id; + $jsonRecord->subject = $sentMessage->subject; + $jsonRecord->body = $sentMessage->body; + $jsonRecord->from = $sentMessage->vorname.' '.$sentMessage->nachname; + $sentDate = new DateTime($sentMessage->sent); + $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); + $jsonRecord->status = $sentMessage->status; $jsonArray[] = $jsonRecord; } - $jsonNestedData = success(json_encode($jsonArray)); + $jsonResult = success(json_encode($jsonArray)); } - return $jsonNestedData; + return $jsonResult; } /** @@ -260,7 +301,6 @@ class Messages_model extends CI_Model if (isError($msgVarsData)) show_error(getData($msgVarsData)); if (!hasData($msgVarsData)) show_error('No recipients were given'); - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents); // Adds the organisation unit to each prestudent @@ -337,6 +377,34 @@ class Messages_model extends CI_Model return success('Messages sent successfully'); } + /** + * Send a message to an organisation unit + */ + public function sendToOrganisationUnit($receiverOU, $subject, $body) + { + if (isEmptyString($receiverOU)) return error('Not a valid organisation unit'); + if (isEmptyString($subject)) return error('Subject is an empty string'); + if (isEmptyString($body)) return error('Body is an empty string'); + + $sender_id = getAuthPersonId(); + + $message = $this->messagelib->sendMessageOU( + $receiverOU, // receiverPersonId + $subject, // subject + $body, // body + $sender_id // sender_id + ); + + if (isError($message)) return $message; + if (!hasData($message)) return error('No messages were saved in database'); + + // Write log entry + $personLog = $this->_personLog($sender_id, $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID), getData($message)[0], $receiverOU); + if (isError($personLog)) return $personLog; + + return success('Messages sent successfully'); + } + //------------------------------------------------------------------------------------------------------------------ // Public methods called by controller system/messages/Messages @@ -447,18 +515,21 @@ class Messages_model extends CI_Model /** * Perform a person log after a message is sent */ - private function _personLog($sender_id, $receiver_id, $message_id) + private function _personLog($sender_id, $receiver_id, $message_id, $receiverOU = null) { // In case the message is accessed via ViewMessage controller -> no authentication // If no authentication is performed then use a hard coded uid $loggedUserUID = isLogged() ? getAuthUID() : self::NO_AUTH_UID; + $message = 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id; + if (!isEmptyString($receiverOU)) $message .= ', receiverOU: '.$receiverOU; + return $this->personloglib->log( $receiver_id, 'Action', array( 'name' => 'Message sent', - 'message' => 'Message sent from person '.$sender_id.' to '.$receiver_id.', message id: '.$message_id, + 'message' => $message, 'success' => 'true' ), 'kommunikation', diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index ffc6afb0e..b4c756e52 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -523,4 +523,20 @@ class Prestudent_model extends DB_Model } } } + + /** + * Get organisation units for all the prestudents of a person + */ + public function getOrganisationunitsByPersonId($person_id) + { + $query = 'SELECT o.oe_kurzbz, o.bezeichnung + FROM public.tbl_prestudent p + JOIN public.tbl_studiengang s USING(studiengang_kz) + JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) + WHERE p.person_id = ? + GROUP BY o.oe_kurzbz, o.bezeichnung + ORDER BY o.bezeichnung'; + + return $this->execQuery($query, array($person_id)); + } } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8d1162de5..39961cdbf 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -303,13 +303,13 @@ class Recipient_model extends DB_Model /** * */ - public function getReceivedMessages($person_id) + public function getReceivedMessages($person_id, $functions) { $sql = 'SELECT mr.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mr.sent AS sent, p.vorname, p.nachname, MAX(ms.status) AS status @@ -327,9 +327,34 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname - ORDER BY mr.sent DESC'; + UNION + SELECT mrou.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mrou.sent AS sent, + p.vorname, + p.nachname, + MAX(ms.status) AS status + FROM public.tbl_person p + JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) + JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) + JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) + JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + WHERE p.person_id = ? + AND mrou.sent IS NOT NULL + AND mrou.sentinfo IS NULL + GROUP BY mrou.message_id, + mm.relationmessage_id, + mm.subject, + mm.body, + mrou.sent, + p.vorname, + p.nachname + ORDER BY sent DESC'; - return $this->execQuery($sql, array($person_id)); + return $this->execQuery($sql, array($person_id, $functions, $person_id)); } /** @@ -342,10 +367,13 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.vorname, + p.nachname, MAX(ms.status) AS status FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mr.person_id) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -353,7 +381,9 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent + mr.sent, + p.vorname, + p.nachname ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index e3ff133f0..b8d2ea4a6 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -6,15 +6,28 @@ 'jquery' => true, 'jqueryui' => true, 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, 'momentjs' => true, 'tabulator' => true, 'ajaxlib' => true, 'dialoglib' => true, - 'customJSs' => array('public/js/messaging/messageClient.js') + 'tinymce' => true, + 'customJSs' => array('public/js/messaging/read.js') ) ); ?> +
+
+ + +
+
diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php new file mode 100644 index 000000000..a21a724b2 --- /dev/null +++ b/application/views/system/messages/ajaxWrite.php @@ -0,0 +1,71 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a new message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/public/js/messaging/messageClient.js b/public/js/messaging/messageClient.js deleted file mode 100644 index 850777ea9..000000000 --- a/public/js/messaging/messageClient.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * - */ -$(document).ready(function () { - - FHC_AjaxClient.ajaxCallGet( - FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listMessages', - null, - { - successCallback: function(data, textStatus, jqXHR) { - - if (FHC_AjaxClient.hasData(data)) - { - try - { - var jsonMessageLst = JSON.parse(FHC_AjaxClient.getData(data)); - - console.log(jsonMessageLst); - - var tableMessageLst = new Tabulator("#lstMessagesPanel", { - height: "400px", - data: jsonMessageLst, - dataTree: true, - dataTreeStartExpanded: true, - dataTreeElementColumn: "subject", - columns: [ - {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400}, - {title: "Date", field: "sent", sorter: "datetime", width: 150} - ], - rowClick: function(e, row) { - // TODO - } - }); - } - catch (syntaxError) - { - FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); - } - } - else - { - FHC_DialogLib.alertWarning("No message currently available"); - } - }, - errorCallback: function() { - - }, - veilTimeout: 300 - } - ); - -}); diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 4146b7008..08a3b46a0 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -1,6 +1,6 @@ -/** - * JS used by view system/messages/htmlWriteTemplate - */ +// ******************************************************** +// JS used by view system/messages/htmlWriteTemplate +// ******************************************************** function tinymcePreviewSetContent() { @@ -52,12 +52,12 @@ $(document).ready(function () }); tinymce.init({ + selector: "#tinymcePreview", + plugins: "autoresize", menubar: false, toolbar: false, statusbar: false, readonly: 1, - selector: "#tinymcePreview", - plugins: "autoresize", autoresize_min_height: 150, autoresize_bottom_margin: 10 }); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js new file mode 100644 index 000000000..c4a27edc6 --- /dev/null +++ b/public/js/messaging/read.js @@ -0,0 +1,116 @@ +// *********************************************************************** +// List all personal messages, used by view system/messages/ajaxRead +// *********************************************************************** + +// +var tableMessageLst; + +/** + * + */ +function genericError() +{ + FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); +} + +/** + * + */ +function getReceivedMessages() +{ + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listReceivedMessages'); +} + +/** + * + */ +function getSentMessages() +{ + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listSentMessages'); +} + +/** + * + */ +function _getMessages(getMessagesURL) +{ + FHC_AjaxClient.ajaxCallGet( + getMessagesURL, + null, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.hasData(data)) + { + try + { + tableMessageLst.replaceData(JSON.parse(FHC_AjaxClient.getData(data))); + } + catch (syntaxError) + { + genericError(); + } + } + }, + errorCallback: genericError, + veilTimeout: 300 + } + ); +} + +/** + * + */ +function changeTinyMCE(e, row) +{ + tinyMCE.get("readMessagePanel").setContent(row._row.data.body); +} + +/** + * + */ +function toggleMessages() +{ + // + if ($(this)[0].className.search('active') == -1) + { + $(this)[0].id == 'r' ? getReceivedMessages() : getSentMessages(); + } +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#readMessagePanel", + plugins: "autoresize", + menubar: false, + toolbar: false, + statusbar: false, + readonly: 1, + autoresize_min_height: 200, + autoresize_bottom_margin: 0 + }); + + // + tableMessageLst = new Tabulator("#lstMessagesPanel", { + height: "400px", + pagination: "local", + columns: [ + {title: "Subject", field: "subject", width: 700, responsive: 0}, + {title: "From", field: "from", width: 400}, + {title: "Date", field: "sent", sorter: "datetime", width: 150} + ], + rowClick: changeTinyMCE + }); + + // + $('.toggleMessages .btn').click(toggleMessages); + + // + getReceivedMessages(); + +}); diff --git a/public/js/messaging/write.js b/public/js/messaging/write.js new file mode 100644 index 000000000..180a47c36 --- /dev/null +++ b/public/js/messaging/write.js @@ -0,0 +1,52 @@ +// **************************************************************************************** +// Write a message to an organisation unit, used by view system/messages/ajaxWrite +// **************************************************************************************** + +/** + * + */ +function sendMessageToOU() +{ + if ($('#organisationUnit').val() == 0) + { + FHC_DialogLib.alertWarning("Not valid organisation unit"); + } + else + { + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/sendMessageToOU', + { + receiverOU: $('#organisationUnit').val(), + subject: $('#subject').val(), + body: tinyMCE.get("body").getContent() + }, + { + successCallback: function(data, textStatus, jqXHR) { + FHC_DialogLib.alertSuccess("Message sent succesfully"); + }, + errorCallback: function() { + FHC_DialogLib.alertError("Error"); + }, + veilTimeout: 300 + } + ); + } +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#body", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10 + }); + + $('#sendButton').click(sendMessageToOU); + +}); From 99e541d5065fd3623fe5cc4261e827f1725b2d69 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 28 Jun 2019 19:18:18 +0200 Subject: [PATCH 012/157] Fixed receiver/sender retrieved from database --- application/models/CL/Messages_model.php | 2 +- application/models/system/Recipient_model.php | 11 ++++++----- public/js/messaging/read.js | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 5810487a9..37b244038 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -124,7 +124,7 @@ class Messages_model extends CI_Model $jsonRecord->message_id = $sentMessage->message_id; $jsonRecord->subject = $sentMessage->subject; $jsonRecord->body = $sentMessage->body; - $jsonRecord->from = $sentMessage->vorname.' '.$sentMessage->nachname; + $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 39961cdbf..8a3ee1aa6 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -316,7 +316,7 @@ class Recipient_model extends DB_Model FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) - JOIN public.tbl_person p ON (p.person_id = mm.person_id) + JOIN public.tbl_person p ON (p.person_id = mr.person_id) WHERE mr.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -333,8 +333,8 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mrou.sent AS sent, - p.vorname, - p.nachname, + pr.vorname, + pr.nachname, MAX(ms.status) AS status FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) @@ -342,6 +342,7 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mrou.person_id) WHERE p.person_id = ? AND mrou.sent IS NOT NULL AND mrou.sentinfo IS NULL @@ -350,8 +351,8 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mrou.sent, - p.vorname, - p.nachname + pr.vorname, + pr.nachname ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index c4a27edc6..348e6b3ed 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -102,6 +102,7 @@ $(document).ready(function () { columns: [ {title: "Subject", field: "subject", width: 700, responsive: 0}, {title: "From", field: "from", width: 400}, + {title: "To", field: "to", width: 400}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], rowClick: changeTinyMCE From c62b4dc018fb62ced6370187d7d7ce28eae71ceb Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 11:15:07 +0200 Subject: [PATCH 013/157] - Added new public method setMessageRead to system/messages/MessageClient - system/Recipient_model methods getReceivedMessages and getSentMessages now retrieve person_id from tbl_msg_status - Added new public method setMessageRead to CL/Messages_model - Improved code in public/js/messaging/read.js --- .../system/messages/MessageClient.php | 16 ++- application/models/CL/Messages_model.php | 79 ++++++++--- application/models/system/Recipient_model.php | 27 ++-- public/js/messaging/read.js | 128 +++++++++++++----- 4 files changed, 183 insertions(+), 67 deletions(-) diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 1062202c1..4cc4c9f2a 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -12,7 +12,8 @@ class MessageClient extends Auth_Controller 'write' => array('basis/person:r'), 'listReceivedMessages' => array('basis/person:r'), 'listSentMessages' => array('basis/person:r'), - 'sendMessageToOU' => array('basis/person:r') + 'sendMessageToOU' => array('basis/person:r'), + 'setMessageRead' => array('basis/person:r') ) ); @@ -55,7 +56,7 @@ class MessageClient extends Auth_Controller } /** - * + * Sends a message to an organisation unit */ public function sendMessageToOU() { @@ -65,4 +66,15 @@ class MessageClient extends Auth_Controller $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } + + /** + * Set a message as read + */ + public function setMessageRead() + { + $message_id = $this->input->post('message_id'); + $statusPersonId = $this->input->post('statusPersonId'); + + $this->outputJson($this->CLMessagesModel->setMessageRead($message_id, $statusPersonId)); + } } diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 37b244038..e907022aa 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -2,13 +2,23 @@ /** * Messages GUI logic - * This model extends CI_Model because here is just implemented logic - * It does not represent a resource (ex. like models that extend DB_Model) + * - This model extends CI_Model because here is just implemented logic + * - It does not represent a resource (ex. like models that extend DB_Model) */ class Messages_model extends CI_Model { - const REPLY_SUBJECT_PREFIX = 'Re: '; - const REPLY_BODY_FORMAT = '

On %s %s %s wrote:
%s
'; + const REPLY_SUBJECT_PREFIX = 'Re: '; // reply subject prefix + // To quote a reply body message + const REPLY_BODY_FORMAT = '
+
+
+ + On %s %s %s wrote: + +
+
+ %s +
'; const NO_AUTH_UID = 'online'; // hard coded uid if no authentication is performed @@ -38,7 +48,28 @@ class Messages_model extends CI_Model // Public methods /** - * + * Set a message as read by its id ($message_id + $person_id) + */ + public function setMessageRead($message_id, $person_id) + { + // Checks parameters + if (!is_numeric($message_id) || !is_numeric($person_id)) return error('Invalid setMessageRead parameters'); + + // Loads needed models + $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); + + // Set date used to insert + $statusData = array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ + ); + + return $this->MsgStatusModel->insert($statusData); // insert and return result + } + + /** + * Prepares data for the view system/messages/ajaxWrite */ public function prepareAjaxWrite() { @@ -60,26 +91,31 @@ class Messages_model extends CI_Model } /** - * + * Prepares data for the view system/messages/ajaxRead + * If everything is fine returns a list of received messages (objects) */ public function prepareAjaxReadReceived() { - $jsonResult = error('Something did not go as it should'); - + // Name and surname of the logged user $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + // If empty then use a hard coded one if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + // Retrieves received messages for the logged user and its organisation units $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( getAuthPersonId(), $this->config->item(MessageLib::CFG_OU_RECEIVERS) ); + // If an error occurred return it if (isError($receivedMessagesResult)) return $receivedMessagesResult; + // If data were found if (hasData($receivedMessagesResult)) { - $jsonArray = array(); + $jsonArray = array(); // array that contains all the received messages + // Collect'em all in the array $jsonArray foreach (getData($receivedMessagesResult) as $receivedMessage) { $jsonRecord = new stdClass(); @@ -90,34 +126,38 @@ class Messages_model extends CI_Model $sentDate = new DateTime($receivedMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; + $jsonRecord->statusPersonId = $receivedMessage->statuspersonid; $jsonArray[] = $jsonRecord; } - $jsonResult = success(json_encode($jsonArray)); + return success(json_encode($jsonArray)); // return as an json encoded string } - return $jsonResult; + return success('No messages were found'); // NOT a blocking error } /** - * + * Prepares data for the view system/messages/ajaxRead + * If everything is fine returns a list of sent messages (objects) */ public function prepareAjaxReadSent() { - $jsonResult = error('Something did not go as it should'); - + // Name and surname of the logged user $loggedUserName = getAuthFirstname().' '.getAuthSurname(); + // If empty then use a hard coded one if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; + // Retrieves sent messages from the logged user $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); - if (isError($sentMessagesResult)) return $sentMessagesResult; + if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) { - $jsonArray = array(); + $jsonArray = array();// array that contains all the sent messages + // Collect'em all in the array $jsonArray foreach (getData($sentMessagesResult) as $sentMessage) { $jsonRecord = new stdClass(); @@ -128,14 +168,15 @@ class Messages_model extends CI_Model $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; + $jsonRecord->statusPersonId = $sentMessage->statuspersonid; $jsonArray[] = $jsonRecord; } - $jsonResult = success(json_encode($jsonArray)); + return success(json_encode($jsonArray)); // return as an json encoded string } - return $jsonResult; + return success('No messages were found'); // NOT a blocking error } /** @@ -540,7 +581,7 @@ class Messages_model extends CI_Model } /** - * + * Quotes the previous message body */ private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate) { diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8a3ee1aa6..46cf0e36f 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -301,18 +301,21 @@ class Recipient_model extends DB_Model } /** - * + * - Gets the directly recieved messages using the given person id + * - Gets the recieved messages from an organisation unit where this person plays a role given by the parameter functions */ public function getReceivedMessages($person_id, $functions) { - $sql = 'SELECT mr.message_id, + $sql = '-- Messages sent directly to the person + SELECT mr.message_id, mm.relationmessage_id, mm.subject, mm.body, mr.sent AS sent, p.vorname, p.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) @@ -326,8 +329,10 @@ class Recipient_model extends DB_Model mm.body, mr.sent, p.vorname, - p.nachname + p.nachname, + ms.person_id UNION + -- Messages sent to a person that belongs to the recipient organisation unit SELECT mrou.message_id, mm.relationmessage_id, mm.subject, @@ -335,7 +340,8 @@ class Recipient_model extends DB_Model mrou.sent AS sent, pr.vorname, pr.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) @@ -352,14 +358,15 @@ class Recipient_model extends DB_Model mm.body, mrou.sent, pr.vorname, - pr.nachname + pr.nachname, + ms.person_id ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); } /** - * + * Gets all the sent message by the given person */ public function getSentMessages($person_id) { @@ -370,7 +377,8 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname, - MAX(ms.status) AS status + MAX(ms.status) AS status, + ms.person_id AS statusPersonId FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) @@ -384,7 +392,8 @@ class Recipient_model extends DB_Model mm.body, mr.sent, p.vorname, - p.nachname + p.nachname, + ms.person_id ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index 348e6b3ed..99426bffa 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -2,35 +2,108 @@ // List all personal messages, used by view system/messages/ajaxRead // *********************************************************************** -// +// Global variable that contains tha tabulator instance var tableMessageLst; /** - * + * Use DialogLib to display a Generic error */ -function genericError() +function readMessagesGenericError() { FHC_DialogLib.alertError("An error occurred while retrieving message, contact the website administrator"); } /** - * + * Gets all the received messages */ function getReceivedMessages() { - _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listReceivedMessages'); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listReceivedMessages"); } /** - * + * Gets all the sent messages */ function getSentMessages() { - _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + '/listSentMessages'); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listSentMessages"); } /** - * + * Change the TinyMCE content + */ +function changeTinyMCE(row) +{ + tinyMCE.get("readMessagePanel").setContent(row.getData().body); +} + +/** + * Called on Tabulator row click event + * - If a clicked message is unread thes is set as read + * - Change the TinyMCE content with the clicked message body + */ +function rowClick(e, row) +{ + // If the message is unread + if (row.getData().status == "0") + { + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + "/setMessageRead", + { + message_id: row.getData().message_id, + statusPersonId: row.getData().statusPersonId + }, + { + successCallback: function(data, textStatus, jqXHR) { + + if (FHC_AjaxClient.isSuccess(data)) + { + rowFormatter(row, "normal"); + } + else + { + readMessagesGenericError(); + } + }, + errorCallback: readMessagesGenericError, + veilTimeout: 300 + } + ); + } + + changeTinyMCE(row); // Change TinyMCE content +} + +/** + * Radio button click event to switch between received and sent messages + */ +function toggleMessages() +{ + // + if ($(this)[0].className.search("active") == -1) + { + $(this)[0].id == "r" ? getReceivedMessages() : getSentMessages(); + } +} + +/** + * Formats tabulator rows + */ +function rowFormatter(row, fontWeight = 700) +{ + if (row.getData().status == "0") + { + var cells = row.getElement().childNodes; + + for (var i = 0; i < cells.length; i++) + { + cells[i].style.fontWeight = fontWeight; + } + } +} + +/** + * Get received/sent messages and change tabulator content */ function _getMessages(getMessagesURL) { @@ -48,42 +121,22 @@ function _getMessages(getMessagesURL) } catch (syntaxError) { - genericError(); + readMessagesGenericError(); } } }, - errorCallback: genericError, + errorCallback: readMessagesGenericError, veilTimeout: 300 } ); } /** - * - */ -function changeTinyMCE(e, row) -{ - tinyMCE.get("readMessagePanel").setContent(row._row.data.body); -} - -/** - * - */ -function toggleMessages() -{ - // - if ($(this)[0].className.search('active') == -1) - { - $(this)[0].id == 'r' ? getReceivedMessages() : getSentMessages(); - } -} - -/** - * + * Start! */ $(document).ready(function () { - // + // TinyMCE initialization tinymce.init({ selector: "#readMessagePanel", plugins: "autoresize", @@ -95,7 +148,7 @@ $(document).ready(function () { autoresize_bottom_margin: 0 }); - // + // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", pagination: "local", @@ -105,13 +158,14 @@ $(document).ready(function () { {title: "To", field: "to", width: 400}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], - rowClick: changeTinyMCE + rowClick: rowClick, + rowFormatter: rowFormatter }); - // - $('.toggleMessages .btn').click(toggleMessages); + // Bind radio buttons click event with toggleMessages function + $(".toggleMessages .btn").click(toggleMessages); - // + // First retrieve the received message and populate the tabulator getReceivedMessages(); }); From 18ea98416f683e5291e10bd50d95a458aae8e083 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 15:11:58 +0200 Subject: [PATCH 014/157] From/To toggle tabulator columns --- public/js/messaging/read.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index 99426bffa..e1fe784d0 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -18,6 +18,9 @@ function readMessagesGenericError() */ function getReceivedMessages() { + tableMessageLst.hideColumn("to"); + tableMessageLst.showColumn("from"); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listReceivedMessages"); } @@ -26,6 +29,9 @@ function getReceivedMessages() */ function getSentMessages() { + tableMessageLst.hideColumn("from"); + tableMessageLst.showColumn("to"); + _getMessages(FHC_JS_DATA_STORAGE_OBJECT.called_path + "/listSentMessages"); } @@ -154,8 +160,8 @@ $(document).ready(function () { pagination: "local", columns: [ {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400}, - {title: "To", field: "to", width: 400}, + {title: "From", field: "from", width: 400, visible: false}, + {title: "To", field: "to", width: 400, visible: false}, {title: "Date", field: "sent", sorter: "datetime", width: 150} ], rowClick: rowClick, From 48bcc77c975ec19ddc7c0ca8bfe4f6fa4b886735 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 4 Jul 2019 17:18:01 +0200 Subject: [PATCH 015/157] - Added CSS public/css/Tabulator.css and public/css/TinyMCE.css - Added these new CSS to views/templates/FHC-Header.php - Unified messages CSS in public/css/messaging/message.css - Messages Inbox/Outbox GUI beautified --- .../views/system/messages/ajaxRead.php | 19 +- .../views/system/messages/ajaxWrite.php | 2 +- .../views/system/messages/htmlError.php | 2 +- .../views/system/messages/htmlRead.php | 2 +- .../views/system/messages/htmlSuccess.php | 2 +- .../views/system/messages/htmlWriteReply.php | 2 +- .../system/messages/htmlWriteTemplate.php | 2 +- application/views/templates/FHC-Header.php | 9 +- public/css/Tabulator.css | 14 ++ public/css/TinyMCE.css | 7 + public/css/messaging/message.css | 191 ++++++++++++++++++ public/css/messaging/messageReply.css | 17 -- public/css/messaging/messageSent.css | 25 --- public/css/messaging/messageWrite.css | 29 --- public/js/messaging/read.js | 20 +- 15 files changed, 245 insertions(+), 98 deletions(-) create mode 100644 public/css/Tabulator.css create mode 100644 public/css/TinyMCE.css create mode 100644 public/css/messaging/message.css delete mode 100644 public/css/messaging/messageReply.css delete mode 100644 public/css/messaging/messageSent.css delete mode 100644 public/css/messaging/messageWrite.css diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index b8d2ea4a6..f5a733c74 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -13,21 +13,20 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, - 'customJSs' => array('public/js/messaging/read.js') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') ) ); ?> -
-
- - +
+
+ + + +
-
+
diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index a21a724b2..88767628c 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -11,7 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') ) ); diff --git a/application/views/system/messages/htmlError.php b/application/views/system/messages/htmlError.php index 7e029b50c..78ffc7164 100644 --- a/application/views/system/messages/htmlError.php +++ b/application/views/system/messages/htmlError.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 01a5421ac..390e84ccc 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageReply.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlSuccess.php b/application/views/system/messages/htmlSuccess.php index 0260c9d16..e421a77e0 100644 --- a/application/views/system/messages/htmlSuccess.php +++ b/application/views/system/messages/htmlSuccess.php @@ -7,7 +7,7 @@ 'bootstrap' => true, 'fontawesome' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageSent.css') + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') ) ); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index b9932148b..dde6cf17a 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -8,7 +8,7 @@ 'fontawesome' => true, 'tinymce' => true, 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWriteReply.js') ) ); diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 7132cfb36..9d087f2ca 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -11,7 +11,7 @@ 'tinymce' => true, 'sbadmintemplate' => true, 'widgets' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/messageWrite.css'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/messageWrite.js') ) ); diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 7b75e2ad7..2d6a92ace 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -80,7 +80,14 @@ } // Tabulator CSS - if ($tabulator === true) generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + if ($tabulator === true) + { + generateCSSsInclude('vendor/olifolkerd/tabulator/dist/css/bootstrap/tabulator_bootstrap.min.css'); + generateCSSsInclude('public/css/Tabulator.css'); + } + + // Tinymce CSS + if ($tinymce === true) generateCSSsInclude('public/css/TinyMCE.css'); // -------------------------------------------------------------------------------------------------------- // From public folder diff --git a/public/css/Tabulator.css b/public/css/Tabulator.css new file mode 100644 index 000000000..359f29e72 --- /dev/null +++ b/public/css/Tabulator.css @@ -0,0 +1,14 @@ +.tabulator-col { + font-size: 14px; +} + +.tabulator-page { + color: black; + opacity: 1 !important; + padding: 2px 7px !important; + border: 0px !important; +} + +.tabulator-page.active { + color: #337ab7 !important; +} diff --git a/public/css/TinyMCE.css b/public/css/TinyMCE.css new file mode 100644 index 000000000..a6d956b48 --- /dev/null +++ b/public/css/TinyMCE.css @@ -0,0 +1,7 @@ +.mce-tinymce .mce-container .mce-panel { + border-width: 0px; +} + +.mce-panel { + border-width: 0px !important; +} diff --git a/public/css/messaging/message.css b/public/css/messaging/message.css new file mode 100644 index 000000000..5d62a5e6a --- /dev/null +++ b/public/css/messaging/message.css @@ -0,0 +1,191 @@ +/* Smaller subject field */ +input[type=text] { + height: 28px; + padding: 0; +} + +.msgfield label { + margin-bottom: 0 !important; + margin-top: 3px; +} + +@media screen and (min-width: 1200px) { + .col-lg-1.msgfieldcol-left { + width: 13%; + } + + .col-lg-11.msgfieldcol-right { + width: 87%; + } +} + +#sendButton { + width: 120px; +} + +/* Overwrites the Widget.css class */ +div .width-150px { + width: 200px; +} + +.panel-heading { + font-size: 16px; +} + +.signatureblock { + color: grey; +} + +.signatureblocklink { + color: grey; +} + +.signatureblocklink:hover { + color: #337ab7; +} + +.rwd-line { + display: block; +} + +@media screen and (min-width: 1831px) { + .rwd-line { + display: inline; + } +} + +.panel-heading { + font-size: 16px; +} + +@media screen and (min-width: 1500px) { + #msgtable { + width: 70%; + } +} + +#msgtable td { + border: none !important; +} + +#replybutton { + width: 120px; +} + +/* STYLE THE HTML ELEMENTS (INCLUDES RESETS FOR THE DEFAULT FIELDSET AND LEGEND STYLES) */ +fieldset { + margin: 0; + padding: 2rem; + box-sizing: border-box; + display: block; + border: none; + border: solid 1px #CCC; + min-width: 0; + background-color: #FFF; +} +fieldset legend { + margin: 0 0 1.5rem; + padding: 0; + width: 100%; + float: left; + display: table; + font-size: 1.5rem; + line-height: 140%; + font-weight: 600; + color: #333; +} +fieldset legend + * { + clear: both; +} +body:not(:-moz-handler-blocked) fieldset { + display: table-cell; +} + +/* TOGGLE STYLING */ +.toggle { + margin: 0 0 1.5rem; + box-sizing: border-box; + font-size: 0; + display: flex; + flex-flow: row nowrap; + justify-content: flex-start; + align-items: stretch; +} +.toggle input { + width: 0; + height: 0; + position: absolute; + left: -9999px; +} +.toggle input + label { + margin: 0; + padding: .75rem 2rem; + box-sizing: border-box; + position: relative; + display: inline-block; + border: solid 1px #DDD; + background-color: #FFF; + font-size: 14px; + line-height: 140%; + font-weight: 600; + text-align: center; + box-shadow: 0 0 0 rgba(255, 255, 255, 0); + transition: border-color .15s ease-out, color .25s ease-out, background-color .15s ease-out, box-shadow .15s ease-out; + cursor: pointer; +} +.toggle input + label:first-of-type { + border-radius: 6px 0 0 6px; + border-right: none; +} +.toggle input + label:last-of-type { + border-radius: 0 6px 6px 0; + border-left: none; +} +.toggle input:hover + label { + border-color: #213140; +} +.toggle input:checked + label { + background-color: #337ab7; + color: #FFF; + box-shadow: 0 0 10px rgba(102, 179, 251, 0.5); + border-color: #337ab7; + z-index: 1; +} +.toggle input:focus + label { + outline: dotted 1px #CCC; + outline-offset: .45rem; +} +@media (max-width: 800px) { + .toggle input + label { + padding: .75rem .25rem; + flex: 0 0 50%; + display: flex; + justify-content: center; + align-items: center; + } +} + +/* STYLING FOR THE STATUS HELPER TEXT FOR THE DEMO */ +.status { + margin: 0; + font-size: 1rem; + font-weight: 400; +} +.status span { + font-weight: 600; + color: #B6985A; +} +.status span:first-of-type { + display: inline; +} +.status span:last-of-type { + display: none; +} +@media (max-width: 800px) { + .status span:first-of-type { + display: none; + } + .status span:last-of-type { + display: inline; + } +} diff --git a/public/css/messaging/messageReply.css b/public/css/messaging/messageReply.css deleted file mode 100644 index 17f978ecc..000000000 --- a/public/css/messaging/messageReply.css +++ /dev/null @@ -1,17 +0,0 @@ -.panel-heading { - font-size: 16px; -} - -@media screen and (min-width: 1500px) { - #msgtable { - width: 70%; - } -} - -#msgtable td { - border: none !important; -} - -#replybutton { - width: 120px; -} diff --git a/public/css/messaging/messageSent.css b/public/css/messaging/messageSent.css deleted file mode 100644 index 96403d797..000000000 --- a/public/css/messaging/messageSent.css +++ /dev/null @@ -1,25 +0,0 @@ -.panel-heading { - font-size: 16px; -} - -.signatureblock { - color: grey; -} - -.signatureblocklink { - color: grey; -} - -.signatureblocklink:hover { - color: #337ab7; -} - -.rwd-line { - display: block; -} - -@media screen and (min-width: 1831px) { - .rwd-line { - display: inline; - } -} diff --git a/public/css/messaging/messageWrite.css b/public/css/messaging/messageWrite.css deleted file mode 100644 index 3b5e1fd0e..000000000 --- a/public/css/messaging/messageWrite.css +++ /dev/null @@ -1,29 +0,0 @@ -/*smaller subject field*/ -input[type=text] { - height: 28px; - padding: 0; -} - -.msgfield label { - margin-bottom: 0 !important; - margin-top: 3px; -} - -@media screen and (min-width: 1200px) { - .col-lg-1.msgfieldcol-left { - width: 13%; - } - - .col-lg-11.msgfieldcol-right { - width: 87%; - } -} - -#sendButton { - width: 120px; -} - -/* Overwrites the Widget.css class */ -div .width-150px { - width: 200px; -} diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index e1fe784d0..edafe7483 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -85,11 +85,9 @@ function rowClick(e, row) */ function toggleMessages() { - // - if ($(this)[0].className.search("active") == -1) - { - $(this)[0].id == "r" ? getReceivedMessages() : getSentMessages(); - } + $(this)[0].id == "received" ? getReceivedMessages() : getSentMessages(); + + tableMessageLst.redraw(); // redraw table after its content is changed } /** @@ -158,18 +156,20 @@ $(document).ready(function () { tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", pagination: "local", + layout: "fitColumns", + layoutColumnsOnNewData: true, columns: [ - {title: "Subject", field: "subject", width: 700, responsive: 0}, - {title: "From", field: "from", width: 400, visible: false}, - {title: "To", field: "to", width: 400, visible: false}, - {title: "Date", field: "sent", sorter: "datetime", width: 150} + {title: "Subject", field: "subject", responsive: 0}, + {title: "From", field: "from", visible: false}, + {title: "To", field: "to", visible: false}, + {title: "Date", field: "sent", sorter: "datetime"} ], rowClick: rowClick, rowFormatter: rowFormatter }); // Bind radio buttons click event with toggleMessages function - $(".toggleMessages .btn").click(toggleMessages); + $("#toggleMessages input").click(toggleMessages); // First retrieve the received message and populate the tabulator getReceivedMessages(); From c30135f197c2bc3363d8ecbf6c3c48a27ca0eafe Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 17 Sep 2019 10:38:25 +0200 Subject: [PATCH 016/157] Now MessageClient extends FHC_Controller and then starts the authentication --- .../system/messages/MessageClient.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index 4cc4c9f2a..f7bc760ad 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -2,20 +2,19 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class MessageClient extends Auth_Controller +/** + * NOTE: MessageClient extends FHC_Controller and NOT Auth_Controller to be able to use + * the authentication system without the need to load the permissions system + */ +class MessageClient extends FHC_Controller { public function __construct() { - parent::__construct( - array( - 'read' => array('basis/person:r'), - 'write' => array('basis/person:r'), - 'listReceivedMessages' => array('basis/person:r'), - 'listSentMessages' => array('basis/person:r'), - 'sendMessageToOU' => array('basis/person:r'), - 'setMessageRead' => array('basis/person:r') - ) - ); + parent::__construct(); + + // Loads authentication library and starts authentication + // NOTE: it is loaded here because the controller extends FHC_Controller and NOT Auth_Controller + $this->load->library('AuthLib'); // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); From 509fdef03b565bcb3ed744b10276743cd85d2be8 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 15 Oct 2019 11:54:01 +0200 Subject: [PATCH 017/157] - Removed tabulator local pagination for messages list - Removed error messages when the messages list is empty --- public/js/messaging/read.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index edafe7483..c3b117636 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -119,13 +119,18 @@ function _getMessages(getMessagesURL) if (FHC_AjaxClient.hasData(data)) { - try + var messages = FHC_AjaxClient.getData(data); + + if ($.isArray(messages)) { - tableMessageLst.replaceData(JSON.parse(FHC_AjaxClient.getData(data))); - } - catch (syntaxError) - { - readMessagesGenericError(); + try + { + tableMessageLst.replaceData(JSON.parse()); + } + catch (syntaxError) + { + readMessagesGenericError(); + } } } }, @@ -155,7 +160,6 @@ $(document).ready(function () { // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { height: "400px", - pagination: "local", layout: "fitColumns", layoutColumnsOnNewData: true, columns: [ From d40fd6391a1c876bca5cfbaee42be569587b9816 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:30:16 +0100 Subject: [PATCH 018/157] Added some phrases for the messaging system, english only --- system/phrasesupdate.php | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 4f5145034..a2ff737c2 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -3450,6 +3450,66 @@ $phrases = array( 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'write', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Write', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'received', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Received', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'global', + 'phrase' => 'reply', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Reply', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From 6594a5288bfb38bfff2ca7a089b490b71ef03327 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:30:50 +0100 Subject: [PATCH 019/157] Better CSS for messaging system pages --- public/css/messaging/message.css | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/public/css/messaging/message.css b/public/css/messaging/message.css index 5d62a5e6a..f5440b892 100644 --- a/public/css/messaging/message.css +++ b/public/css/messaging/message.css @@ -83,6 +83,7 @@ fieldset { min-width: 0; background-color: #FFF; } + fieldset legend { margin: 0 0 1.5rem; padding: 0; @@ -94,9 +95,11 @@ fieldset legend { font-weight: 600; color: #333; } + fieldset legend + * { clear: both; } + body:not(:-moz-handler-blocked) fieldset { display: table-cell; } @@ -106,17 +109,18 @@ body:not(:-moz-handler-blocked) fieldset { margin: 0 0 1.5rem; box-sizing: border-box; font-size: 0; - display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: stretch; } + .toggle input { width: 0; height: 0; position: absolute; left: -9999px; } + .toggle input + label { margin: 0; padding: .75rem 2rem; @@ -133,17 +137,21 @@ body:not(:-moz-handler-blocked) fieldset { transition: border-color .15s ease-out, color .25s ease-out, background-color .15s ease-out, box-shadow .15s ease-out; cursor: pointer; } + .toggle input + label:first-of-type { border-radius: 6px 0 0 6px; border-right: none; } + .toggle input + label:last-of-type { border-radius: 0 6px 6px 0; border-left: none; } + .toggle input:hover + label { border-color: #213140; } + .toggle input:checked + label { background-color: #337ab7; color: #FFF; @@ -151,15 +159,16 @@ body:not(:-moz-handler-blocked) fieldset { border-color: #337ab7; z-index: 1; } + .toggle input:focus + label { outline: dotted 1px #CCC; outline-offset: .45rem; } + @media (max-width: 800px) { .toggle input + label { padding: .75rem .25rem; flex: 0 0 50%; - display: flex; justify-content: center; align-items: center; } @@ -171,16 +180,20 @@ body:not(:-moz-handler-blocked) fieldset { font-size: 1rem; font-weight: 400; } + .status span { font-weight: 600; color: #B6985A; } + .status span:first-of-type { display: inline; } + .status span:last-of-type { display: none; } + @media (max-width: 800px) { .status span:first-of-type { display: none; @@ -189,3 +202,9 @@ body:not(:-moz-handler-blocked) fieldset { display: inline; } } + + +.buttonsSpacer { + display: inline-block; + width: 30px; +} From 36e5009d68b0731a7d35e5e260b55e055f997287 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:31:21 +0100 Subject: [PATCH 020/157] Fixed problems with DialogLib --- public/js/DialogLib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/DialogLib.js b/public/js/DialogLib.js index 05558844a..3b472cd6a 100644 --- a/public/js/DialogLib.js +++ b/public/js/DialogLib.js @@ -74,7 +74,7 @@ var FHC_DialogLib = { buttons: [{ text: "Ok", click: function() { - $(this).dialog("close"); + $("#fhc-dialoglib-dialog").remove(); } }] }); From 2a4360862af77f03d59069f9041001184971fa5e Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 30 Oct 2019 18:35:46 +0100 Subject: [PATCH 021/157] =?UTF-8?q?-=20Reply=20Button=20in=20Inbox/outbox?= =?UTF-8?q?=20Page=20-=20Write=20new=20message=20Button=20with=20Layer/Pop?= =?UTF-8?q?up=20-=20Degree=20Programs=20drop=20down=20displays=20longer=20?= =?UTF-8?q?name=20(if=20prestudent=20best=C3=A4tigt=20(alias=20interessent?= =?UTF-8?q?=20with=20bestaetigtam=20!=3D=20null=20)=20receiver->=20dp,=20o?= =?UTF-8?q?therwise=20->=20infocenter)=20-=20SQL=20to=20get=20OU=20recipie?= =?UTF-8?q?nt=20doesn't=20use=20beginn=20/=20End=20of=20function=20-=20Alw?= =?UTF-8?q?ays=20set=20insertvon=20in=20tbl=5Fmsg=5Fstatus=20-=20Add=20Mul?= =?UTF-8?q?tilanguage=20Support=20for=20Message=20Page=20(not=20completed?= =?UTF-8?q?=20yet)=20-=20If=20in=20sent=20mode=20do=20not=20set=20messages?= =?UTF-8?q?=20as=20read=20-=20Error=20message=20when=20there=20are=20no=20?= =?UTF-8?q?Messages=20available=20shouldnt=20be=20displayed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/messages/MessageClient.php | 33 ++++++ application/libraries/MessageLib.php | 35 +++++- application/models/CL/Messages_model.php | 71 +++++++++--- application/models/crm/Prestudent_model.php | 18 ++- application/models/system/Recipient_model.php | 109 ++++++++++++++++-- .../views/system/messages/ajaxRead.php | 90 +++++++++------ .../views/system/messages/ajaxWriteReply.php | 80 +++++++++++++ public/js/messaging/read.js | 88 ++++++++++++-- public/js/messaging/writeReply.js | 48 ++++++++ 9 files changed, 494 insertions(+), 78 deletions(-) create mode 100644 application/views/system/messages/ajaxWriteReply.php create mode 100644 public/js/messaging/writeReply.js diff --git a/application/controllers/system/messages/MessageClient.php b/application/controllers/system/messages/MessageClient.php index f7bc760ad..a0cc5c518 100644 --- a/application/controllers/system/messages/MessageClient.php +++ b/application/controllers/system/messages/MessageClient.php @@ -18,6 +18,14 @@ class MessageClient extends FHC_Controller // Loads model CLMessagesModel which contains the GUI logic $this->load->model('CL/Messages_model', 'CLMessagesModel'); + + // Phrases used in loaded views + $this->loadPhrases( + array( + 'global', + 'ui' + ) + ); } /** @@ -38,6 +46,17 @@ class MessageClient extends FHC_Controller $this->load->view('system/messages/ajaxWrite', $this->CLMessagesModel->prepareAjaxWrite()); } + /** + * Starts the GUI used to reply to a received personal message + */ + public function writeReply() + { + $token = $this->input->get('token'); + + // Loads the view to reply to a message + $this->load->view('system/messages/ajaxWriteReply', $this->CLMessagesModel->prepareAjaxWriteReply($token)); + } + /** * Returns JSON that that contains all the received messages by the currently logged user */ @@ -66,6 +85,20 @@ class MessageClient extends FHC_Controller $this->outputJson($this->CLMessagesModel->sendToOrganisationUnit($receiverOU, $subject, $body)); } + /** + * Sends a message to an organisation unit + */ + public function sendMessageReply() + { + $receiver_id = $this->input->post('receiver_id'); + $relationmessage_id = $this->input->post('relationmessage_id'); + $token = $this->input->post('token'); + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); + + $this->outputJson($this->CLMessagesModel->sendReply($receiver_id, $subject, $body, $relationmessage_id, $token)); + } + /** * Set a message as read */ diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 18b958e14..9224996c8 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -272,10 +272,17 @@ class MessageLib // If NOT found then insert the read status if (!$found) { + $uid = null; + if (!isEmptyString($messageTokenResult[0]->uid)) + { + $uid = $messageTokenResult[0]->uid; + } + $statusData = array( 'message_id' => getData($messageTokenResult)[0]->message_id, 'person_id' => getData($messageTokenResult)[0]->receiver_id, - 'status' => MSG_STATUS_READ + 'status' => MSG_STATUS_READ, + 'insertvon' => $uid ); $messageTokenResultIns = $this->_ci->MsgStatusModel->insert($statusData); @@ -383,6 +390,15 @@ class MessageLib // Starts database transaction $this->_ci->db->trans_start(false); + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + + $uid = null; + $benutzerDB = $this->_ci->BenutzerModel->loadWhere(array('person_id' => $sender_id)); + if (hasData($benutzerDB)) + { + $uid = getData($benutzerDB)[0]->uid; + } + // Store message information in tbl_msg_message $messageData = array( 'person_id' => $sender_id, @@ -413,7 +429,8 @@ class MessageLib $statusData = array( 'message_id' => $messageId, 'person_id' => $receiver_id, - 'status' => MSG_STATUS_UNREAD + 'status' => MSG_STATUS_UNREAD, + 'insertvon' => $uid ); $saveMessageResult = $this->_ci->MsgStatusModel->insert($statusData); } @@ -511,7 +528,17 @@ class MessageLib if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error - return $this->_sendNotice(getData($messageResult)); + $messages = getData($messageResult); + if (count($messages) == 1 && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)) + { + $messages = $this->_ci->RecipientModel->getReceivedMessagesByOE( + $messages[0]->oe_kurzbz, + $this->_ci->config->item(MessageLib::CFG_OU_RECEIVERS), + self::EMAIL_KONTAKT_TYPE + ); + } + + return $this->_sendNotice($messages); } /** @@ -614,11 +641,13 @@ class MessageLib // Checks if sender is fine $sender = $this->_getSender($sender_id); if (!hasData($sender)) return $sender; + // Checks if the sender and receiver organisation unit are valid if (($receiversOU != null && !$this->_ouExists($receiversOU)) || ($senderOU != null && !$this->_ouExists($senderOU))) { return error('The given organisation unit is not valid', MSG_ERR_INVALID_OU); } + // Checks subjects if (isEmptyString($subject)) return error('The given subject is an empty string', MSG_ERR_INVALID_SUBJECT); // Checks body diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index e907022aa..7673a6d71 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -62,7 +62,8 @@ class Messages_model extends CI_Model $statusData = array( 'message_id' => $message_id, 'person_id' => $person_id, - 'status' => MSG_STATUS_READ + 'status' => MSG_STATUS_READ, + 'insertvon' => getAuthUID() ); return $this->MsgStatusModel->insert($statusData); // insert and return result @@ -83,25 +84,61 @@ class Messages_model extends CI_Model { foreach (getData($ouResult) as $ou) { - $ouOptions .= sprintf("\n".'', $ou->oe_kurzbz, $ou->bezeichnung); + $ouOptions .= sprintf( + "\n".'', + is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : 'infocenter', + $ou->bezeichnung + ); } } return array('organisationUnitOptions' => $ouOptions); } + /** + * Prepares data for the view system/messages/ajaxWriteReply + */ + public function prepareAjaxWriteReply($token) + { + if (isEmptyString($token)) show_error('The given token is not valid'); + + // Retrieves message using the given token + $messageResult = $this->MessageTokenModel->getMessageByToken($token); + if (isError($messageResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + if (hasData($messageResult)) + { + $message = getData($messageResult)[0]; // Found message data + + // Retrieves message sender information + $senderResult = $this->MessageTokenModel->getSenderData($message->sender_id); + if (isError($senderResult)) show_error('An error occurred while loading this page, please contact the site administrator'); + + if (hasData($senderResult)) + { + $sender = getData($senderResult)[0]; // Found sender data + + $replySubject = self::REPLY_SUBJECT_PREFIX.$message->subject; + $replyBody = $this->_getReplyBody($message->body, $sender->vorname, $sender->nachname, $message->sent); + + return array ( + 'receiver' => $sender->vorname.' '.$sender->nachname, // yep! the sender of the sent message is the receiver of the reply message + 'subject' => $replySubject, + 'body' => $replyBody, + 'receiver_id' => $message->sender_id, + 'relationmessage_id' => $message->message_id, + 'token' => $token + ); + } + } + } + /** * Prepares data for the view system/messages/ajaxRead * If everything is fine returns a list of received messages (objects) */ public function prepareAjaxReadReceived() { - // Name and surname of the logged user - $loggedUserName = getAuthFirstname().' '.getAuthSurname(); - - // If empty then use a hard coded one - if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - // Retrieves received messages for the logged user and its organisation units $receivedMessagesResult = $this->RecipientModel->getReceivedMessages( getAuthPersonId(), @@ -127,6 +164,7 @@ class Messages_model extends CI_Model $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $receivedMessage->status; $jsonRecord->statusPersonId = $receivedMessage->statuspersonid; + $jsonRecord->token = $receivedMessage->token; $jsonArray[] = $jsonRecord; } @@ -143,12 +181,6 @@ class Messages_model extends CI_Model */ public function prepareAjaxReadSent() { - // Name and surname of the logged user - $loggedUserName = getAuthFirstname().' '.getAuthSurname(); - - // If empty then use a hard coded one - if (isEmptyString($loggedUserName)) $loggedUserName = 'Me'; - // Retrieves sent messages from the logged user $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it @@ -164,11 +196,20 @@ class Messages_model extends CI_Model $jsonRecord->message_id = $sentMessage->message_id; $jsonRecord->subject = $sentMessage->subject; $jsonRecord->body = $sentMessage->body; - $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; $sentDate = new DateTime($sentMessage->sent); $jsonRecord->sent = $sentDate->format('d/m/Y H:i:s'); $jsonRecord->status = $sentMessage->status; $jsonRecord->statusPersonId = $sentMessage->statuspersonid; + $jsonRecord->token = $sentMessage->token; + + if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)) + { + $jsonRecord->to = $sentMessage->sg; + } + else + { + $jsonRecord->to = $sentMessage->vorname.' '.$sentMessage->nachname; + } $jsonArray[] = $jsonRecord; } diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index b4c756e52..b1ae9b8e9 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -529,13 +529,23 @@ class Prestudent_model extends DB_Model */ public function getOrganisationunitsByPersonId($person_id) { - $query = 'SELECT o.oe_kurzbz, o.bezeichnung + $query = 'SELECT o.oe_kurzbz, + sg.bezeichnung, + ps.prestudent_id FROM public.tbl_prestudent p - JOIN public.tbl_studiengang s USING(studiengang_kz) + JOIN public.tbl_studiengang sg USING(studiengang_kz) JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) + LEFT JOIN ( + SELECT prestudent_id + FROM public.tbl_prestudentstatus + WHERE bestaetigtam IS NOT NULL + AND status_kurzbz = \'Interessent\' + ) ps USING(prestudent_id) WHERE p.person_id = ? - GROUP BY o.oe_kurzbz, o.bezeichnung - ORDER BY o.bezeichnung'; + GROUP BY o.oe_kurzbz, + sg.bezeichnung, + ps.prestudent_id + ORDER BY sg.bezeichnung'; return $this->execQuery($query, array($person_id)); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 46cf0e36f..76a0bf435 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -57,11 +57,13 @@ class Recipient_model extends DB_Model m.oe_kurzbz, s.status, s.statusinfo, - s.insertamum as statusamum + s.insertamum as statusamum, + b.uid FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) JOIN ( SELECT * FROM public.tbl_msg_status WHERE status < ? ORDER BY insertamum DESC, status DESC - ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id) + ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id), + LEFT JOIN public.tbl_benutzer b USING(person_id) WHERE r.token = ? LIMIT 1'; @@ -217,7 +219,8 @@ class Recipient_model extends DB_Model mr.token, mm.subject, mm.body, - mr.sentinfo + mr.sentinfo, + mr.oe_kurzbz FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) LEFT JOIN ( SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? @@ -315,11 +318,12 @@ class Recipient_model extends DB_Model p.vorname, p.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + mr.token FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm ON (mm.message_id = mr.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) - JOIN public.tbl_person p ON (p.person_id = mr.person_id) + JOIN public.tbl_person p ON (p.person_id = mm.person_id) WHERE mr.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -330,7 +334,8 @@ class Recipient_model extends DB_Model mr.sent, p.vorname, p.nachname, - ms.person_id + ms.person_id, + mr.token UNION -- Messages sent to a person that belongs to the recipient organisation unit SELECT mrou.message_id, @@ -341,14 +346,21 @@ class Recipient_model extends DB_Model pr.vorname, pr.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + mrou.token FROM public.tbl_person p JOIN public.tbl_benutzer b ON (b.person_id = p.person_id) - JOIN (SELECT uid, oe_kurzbz FROM public.tbl_benutzerfunktion WHERE funktion_kurzbz IN ?) bf ON (bf.uid = b.uid) + JOIN ( + SELECT uid, oe_kurzbz + FROM public.tbl_benutzerfunktion + WHERE (datum_von IS NULL OR datum_von <= NOW()) + AND (datum_bis IS NULL OR datum_bis >= NOW()) + AND funktion_kurzbz IN ? + ) bf ON (bf.uid = b.uid) JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) - JOIN public.tbl_person pr ON (pr.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) WHERE p.person_id = ? AND mrou.sent IS NOT NULL AND mrou.sentinfo IS NULL @@ -359,12 +371,78 @@ class Recipient_model extends DB_Model mrou.sent, pr.vorname, pr.nachname, - ms.person_id + ms.person_id, + mrou.token ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id, $functions, $person_id)); } + /** + * Gets only the recieved messages from an organisation unit where this person plays a role given by the parameter functions + */ + public function getReceivedMessagesByOE($oe_kurzbz, $functions, $kontaktType) + { + // Messages sent to a person that belongs to the recipient organisation unit + $sql = 'SELECT mm.message_id, + mm.subject, + mm.body, + mrou.person_id as receiver_id, + mrou.sentinfo, + mrou.token, + mrou.oe_kurzbz, + ks.kontakt as sender, + kr.kontakt as receiver, + mu.mitarbeiter_uid as employeeContact, + mb.mitarbeiter_uid as senderemployeeContact + FROM public.tbl_benutzer b + JOIN ( + SELECT uid, oe_kurzbz + FROM public.tbl_benutzerfunktion + WHERE (datum_von IS NULL OR datum_von <= NOW()) + AND (datum_bis IS NULL OR datum_bis >= NOW()) + AND funktion_kurzbz IN ? + ) bf ON (bf.uid = b.uid) + JOIN public.tbl_msg_recipient mrou ON (mrou.oe_kurzbz = bf.oe_kurzbz) + JOIN public.tbl_msg_message mm ON (mm.message_id = mrou.message_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) + JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) + LEFT JOIN ( + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? + ) ks ON (ks.person_id = mm.person_id) + LEFT JOIN ( + SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? + ) kr ON (kr.person_id = mrou.person_id) + LEFT JOIN ( + SELECT b.person_id, + m.mitarbeiter_uid + FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE b.aktiv = TRUE + ) mu ON (mu.person_id = mrou.person_id) + LEFT JOIN ( + SELECT b.person_id, + m.mitarbeiter_uid + FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE b.aktiv = TRUE + ) mb ON (mb.person_id = mm.person_id) + WHERE bf.oe_kurzbz = ? + AND mrou.sent IS NULL + AND mrou.sentinfo IS NOT NULL + GROUP BY mm.message_id, + mm.subject, + mm.body, + mrou.person_id, + mrou.sentinfo, + mrou.token, + mrou.oe_kurzbz, + ks.kontakt, + kr.kontakt, + mu.mitarbeiter_uid, + mb.mitarbeiter_uid'; + + return $this->execQuery($sql, array($functions, $kontaktType, $kontaktType, $oe_kurzbz)); + } + /** * Gets all the sent message by the given person */ @@ -375,14 +453,18 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.person_id, p.vorname, p.nachname, MAX(ms.status) AS status, - ms.person_id AS statusPersonId + ms.person_id AS statusPersonId, + sg.bezeichnung AS sg, + mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) + LEFT JOIN public.tbl_studiengang sg ON (sg.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -391,9 +473,12 @@ class Recipient_model extends DB_Model mm.subject, mm.body, mr.sent, + p.person_id, p.vorname, p.nachname, - ms.person_id + ms.person_id, + sg.bezeichnung, + mr.token ORDER BY mr.sent DESC'; return $this->execQuery($sql, array($person_id)); diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index f5a733c74..1e4dbd187 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -1,34 +1,56 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Read personal messages', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'momentjs' => true, - 'tabulator' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') - ) - ); -?> - -
-
- - - - -
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read personal messages', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'momentjs' => true, + 'tabulator' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') + ) + ); +?> + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php new file mode 100644 index 000000000..25602271c --- /dev/null +++ b/application/views/system/messages/ajaxWriteReply.php @@ -0,0 +1,80 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Reply to a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/public/js/messaging/read.js b/public/js/messaging/read.js index c3b117636..cc463b3f7 100644 --- a/public/js/messaging/read.js +++ b/public/js/messaging/read.js @@ -4,6 +4,7 @@ // Global variable that contains tha tabulator instance var tableMessageLst; +var selectedToggleMessage = "received"; /** * Use DialogLib to display a Generic error @@ -40,7 +41,14 @@ function getSentMessages() */ function changeTinyMCE(row) { - tinyMCE.get("readMessagePanel").setContent(row.getData().body); + if (row == null) + { + tinyMCE.get("readMessagePanel").setContent(''); + } + else + { + tinyMCE.get("readMessagePanel").setContent(row.getData().body); + } } /** @@ -50,8 +58,8 @@ function changeTinyMCE(row) */ function rowClick(e, row) { - // If the message is unread - if (row.getData().status == "0") + // If in received mode and the message is not unread + if (selectedToggleMessage == "received" && row.getData().status == "0") { FHC_AjaxClient.ajaxCallPost( FHC_JS_DATA_STORAGE_OBJECT.called_path + "/setMessageRead", @@ -64,7 +72,8 @@ function rowClick(e, row) if (FHC_AjaxClient.isSuccess(data)) { - rowFormatter(row, "normal"); + rowFormatter(row, "normal"); // format row + row.getData().status = "1"; // update status to read } else { @@ -77,6 +86,12 @@ function rowClick(e, row) ); } + // If NOT in send mode + if (selectedToggleMessage == "received") + { + $("#replyMessage").show(); + } + changeTinyMCE(row); // Change TinyMCE content } @@ -85,8 +100,19 @@ function rowClick(e, row) */ function toggleMessages() { - $(this)[0].id == "received" ? getReceivedMessages() : getSentMessages(); + if ($(this)[0].id == "received") + { + selectedToggleMessage = "received"; + getReceivedMessages(); + } + else + { + selectedToggleMessage = "send"; + $("#replyMessage").hide(); + getSentMessages(); + } + changeTinyMCE(null); // clean tinymce tableMessageLst.redraw(); // redraw table after its content is changed } @@ -119,13 +145,19 @@ function _getMessages(getMessagesURL) if (FHC_AjaxClient.hasData(data)) { - var messages = FHC_AjaxClient.getData(data); + var messages = null; + + try + { + messages = JSON.parse(FHC_AjaxClient.getData(data)); + } + catch (syntaxError) {} if ($.isArray(messages)) { try { - tableMessageLst.replaceData(JSON.parse()); + tableMessageLst.replaceData(messages); } catch (syntaxError) { @@ -141,10 +173,39 @@ function _getMessages(getMessagesURL) } /** - * Start! + * Open new tab/window to write a new message + */ +function writeNewMessage() +{ + window.open("write", "_blank"); +} + +/** + * Open new tab/window to reply to a received message + */ +function replyMessage() +{ + var selectedMessages = tableMessageLst.getSelectedData(); + + if ($.isArray(selectedMessages)) + { + var selectedMessage = selectedMessages[0]; + + window.open("writeReply?token=" + selectedMessage.token, "_blank"); + } + else // + { + FHC_DialogLib.alertInfo("Please select a message"); + } +} + +/** + * Start me up! */ $(document).ready(function () { + $("#replyMessage").hide(); + // TinyMCE initialization tinymce.init({ selector: "#readMessagePanel", @@ -153,14 +214,15 @@ $(document).ready(function () { toolbar: false, statusbar: false, readonly: 1, - autoresize_min_height: 200, + autoresize_min_height: 300, autoresize_bottom_margin: 0 }); // Tabulator initialization tableMessageLst = new Tabulator("#lstMessagesPanel", { - height: "400px", + height: "270px", layout: "fitColumns", + selectable: 1, layoutColumnsOnNewData: true, columns: [ {title: "Subject", field: "subject", responsive: 0}, @@ -175,6 +237,12 @@ $(document).ready(function () { // Bind radio buttons click event with toggleMessages function $("#toggleMessages input").click(toggleMessages); + // Bind write a new message button + $("#writeMessage").click(writeNewMessage); + + // Bind reply to a message button + $("#replyMessage").click(replyMessage); + // First retrieve the received message and populate the tabulator getReceivedMessages(); diff --git a/public/js/messaging/writeReply.js b/public/js/messaging/writeReply.js new file mode 100644 index 000000000..aeb13dc2c --- /dev/null +++ b/public/js/messaging/writeReply.js @@ -0,0 +1,48 @@ +// **************************************************************************************** +// Write a reply to a received message, used by view system/messages/ajaxWriteReply +// **************************************************************************************** + +/** + * + */ +function sendReply() +{ + FHC_AjaxClient.ajaxCallPost( + FHC_JS_DATA_STORAGE_OBJECT.called_path + '/sendMessageReply', + { + receiver_id: $('#receiver_id').val(), + relationmessage_id: $('#relationmessage_id').val(), + token: $('#token').val(), + subject: $('#subject').html(), + body: tinyMCE.get("body").getContent() + }, + { + successCallback: function(data, textStatus, jqXHR) { + + FHC_DialogLib.alertSuccess("Message sent succesfully"); + }, + errorCallback: function() { + FHC_DialogLib.alertError("Error"); + }, + veilTimeout: 300 + } + ); +} + +/** + * + */ +$(document).ready(function () { + + // + tinymce.init({ + selector: "#body", + plugins: "autoresize", + autoresize_min_height: 150, + autoresize_max_height: 600, + autoresize_bottom_margin: 10 + }); + + $('#sendButton').click(sendReply); + +}); From ece06bc462971022917b2b81fbfc5ad7fc622281 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 6 Nov 2019 16:34:20 +0100 Subject: [PATCH 022/157] Notice email for all people allowed to receive messages for an organisation unit --- application/libraries/MessageLib.php | 12 +++++++++--- application/models/system/Recipient_model.php | 6 +++--- public/js/messaging/write.js | 10 +++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 9224996c8..cff457a77 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -528,17 +528,23 @@ class MessageLib if (isError($messageResult)) return $messageResult; // if an error occured then return it if (!hasData($messageResult)) return error('No data found with the given message id'); // if no data found then return an error + // If the message was sent to an organisation unit, then retrives the allowed people to receive the notice email for that organisation unit $messages = getData($messageResult); - if (count($messages) == 1 && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID)) + if (count($messages) == 1 + && $messages[0]->receiver_id == $this->_ci->config->item(self::CFG_SYSTEM_PERSON_ID) + && !isEmptyString($messages[0]->oe_kurzbz)) { - $messages = $this->_ci->RecipientModel->getReceivedMessagesByOE( + $messageResult = $this->_ci->RecipientModel->getMessagesToSentToOE( $messages[0]->oe_kurzbz, $this->_ci->config->item(MessageLib::CFG_OU_RECEIVERS), self::EMAIL_KONTAKT_TYPE ); } - return $this->_sendNotice($messages); + if (isError($messageResult)) return $messageResult; + if (!hasData($messageResult)) return error('It is not possible to retrieve the recipient for this message: '.$message_id); + + return $this->_sendNotice(getData($messageResult)); } /** diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 76a0bf435..4d5e4b986 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -379,9 +379,9 @@ class Recipient_model extends DB_Model } /** - * Gets only the recieved messages from an organisation unit where this person plays a role given by the parameter functions + * Get all the messages to sent to an organisation unit */ - public function getReceivedMessagesByOE($oe_kurzbz, $functions, $kontaktType) + public function getMessagesToSentToOE($oe_kurzbz, $functions, $kontaktType) { // Messages sent to a person that belongs to the recipient organisation unit $sql = 'SELECT mm.message_id, @@ -427,7 +427,7 @@ class Recipient_model extends DB_Model ) mb ON (mb.person_id = mm.person_id) WHERE bf.oe_kurzbz = ? AND mrou.sent IS NULL - AND mrou.sentinfo IS NOT NULL + AND mrou.sentinfo IS NULL GROUP BY mm.message_id, mm.subject, mm.body, diff --git a/public/js/messaging/write.js b/public/js/messaging/write.js index 180a47c36..7be07f28a 100644 --- a/public/js/messaging/write.js +++ b/public/js/messaging/write.js @@ -22,7 +22,15 @@ function sendMessageToOU() }, { successCallback: function(data, textStatus, jqXHR) { - FHC_DialogLib.alertSuccess("Message sent succesfully"); + + if (FHC_AjaxClient.isSuccess(data)) + { + FHC_DialogLib.alertSuccess("Message sent succesfully"); + } + else + { + FHC_DialogLib.alertError("Error"); + } }, errorCallback: function() { FHC_DialogLib.alertError("Error"); From 565cf93f5d1f8177245cd8078c7c7be25cb30ec3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 14 Nov 2019 13:49:31 +0100 Subject: [PATCH 023/157] - Messages GUI multilingual - Tabulator refresh fixed --- application/views/system/messages/ajaxRead.php | 1 + application/views/system/messages/ajaxWrite.php | 13 ++++++++----- .../views/system/messages/ajaxWriteReply.php | 11 ++++++----- .../views/system/messages/htmlWriteTemplate.php | 1 + public/js/messaging/messageWrite.js | 4 ++-- public/js/messaging/messageWriteReply.js | 2 +- public/js/messaging/read.js | 6 ++++-- public/js/messaging/write.js | 8 ++++---- 8 files changed, 27 insertions(+), 19 deletions(-) diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 1e4dbd187..2ff1f6cbb 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -13,6 +13,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/read.js') ) diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 88767628c..6080f3eef 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -11,6 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') ) @@ -22,13 +23,13 @@
- +
- +

- +
diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 25602271c..36d999fc0 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -11,6 +11,7 @@ 'ajaxlib' => true, 'dialoglib' => true, 'tinymce' => true, + 'phrases' => array('global', 'ui'), 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') ) @@ -22,13 +23,13 @@
- +
- +
@@ -40,7 +41,7 @@
- +
 
@@ -53,7 +54,7 @@
- +
"; - echo "
".$p->t('global/datei').":
"; - echo " \n"; - echo " \n"; - echo "\n"; - } - echo "\n"; - - } - } - -} -//notenübersicht -else -{ - if ($lektorenansicht == 1) - { - $uid_arr = Array(); - $vorname_arr = Array(); - $nachname_arr = Array(); - - $qry_stud_dd = "SELECT uid, vorname, nachname, matrikelnr FROM campus.vw_student_lehrveranstaltung JOIN campus.vw_student using(uid) WHERE studiensemester_kurzbz = ".$db->db_add_param($stsem)." and lehreinheit_id = ".$db->db_add_param($lehreinheit_id, FHC_INTEGER)." ORDER BY nachname, vorname"; - if($result_stud_dd = $db->db_query($qry_stud_dd)) - { - $i=1; - while($row_stud_dd = $db->db_fetch_object($result_stud_dd)) - { - $uid_arr[] = $row_stud_dd->uid; - $vorname_arr[] = $row_stud_dd->vorname; - $nachname_arr[] = $row_stud_dd->nachname; - - } - } - - echo "


"; - echo $p->t('benotungstool/studentenAuswaehlen').": "; - $key = array_search($uid,$uid_arr); - $prev = $key-1; - $next = $key+1; - if ($key > 0) - echo " << "; - echo ""; - if ($key < count($uid_arr)-1) - echo "
>> "; - - echo "


"; - } - - echo "
".$p->t('benotungstool/leistungsuebersichtNotenuebersichtFuer')." $name

"; - echo "
"; - - $uebung_obj = new uebung(); - $uebung_obj->load_uebung($lehreinheit_id,1); - if(count($uebung_obj->uebungen)>0) - { - - echo ""; - echo " \n"; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " "; - echo " \n"; - foreach ($uebung_obj->uebungen as $row) - { - - $subuebung_obj = new uebung(); - $subuebung_obj->load_uebung($lehreinheit_id,2,$row->uebung_id); - $l1note = new studentnote(); - if(count($subuebung_obj->uebungen) >= 0) - { - - - $l1note->calc_l1_note($row->uebung_id, $user, $lehreinheit_id); - if ($l1note->negativ) - $l1_note = 5; - else - $l1_note = $l1note->l1_note; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo ""; - echo "\n"; - echo " \n"; - - } - - if(count($subuebung_obj->uebungen) > 0) - { - - foreach ($subuebung_obj->uebungen as $subrow) - { - - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - if ($subrow->beispiele) - { - $l1note->calc_punkte($subrow->uebung_id, $user); - echo " "; - echo " \n"; - echo " \n"; - } - else if ($subrow->abgabe) - { - $l1note->calc_note($subrow->uebung_id, $user); - echo " \n"; - echo " "; - echo " \n"; - } - echo " \n"; /* - if($datum_obj->mktime_fromtimestamp($subrow->freigabevon)mktime_fromtimestamp($subrow->freigabebis)>time()) - echo ' + '; - else - echo ' - '; - */ - - } - - } - } - $l1note->calc_gesamtnote($lehreinheit_id, $stsem, $user); - if ($l1note->negativ) - $gesamtnote = 5; - else - $gesamtnote = $l1note->studentgesamtnote; - echo ""; - - - echo "
".$p->t('benotungstool/aufgabe')."".$p->t('benotungstool/gewicht')."".$p->t('benotungstool/punkte')."".$p->t('benotungstool/teilnote')."".$p->t('benotungstool/note')."
"; - echo $row->bezeichnung; - if ($row->positiv) - echo "*"; - echo " ".$row->gewicht.""; - if ($l1note->punkte_gesamt_l1 >0) - echo $l1note->punkte_gesamt_l1; - echo "".$l1_note."
- \n"; - echo $subrow->bezeichnung; - if ($subrow->positiv) - echo "*"; - echo " \n"; - if ($subrow->abgabe) - echo $subrow->gewicht; - echo " ".$l1note->punkte_gesamt."".$l1note->note."
".$p->t('benotungstool/errechneteGesamtnote').": ".$gesamtnote."
"; - echo "".$p->t('benotungstool/mussPositivSein').""; - } - - echo "
"; - - $legesamtnote = new legesamtnote($lehreinheit_id); - - if (!$legesamtnote->load($user, $lehreinheit_id)) - { - $lenote = null; - } - else - { - $lenote = $legesamtnote->note; - } - if ($lvgesamtnote = new lvgesamtnote($lvid,$user,$stsem)) - { - $lvnote = $lvgesamtnote->note; - } - else - $lvnote = null; - if ($zeugnisnote = new zeugnisnote($lvid,$user,$stsem)) - { - $znote = $zeugnisnote->note; - } - else - $znote = null; - - echo "\n"; - echo " "; - echo "\n"; - echo ""; - echo ""; - echo "\n"; - echo "\n"; - echo ""; - echo ""; - echo "\n"; - echo "\n"; - echo ""; - echo ""; - echo "\n"; - echo "
".$p->t('benotungstool/eingetrageneNoten')."
".$p->t('global/lehreinheit')."".$lenote."
".$p->t('global/lehrveranstaltung')."".$lvnote."
".$p->t('benotungstool/zeunis')."".$znote."
"; - - echo "
"; -} -?> - - diff --git a/cis/private/lehre/benotungstool/studentenpunkteverwalten.php b/cis/private/lehre/benotungstool/studentenpunkteverwalten.php deleted file mode 100644 index 199b3a841..000000000 --- a/cis/private/lehre/benotungstool/studentenpunkteverwalten.php +++ /dev/null @@ -1,978 +0,0 @@ -, - * Andreas Oesterreicher and - * Rudolf Hangl . - */ - -require_once('../../../../config/cis.config.inc.php'); -require_once('../../../../include/basis_db.class.php'); -require_once('../../../../include/functions.inc.php'); -require_once('../../../../include/lehrveranstaltung.class.php'); -require_once('../../../../include/studiengang.class.php'); -require_once('../../../../include/studiensemester.class.php'); -require_once('../../../../include/lehreinheit.class.php'); -require_once('../../../../include/benutzerberechtigung.class.php'); -require_once('../../../../include/uebung.class.php'); -require_once('../../../../include/beispiel.class.php'); -require_once('../../../../include/studentnote.class.php'); -require_once('../../../../include/datum.class.php'); -require_once('functions.inc.php'); -require_once('../../../../include/phrasen.class.php'); - -$sprache = getSprache(); -$p = new phrasen($sprache); -if (!$db = new basis_db()) - die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); -$user = get_uid(); - -if(!check_lektor($user)) - die($p->t('global/keineBerechtigungFuerDieseSeite')); - -$rechte = new benutzerberechtigung(); -$rechte->getBerechtigungen($user); - -if(isset($_GET['lvid']) && is_numeric($_GET['lvid'])) //Lehrveranstaltung_id - $lvid = $_GET['lvid']; -else - die($p->t('global/fehlerBeiDerParameteruebergabe')); - -if(isset($_GET['lehreinheit_id']) && is_numeric($_GET['lehreinheit_id'])) //Lehreinheit_id - $lehreinheit_id = $_GET['lehreinheit_id']; -else - $lehreinheit_id = ''; - -//Laden der Lehrveranstaltung -$lv_obj = new lehrveranstaltung(); -if(!$lv_obj->load($lvid)) - die($lv_obj->errormsg); - -//Studiengang laden -$stg_obj = new studiengang($lv_obj->studiengang_kz); - -if(isset($_GET['stsem'])) - $stsem = $_GET['stsem']; -else - $stsem = ''; - -//Vars -$datum_obj = new datum(); - -$uebung_id = (isset($_GET['uebung_id'])?$_GET['uebung_id']:''); -$uid = (isset($_GET['uid'])?$_GET['uid']:''); - -//Abgabedatei ausliefern -if (isset($_GET["download_abgabe"])){ - $file=$_GET["download_abgabe"]; - $uebung_id = $_GET["uebung_id"]; - $ueb = new uebung(); - $ueb->load_studentuebung($uid, $uebung_id); - $ueb->load_abgabe($ueb->abgabe_id); - $filename = BENOTUNGSTOOL_PATH."abgabe/".$ueb->abgabedatei; - header('Content-Type: application/octet-stream'); - header('Content-disposition: attachment; filename="'.$file.'"'); - readfile($filename); - exit; -} - -//Handbuch ausliefern -if (isset($_GET["handbuch"])){ - $filename = BENOTUNGSTOOL_PATH."handbuch_benotungstool.pdf"; - header('Content-Type: application/octet-stream'); - header('Content-disposition: attachment; filename="handbuch_benotungstool.pdf"'); - readfile($filename); - exit; -} - - -if (isset($_FILES["abgabedatei"])) -{ - //echo $_FILES["abgabedatei"]; - $abgabedatei_up = $_FILES["abgabedatei"]["tmp_name"]; - - if ($abgabedatei_up) - { - $student_uid = $uid; - $datum = date('Y-m-d H:i:s'); - $datumstr = ereg_replace(" ","_",$datum); - $name_up = pathinfo($_FILES["abgabedatei"]["name"]); - $name_neu = makeUploadName($db, $which='abgabe', $lehreinheit_id=$lehreinheit_id, $uebung_id=$uebung_id, $ss=$stsem,$uid=$student_uid, $date=$datumstr); - $name_neu = preg_replace('/[^A-Za-z0-9\-_]/', '',$name_neu); - $abgabedatei = $name_neu.".".$name_up["extension"]; - $abgabepfad = BENOTUNGSTOOL_PATH."abgabe/".$abgabedatei; - - $uebung_obj = new uebung(); - $uebung_obj->load_studentuebung($student_uid, $uebung_id); - - - if ($uebung_obj->errormsg != "") - { - $uebung_obj->student_uid = $student_uid; - $uebung_obj->mitarbeiter_uid = null; - $uebung_obj->abgabe_id = null; - $uebung_obj->uebung_id = $uebung_id; - $uebung_obj->note = null; - $uebung_obj->mitarbeitspunkte = null; - $uebung_obj->punkte = null; - $uebung_obj->anmerkung = null; - $uebung_obj->benotungsdatum = null; - $uebung_obj->updateamum = null; - $uebung_obj->updatevon = null; - $uebung_obj->insertamum = $datum; - $uebung_obj->insertvon = $user; - $uebung_obj->new = true; - $uebung_obj->studentuebung_save($new=true); - echo $uebung_obj->errormsg; - - } - if ($uebung_obj->abgabe_id != null) - { - $uebung_obj->load_abgabe($uebung_obj->abgabe_id); - unlink(BENOTUNGSTOOL_PATH."abgabe/".$uebung_obj->abgabedatei); - $uebung_obj->abgabedatei = $abgabedatei; - $uebung_obj->abgabezeit = $datum; - $uebung_obj->abgabe_anmerkung = ""; - $uebung_obj->abgabe_save(false); - } - else - { - $uebung_obj->abgabedatei = $abgabedatei; - $uebung_obj->abgabezeit = $datum; - $uebung_obj->abgabe_anmerkung = ""; - $uebung_obj->abgabe_save(true); - } - $uebung_obj->studentuebung_save(false); - //Abgabedatei ablegen - move_uploaded_file($_FILES['abgabedatei']['tmp_name'], $abgabepfad); - } -} -else - $abgabedatei_up = null; - -?> - - - - - -<?php echo $p->t('benotungstool/benotungstool');?> - - - - -

'.$p->t('benotungstool/benotungstool'); -echo '

'."\n"; - -//Studiensemester laden -$stsem_obj = new studiensemester(); -if($stsem=='') - $stsem = $stsem_obj->getaktorNext(); - -$stsem_obj->getAll(); - -//Studiensemester DropDown -$stsem_content = $p->t('global/studiensemester').": \n"; - -//Lehreinheiten laden -if($rechte->isBerechtigt('admin',0) || $rechte->isBerechtigt('admin',$lv_obj->studiengang_kz) || $rechte->isBerechtigt('lehre',$lv_obj->studiengang_kz)) -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); -} -else -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id IN (SELECT lehrveranstaltung_id FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitmitarbeiter USING(lehreinheit_id) WHERE mitarbeiter_uid=".$db->db_add_param($user).") AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); - -} - -if($result = $db->db_query($qry)) -{ - if($db->db_num_rows($result)>0) - { - //Lehreinheiten DropDown - echo $p->t('global/lehreinheit').": '; - } - else - { - if($row = $db->db_fetch_object($result)) - $lehreinheit_id = $row->lehreinheit_id; - } -} -else -{ - echo $p->t('benotungstool/fehlerBeimAuslesen'); -} -echo $stsem_content; -echo ''; -echo ''; -echo ''; -echo " -
 \n"; -echo "".$lv_obj->bezeichnung_arr[$sprache]."
"; - -if($lehreinheit_id=='') - die($p->t('benotungstool/keinePassendeLehreinheitGefunden')); - -//Menue -include("menue.inc.php"); -/* -echo "\n\n"; -echo "
 Verwaltung     - Anwesenheits- und Übersichtstabelle     - Studentenpunkte verwalten     - Statistik -

-\n"; -*/ - -echo "

".$p->t('benotungstool/studentenaufgabenVerwalten')."

"; -if(isset($_POST['submit'])) -{ - $error=false; - $punkte = (isset($_POST['punkte'])?mb_ereg_replace(',','.',$_POST['punkte']):''); - if(isset($punkte) && is_numeric($punkte) && !isset($_POST['abgabe'])) - { - $ueb_obj = new uebung(); - if($ueb_obj->load_studentuebung($uid, $uebung_id)) - $ueb_obj->new = false; - else - { - $ueb_obj->new = true; - $ueb_obj->insertamum = date('Y-m-d H:i:s'); - $ueb_obj->insertvon = $user; - } - - $ueb_obj->mitarbeitspunkte = $punkte; - $ueb_obj->anmerkung = $_POST['anmerkung']; - $ueb_obj->updateamum = date('Y-m-d H:i:s'); - $ueb_obj->updatevon = $user; - $ueb_obj->mitarbeiter_uid = $user; - $ueb_obj->uebung_id = $uebung_id; - $ueb_obj->student_uid = $uid; - - if(!$ueb_obj->studentuebung_save()) - $error = true; - - $bsp_obj = new beispiel(); - - if($bsp_obj->load_beispiel($uebung_id)) - { - foreach ($bsp_obj->beispiele as $row) - { - $stud_bsp_obj = new beispiel(); - - if($stud_bsp_obj->load_studentbeispiel($uid, $row->beispiel_id)) - { - $stud_bsp_obj->new=false; - } - else - { - $stud_bsp_obj->new=true; - $stud_bsp_obj->insertamum = date('Y-m-d H:i:s'); - $stud_bsp_obj->insertvon = $user; - } - $stud_bsp_obj->vorbereitet = ($_POST['solved_'.$row->beispiel_id]==1?true:false); - $stud_bsp_obj->probleme = (isset($_POST['problem_'.$row->beispiel_id])?true:false); - $stud_bsp_obj->updateamum = date('Y-m-d H:i:s'); - $stud_bsp_obj->updatevon = $user; - $stud_bsp_obj->student_uid = $uid; - $stud_bsp_obj->beispiel_id = $row->beispiel_id; - - if(!$stud_bsp_obj->studentbeispiel_save()) - { - echo $stud_bsp_obj->errormsg; - $error=true; - } - } - } - - if($error) - echo "".$p->t('benotungstool/esKonntenNichtAlleDatenGespeichertWerden').""; - else - echo $p->t('global/erfolgreichgespeichert')."
"; - - } - else if (!isset($_POST['abgabe'])) - { - echo "".$p->t('benotungstool/punkteSindUngueltig').""; - } - if(isset($_POST['abgabe']) && is_numeric($_POST['note'])) - { - $note = $_POST['note']; - $ueb_obj = new uebung(); - if($ueb_obj->load_studentuebung($uid, $uebung_id)) - $ueb_obj->new = false; - else - { - $ueb_obj->new = true; - $ueb_obj->insertamum = date('Y-m-d H:i:s'); - $ueb_obj->insertvon = $user; - } - - $ueb_obj->note = $note; - $ueb_obj->anmerkung = $_POST['anmerkung']; - $ueb_obj->updateamum = date('Y-m-d H:i:s'); - $ueb_obj->updatevon = $user; - $ueb_obj->mitarbeiter_uid = $user; - $ueb_obj->uebung_id = $uebung_id; - $ueb_obj->student_uid = $uid; - - if(!$ueb_obj->studentuebung_save()) - $error = true; - if($error) - echo "".$p->t('benotungstool/esKonntenNichtAlleDatenGespeichertWerden').""; - else - echo $p->t('global/erfolgreichgespeichert')."
"; - } - else if (isset($_POST['abgabe'])) - echo "".$p->t('benotungstool/noteIstUngueltig')."
"; -} - -if(isset($_GET['uid']) && $_GET['uid']!='') -{ - //Punkte eintragen - $uid = addslashes($_GET['uid']); - - $qry_stud = "SELECT vorname, nachname, uid FROM campus.vw_student WHERE uid='$uid'"; - - if(!$result_stud = $db->db_query($qry_stud)) - die($p->t('benotungstool/fehlerBeimLadenDesStudenten')); - - if(!$row_stud = $db->db_fetch_object($result_stud)) - die($p->t('benotungstool/studentWurdeNichtGefunden')); - - //echo "$row_stud->vorname $row_stud->nachname
\n"; - - - - $uid_arr = Array(); - $vorname_arr = Array(); - $nachname_arr = Array(); - - // studentenquery - $qry_stud_dd = "SELECT uid, vorname, nachname, matrikelnr FROM campus.vw_student_lehrveranstaltung JOIN campus.vw_student using(uid) WHERE studiensemester_kurzbz = ".$db->db_add_param($stsem)." and lehreinheit_id = ".$db->db_add_param($lehreinheit_id, FHC_INTEGER)." ORDER BY nachname, vorname"; - if($result_stud_dd = $db->db_query($qry_stud_dd)) - { - $i=1; - while($row_stud_dd = $db->db_fetch_object($result_stud_dd)) - { - $uid_arr[] = $row_stud_dd->uid; - $vorname_arr[] = $row_stud_dd->vorname; - $nachname_arr[] = $row_stud_dd->nachname; - - } - } -// } -// } - echo $p->t('benotungstool/studentenAuswaehlen').": "; - $key = array_search($uid,$uid_arr); - $prev = $key-1; - $next = $key+1; - if ($key > 0) - echo " << "; - echo ""; - if ($key < count($uid_arr)-1) - echo " >> "; - - - $uebung_obj = new uebung(); - $uebung_obj->load_uebung($lehreinheit_id,1); - if(count($uebung_obj->uebungen)>0) - { - echo "'; - - echo " -
"; - echo "
".$p->t('benotungstool/waehlenSieEineAufgabeAus').": '; - - echo '
- - - - - - - - - -
+...".$p->t('benotungstool/freigeschaltet').".
-...".$p->t('benotungstool/nichtFreigeschaltet').".
-
"; - } - else - die($p->t('benotungstool/derzeitSindKeineUebungenAngelegt')); - - $ueb_obj = new uebung(); - $ueb_obj->load($uebung_id); - if($ueb_obj->load_studentuebung($uid, $uebung_id)) - { - $anmerkung = $ueb_obj->anmerkung; - $mitarbeit = $ueb_obj->mitarbeitspunkte; - $note = $ueb_obj->note; - } - else - { - $anmerkung = ''; - $mitarbeit = 0; - $note = ''; - } - - if ($ueb_obj->beispiele && is_numeric($_GET['uebung_id'])) - { - echo " -
- - - - - - -
- ".$p->t('global/anmerkung').":
- -

- - - - - - - - "; - - $bsp_obj = new beispiel(); - $bsp_obj->load_beispiel($uebung_id); - - foreach ($bsp_obj->beispiele as $row) - { - $stud_bsp_obj = new beispiel(); - if($stud_bsp_obj->load_studentbeispiel($uid, $row->beispiel_id)) - { - $vorbereitet = $stud_bsp_obj->vorbereitet; - $probleme = $stud_bsp_obj->probleme; - } - else - { - $vorbereitet = false; - $probleme = false; - } - echo " - - - - - - "; - } - - echo "
".$p->t('benotungstool/beispiel')."".$p->t('benotungstool/vorbereitet')."".$p->t('benotungstool/nichtVorbereitet')."".$p->t('benotungstool/probleme')."".$p->t('benotungstool/punkte')."
$row->bezeichnung$row->punkte
"; - - - - $ueb_obj->load_studentuebung($uid, $uebung_id); - if ($ueb_obj->abgabe_id) - { - $ueb_obj->load_abgabe($ueb_obj->abgabe_id); - $filename = $ueb_obj->abgabedatei; - } - else - $filename=''; - - if ($filename != '') - echo "
".$p->t('benotungstool/abgabedatei').": ".$filename."

"; - - - - echo " -
"; - - //Gesamtpunkte diese Kreuzerlliste - $qry = "SELECT sum(punkte) as punktegesamt FROM campus.tbl_beispiel WHERE uebung_id=".$db->db_add_param($uebung_id, FHC_INTEGER); - $punkte_gesamt=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $punkte_gesamt = $row->punktegesamt; - - //Eingetragen diese Kreuzerlliste - $qry = "SELECT sum(punkte) as punkteeingetragen FROM campus.tbl_beispiel JOIN campus.tbl_studentbeispiel USING(beispiel_id) WHERE uebung_id=".$db->db_add_param($uebung_id, FHC_INTEGER)." AND student_uid=".$db->db_add_param($uid)." AND vorbereitet=true"; - $punkte_eingetragen=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $punkte_eingetragen = ($row->punkteeingetragen!=''?$row->punkteeingetragen:0); - - - //Gesamtpunkte alle Kreuzerllisten in dieser Übung - $ueb_help = new uebung($uebung_id); - $liste_id = $ueb_help->liste_id; - $qry = "SELECT sum(tbl_beispiel.punkte) as punktegesamt_alle FROM campus.tbl_beispiel, campus.tbl_uebung - WHERE tbl_uebung.uebung_id=tbl_beispiel.uebung_id AND - tbl_uebung.lehreinheit_id=".$db->db_add_param($lehreinheit_id, FHC_INTEGER)." and tbl_uebung.liste_id = ".$db->db_add_param($liste_id, FHC_INTEGER); - $punkte_gesamt_alle=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $punkte_gesamt_alle = $row->punktegesamt_alle; - - //Eingetragen alle Kreuzerllisten - $qry = "SELECT sum(tbl_beispiel.punkte) as punkteeingetragen_alle FROM campus.tbl_beispiel, campus.tbl_studentbeispiel, campus.tbl_uebung - WHERE tbl_beispiel.beispiel_id = tbl_studentbeispiel.beispiel_id AND - tbl_uebung.uebung_id=tbl_beispiel.uebung_id AND - tbl_uebung.lehreinheit_id=".$db->db_add_param($lehreinheit_id)." AND - tbl_uebung.liste_id = ".$db->db_add_param($liste_id)." AND - tbl_studentbeispiel.student_uid=".$db->db_add_param($uid)." AND vorbereitet=true"; - $punkte_eingetragen_alle=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $punkte_eingetragen_alle = ($row->punkteeingetragen_alle!=''?$row->punkteeingetragen_alle:0); - - //Mitarbeitspunkte - $qry = "SELECT sum(mitarbeitspunkte) as mitarbeitspunkte FROM campus.tbl_studentuebung JOIN campus.tbl_uebung USING(uebung_id) - WHERE lehreinheit_id=".$db->db_add_param($lehreinheit_id, FHC_INTEGER)." AND student_uid=".$db->db_add_param($uid)." and liste_id=".$db->db_add_param($liste_id); - $mitarbeit_alle=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $mitarbeit_alle = ($row->mitarbeitspunkte!=''?$row->mitarbeitspunkte:0); - - //Mitarbeitspunkte - $qry = "SELECT mitarbeitspunkte FROM campus.tbl_studentuebung - WHERE uebung_id=".$db->db_add_param($uebung_id, FHC_INTEGER)." AND student_uid=".$db->db_add_param($uid); - $mitarbeit=0; - if($result=$db->db_query($qry)) - if($row = $db->db_fetch_object($result)) - $mitarbeit = ($row->mitarbeitspunkte!=''?$row->mitarbeitspunkte:0); - echo " -
- - - - - - - - - - - - -
Diese Kreuzerlliste:
".$p->t('benotungstool/punkteInsgesamtMoeglich').":$punkte_gesamt
".$p->t('benotungstool/punkteEingetragen').":$punkte_eingetragen
-

- - - - - - - - - - - - -
".$p->t('benotungstool/alleKreuzerllistenDieserUebung').":
".$p->t('benotungstool/punkteInsgesamtMoeglich').":$punkte_gesamt_alle
".$p->t('benotungstool/punkteEingetragen').":$punkte_eingetragen_alle
-

- - - - - - - - - - - - -
".$p->t('benotungstool/mitarbeitspunkte').":
".$p->t('benotungstool/bisherInsgesamt').":$mitarbeit_alle
".$p->t('benotungstool/dieseKreuzerlliste').":
- "; - - - echo " -
  - - -
- -
- "; - } - else if (is_numeric($_GET['uebung_id'])) - { - $ueb_obj->load_studentuebung($uid, $uebung_id); - if ($ueb_obj->abgabe_id) - { - $ueb_obj->load_abgabe($ueb_obj->abgabe_id); - $filename = $ueb_obj->abgabedatei; - } - else - $filename=''; - //Abgaben benoten - $studentnote = new studentnote($lehreinheit_id,$stsem,$uid,$uebung_id); - $studentnote->calc_note($uebung_id, $uid); - echo "".$p->t('benotungstool/note').": ".$studentnote->note." (Gewicht: ".$ueb_obj->gewicht.")

"; - if ($filename != '') - echo $p->t('benotungstool/abgabedatei').": ".$filename."

"; - echo " -
-
- ".$p->t('global/anmerkung').":
- -
- - - - - "; - echo " - - - - -
Note
- - -
- "; - - } - echo "
"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "
\n"; - echo " ".$p->t('benotungstool/studentenabgabedatei').":
"; - echo "
"; -} -else -{ - - //Übungen benoten - $uebung_obj = new uebung(); - $uebung_obj->load_uebung($lehreinheit_id,1); - if(count($uebung_obj->uebungen)>0) - { - echo "
"; - echo "
".$p->t('benotungstool/aufgabeKreuzerllistenAbgaben').": '; - echo " [".$p->t('benotungstool/benoten')."]"; - $abgabe_obj = new uebung($uebung_id); - if ($abgabe_obj->abgabe && glob(BENOTUNGSTOOL_PATH."abgabe/*_[WS]S[0-9][0-9][0-9][0-9]_".$uebung_id."_*")) - { - $date = date('Y-m-d_H:i:s'); - $downloadname = makeUploadName($db, $which="zip", $lehreinheit_id, $uebung_id, $stsem, $uid=null, $date); - $downloadname = str_replace($uebung_id, str_replace(" ","_",$abgabe_obj->bezeichnung), $downloadname); - $downloadname = preg_replace('/[^A-Za-z0-9\-_]/', '',$downloadname); - echo " [".$p->t('benotungstool/abgabenDownloaden')."]"; - } - else - echo "[".$p->t('benotungstool/keineAbgabenVerfuegbar')."]"; - - echo '
'; - } - - - - - echo "


"; - //Studentenliste - echo $p->t('benotungstool/bitteWaehlenSieDenStudentenAus')."
"; - echo " - - "; - - echo " - - - - - - - - - - - - - - - - - - - "; - /* - if($row_grp->gruppe_kurzbz!='') - { - echo " - - - "; - $qry_stud = "SELECT uid, vorname, nachname, matrikelnr FROM campus.vw_student JOIN public.tbl_benutzergruppe USING(uid) WHERE gruppe_kurzbz='".addslashes($row_grp->gruppe_kurzbz)."' AND studiensemester_kurzbz = '".$stsem."' ORDER BY nachname, vorname"; - } - else - { - echo " - - - "; - $qry_stud = "SELECT uid, vorname, nachname, matrikelnr FROM campus.vw_student - WHERE studiengang_kz='$row_grp->studiengang_kz' AND - semester='$row_grp->semester' ". - ($row_grp->verband!=''?" AND trim(verband)=trim('$row_grp->verband')":''). - ($row_grp->gruppe!=''?" AND trim(gruppe)=trim('$row_grp->gruppe')":''). - " ORDER BY nachname, vorname"; - } - */ - // studentenquery - $qry_stud = "SELECT uid, vorname, nachname, matrikelnr FROM campus.vw_student_lehrveranstaltung JOIN campus.vw_student using(uid) WHERE studiensemester_kurzbz = '".$stsem."' and lehreinheit_id = '".$lehreinheit_id."' ORDER BY nachname, vorname"; - if($result_stud = $db->db_query($qry_stud)) - { - $i=1; - while($row_stud = $db->db_fetch_object($result_stud)) - { - - - - echo " - - - - - - "; - $i++; - } - } -// } -// } - echo "
    
".$p->t('global/uid')."".$p->t('global/nachname')."".$p->t('global/vorname')."".$p->t('benotungstool/studentenansicht')."
    
$row_grp->gruppe_kurzbz
Verband $row_grp->verband ".($row_grp->gruppe!=''?"Gruppe $row_grp->gruppe":'')."
$row_stud->uid$row_stud->nachname$row_stud->vorname".$p->t('benotungstool/studentenansicht')."
"; -} -?> -
- - diff --git a/cis/private/lehre/benotungstool/verwaltung.php b/cis/private/lehre/benotungstool/verwaltung.php deleted file mode 100644 index e35eaecb1..000000000 --- a/cis/private/lehre/benotungstool/verwaltung.php +++ /dev/null @@ -1,941 +0,0 @@ -, - * Andreas Oesterreicher and - * Rudolf Hangl . - */ - -require_once('../../../../config/cis.config.inc.php'); -require_once('../../../../include/basis_db.class.php'); -require_once('../../../../include/functions.inc.php'); -require_once('../../../../include/lehrveranstaltung.class.php'); -require_once('../../../../include/studiengang.class.php'); -require_once('../../../../include/studiensemester.class.php'); -require_once('../../../../include/lehreinheit.class.php'); -require_once('../../../../include/benutzerberechtigung.class.php'); -require_once('../../../../include/uebung.class.php'); -require_once('../../../../include/beispiel.class.php'); -require_once('../../../../include/datum.class.php'); -require_once('functions.inc.php'); -require_once('../../../../include/phrasen.class.php'); - -$sprache = getSprache(); -$p = new phrasen($sprache); - -if (!$db = new basis_db()) - die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); - - -function microtime_float() -{ - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); -} -$time = microtime_float(); -?> - - - - - -Kreuzerltool - - - - -t('global/keineBerechtigungFuerDieseSeite')); - -$rechte = new benutzerberechtigung(); -$rechte->getBerechtigungen($user); - -if(isset($_GET['lvid']) && is_numeric($_GET['lvid'])) //Lehrveranstaltung_id - $lvid = $_GET['lvid']; -else - die($p->t('global/fehlerBeiDerParameteruebergabe')); - -if(isset($_GET['lehreinheit_id']) && is_numeric($_GET['lehreinheit_id'])) //Lehreinheit_id - $lehreinheit_id = $_GET['lehreinheit_id']; -else - $lehreinheit_id = ''; - -//Laden der Lehrveranstaltung -$lv_obj = new lehrveranstaltung(); -if(!$lv_obj->load($lvid)) - die($lv_obj->errormsg); - -//Studiengang laden -$stg_obj = new studiengang($lv_obj->studiengang_kz); - -if(isset($_GET['stsem'])) - $stsem = $_GET['stsem']; -else - $stsem = ''; - -//Vars -$datum_obj = new datum(); -$global_msg =''; -$error_thema=''; -$error_anzahlderbeispiele=''; -$error_punkteprobeispiel=''; -$error_freigabebis=''; -$error_freigabevon=''; -$error_gewicht=''; - -$thema = (isset($_POST['thema'])?$_POST['thema']:''); -$anzahlderbeispiele = (isset($_POST['anzahlderbeispiele'])?$_POST['anzahlderbeispiele']:''); -$punkteprobeispiel = (isset($_POST['punkteprobeispiel'])?$_POST['punkteprobeispiel']:''); -$punkteprobeispiel = mb_ereg_replace(',','.',$punkteprobeispiel); -$freigabebis = (isset($_POST['freigabebis'])?$_POST['freigabebis']:''); -$freigabevon = (isset($_POST['freigabevon'])?$_POST['freigabevon']:''); -$gewicht = (isset($_POST['gewicht'])?$_POST['gewicht']:''); -$positiv = (isset($_POST['positiv'])?$_POST['positiv']:''); - -$uebung_id = (isset($_GET['uebung_id'])?$_GET['uebung_id']:''); -$copy_content = ''; -$copy_dropdown = ''; - -//Kopfzeile -echo '

'.$p->t('benotungstool/benotungstool'); -echo '

'."\n"; - -//Studiensemester laden -$stsem_obj = new studiensemester(); -if($stsem=='') - $stsem = $stsem_obj->getaktorNext(); - -$stsem_obj->getAll(); - - -//Studiensemester DropDown -$stsem_content = $p->t('global/studiensemester').": \n"; - -//Lehreinheiten laden -if($rechte->isBerechtigt('admin',0) || $rechte->isBerechtigt('admin',$lv_obj->studiengang_kz) || $rechte->isBerechtigt('lehre',$lv_obj->studiengang_kz)) -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); -} -else -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id IN (SELECT lehrveranstaltung_id FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitmitarbeiter USING(lehreinheit_id) WHERE mitarbeiter_uid=".$db->db_add_param($user).") AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); -} - -if($result = $db->db_query($qry)) -{ - $result_alle_lehreinheiten = $result; - if($db->db_num_rows($result)>1) - { - //Lehreinheiten DropDown - echo $p->t('global/lehreinheit').": "; - while($row = $db->db_fetch_object($result)) - { - if($lehreinheit_id=='') - $lehreinheit_id=$row->lehreinheit_id; - $selected = ($row->lehreinheit_id == $lehreinheit_id?'selected':''); - //Zugeteilte Lektoren - $qry_lektoren = "SELECT * FROM lehre.tbl_lehreinheitmitarbeiter JOIN public.tbl_mitarbeiter using(mitarbeiter_uid) WHERE lehreinheit_id=".$db->db_add_param($row->lehreinheit_id, FHC_INTEGER); - if($result_lektoren = $db->db_query($qry_lektoren)) - { - $lektoren = '( '; - $i=0; - while($row_lektoren = $db->db_fetch_object($result_lektoren)) - { - $lektoren .= $row_lektoren->kurzbz; - $i++; - if($i<$db->db_num_rows($result_lektoren)) - $lektoren.=', '; - else - $lektoren.=' '; - } - $lektoren .=')'; - } - - - //Zugeteilte Gruppen - $qry_gruppen = "SELECT * FROM lehre.tbl_lehreinheitgruppe WHERE lehreinheit_id=".$db->db_add_param($row->lehreinheit_id, FHC_INTEGER); - if($result_gruppen = $db->db_query($qry_gruppen)) - { - $gruppen = ''; - $i=0; - while($row_gruppen = $db->db_fetch_object($result_gruppen)) - { - if($row_gruppen->gruppe_kurzbz=='') - $gruppen.=$row_gruppen->semester.$row_gruppen->verband.$row_gruppen->gruppe; - else - $gruppen.=$row_gruppen->gruppe_kurzbz; - $i++; - if($i<$db->db_num_rows($result_gruppen)) - $gruppen.=', '; - else - $gruppen.=' '; - } - } - echo "\n"; - if ($lehreinheit_id != $row->lehreinheit_id) - $copy_dropdown .= ""; - } - echo ' '; - $copy_dropdown .=""; - } - else - { - if($row = $db->db_fetch_object($result)) - $lehreinheit_id = $row->lehreinheit_id; - } -} -else -{ - echo $p->t('benotungstool/fehlerBeimAuslesen'); -} -echo $stsem_content; -echo '
'; - -echo ''; -echo ''; -echo "
 \n"; - -echo "

".$lv_obj->bezeichnung_arr[$sprache]."

"; - -if($lehreinheit_id=='') - die($p->t('benotungstool/esGibtKeineLehreinheiten')); - -//Menue -include("menue.inc.php"); -/* -echo "\n\n"; -echo "
- Verwaltung     - Anwesenheits- und Übersichtstabelle     - Studentenpunkte verwalten     - Statistik -

-\n"; -*/ - -//echo "studiensemester: $stsem
"; -//echo "lehrveranstaltung: $lvid
"; -//echo "lehreinheit: $lehreinheit_id
"; -//Übung in andere LE kopieren - -if (isset($_REQUEST["copy_uebung"])) -{ - $copy_insert = 0; - $copy_update = 0; - $copy_insert_bsp = 0; - $copy_update_bsp = 0; - $uebung_id_source = $_REQUEST["uebung_id_source"]; - $lehreinheit_id_target = $_REQUEST["lehreinheit_id_target"]; - if (!is_numeric($uebung_id_source) or !is_numeric($lehreinheit_id_target)) - echo "".$p->t('benotungstool/uebungUndLehreinheit')."!"; - else - { - $ueb_1 = new uebung($uebung_id_source); - $nummer_source = $ueb_1->nummer; - $qry = "SELECT * from campus.tbl_uebung where nummer = ".$db->db_add_param($nummer_source)." and lehreinheit_id = ".$db->db_add_param($lehreinheit_id_target, FHC_INTEGER); - //echo $qry; - if($result1 = $db->db_query($qry)) - { - if ($db->db_num_rows($result1) >0) - { - $row1 = $db->db_fetch_object($result1); - $ueb_1_target =new uebung($row1->uebung_id); - $ueb_1_target->new = false; - $new = null; - $ueb_1_target->insertamum = null; - $ueb_1_target->insertvon = null; - $ueb_1_target->updateamum = date('Y-m-d H:i:s'); - $ueb_1_target->updatevon = $user; - $copy_update++; - } - else - { - $ueb_1_target =new uebung(); - $ueb_1_target->new = true; - $new = true; - $ueb_1_target->insertamum = date('Y-m-d H:i:s'); - $ueb_1_target->insertvon = $user; - $ueb_1_target->updateamum = null; - $ueb_1_target->updatevon = null; - $copy_insert++; - } - $ueb_1_target->gewicht = $ueb_1->gewicht; - $ueb_1_target->punkte = null; - $ueb_1_target->angabedatei=null; - $ueb_1_target->freigabevon = null; - $ueb_1_target->freigabebis = null; - $ueb_1_target->abgabe = false; - $ueb_1_target->beispiele = false; - $ueb_1_target->statistik = false; - $ueb_1_target->maxstd = null; - $ueb_1_target->maxbsp=null; - $ueb_1_target->liste_id=null; - $ueb_1_target->bezeichnung = $ueb_1->bezeichnung; - $ueb_1_target->positiv = $ueb_1->positiv; - $ueb_1_target->defaultbemerkung = $ueb_1->defaultbemerkung; - $ueb_1_target->lehreinheit_id = $lehreinheit_id_target; - $ueb_1_target->nummer = $nummer_source; - - if (!$ueb_1_target->save($new)) - { - $error = 1; - echo "".$p->t('benotungstool/hauptuebungKonnteNichtKopiertWerden')."!"; - } - - else - { - // Subübungen durchlaufen - $error = 0; - $ueb_2 = new uebung(); - $ueb_2->load_uebung($lehreinheit_id,2,$uebung_id_source); - - $ueb_2anzahl = count($ueb_2->uebungen); - if ($ueb_2anzahl >0) - { - foreach ($ueb_2->uebungen as $subrow) - { - - $nummer_source2 = $subrow->nummer; - $qry2 = "SELECT * from campus.tbl_uebung where nummer = ".$db->db_add_param($nummer_source2)." and lehreinheit_id = ".$db->db_add_param($lehreinheit_id_target, FHC_INTEGER); - $result2 = $db->db_query($qry2); - - if ($db->db_num_rows($result2) >0) - { - $row2 = $db->db_fetch_object($result2); - $ueb_2_target =new uebung($row2->uebung_id); - $ueb_2_target->new = false; - $new = null; - $ueb_2_target->insertamum = null; - $ueb_2_target->insertvon = null; - $ueb_2_target->updateamum = date('Y-m-d H:i:s'); - $ueb_2_target->updatevon = $user; - $copy_update++; - } - else - { - $ueb_2_target =new uebung(); - $ueb_2_target->new = true; - $new = true; - $ueb_2_target->insertamum = date('Y-m-d H:i:s'); - $ueb_2_target->insertvon = $user; - $ueb_2_target->updateamum = null; - $ueb_2_target->updatevon = null; - $copy_insert++; - } - $ueb_2_target->gewicht = $subrow->gewicht; - $ueb_2_target->punkte = $subrow->punkte; - $ueb_2_target->angabedatei=null; - $ueb_2_target->freigabevon = $subrow->freigabevon; - $ueb_2_target->freigabebis = $subrow->freigabebis; - $ueb_2_target->abgabe = $subrow->abgabe; - $ueb_2_target->beispiele = $subrow->beispiele; - $ueb_2_target->statistik = $subrow->statistik; - $ueb_2_target->maxstd = $subrow->maxstd; - $ueb_2_target->maxbsp=$subrow->maxbsp; - $ueb_2_target->liste_id=$ueb_1_target->uebung_id; - $ueb_2_target->bezeichnung = $subrow->bezeichnung; - $ueb_2_target->positiv = $subrow->positiv; - $ueb_2_target->defaultbemerkung = $subrow->defaultbemerkung; - $ueb_2_target->lehreinheit_id = $lehreinheit_id_target; - $ueb_2_target->nummer = $nummer_source2; - - if (!$ueb_2_target->save($new)) - { - $error = 1; - echo "".$p->t('benotungstool/uebungKonnteNichtKopiertWerden')."!"; - } - - //angabedatei syncen - if ($subrow->angabedatei != "") - { - $angabedatei_source = $subrow->angabedatei; - $angabedatei_target = makeUploadName($db, 'angabe', $lehreinheit_id, $ueb_2_target->uebung_id, $stsem); - $angabedatei_target .= ".".mb_substr($angabedatei_source, mb_strrpos($angabedatei_source, '.') + 1); - echo $angabedatei_source."->".$angabedatei_target."
"; - exec("cp ".BENOTUNGSTOOL_PATH."angabe/".$angabedatei_source." ".BENOTUNGSTOOL_PATH."angabe/".$angabedatei_target); - $angabeupdate = "update campus.tbl_uebung set angabedatei = ".$db->db_add_param($angabedatei_target)." where uebung_id = ".$db->db_add_param($ueb_2_target->uebung_id, FHC_INTEGER); - $db->db_query($angabeupdate); - } - - if (($error == 0) and $ueb_2_target->beispiele) - { - // beispiele synchronisieren - $bsp_obj = new beispiel(); - $bsp_obj->load_beispiel($subrow->uebung_id); - foreach ($bsp_obj->beispiele as $bsp) - { - $nummer_source_bsp = $bsp->nummer; - $qrybsp = "SELECT * from campus.tbl_beispiel where nummer = ".$db->db_add_param($nummer_source_bsp)." and uebung_id = ".$db->db_add_param($ueb_2_target->uebung_id, FHC_INTEGER); - $resultbsp = $db->db_query($qrybsp); - - if ($db->db_num_rows($resultbsp) >0) - { - $rowbsp = $db->db_fetch_object($resultbsp); - $bsp_target =new beispiel($rowbsp->beispiel_id); - $bsp_target->new = false; - $new = null; - $bsp_target->insertamum = null; - $bsp_target->insertvon = null; - $bsp_target->updateamum = date('Y-m-d H:i:s'); - $bsp_target->updatevon = $user; - $copy_update_bsp++; - } - else - { - $bsp_target =new beispiel(); - $bsp_target->new = true; - $new = true; - $bsp_target->insertamum = date('Y-m-d H:i:s'); - $bsp_target->insertvon = $user; - $bsp_target->updateamum = null; - $bsp_target->updatevon = null; - $copy_insert_bsp++; - } - $bsp_target->uebung_id = $ueb_2_target->uebung_id; - $bsp_target->nummer = $nummer_source_bsp; - $bsp_target->bezeichnung = $bsp->bezeichnung; - $bsp_target->punkte = $bsp->punkte; - - if (!$bsp_target->save($new)) - { - $error = 1; - echo "".$p->t('benotungstool/beispieleKonntenNichtAngelegtWerden').""; - } - - //Notenschlüssel synchronisieren - $clear = "delete from campus.tbl_notenschluesseluebung where uebung_id = ".$db->db_add_param($ueb_1_target->uebung_id, FHC_INTEGER); - $db->db_query($clear); - - $qry_ns_source = "SELECT * from campus.tbl_notenschluesseluebung where uebung_id = ".$db->db_add_param($uebung_id_source, FHC_INTEGER); - $result_ns_source = $db->db_query($qry_ns_source); - while($row_ns = $db->db_fetch_object($result_ns_source)) - { - $ns_insert = "INSERT INTO campus.tbl_notenschluesseluebung values (".$db->db_add_param($ueb_1_target->uebung_id).",".$db->db_add_param($row_ns->note).", ".$db->db_add_param($row_ns->punkte).")"; - $db->db_query($ns_insert); - } - - } - } - - } - } - } - - } - else - echo "".$p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')."!"; - - if ($error == 0) - echo $p->t('benotungstool/uebungErfolgreichKopiert')."! (Ü: ".$copy_insert."/".$copy_update."; B: ".$copy_insert_bsp."/".$copy_update_bsp.")"; - } -} - - - -echo "

".$p->t('benotungstool/uebungenAnlegenUndVerwalten')."

"; -echo "
"; - -//Anlegen einer neuen Uebung -if(isset($_POST['uebung_neu'])) -{ - if(isset($thema)) - { - //pruefen ob alle Daten eingegeben wurden - $error=false; - $error_msg = ''; - if($thema=='') - { - //$error_thema .= "Thema muss eingegeben werden"; - echo "".$p->t('benotungstool/themaMussEingegebenWerden').""; - $error=true; - } - if(!is_numeric($gewicht)) - { - echo "".$p->t('benotungstool/gewichtMussEineZahlSein').""; - $error = true; - } - - if(!$error) - { - //Uebung anlegen - $datum_obj = new datum(); - $uebung_obj = new uebung(); - $uebung_obj->gewicht=$gewicht; - $uebung_obj->punkte=''; - $uebung_obj->angabedatei=''; - $uebung_obj->freigabevon = null; - $uebung_obj->freigabebis = null; - $uebung_obj->abgabe=false; - $uebung_obj->beispiele=false; - $uebung_obj->bezeichnung=$thema; - $uebung_obj->positiv=isset($_POST['positiv']); - $uebung_obj->defaultbemerkung=''; - $uebung_obj->lehreinheit_id=$lehreinheit_id; - $uebung_obj->updateamum = date('Y-m-d H:i:s'); - $uebung_obj->updatevon = $user; - $uebung_obj->insertamum = date('Y-m-d H:i:s'); - $uebung_obj->insertvon = $user; - $uebung_obj->statistik = false; - $uebung_obj->liste_id = null; - $uebung_obj->get_next_nummer(); - $uebung_obj->nummer = $uebung_obj->next_nummer; - - if($uebung_obj->save(true)) - { - if($error_msg!='') - echo "$error_msg"; - //else - // header("Location: verwaltung_listen.php?lvid=$lvid&stsem=$stsem&lehreinheit_id=$lehreinheit_id&liste_id=$uebung_obj->uebung_id"); - } - else - echo "$uebung_obj->errormsg"; - } - - } - else - echo "".$p->t('benotungstool/uebungKonnteNichtAngelegtWerden')."!
"; -} - - -//Loeschen einer Uebung -if(isset($_POST['delete_uebung'])) -{ - if(isset($_POST['uebung'])) - { - $ueb_obj = new uebung(); - $error_msg=''; - //Ausgewaehlte Beispiele holen - $delete_ids = $_POST['uebung']; - foreach($delete_ids as $id) - { - //Beispiel loeschen - if(!$ueb_obj->delete($id)) - $error_msg=$ueb_obj->errormsg; - } - if($error_msg!='') - echo "$error_msg"; - } -} - -//Editieren einer Uebung -if(isset($_POST['uebung_edit'])) -{ - $error = false; - if($thema=='') - { - echo "".$p->t('benotungstool/themaMussEingegebenWerden')."'"; - $error = true; - } - - - if(!$error) - { - $uebung_obj = new uebung($uebung_id); - $uebung_obj->gewicht=''; - $uebung_obj->punkte=''; - $uebung_obj->angabedatei=''; - $uebung_obj->freigabevon = null; - $uebung_obj->freigabebis = null; - $uebung_obj->abgabe=false; - $uebung_obj->beispiele=false; - $uebung_obj->bezeichnung=$thema; - $uebung_obj->positiv=true; - $uebung_obj->defaultbemerkung=''; - $uebung_obj->lehreinheit_id=$lehreinheit_id; - $uebung_obj->updateamum = date('Y-m-d H:i:s'); - $uebung_obj->updatevon = $user; - $uebung_obj->uebung_id = $uebung_id; - $uebung_obj->statistik = false; - - if($uebung_obj->save(false)) - header("Location: verwaltung.php?lvid=$lvid&stsem=$stsem&lehreinheit_id=$lehreinheit_id"); - //echo "Die Änderung wurde gespeichert!"; - else - echo "$uebung_obj->errormsg"; - } - -} - - -//Eine Uebung in eine andere Lehreinheit kopieren -if(isset($_GET['kopieren']) && $_GET['kopieren']=='true') -{ - //echo "Kopiere Uebung ".$_GET['uebung_copy_id']." to ".$_POST['lehreinheit_copy_id']; - //Laden der zu kopierenden Uebung - if(is_numeric($_GET['uebung_copy_id']) && is_numeric($_POST['lehreinheit_copy_id'])) - { - //Source Uebung Laden - $qry = "SELECT * FROM campus.tbl_uebung WHERE uebung_id=".$db->db_add_param($_GET['uebung_copy_id'], FHC_INTEGER); - if($result_source = $db->db_query($qry)) - { - if($row_source = $db->db_fetch_object($result_source)) - { - //Berechtigung Checken - $qry = "SELECT * FROM lehre.tbl_lehreinheitmitarbeiter WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_copy_id'], FHC_INTEGER)." AND mitarbeiter_uid=".$db->db_add_param($user); - if($row_berechtigt = $db->db_query($qry)) - { - if($db->db_num_rows($row_berechtigt)>0 || - $rechte->isBerechtigt('admin',0) || - $rechte->isBerechtigt('admin',$lv_obj->studiengang_kz) - || $rechte->isBerechtigt('lehre',$lv_obj->studiengang_kz)) - { - //Schauen ob bereits eine uebung mit diesem Namen vorhanden ist - $qry = "SELECT * FROM campus.tbl_uebung WHERE lehreinheit_id=".$db->db_add_param($_POST['lehreinheit_copy_id'], FHC_INTEGER)." AND bezeichnung=".$db->db_add_param($row_source->bezeichnung); - $result_bezeichnung_exists = $db->db_query($qry); - if($db->db_num_rows($result_bezeichnung_exists)==0) - { - //Uebung einfuegen - $uebung_dest = new uebung(); - $uebung_dest->gewicht = $row_source->punkte; - $uebung_dest->punkte = $row_source->punkte; - $uebung_dest->angabedatei = $row_source->angabedatei; - $uebung_dest->freigabevon = $row_source->freigabevon; - $uebung_dest->freigabebis = $row_source->freigabebis; - $uebung_dest->abgabe = ($row_source->abgabe=='t'?true:false); - $uebung_dest->beispiele = ($row_source->beispiele=='t'?true:false); - $uebung_dest->bezeichnung = $row_source->bezeichnung; - $uebung_dest->positiv = ($row_source->positiv=='t'?true:false); - $uebung_dest->statistik = ($row_source->statistik=='t'?true:false); - $uebung_dest->defaultbemerkung = $row_source->defaultbemerkung; - $uebung_dest->lehreinheit_id = $_POST['lehreinheit_copy_id']; - $ubeung_dest->updateamum = date('Y-m-d H:i:s'); - $uebung_dest->updatevon = $user; - $uebung_dest->insertamum = date('Y-m-d H:i:s'); - $uebung_dest->insertvon = $user; - - if($uebung_dest->save(true)) - { - //Beispiel laden - $qry = "SELECT * FROM campus.tbl_beispiel WHERE uebung_id=".$db->db_add_param($_GET['uebung_copy_id'], FHC_INTEGER); - if($result_bsp_source = $db->db_query($qry)) - { - $error_bsp_save=false; - while($row_bsp_source = $db->db_fetch_object($result_bsp_source)) - { - //Beispiel speichern - $beispiel_dest = new beispiel(); - $beispiel_dest->uebung_id = $uebung_dest->uebung_id; - $beispiel_dest->bezeichnung = $row_bsp_source->bezeichnung; - $beispiel_dest->punkte = $row_bsp_source->punkte; - $beispiel_dest->updateamum = date('Y-m-d H:i:s'); - $beispiel_dest->updatevon = $user; - $beispiel_dest->insertamum = date('Y-m-d H:i:s'); - $beispiel_dest->insertvon = $user; - - if(!$beispiel_dest->save(true)) - $error_bsp_save=true; - } - - if($error_bsp_save) - echo "".$p->t('benotungstool/fehlerNichtAlleBeispieleKopiert').""; - else - echo $p->t('benotungstool/datenErfolgreichKopiert'); - } - } - else - { - - echo "".$p->t('benotungstool/fehlerKopierenDerDaten').": $uebung_dest->errormsg"; - } - } - else - echo "".$p->t('benotungstool/fehlerBeimKopieren')."!"; - } - else - echo "".$p->t('global/keineBerechtigungFuerDieseSeite').""; - } - } - else - echo "".$p->t('benotungstool/uebung')." ".$_GET['uebung_copy_id']." ".$p->t('benotungstool/wurdeNichtGefunden').""; - } - else - echo "".$p->t('benotungstool/uebung')." ".$_GET['uebung_copy_id']." ".$p->t('benotungstool/wurdeNichtGefunden').""; - } - else - echo "".$p->t('global/fehlerBeiDerParameteruebergabe').""; -} - -//Uebersichtstabelle -if(isset($uebung_id) && $uebung_id!='') -{ - echo "
"; - //Bearbeiten der ausgewaehlten Uebung - echo "
\n"; - echo "\n"; - echo ""; - - $uebung_obj = new uebung(); - $uebung_obj->load($uebung_id); - - echo " - - - -
".$p->t('benotungstool/ausgewaehlteUebungBearbeiten')." 
 
".$p->t('benotungstool/thema')."$error_thema
-
"; - - $beispiel_obj = new beispiel(); - $beispiel_obj->load_beispiel($uebung_id); - $anzahl = count($beispiel_obj->beispiele); - echo "
"; - - echo "
"; - - echo ""; -} -else -{ - //Gesamtuebersicht ueber alle Uebungen - - echo "
"; - echo "
"; - echo ""; - - $uebung_obj = new uebung(); - $uebung_obj->load_uebung($lehreinheit_id,$level=1,$uebung_id=null); - $anzahl = count($uebung_obj->uebungen); - //$copy_content="
".$p->t('benotungstool/vorhandeneUebungenBearbeiten')."
"; - $has_copy_content=false; - if($anzahl>0) - { - echo ""; - - //Alle Lehreinheiten holen die zu dieser lehrveranstaltung gehoeren - //und der angemeldete User berechtigt ist - $copy_option_content = array(); - for($i=0;$i<$db->db_num_rows($result_alle_lehreinheiten);$i++) - { - $row_alle_lehreinheiten = $db->db_fetch_object($result_alle_lehreinheiten,$i); - if($lehreinheit_id!=$row_alle_lehreinheiten->lehreinheit_id) - { - //zugeteilte Lektoren holen - $qry_lektoren = "SELECT * FROM lehre.tbl_lehreinheitmitarbeiter JOIN public.tbl_mitarbeiter using(mitarbeiter_uid) WHERE lehreinheit_id=".$db->db_add_param($row_alle_lehreinheiten->lehreinheit_id,FHC_INTEGER); - if($result_lektoren = $db->db_query($qry_lektoren)) - { - $lektoren = '( '; - $j=0; - while($row_lektoren = $db->db_fetch_object($result_lektoren)) - { - $lektoren .= $row_lektoren->kurzbz; - $j++; - if($j<$db->db_num_rows($result_lektoren)) - $lektoren.=', '; - else - $lektoren.=' '; - } - $lektoren .=')'; - } - //zugeteilte Gruppen holen - $qry_gruppen = "SELECT * FROM lehre.tbl_lehreinheitgruppe WHERE lehreinheit_id=".$db->db_add_param($row_alle_lehreinheiten->lehreinheit_id, FHC_INTEGER); - if($result_gruppen = $db->db_query($qry_gruppen)) - { - $gruppen = ''; - $j=0; - while($row_gruppen = $db->db_fetch_object($result_gruppen)) - { - if($row_gruppen->gruppe_kurzbz=='') - $gruppen.=$row_gruppen->semester.$row_gruppen->verband.$row_gruppen->gruppe; - else - $gruppen.=$row_gruppen->gruppe_kurzbz; - $j++; - if($j<$db->db_num_rows($result_gruppen)) - $gruppen.=', '; - else - $gruppen.=' '; - } - } - //$copy_option_content.= "\n"; - $copy_le_content[$row_alle_lehreinheiten->lehreinheit_id] = "$row_alle_lehreinheiten->lfbez-$row_alle_lehreinheiten->lehrform_kurzbz - $gruppen $lektoren"; - } - - } - $uebung_id_source_dropdown = ""; - echo ""; - echo ""; - - $subuebung_obj = new uebung(); - $subuebung_obj->load_uebung($lehreinheit_id,$level=2,$uebung_id=$row->uebung_id); - $subanzahl = count($subuebung_obj->uebungen); - echo ""; - } - echo ""; - echo ""; - if ($copy_dropdown != '') - { - echo ""; - echo ""; - - $uebung_id_source_dropdown .= ""; - echo ""; - } - } - else - echo ""; - - echo "
Übung in andere LE kopieren
 
 
 
".$p->t('benotungstool/thema')."".$p->t('benotungstool/freigeschalten')."".$p->t('benotungstool/auswahl')."
"; - echo " ".$row->bezeichnung.""; - echo ""; - - //if((strtotime(strftime($row->freigabevon))<=time()) && (strtotime(strftime($row->freigabebis))>=time())) - // echo 'Ja'; - //else - // echo 'Nein'; - echo "
"; - echo ""; - //echo "
    "; - foreach ($subuebung_obj->uebungen as $subrow) - { - echo "
"; - } - //echo ""; - echo ""; - echo "
 
".$p->t('benotungstool/vorhandeneUebungenKopieren')."
"; - echo "
".$p->t('benotungstool/uebung')."".$p->t('global/lehreinheit')."
".$uebung_id_source_dropdown."->".$copy_dropdown."
"; - echo "
".$p->t('benotungstool/derzeitSindKeineUebungenAngelegt')."
-

"; - - - //Kopier-Buttons anzeigen - //$copy_content.='
'; - //echo "
"; - //if($has_copy_content) - // echo $copy_content; - //echo "
"; - - //Uebung neu anlegen - if(!isset($_POST['uebung_neu'])) - { - $thema = $p->t('benotungstool/uebung')." ".($anzahl<9?'0'.($anzahl+1):($anzahl+1)); - $anzahlderbeispiele = 10; - $punkteprobeispiel = 1; - $freigabevon = date('d.m.Y H:i'); - $freigabebis = date('d.m.Y H:i'); - } - - echo ""; - echo " -
- - - - - - - -
".$p->t('benotungstool/neueUebungAnlegen')."
".$p->t('benotungstool/thema')."$error_thema
".$p->t('benotungstool/gewicht')."$error_gewicht
".$p->t('benotungstool/positiv')."
-
- "; -} -?> - - - - diff --git a/cis/private/lehre/benotungstool/verwaltung_listen.php b/cis/private/lehre/benotungstool/verwaltung_listen.php deleted file mode 100644 index 85b1c016e..000000000 --- a/cis/private/lehre/benotungstool/verwaltung_listen.php +++ /dev/null @@ -1,1250 +0,0 @@ -, - * Andreas Oesterreicher and - * Rudolf Hangl < rudolf.hangl@technikum-wien.at > - * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > - */ - -require_once('../../../../config/cis.config.inc.php'); -require_once('../../../../include/basis_db.class.php'); -require_once('../../../../include/functions.inc.php'); -require_once('../../../../include/lehrveranstaltung.class.php'); -require_once('../../../../include/studiengang.class.php'); -require_once('../../../../include/studiensemester.class.php'); -require_once('../../../../include/lehreinheit.class.php'); -require_once('../../../../include/benutzerberechtigung.class.php'); -require_once('../../../../include/uebung.class.php'); -require_once('../../../../include/beispiel.class.php'); -require_once('../../../../include/datum.class.php'); -require_once('functions.inc.php'); -require_once('../../../../include/phrasen.class.php'); - -$sprache = getSprache(); -$p = new phrasen($sprache); - -if (!$db = new basis_db()) - die($p->t('global/fehlerBeimOeffnenDerDatenbankverbindung')); - -function microtime_float() -{ - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); -} -$time = microtime_float(); -$user = get_uid(); - -if(!check_lektor($user)) - die($p->t('global/keineBerechtigungFuerDieseSeite')); - -$rechte = new benutzerberechtigung(); -$rechte->getBerechtigungen($user); - -if(isset($_GET['lvid']) && is_numeric($_GET['lvid'])) //Lehrveranstaltung_id - $lvid = $_GET['lvid']; -else - die($p->t('global/fehlerBeiDerParameteruebergabe')); - -if(isset($_GET['lehreinheit_id']) && is_numeric($_GET['lehreinheit_id'])) //Lehreinheit_id - $lehreinheit_id = $_GET['lehreinheit_id']; -else - $lehreinheit_id = ''; - -//Angabedatei ausliefern -if (isset($_GET["download"])){ - $file=$_GET["download"]; - $uebung_id = $_GET["uebung_id"]; - $ueb = new uebung(); - $ueb->load($uebung_id); - $filename = BENOTUNGSTOOL_PATH."angabe/".$ueb->angabedatei; - header('Content-Type: application/octet-stream'); - header('Content-disposition: attachment; filename="'.$file.'"'); - readfile($filename); - exit; -} - -?> - - - - - -Kreuzerltool - - - - -load($lvid)) - die($lv_obj->errormsg); - -//Studiengang laden -$stg_obj = new studiengang($lv_obj->studiengang_kz); - -if(isset($_GET['stsem'])) - $stsem = $_GET['stsem']; -else - $stsem = ''; - -//Vars -$datum_obj = new datum(); -$global_msg =''; -$error_thema=''; -$error_anzahlderbeispiele=''; -$error_punkteprobeispiel=''; -$error_freigabebis=''; -$error_freigabevon=''; -$error_maxstd = ''; -$error_maxbsp = ''; -$error_gewicht = ''; - -$thema = (isset($_POST['thema'])?$_POST['thema']:''); -$liste_id = (isset($_REQUEST['liste_id'])?$_REQUEST['liste_id']:''); -$anzahlderbeispiele = (isset($_POST['anzahlderbeispiele'])?$_POST['anzahlderbeispiele']:''); -$punkteprobeispiel = (isset($_POST['punkteprobeispiel'])?$_POST['punkteprobeispiel']:''); -$punkteprobeispiel = mb_ereg_replace(',','.',$punkteprobeispiel); -$freigabebis = (isset($_POST['freigabebis'])?$_POST['freigabebis']:''); -$freigabevon = (isset($_POST['freigabevon'])?$_POST['freigabevon']:''); -$maxstd = (isset($_POST['maxstd'])?$_POST['maxstd']:''); -$maxbsp = (isset($_POST['maxbsp'])?$_POST['maxbsp']:''); -$gewicht = (isset($_POST['gewicht'])?$_POST['gewicht']:''); -if (isset($_FILES["angabedatei"])) - $angabedatei_up = $_FILES["angabedatei"]["tmp_name"]; -else - $angabedatei_up = null; - -$beispiel_id = (isset($_GET['beispiel_id'])?$_GET['beispiel_id']:''); -$uebung_id = (isset($_GET['uebung_id'])?$_GET['uebung_id']:''); - -//Angabedatei löschen -if (isset($_GET["deletefile"])){ - $file=$_GET["deletefile"]; - $ueb = new uebung(); - $ueb->load($uebung_id); - $filename = BENOTUNGSTOOL_PATH."angabe/".$ueb->angabedatei; - $ueb->angabedatei = ''; - $ueb->save(false); - unlink($filename); -} - -//notenschlüssel anlegen -if (isset($_POST["schluessel"]) && $_POST["schluessel"]=='Speichern') -{ - $punkte_arr = array(); - $punkte_arr[1] = $_POST["schluessel_punkte_1"]; - $punkte_arr[2] = $_POST["schluessel_punkte_2"]; - $punkte_arr[3] = $_POST["schluessel_punkte_3"]; - $punkte_arr[4] = $_POST["schluessel_punkte_4"]; - $punkte_arr[5] = $_POST["schluessel_punkte_5"]; - for ($i=1;$i<=5;$i++) - { - if (is_numeric($punkte_arr[$i])) - { - $qry = "select * from campus.tbl_notenschluesseluebung where uebung_id = ".$db->db_add_param($liste_id, FHC_INTEGER)." and note = ".$db->db_add_param($i); - $result = $db->db_query($qry); - if($db->db_num_rows($result)>0) - $str = "update campus.tbl_notenschluesseluebung set punkte = ".$db->db_add_param($punkte_arr[$i])." where uebung_id = ".$db->db_add_param($liste_id, FHC_INTEGER)." and note = ".$db->db_add_param($i); - else - $str = "insert into campus.tbl_notenschluesseluebung (uebung_id, note, punkte) values (".$db->db_add_param($liste_id).",".$db->db_add_param($i).",".$db->db_add_param($punkte_arr[$i]).")"; - if (!$db->db_query($str)) - echo "Daten konnten nicht gespeichert werden"; - } - } -} -//Kopfzeile -echo ''; -echo ' '; -echo ''; -echo '
 

'.$p->t('benotungstool/benotungstool'); -echo '

'."\n"; - -//Studiensemester laden -$stsem_obj = new studiensemester(); -if($stsem=='') - $stsem = $stsem_obj->getaktorNext(); - -$stsem_obj->getAll(); - - -//Studiensemester DropDown -$stsem_content = $p->t('global/studiensemester').": \n"; - -//Lehreinheiten laden -if($rechte->isBerechtigt('admin',0) || $rechte->isBerechtigt('admin',$lv_obj->studiengang_kz) || $rechte->isBerechtigt('lehre',$lv_obj->studiengang_kz)) -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); -} -else -{ - $qry = "SELECT - distinct lehrfach.kurzbz as lfbez, tbl_lehreinheit.lehreinheit_id, tbl_lehreinheit.lehrform_kurzbz as lehrform_kurzbz - FROM - lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung as lehrfach, lehre.tbl_lehreinheitmitarbeiter - WHERE - tbl_lehreinheit.lehrveranstaltung_id=".$db->db_add_param($lvid, FHC_INTEGER)." AND - tbl_lehreinheit.lehrfach_id = lehrfach.lehrveranstaltung_id AND - tbl_lehreinheit.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id IN (SELECT lehrveranstaltung_id FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitmitarbeiter USING(lehreinheit_id) WHERE mitarbeiter_uid=".$db->db_add_param($user).") AND - tbl_lehreinheit.studiensemester_kurzbz = ".$db->db_add_param($stsem); -} - -if($result = $db->db_query($qry)) -{ - $result_alle_lehreinheiten = $result; - if($db->db_num_rows($result)>1) - { - //Lehreinheiten DropDown - echo " ".$p->t('global/lehreinheit').": '; - } - else - { - if($row = $db->db_fetch_object($result)) - $lehreinheit_id = $row->lehreinheit_id; - } -} -else -{ - echo $p->t('benotungstool/fehlerBeimAuslesen'); -} -echo $stsem_content; -echo '
'; -echo ''; -echo ''; -echo " -
 \n"; -echo "

".$lv_obj->bezeichnung_arr[$sprache]."

"; - -if($lehreinheit_id=='') - die($p->t('benotungstool/esGibtKeineLehreinheiten')); - -//Menue -include("menue.inc.php"); -/* -echo "\n\n"; -echo "
- Verwaltung     - Anwesenheits- und Übersichtstabelle     - Studentenpunkte verwalten     - Statistik -

-\n"; -*/ - -//echo "studiensemester: $stsem
"; -//echo "lehrveranstaltung: $lvid
"; -//echo "lehreinheit: $lehreinheit_id
"; - -echo "

".$p->t('benotungstool/uebungVerwalten')."

"; - -//Anlegen einer neuen Uebung -if(isset($_POST['uebung_neu']) || isset($_POST['abgabe_neu'])) -{ - if(isset($thema)) - { - //pruefen ob alle Daten eingegeben wurden - $error=false; - if($thema=='') - { - $error_thema.= "".$p->t('benotungstool/themaMussEingegebenWerden').""; - $error=true; - } - if(!is_numeric($gewicht)) - { - echo "".$p->t('benotungstool/gewichtMussEineZahlSein').""; - $error = true; - } - if (isset($_POST['uebung_neu'])) - { - if(!is_numeric($punkteprobeispiel)) - { - $error_punkteprobeispiel= "".$p->t('benotungstool/punkteProBeispielGueltigeZahl').""; - $error=true; - } - elseif($punkteprobeispiel<0) - { - $error_punkteprobeispiel = "".$p->t('benotungstool/punkteProBeispielNichtNegativ').""; - $error=true; - } - if(!is_numeric($anzahlderbeispiele)) - { - $error_anzahlderbeispiele = "".$p->t('benotungstool/anzahlDerBeispieleGueltigeZahl').""; - $error=true; - } - elseif($anzahlderbeispiele<0) - { - $error_anzahlderbeispiele = "".$p->t('benotungstool/anzahlDerBeispieleNichtNegativ').""; - $error=true; - } - elseif($anzahlderbeispiele>99) - { - $error_anzahlderbeispiele = "".$p->t('benotungstool/anzahlDerBeispieleKleiner100').""; - $error=true; - } - - if ($maxstd != '') - { - if(!is_numeric($maxstd)) - { - $error_maxstd = "".$p->t('benotungstool/anzahlStudentenGueltigeZahl').""; - $error=true; - } - elseif($maxstd<0) - { - $error_maxstd = "".$p->t('benotungstool/anzahlStudentenNichtNegativ').""; - $error=true; - } - elseif($maxstd>99) - { - $error_maxd = "".$p->t('benotungstool/anzahlStudentenKleiner100').""; - $error=true; - } - } - else - $maxstd = null; - - if ($maxbsp != '') - { - if(!is_numeric($maxbsp)) - { - $error_maxbsp = "".$p->t('benotungstool/anzahlStudentenGueltigeZahl').""; - $error=true; - } - elseif($maxbsp<0) - { - $error_maxbsp = "".$p->t('benotungstool/anzahlStudentenNichtNegativ').""; - $error=true; - } - elseif($maxbsp>99) - { - $error_maxbsp = "".$p->t('benotungstool/anzahlStudentenKleiner100').""; - $error=true; - } - } - else - $maxbsp = null; - } - - $freigabevon_sav = $datum_obj->mktime_datumundzeit($freigabevon); - $freigabebis_sav = $datum_obj->mktime_datumundzeit($freigabebis); - - if(!$freigabebis_sav) - { - $error_freigabebis = "".$p->t('benotungstool/bisDatumUngueltigesFormat').""; - $error=true; - } - - if(!$freigabevon_sav) - { - $error_freigabevon = "".$p->t('benotungstool/vonDatumUngueltigesFormat').""; - $error=true; - } - - if($freigabevon_sav && $freigabebis_sav && $freigabevon_sav>$freigabebis_sav) - { - $error_freigabevon = "".$p->t('benotungstool/vonDatumNichtGroesserAlsBisDatum').""; - $error=true; - } - - if(!$error) - { - - //Uebung anlegen (KL oder Abgabe) - $datum_obj = new datum(); - $uebung_obj = new uebung(); - //$uebung_obj->gewicht=''; - $uebung_obj->punkte=''; - $uebung_obj->angabedatei=''; - $uebung_obj->freigabevon = date('Y-m-d H:i',$freigabevon_sav); - $uebung_obj->freigabebis = date('Y-m-d H:i',$freigabebis_sav); - if (isset($_POST["uebung_neu"])) - { - if (isset($_POST["kl_abgabe"])) - $uebung_obj->abgabe=true; - else - $uebung_obj->abgabe=false; - $uebung_obj->beispiele=true; - } - else - { - $uebung_obj->abgabe=true; - $uebung_obj->beispiele=false; - } - $uebung_obj->bezeichnung=$thema; - $uebung_obj->positiv=isset($_POST['positiv']); - $uebung_obj->defaultbemerkung=''; - $uebung_obj->lehreinheit_id=$lehreinheit_id; - $uebung_obj->updateamum = date('Y-m-d H:i:s'); - $uebung_obj->updatevon = $user; - $uebung_obj->insertamum = date('Y-m-d H:i:s'); - $uebung_obj->insertvon = $user; - $uebung_obj->statistik = isset($_POST['statistik']); - $uebung_obj->liste_id = $liste_id; - $uebung_obj->maxstd = $maxstd; - $uebung_obj->maxbsp = $maxbsp; - $uebung_obj->gewicht = $gewicht; - $uebung_obj->get_next_nummer(); - $uebung_obj->nummer = $uebung_obj->next_nummer; - - if($uebung_obj->save(true)) - { - $uebung_id = $uebung_obj->uebung_id; - - //Angabedatei ablegen - if ($angabedatei_up) - { - $name_up = pathinfo($_FILES["angabedatei"]["name"]); - //Handle double file extensions (e.g.: .tar.gz) - //Array of possible double extensions - $ext_array = array('.tar.gz','.tar.bz2','.tar.xz','.tar.lzma','.tar.Z'); - //Find occurence of extensions ending with ".tar." - if (in_array(substr($_FILES["angabedatei"]["name"], strripos($_FILES["angabedatei"]["name"], '.tar.')), $ext_array)) - $extension = substr($_FILES["angabedatei"]["name"], strripos($_FILES["angabedatei"]["name"]+1, '.tar.')); - else - $extension = $name_up["extension"]; - - $name_neu = makeUploadName($db, $which='angabe', $lehreinheit_id=$lehreinheit_id, $uebung_id=$uebung_id, $ss=$stsem); - $angabedatei = $name_neu.".".$extension; - - $angabepfad = BENOTUNGSTOOL_PATH."angabe/".$angabedatei; - //$angabepfad = BENOTUNGSTOOL_PATH.$angabedatei; - //unlink($angabepfad); - //echo $angabepfad; - move_uploaded_file($_FILES['angabedatei']['tmp_name'], $angabepfad); - $uebung_obj->angabedatei = $angabedatei; - $uebung_obj->save(false); - } - //Beispiele anlegen - - $error_msg=''; - for($i=0;$i<$anzahlderbeispiele;$i++) - { - $beispiel_obj = new beispiel(); - $beispiel_obj->uebung_id = $uebung_id; - $beispiel_obj->bezeichnung = "Beispiel ".($i<9?'0'.($i+1):($i+1)); - $beispiel_obj->punkte = $punkteprobeispiel; - $beispiel_obj->updateamum = date('Y-m-d H:i:s'); - $beispiel_obj->updatevon = $user; - $beispiel_obj->insertamum = date('Y-m-d H:i:s'); - $beispiel_obj->insertvon = $user; - $beispiel_obj->get_next_nummer(); - $beispiel_obj->nummer = $beispiel_obj->next_nummer; - - if(!$beispiel_obj->save(true)) - $error_msg = $beispiel_obj->errormsg; - } - if($error_msg!='') - echo "$error_msg"; - } - else - echo "$uebung_obj->errormsg"; - } - - } - else - echo "".$p->t('benotungstool/kreuzerllisteNichtAngelegt')."!
"; -} - -//Loeschen eines Beispiels -if(isset($_POST['beispiel_delete'])) -{ - if(isset($_POST['beispiel'])) - { - $beispiel_obj = new beispiel(); - $error_msg=''; - //Ausgewaehlte Beispiele holen - $delete_ids = $_POST['beispiel']; - foreach($delete_ids as $id) - { - //Beispiel loeschen - if(!$beispiel_obj->delete($id)) - $error_msg=$beispiel_obj->errormsg; - } - if($error_msg!='') - echo "$error_msg"; - } -} - -//Loeschen einer Uebung -if(isset($_POST['delete_uebung'])) -{ - if(isset($_POST['uebung'])) - { - $ueb_obj = new uebung(); - $error_msg=''; - //Ausgewaehlte Beispiele holen - $delete_ids = $_POST['uebung']; - foreach($delete_ids as $id) - { - //Beispiel loeschen - if(!$ueb_obj->delete($id)) - $error_msg=$ueb_obj->errormsg; - } - if($error_msg!='') - echo "$error_msg"; - } -} - -//Editieren einer Uebung -if(isset($_POST['uebung_edit'])) -{ - $error = false; - if($thema=='') - { - echo "".$p->t('benotungstool/themaMussEingegebenWerden').""; - $error = true; - } - if(!is_numeric($gewicht)) - { - echo "".$p->t('benotungstool/gewichtMussEineZahlSein').""; - $error = true; - } - $freigabevon_sav = $datum_obj->mktime_datumundzeit($freigabevon); - $freigabebis_sav = $datum_obj->mktime_datumundzeit($freigabebis); - - if ($maxstd != '') - { - if(!is_numeric($maxstd)) - { - echo "".$p->t('benotungstool/anzahlStudentenGueltigeZahl').""; - $error=true; - } - elseif($maxstd<0) - { - echo "".$p->t('benotungstool/anzahlStudentenNichtNegativ').""; - $error=true; - } - elseif($maxstd>99) - { - echo "".$p->t('benotungstool/anzahlStudentenKleiner100').""; - $error=true; - } - } - else - $maxstd = null; - - if ($maxbsp != '') - { - if(!is_numeric($maxbsp)) - { - echo "".$p->t('benotungstool/anzahlStudentenGueltigeZahl').""; - $error=true; - } - elseif($maxbsp<0) - { - echo "".$p->t('benotungstool/anzahlStudentenNichtNegativ').""; - $error=true; - } - elseif($maxbsp>99) - { - echo "".$p->t('benotungstool/anzahlStudentenKleiner100').""; - $error=true; - } - } - else - $maxbsp = null; - - if($freigabevon_sav>$freigabebis_sav) - { - echo "".$p->t('benotungstool/vonDatumNichtGroesserAlsBisDatum').""; - $error=true; - } - if(!$freigabebis_sav) - { - echo "".$p->t('benotungstool/bisDatumUngueltigesFormat').""; - $error=true; - } - - if(!$freigabevon_sav) - { - echo "".$p->t('benotungstool/vonDatumUngueltigesFormat').""; - $error=true; - } - - if(!$error) - { - //Angabedatei ablegen - if ($angabedatei_up) - { - $name_up = pathinfo($_FILES["angabedatei"]["name"]); - //Handle double file extensions (e.g.: .tar.gz) - //Array of possible double extensions - $ext_array = array('.tar.gz','.tar.bz2','.tar.xz','.tar.lzma','.tar.Z'); - //Find occurence of extensions ending with ".tar." - if (in_array(substr($_FILES["angabedatei"]["name"], strripos($_FILES["angabedatei"]["name"], '.tar.')), $ext_array)) - $extension = substr($_FILES["angabedatei"]["name"], strripos($_FILES["angabedatei"]["name"]+1, '.tar.')); - else - $extension = $name_up["extension"]; - $name_neu = makeUploadName($db, $which='angabe', $lehreinheit_id=$lehreinheit_id, $uebung_id=$uebung_id, $ss=$stsem); - $angabedatei_neu = $name_neu.".".$extension; - - $angabepfad = BENOTUNGSTOOL_PATH."angabe/".$angabedatei_neu; - //$angabepfad = BENOTUNGSTOOL_PATH.$angabedatei; - //unlink($angabepfad); - //echo $angabepfad; - foreach (glob(BENOTUNGSTOOL_PATH."angabe/*".$uebung_id.".*") as $old) - unlink($old); - move_uploaded_file($_FILES['angabedatei']['tmp_name'], $angabepfad); - } - else - { - $uebung_akt = new uebung(); - $uebung_akt->load($uebung_id); - $angabedatei_neu = $uebung_akt->angabedatei; - } - $uebung_obj = new uebung(); - $uebung_obj->load($uebung_id); - $uebung_obj->gewicht=$gewicht; - $uebung_obj->punkte=''; - $uebung_obj->angabedatei=$angabedatei_neu; - $uebung_obj->freigabevon = date('Y-m-d H:i',$freigabevon_sav); - $uebung_obj->freigabebis = date('Y-m-d H:i',$freigabebis_sav); - if ($uebung_obj->beispiele) - $uebung_obj->abgabe = (isset($_POST['kl_abgabe'])?true:false); - //$uebung_obj->beispiele=true; - $uebung_obj->bezeichnung=$thema; - $uebung_obj->positiv=(isset($_POST['positiv'])?true:false); - $uebung_obj->defaultbemerkung=''; - $uebung_obj->lehreinheit_id=$lehreinheit_id; - $uebung_obj->updateamum = date('Y-m-d H:i:s'); - $uebung_obj->updatevon = $user; - $uebung_obj->uebung_id = $uebung_id; - $uebung_obj->statistik = (isset($_POST['statistik'])?true:false); - $uebung_obj->liste_id = $_POST["liste_id"]; - $uebung_obj->maxstd = $maxstd; - $uebung_obj->maxbsp = $maxbsp; - - if($uebung_obj->save(false)) - echo "Die Änderung wurde gespeichert!"; - else - echo "$uebung_obj->errormsg"; - } - -} - -// Notenschluessel toggle - -if (isset($_GET['liste_id']) && isset($_GET['notenschluessel'])) -{ - $ueb_ns = new uebung(); - $ueb_ns->toggle_prozent_punkte($_GET['liste_id']); - echo $ueb_ns->errormsg; -} - - -//Editieren einer Liste -if(isset($_POST['liste_edit'])) -{ - $error = false; - if($thema=='') - { - echo "".$p->t('benotungstool/themaMussEingegebenWerden').""; - $error = true; - } - if(!is_numeric($gewicht)) - { - echo "".$p->t('benotungstool/gewichtMussEineZahlSein').""; - $error = true; - } - - - if(!$error) - { - - $uebung_obj = new uebung(); - $uebung_obj->load($_GET['liste_id']); - $uebung_obj->gewicht=$gewicht; - $uebung_obj->punkte=''; - $uebung_obj->angabedatei=''; - $uebung_obj->freigabevon = null; - $uebung_obj->freigabebis = null; - //$uebung_obj->abgabe=false; - //$uebung_obj->beispiele=true; - $uebung_obj->bezeichnung=$thema; - $uebung_obj->positiv=(isset($_POST['positiv'])?true:false); - $uebung_obj->defaultbemerkung=''; - $uebung_obj->lehreinheit_id=$lehreinheit_id; - $uebung_obj->updateamum = date('Y-m-d H:i:s'); - $uebung_obj->updatevon = $user; - $uebung_obj->uebung_id = $_REQUEST["liste_id"]; - //$uebung_obj->statistik = (isset($_POST['statistik'])?true:false); - $uebung_obj->liste_id = ''; - //$uebung_obj->maxstd = $maxstd; - //$uebung_obj->maxbsp = $maxbsp; - - if($uebung_obj->save(false)) - echo $p->t('global/erfolgreichgespeichert')."!"; - else - echo "$uebung_obj->errormsg"; - } - -} - -//Neues Beispiel anlegen -if(isset($_POST['beispiel_neu']) || isset($_POST['beispiel_edit'])) -{ - if(isset($_POST['beispiel_edit']) && (!isset($beispiel_id) || !is_numeric($beispiel_id))) - { - echo "".$p->t('benotungstool/beispielIdUngueltig').""; - } - else - { - if(isset($uebung_id) && $uebung_id!='' && is_numeric($uebung_id)) - { - $punkte = (isset($_POST['punkte'])?$_POST['punkte']:''); - $punkte = mb_ereg_replace(',','.',$punkte); - $bezeichnung = $_REQUEST["bezeichnung"]; - if(is_numeric($punkte) && $punkte!='') - { - if($bezeichnung!='') - { - $beispiel_obj = new beispiel(); - if(isset($_POST['beispiel_edit'])) - { - $beispiel_obj->load($beispiel_id); - $beispiel_obj->beispiel_id= $beispiel_id; - $beispiel_obj->new=false; - } - else - { - $beispiel_obj->new=true; - $beispiel_obj->insertamum = date('Y-m-d H:i:s'); - $beispiel_obj->insertvon = $user; - $beispiel_obj->get_next_nummer(); - $beispiel_obj->nummer = $beispiel_obj->next_nummer; - } - - $beispiel_obj->uebung_id = $uebung_id; - $beispiel_obj->bezeichnung = $bezeichnung; - $beispiel_obj->punkte = $punkte; - $beispiel_obj->updateamum = date('Y-m-d H:i:s'); - $beispiel_obj->updatevon = $user; - if($beispiel_obj->save()) - { - $beispiel_id=''; - } - else - echo "$beispiel_obj->errormsg"; - } - else - echo "".$p->t('benotungstool/bezeichnungMussEingegebenWerden').""; - } - else - echo "".$p->t('benotungstool/punkteMuessenEineGueltigeZahlSein').""; - } - else - echo "".$p->t('benotungstool/zugehoerigeUebungFehlerhaft').""; - } -} - - - -//Uebersichtstabelle -if(isset($_GET["uebung_id"]) && $_GET["uebung_id"]!='') -{ - - echo "
"; - //Bearbeiten der ausgewaehlten Uebung - echo "
\n"; - echo "\n"; - echo ""; - - $uebung_obj = new uebung(); - $uebung_obj->load($uebung_id); - //$downloadname = mb_ereg_replace($uebung_id,ereg_replace(' ','_',$uebung_obj->bezeichnung), $uebung_obj->angabedatei); - $downloadname = mb_str_replace(' ', '_', $uebung_obj->bezeichnung); - $downloadname = mb_str_replace($uebung_id, $downloadname, $uebung_obj->angabedatei); - $downloadname = preg_replace('/[^A-Za-z0-9\-_.]/', '',$downloadname); - echo " - - - "; - - if ($uebung_obj->beispiele){ - echo " - "; - echo""; - echo ""; - } - else if ($uebung_obj->abgabe) - { - echo ""; - echo ""; - } - if ($uebung_obj->beispiele) - echo""; - echo ""; - echo ""; - if ($uebung_obj->angabedatei != '') - echo ""; - else - echo ""; - echo ""; - echo " - - -
".$p->t('benotungstool/ausgewaehlteAufgabeBearbeiten')." 
 
".$p->t('benotungstool/thema')."$error_thema
".$p->t('benotungstool/freigabe')."von mktime_fromtimestamp($uebung_obj->freigabevon))."'>
".$p->t('benotungstool/format')."bis mktime_fromtimestamp($uebung_obj->freigabebis))."'>
".$p->t('benotungstool/maxStudentenBeispiel')."$error_maxstd
".$p->t('benotungstool/maxBeispieleStudent')."$error_maxbsp
".$p->t('benotungstool/abgabe')." abgabe?'checked':'').">
".$p->t('benotungstool/gewicht')."$error_gewicht
".$p->t('benotungstool/positiv')." positiv?'checked':'').">
".$p->t('benotungstool/statistikFuerStudentenAnzeigen')." statistik?'checked':'').">
".$p->t('benotungstool/angabeidatei')."".$downloadname." [del]
- -
"; - - $beispiel_obj = new beispiel(); - $beispiel_obj->load_beispiel($uebung_id); - $anzahl = count($beispiel_obj->beispiele); - echo "
"; - - //Beispiel neu Anlegen - if ($uebung_obj->beispiele) - { - echo "
\n"; - echo "\n"; - echo "\n\n"; - - echo ""; - echo ""; - - echo "
".$p->t('benotungstool/neuesBeispielAnlegen')."
 
".$p->t('global/bezeichnung')." "; - echo " ".$p->t('benotungstool/punkte')."
-
"; - } - - echo "
"; - - - //Uebersicht der Beispiele - if ($uebung_obj->beispiele) - { - echo "
\n"; - echo "\n"; - echo "\n\n"; - - if($anzahl>0) - { - echo "\n"; - foreach ($beispiel_obj->beispiele as $row) - { - echo " - - "; - } - echo ""; - } - else - echo ""; - - echo "
".$p->t('benotungstool/vorhandeneBeispiele')."
 
".$p->t('benotungstool/beispiel')."".$p->t('benotungstool/punkte')."".$p->t('benotungstool/auswahl')."
".$row->bezeichnung."$row->punkte
".$p->t('benotungstool/keineBeispieleAngelegt')."
"; - } - echo "
"; - - //Beispiel Aendern - $error_msg = ''; - if(isset($beispiel_id) && $beispiel_id!='') - { - //Bearbeiten eines Beispiels - if($beispiel_obj->load($beispiel_id)) - { - echo "
\n"; - echo "\n"; - echo "\n\n"; - - echo ""; - echo ""; - - echo "
".$p->t('benotungstool/beispielBearbeiten')."
 
".$p->t('global/bezeichnung')." "; - echo " ".$p->t('benotungstool/punkte')."
-


"; - } - else - $error_msg = $beispiel_obj->errormsg; - } - echo "
"; -} -else -{ - if(isset($liste_id) && $liste_id!='') - { - echo "
"; - //Bearbeiten der ausgewaehlten Liste - echo "
\n"; - echo "\n"; - echo ""; - - $liste_obj = new uebung(); - $liste_obj->load($liste_id); - - echo " - - - -
".$p->t('benotungstool/uebungBearbeiten')." 
 
".$p->t('benotungstool/thema')."$error_thema
".$p->t('benotungstool/gewicht')."$error_gewicht
".$p->t('benotungstool/positiv')." positiv?'checked':'').">
-
"; - } - - //Gesamtuebersicht ueber alle Listen innerhalb der Uebung - echo "
"; - echo "
"; - echo ""; - $studentuebung = new uebung(); - if (!$studentuebung->check_studentuebung($liste_id)) - echo ""; - - $uebung_obj = new uebung(); - $uebung_obj->load_uebung($lehreinheit_id,$level=2,$uebung_id=$liste_id); - $anzahl = count($uebung_obj->uebungen); - $copy_content="
".$p->t('benotungstool/vorhandeneAufgabeBearbeiten')."
"; - $has_copy_content=false; - if($anzahl>0) - { - echo ""; - - //Alle Lehreinheiten holen die zu dieser lehrveranstaltung gehoeren - //und der angemeldete User berechtigt ist - $copy_option_content = array(); - for($i=0;$i<$db->db_num_rows($result_alle_lehreinheiten);$i++) - { - $row_alle_lehreinheiten = $db->db_fetch_object($result_alle_lehreinheiten,$i); - if($lehreinheit_id!=$row_alle_lehreinheiten->lehreinheit_id) - { - //zugeteilte Lektoren holen - $qry_lektoren = "SELECT * FROM lehre.tbl_lehreinheitmitarbeiter JOIN public.tbl_mitarbeiter using(mitarbeiter_uid) WHERE lehreinheit_id=".$db->db_add_param($row_alle_lehreinheiten->lehreinheit_id, FHC_INTEGER); - if($result_lektoren = $db->db_query($qry_lektoren)) - { - $lektoren = '( '; - $j=0; - while($row_lektoren = $db->db_fetch_object($result_lektoren)) - { - $lektoren .= $row_lektoren->kurzbz; - $j++; - if($j<$db->db_num_rows($result_lektoren)) - $lektoren.=', '; - else - $lektoren.=' '; - } - $lektoren .=')'; - } - //zugeteilte Gruppen holen - $qry_gruppen = "SELECT * FROM lehre.tbl_lehreinheitgruppe WHERE lehreinheit_id=".$db->db_add_param($row_alle_lehreinheiten->lehreinheit_id,FHC_INTEGER); - if($result_gruppen = $db->db_query($qry_gruppen)) - { - $gruppen = ''; - $j=0; - while($row_gruppen = $db->db_fetch_object($result_gruppen)) - { - if($row_gruppen->gruppe_kurzbz=='') - $gruppen.=$row_gruppen->semester.$row_gruppen->verband.$row_gruppen->gruppe; - else - $gruppen.=$row_gruppen->gruppe_kurzbz; - $j++; - if($j<$db->db_num_rows($result_gruppen)) - $gruppen.=', '; - else - $gruppen.=' '; - } - } - //$copy_option_content.= "\n"; - $copy_le_content[$row_alle_lehreinheiten->lehreinheit_id] = "$row_alle_lehreinheiten->lfbez-$row_alle_lehreinheiten->lehrform_kurzbz - $gruppen $lektoren"; - } - } - - //Uebungen durchlaufen - foreach ($uebung_obj->uebungen as $row) - { - $has_option_content=false; - echo ""; - //Wenn andere Lehreinheiten vorhanden sind dann wird die moeglichkeit zum kopieren von - //Uebungen in diese Lehreinheiten angeboten. - if(isset($result_alle_lehreinheiten) && $db->db_num_rows($result_alle_lehreinheiten)>1) - { - $copy_content.= ''; - $copy_content.= '"; - } - } - echo ""; - if ($row->beispiele) - $anzeigen = 'beispiele'; - else - $anzeigen = 'abgabe'; - } - else - { - $studentuebung = new uebung(); - if (!$studentuebung->check_studentuebung($liste_id)) - { - echo ""; - $anzeigen = 'beide'; - } - else - $anzeigen = "nada"; - } - - echo "
".$p->t('benotungstool/uebungInAndereLeKopieren')."
 
 
 
".$p->t('benotungstool/thema')."".$p->t('benotungstool/freigeschalten')."".$p->t('benotungstool/auswahl')." 
".$row->bezeichnung.""; - - if((strtotime(strftime($row->freigabevon))<=time()) && (strtotime(strftime($row->freigabebis))>=time())) - echo $p->t('global/ja'); - else - echo $p->t('global/nein'); - echo "
'; - $copy_option_content = ''; - //Lehreinheiten fuer Combo durchgehen und schauen ob - //fuer diese Lehreinheit bereits eine Uebung mit gleichem Namen existiert - //Falls ja wird diese nicht in der Combo angezeigt - foreach ($copy_le_content as $id=>$bezeichnung) - { - $qry = "SELECT uebung_id FROM campus.tbl_uebung WHERE lehreinheit_id=".$db->db_add_param($id, FHC_INTEGER)." AND bezeichnung=".$db->db_add_param($row->bezeichnung); - //echo $qry; - if($result_vorhanden = $db->db_query($qry)) - { - if($db->db_num_rows($result_vorhanden)==0) - { - $copy_option_content.= "\n"; - $has_option_content=true; - $has_copy_content=true; - } - } - } - //Wenn eintraege fuer Combo vorhanden sind dann wirds angezeigt - if($has_option_content) - { - $copy_content.= "\n"; - $copy_content.= "\n '; - $copy_content.= "   "; - $copy_content.= "\n"; - } - else - { - $copy_content.=" "; - } - $copy_content.= "
".$p->t('benotungstool/derzeitSindKeineAufgabenAngelegt')."
-

"; - - //Kopier-Buttons anzeigen - $copy_content.='
'; - echo "
"; - //if($has_copy_content) - // echo $copy_content; - echo "
"; - - //Uebung neu anlegen - if(!isset($_POST['uebung_neu'])) - { - $thema = $p->t('benotungstool/liste')." ".($anzahl<9?'0'.($anzahl+1):($anzahl+1)); - $anzahlderbeispiele = 10; - $punkteprobeispiel = 1; - $freigabevon = date('d.m.Y H:i'); - $freigabebis = date('d.m.Y H:i'); - $maxstudentenprobeispiel = ''; - $maxbeispieleprostudent = ''; - $gewicht = 1; - - } - echo "
"; - - if ($anzeigen != 'abgabe' && $anzeigen != 'nada') - { - echo " -
- - - - - - - - - - - - - - -
".$p->t('benotungstool/neueKreuzerllisteAnlegen')."
".$p->t('benotungstool/thema')."$error_thema
".$p->t('benotungstool/anzahlDerBeispiele')."$error_anzahlderbeispiele
".$p->t('benotungstool/anzahlPunkteProBeispiel')."$error_punkteprobeispiel
".$p->t('benotungstool/maxStudentenBeispiel')."$error_maxstd
".$p->t('benotungstool/maxBeispieleStudent')."$error_maxbsp
".$p->t('benotungstool/freigabe')."von $error_freigabevon
".$p->t('benotungstool/format')."bis $error_freigabebis
".$p->t('benotungstool/abgabe')."
".$p->t('benotungstool/statistikFuerStudentenAnzeigen')."
".$p->t('benotungstool/angabeidatei')."
-
- "; - // notenschlüssel - $qry = "select * from campus.tbl_notenschluesseluebung where uebung_id = ".$db->db_add_param($liste_id, FHC_INTEGER)." order by note"; - if($result = $db->db_query($qry)) - { - $notenschluessel = array(); - $notenschluessel[1] = ''; - $notenschluessel[2] = ''; - $notenschluessel[3] = ''; - $notenschluessel[4] = ''; - $notenschluessel[5] = ''; - if($db->db_num_rows($result)>=1) - { - while($schluesselrow = $db->db_fetch_object($result)) - { - $notenschluessel[$schluesselrow->note] = $schluesselrow->punkte; - } - } - } - - if ($anzeigen != "beide") - { - if ($liste_obj->prozent == 't') - { - $einheit = " %"; - $einheit_link = $p->t('benotungstool/notenschluesselInProzent')." / ".$p->t('benotungstool/punkten').""; - } - else - { - $einheit=" ".$p->t('benotungstool/punkte'); - $einheit_link = $p->t('benotungstool/notenschluesselIn')." ".$p->t('benotungstool/prozentPunkten'); - } - - echo "
\n"; - echo "\n"; - echo ""; - echo ""; - echo ""; - echo "\n"; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - echo "
".$p->t('benotungstool/notenschluesselDefinieren')."
"; - echo $einheit_link; - echo "
 
".$p->t('benotungstool/note')."".$p->t('benotungstool/minimum')."
$einheit
$einheit
$einheit
$einheit
$einheit
"; - if ($liste_obj->prozent == 't') - echo "
"; - echo "
-
"; - } - } - if(!isset($_POST['uebung_neu'])) - $thema = "Abgabe ".($anzahl<9?'0'.($anzahl+1):($anzahl+1)); - - if ($anzeigen != 'beispiele' && $anzeigen != 'nada') - { - echo " -
- - - - - - - - - - -
".$p->t('benotungstool/neueAbgabeAnlegen')."
".$p->t('benotungstool/thema')."$error_thema
".$p->t('benotungstool/freigabe')."von $error_freigabevon
".$p->t('benotungstool/format')."bis $error_freigabebis
".$p->t('benotungstool/gewicht')."$error_gewicht
".$p->t('benotungstool/positiv')."
".$p->t('benotungstool/angabeidatei')."
-
- "; - } -} -?> -
- - diff --git a/cis/private/lehre/benotungstool/zipdownload_benotungstool.php b/cis/private/lehre/benotungstool/zipdownload_benotungstool.php deleted file mode 100644 index 9e177dba7..000000000 --- a/cis/private/lehre/benotungstool/zipdownload_benotungstool.php +++ /dev/null @@ -1,91 +0,0 @@ -, - * Andreas Oesterreicher - * Rudolf Hangl < rudolf.hangl@technikum-wien.at > - * Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at > - */ -/** - * Erstellt ein Zip Archiv des Download-Bereichs und leitet dann zum Download weiter - * @create 20-03-2006 - * Aufruf: zipdownload.php?stg=255&sem=1$short=eng - */ -require_once('../../../../config/cis.config.inc.php'); -require_once('../../../../include/functions.inc.php'); - -$user = get_uid(); - -if(!check_lektor($user)) - die('Sie haben keine Berechtigung fuer diese Seite'); - -//Gueltigkeit der Parameter pruefen -if(!isset($_GET['uebung_id']) || !is_numeric($_GET['uebung_id'])) -{ - die('Fehler bei der Parameteruebergabe'); -} -if(!isset($_GET['lehreinheit_id']) || !is_numeric($_GET['lehreinheit_id'])) -{ - die('Fehler bei der Parameteruebergabe'); -} -if(!isset($_GET['stsem'])) -{ - die('Fehler bei der Parameteruebergabe'); -} -if(!isset($_GET['downloadname'])) -{ - die('Fehler bei der Parameteruebergabe'); -} - -$uebung_id = $_GET['uebung_id']; -$lehreinheit_id = $_GET['lehreinheit_id']; -$stsem = $_GET['stsem']; -$downloadname = $_GET['downloadname']; - -if(mb_strstr($downloadname,'..')) - die('Ungueltiger Parameter gefunden'); - -//Pfade bauen -$pfad = BENOTUNGSTOOL_PATH.'abgabe/'; -$filename = 'download_'.$user.'_'.$downloadname.'.zip'; -$filename_tmp = 'download_'.$user.'_'.$uebung_id.'.zip'; - -if(!check_filename($filename) || !check_filename($filename_tmp)) - die('Ungueltiger Parameter gefunden'); - -//Pfad wechseln -if(chdir($pfad)) -{ - //File loeschen falls es existiert - //if(file_exists("download_".$user."*")) - exec('rm download_'.$user.'*'); - - //Zip File erstellen - exec("zip -r ".escapeshellarg($filename_tmp).' *_[WS]S[0-9][0-9][0-9][0-9]_'.$uebung_id.'_*'); - - //Auf Zip File Verweisen - //header("Location: $pfad$filename"); - header('Content-Type: application/octet-stream'); - header('Content-disposition: attachment; filename="'.$filename.'"'); - readfile($filename_tmp); - unlink($filename_tmp); -} -else -{ - die('Path change failed'); -} -?> diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index 308058fba..82dcbda10 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -16,7 +16,6 @@ define('DEFAULT_MITARBEITER_FIXANGESTELLT', true); define('CIS_LEHRVERANSTALTUNG_NEWSGROUPS_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_FEEDBACK_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_DOWNLOAD_ANZEIGEN',true); -define('CIS_LEHRVERANSTALTUNG_UEBUNGSTOOL_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_PINBOARD_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_MAILSTUDIERENDE_ANZEIGEN',true); define('CIS_LEHRVERANSTALTUNG_STUDENTENUPLOAD_ANZEIGEN',true); diff --git a/include/tw/cis_menu_lv.inc.php b/include/tw/cis_menu_lv.inc.php index 2ab43807b..b8c42da11 100644 --- a/include/tw/cis_menu_lv.inc.php +++ b/include/tw/cis_menu_lv.inc.php @@ -275,41 +275,6 @@ function checkZeilenUmbruch() ); } - // Uebungstool - if((!defined('CIS_LEHRVERANSTALTUNG_UEBUNGSTOOL_ANZEIGEN') || CIS_LEHRVERANSTALTUNG_UEBUNGSTOOL_ANZEIGEN) && $angemeldet) - { - $link=''; - $link_onclick=''; - $text=''; - - if(isset($angezeigtes_stsem)) - $studiensem = '&stsem='.urlencode($angezeigtes_stsem); - else - $studiensem = ''; - - //Kreuzerltool - if($is_lector) - { - $link='benotungstool/verwaltung.php?lvid='.urlencode($lvid).$studiensem; - $text.='
'.$p->t('lehre/benotungstoolHandbuch').' [PDF]'; - } - else - { - $link='benotungstool/studentenansicht.php?lvid='.urlencode($lvid).$studiensem; - } - - $menu[]=array - ( - 'id'=>'core_menu_uebungstool', - 'position'=>'60', - 'name'=>$p->t('lehre/kreuzerltool'), - 'icon'=>'../../../skin/images/button_kreuzerltool.png', - 'link'=>$link, - 'link_onclick'=>$link_onclick, - 'text'=>$text - ); - } - //Gesamtnote if($is_lector && ((!defined('CIS_LEHRVERANSTALTUNG_GESAMTNOTE_ANZEIGEN') || CIS_LEHRVERANSTALTUNG_GESAMTNOTE_ANZEIGEN) && $angemeldet)) { From d496bf599357e6cf6a1177962e4a79804f9112ff Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 3 Feb 2020 16:44:29 +0100 Subject: [PATCH 076/157] When the recipient is infocenter then place a * close to the drop down description and a note under the tinymce box. --- application/models/CL/Messages_model.php | 2 +- .../views/system/messages/ajaxWrite.php | 6 ++++++ system/phrasesupdate.php | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 50639b55b..84f4e59aa 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -88,7 +88,7 @@ class Messages_model extends CI_Model $ouOptions .= sprintf( "\n".'', is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : self::ALT_OE, - $ou->bezeichnung + $ou->bezeichnung . (is_numeric($ou->prestudent_id) ? '' : ' *') ); } } diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 6080f3eef..df6c1bfcb 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -56,6 +56,12 @@
+ +
+ +
+ p->t('ui', 'altRecipientNote'); ?> +

diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index f0c66b758..e4ea4aacb 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4174,6 +4174,26 @@ When on hold, the date is only a reminder.', 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'altRecipientNote', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => '* This is a notice to notice you that you have been noticed DE', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => '* This is a notice to notice you that you have been noticed', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From e19533c0ba6780a980fb2a2eb11ea4b0b2d6eab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 4 Feb 2020 14:30:12 +0100 Subject: [PATCH 077/157] Removed legacy Link from Vilesci Menu --- include/tw/vilesci_menu_main.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/include/tw/vilesci_menu_main.inc.php b/include/tw/vilesci_menu_main.inc.php index c49542246..d465eba28 100644 --- a/include/tw/vilesci_menu_main.inc.php +++ b/include/tw/vilesci_menu_main.inc.php @@ -185,7 +185,6 @@ $menu=array 'Lehreinheiten'=>array('name'=>'Lehreinheiten', 'link'=>'lehre/lehreinheiten_vorrueckung.php', 'target'=>'main','permissions'=>array('lehre/vorrueckung'),), 'Studenten'=>array('name'=>'Studenten', 'link'=>'personen/student_vorrueckung.php', 'target'=>'main','permissions'=>array('student/vorrueckung'),) ), - 'Kreuzerllistekopieren'=>array('name'=>'Kreuzerllisten kopieren', 'link'=>CIS_ROOT.'cis/private/lehre/benotungstool/copy_uebung.php', 'target'=>'_blank','permissions'=>array('admin')), 'Firmenwartung'=>array('name'=>'Firmenwartung', 'link'=>'stammdaten/firma_zusammen_uebersicht.php', 'target'=>'main','permissions'=>array('basis/firma')), 'checkStudenten'=>array('name'=>'CheckStudenten', 'link'=>'../system/checkStudenten.php', 'target'=>'main', 'permissions'=>array('student/stammdaten')), 'StudienplanZuteilung'=>array('name'=>'Studienplan Zuteilung', 'link'=>'lehre/studienplan_zuteilung.php', 'target'=>'main','permissions'=>array('assistenz')), From 53ac4d11ba33eb31c5350d3b50a545cce15eebe6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 4 Feb 2020 14:42:53 +0100 Subject: [PATCH 078/157] Do not retrieve the degree program name from studiengang table but directly from the organization unit table in student sent messages page and student write to organisation unit page --- application/models/CL/Messages_model.php | 4 ++-- application/models/crm/Prestudent_model.php | 7 ++++--- application/models/system/Recipient_model.php | 15 +++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 84f4e59aa..87eff0f99 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -183,7 +183,7 @@ class Messages_model extends CI_Model public function prepareAjaxReadSent() { // Retrieves sent messages from the logged user - $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId(), self::ALT_OE); + $sentMessagesResult = $this->RecipientModel->getSentMessages(getAuthPersonId()); if (isError($sentMessagesResult)) return $sentMessagesResult; // If an error occurred return it if (hasData($sentMessagesResult)) @@ -205,7 +205,7 @@ class Messages_model extends CI_Model if ($sentMessage->person_id == $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID)) { - $jsonRecord->to = $sentMessage->sg; + $jsonRecord->to = $sentMessage->oe; } else { diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 5b74ed5e4..94d77f8d3 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -524,11 +524,12 @@ class Prestudent_model extends DB_Model /** * Get organisation units for all the prestudents of a person + * TODO */ public function getOrganisationunitsByPersonId($person_id) { $query = 'SELECT o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id FROM public.tbl_prestudent p JOIN public.tbl_studiengang sg USING(studiengang_kz) @@ -541,9 +542,9 @@ class Prestudent_model extends DB_Model ) ps USING(prestudent_id) WHERE p.person_id = ? GROUP BY o.oe_kurzbz, - sg.bezeichnung, + o.bezeichnung, ps.prestudent_id - ORDER BY sg.bezeichnung'; + ORDER BY o.bezeichnung'; return $this->execQuery($query, array($person_id)); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 8f5dfa397..c2acd2d56 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -446,7 +446,7 @@ class Recipient_model extends DB_Model /** * Gets all the sent message by the given person */ - public function getSentMessages($person_id, $altOe = '') + public function getSentMessages($person_id) { $sql = 'SELECT mm.message_id, mm.relationmessage_id, @@ -458,18 +458,13 @@ class Recipient_model extends DB_Model p.nachname, MAX(ms.status) AS status, ms.person_id AS statusPersonId, - sg.bezeichnung AS sg, + oe.bezeichnung AS oe, mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - LEFT JOIN ( - SELECT oe_kurzbz, bezeichnung - FROM public.tbl_studiengang - UNION - SELECT ?, ? - ) sg ON (sg.oe_kurzbz = mr.oe_kurzbz) + JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL @@ -482,10 +477,10 @@ class Recipient_model extends DB_Model p.vorname, p.nachname, ms.person_id, - sg.bezeichnung, + oe.bezeichnung, mr.token ORDER BY mr.sent DESC'; - return $this->execQuery($sql, array($altOe, ucfirst($altOe), $person_id)); + return $this->execQuery($sql, array($person_id)); } } From a66d319581e760968fec94f7540a3b74537b8d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 4 Feb 2020 14:58:33 +0100 Subject: [PATCH 079/157] Fixed some XSS Bugs --- cis/index.php | 5 +++-- cis/private/stud_in_grp.php | 2 +- include/pgsql.class.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cis/index.php b/cis/index.php index f9e18cbda..a6ec16786 100644 --- a/cis/index.php +++ b/cis/index.php @@ -70,13 +70,14 @@ if(defined('CIS_CHECK_PASSWORD_CHANGE') && CIS_CHECK_PASSWORD_CHANGE==true) */ function validURLCheck($param) { - if(strstr($param,':')) + if (strstr($param,':') || strstr($param,'//')) { // Der APP_ROOT muss in der URL vorkommen, sonfern es kein relativer Pfad ist // HTTPS und HTTP if(mb_strpos($param, APP_ROOT)!==0 && mb_strpos(mb_str_replace("http://","https://", $param), APP_ROOT)!==0 - && mb_strpos(mb_str_replace("https://","http://", $param), APP_ROOT)!==0) + && mb_strpos(mb_str_replace("https://","http://", $param), APP_ROOT)!==0 + && $param != 'about:blank') { $text="Dies ist eine automatische Mail.\nEs wurde eine mögliche XSS Attacke durchgefuehrt:\n"; $text.="\nFolgende URL wurde versucht aufzurufen: \n".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; diff --git a/cis/private/stud_in_grp.php b/cis/private/stud_in_grp.php index abf3a67a1..d2f9e2d2c 100644 --- a/cis/private/stud_in_grp.php +++ b/cis/private/stud_in_grp.php @@ -183,7 +183,7 @@ else AND studiengang_kz=".$db->db_add_param($_GET['kz']); if (isset($_GET['sem'])) - $qry.=" AND semester=".$db->db_add_param($_GET['sem']); + $qry.=" AND semester=".$db->db_add_param($_GET['sem'], FHC_INTEGER); if (isset($_GET['verband'])) $qry.=" AND verband=".$db->db_add_param($_GET['verband']); diff --git a/include/pgsql.class.php b/include/pgsql.class.php index 52ac9b4f8..7e0333b9f 100644 --- a/include/pgsql.class.php +++ b/include/pgsql.class.php @@ -289,7 +289,7 @@ class basis_db extends db case FHC_INTEGER: $var = $this->db_escape($var); if(!is_numeric($var) && $var!=='') - die('Invalid Integer Parameter detected:'.$var); + die('Invalid Integer Parameter detected'); $var = $this->db_null_value($var, false); break; From 749e9be64d0d996642c6e8fce6756ed412f247c5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 4 Feb 2020 17:02:25 +0100 Subject: [PATCH 080/157] Messaging system: student writes new message: separate logic for master and bachelor --- application/models/crm/Prestudent_model.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 94d77f8d3..b40897d82 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -524,26 +524,30 @@ class Prestudent_model extends DB_Model /** * Get organisation units for all the prestudents of a person - * TODO */ public function getOrganisationunitsByPersonId($person_id) { $query = 'SELECT o.oe_kurzbz, o.bezeichnung, - ps.prestudent_id + (CASE + WHEN sg.typ = \'b\' THEN ps.prestudent_id + WHEN sg.typ = \'m\' THEN p.prestudent_id + ELSE NULL + END) AS prestudent_id FROM public.tbl_prestudent p JOIN public.tbl_studiengang sg USING(studiengang_kz) JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) LEFT JOIN ( SELECT prestudent_id FROM public.tbl_prestudentstatus - WHERE bestaetigtam IS NOT NULL - AND status_kurzbz = \'Interessent\' + WHERE status_kurzbz = \'Bewerber\' ) ps USING(prestudent_id) WHERE p.person_id = ? GROUP BY o.oe_kurzbz, o.bezeichnung, - ps.prestudent_id + sg.typ, + ps.prestudent_id, + p.prestudent_id ORDER BY o.bezeichnung'; return $this->execQuery($query, array($person_id)); From a5ad57ceeefa9b5825646848783229643d3ca400 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 4 Feb 2020 17:53:32 +0100 Subject: [PATCH 081/157] =?UTF-8?q?testtool/admin/edit=5Fgebiet.php:=20Off?= =?UTF-8?q?setpunkte=20k=C3=B6nnen=20nun=20=C3=BCber=20admin=20GUI=20einge?= =?UTF-8?q?tragen=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/admin/edit_gebiet.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index afe81dae7..474546d4a 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -186,6 +186,7 @@ if (isset($_POST['speichern'])) $gebiet->zufallvorschlag = isset($_POST['zufallvorschlag']); $gebiet->levelgleichverteilung = isset($_POST['levelgleichverteilung']); $gebiet->maxpunkte = $_POST['maxpunkte']; + $gebiet->offsetpunkte = $_POST['offsetpunkte']; $gebiet->maxfragen = $_POST['maxfragen']; $gebiet->level_start = $_POST['level_start']; $gebiet->level_sprung_auf = $_POST['level_sprung_auf']; @@ -257,6 +258,8 @@ if ($gebiet_id != '') $hinweis = ''; echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; + echo 'Offsetpunkte (minimale Punkteanzahl)'; + echo ''; echo 'Maximale Fragenanzahl'; echo ''; echo 'Antworten pro Zeile'; From e2f4e35a7f6fc998c17e0decb1f8f64a8e7b8ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 5 Feb 2020 15:25:00 +0100 Subject: [PATCH 082/157] =?UTF-8?q?Lehrauftragsverwaltung=20zeigt=20per=20?= =?UTF-8?q?Default=20das=20aktuelle=20Studiensemester=20statt=20dem=20n?= =?UTF-8?q?=C3=A4chsten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/lehre/lehrauftrag/Lehrauftrag.php | 2 +- .../controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php | 2 +- .../controllers/lehre/lehrauftrag/LehrauftragErteilen.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php index 3c0808d42..62a12742d 100644 --- a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php +++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php @@ -107,7 +107,7 @@ class Lehrauftrag extends Auth_Controller $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value { - $studiensemester = $this->StudiensemesterModel->getNext(); + $studiensemester = $this->StudiensemesterModel->getAktOrNextSemester(); if (hasData($studiensemester)) { $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php index b2282f6f2..4fc0a879b 100644 --- a/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php +++ b/application/controllers/lehre/lehrauftrag/LehrauftragAkzeptieren.php @@ -71,7 +71,7 @@ class LehrauftragAkzeptieren extends Auth_Controller $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value { - $studiensemester = $this->StudiensemesterModel->getNext(); + $studiensemester = $this->StudiensemesterModel->getAktOrNextSemester(); if (hasData($studiensemester)) { $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php index b70b6e2f9..b339c81a4 100644 --- a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php +++ b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php @@ -90,7 +90,7 @@ class LehrauftragErteilen extends Auth_Controller $studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value { - $studiensemester = $this->StudiensemesterModel->getNext(); + $studiensemester = $this->StudiensemesterModel->getAktOrNextSemester(); if (hasData($studiensemester)) { $studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz; From 3d31bf1e0710242b30e12bee1b21c6cebe7ea737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 5 Feb 2020 16:10:33 +0100 Subject: [PATCH 083/157] =?UTF-8?q?Sortierung=20der=20Studienordnungen=20a?= =?UTF-8?q?ngepasst=20damit=20bei=202=20Studienordnungen=20des=20selben=20?= =?UTF-8?q?Studiengangs=20mit=20gleichem=20Beginndatum=20bevorzugt=20die?= =?UTF-8?q?=20l=C3=A4nger=20g=C3=BCltige=20(neuere)=20=20herangezogen=20wi?= =?UTF-8?q?rd=20beim=20Export=20der=20LV-Informationen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/studienordnung.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/studienordnung.class.php b/include/studienordnung.class.php index 58c033057..41d18a60c 100644 --- a/include/studienordnung.class.php +++ b/include/studienordnung.class.php @@ -154,6 +154,7 @@ class studienordnung extends basis_db FROM lehre.tbl_studienordnung sto LEFT JOIN lehre.tbl_studienordnungstatus s USING(status_kurzbz) LEFT JOIN public.tbl_studiensemester ON(sto.gueltigvon=tbl_studiensemester.studiensemester_kurzbz) + LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigvon=stoende.studiensemester_kurzbz) WHERE studiengang_kz='.$this->db_add_param($studiengang_kz, FHC_INTEGER, false); } else @@ -164,6 +165,7 @@ class studienordnung extends basis_db LEFT JOIN lehre.tbl_studienplan USING(studienordnung_id) LEFT JOIN lehre.tbl_studienplan_semester sem USING (studienplan_id) LEFT JOIN public.tbl_studiensemester ON(sto.gueltigvon=tbl_studiensemester.studiensemester_kurzbz) + LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigvon=stoende.studiensemester_kurzbz) WHERE studiengang_kz='.$this->db_add_param($studiengang_kz, FHC_INTEGER, false); if (!is_null($studiensemester_kurzbz)) @@ -172,7 +174,7 @@ class studienordnung extends basis_db $qry.=" AND semester=".$this->db_add_param($semester, FHC_INTEGER,false); } - $qry.=" ORDER BY gueltig_startdatum desc"; + $qry.=" ORDER BY gueltig_startdatum desc, stoende.start nulls first"; if(!$this->db_query($qry)) { @@ -475,10 +477,10 @@ class studienordnung extends basis_db return false; } - $qry = 'SELECT 1 FROM lehre.tbl_studienplan_semester - WHERE studienplan_id + $qry = 'SELECT 1 FROM lehre.tbl_studienplan_semester + WHERE studienplan_id IN (SELECT studienplan_id FROM lehre.tbl_studienplan - WHERE studienordnung_id ='.$this->db_add_param($studienordnung_id).';'; + WHERE studienordnung_id ='.$this->db_add_param($studienordnung_id).';'; if($this->db_query($qry)) { From 32c6f30aa747173deee5eab0c0bdb09e8d2fb922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 5 Feb 2020 16:16:24 +0100 Subject: [PATCH 084/157] Sortierung der Studienordnungen korrigiert --- include/studienordnung.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/studienordnung.class.php b/include/studienordnung.class.php index 41d18a60c..eca5fa52a 100644 --- a/include/studienordnung.class.php +++ b/include/studienordnung.class.php @@ -154,7 +154,7 @@ class studienordnung extends basis_db FROM lehre.tbl_studienordnung sto LEFT JOIN lehre.tbl_studienordnungstatus s USING(status_kurzbz) LEFT JOIN public.tbl_studiensemester ON(sto.gueltigvon=tbl_studiensemester.studiensemester_kurzbz) - LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigvon=stoende.studiensemester_kurzbz) + LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigbis=stoende.studiensemester_kurzbz) WHERE studiengang_kz='.$this->db_add_param($studiengang_kz, FHC_INTEGER, false); } else @@ -165,7 +165,7 @@ class studienordnung extends basis_db LEFT JOIN lehre.tbl_studienplan USING(studienordnung_id) LEFT JOIN lehre.tbl_studienplan_semester sem USING (studienplan_id) LEFT JOIN public.tbl_studiensemester ON(sto.gueltigvon=tbl_studiensemester.studiensemester_kurzbz) - LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigvon=stoende.studiensemester_kurzbz) + LEFT JOIN public.tbl_studiensemester stoende ON(sto.gueltigbis=stoende.studiensemester_kurzbz) WHERE studiengang_kz='.$this->db_add_param($studiengang_kz, FHC_INTEGER, false); if (!is_null($studiensemester_kurzbz)) From 91bb16c47425edaf67a910b22d41f98db8e863eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 5 Feb 2020 17:26:53 +0100 Subject: [PATCH 085/157] Regenerate Session ID after Testtool Login --- cis/testtool/login.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cis/testtool/login.php b/cis/testtool/login.php index e42a623b2..477901803 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -125,6 +125,9 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) { if($rt->freigeschaltet) { + // regenerate Session ID after Login + session_regenerate_id(); + $pruefling = new pruefling(); if($pruefling->getPruefling($ps->prestudent_id)) { From 17ef2f173b0aa9a381c8752a8b01b31ceb102d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 6 Feb 2020 14:28:15 +0100 Subject: [PATCH 086/157] Fixed Error in Bewerberstatistik Excel Export --- content/statistik/bewerberstatistik.php | 30 +++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/content/statistik/bewerberstatistik.php b/content/statistik/bewerberstatistik.php index 766a7d143..932a8c6cb 100644 --- a/content/statistik/bewerberstatistik.php +++ b/content/statistik/bewerberstatistik.php @@ -288,13 +288,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - AND ( - anmeldedatum<=".$db->db_add_param($datum)." - OR - (anmeldedatum is null - AND tbl_rt_person.insertamum<=".$db->db_add_param($datum).") - ) - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz ) ) AS interessentenrtanmeldung, (SELECT count(*) FROM public.tbl_prestudent JOIN public.tbl_prestudentstatus USING (prestudent_id) JOIN public.tbl_person USING(person_id) @@ -310,13 +304,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - AND ( - anmeldedatum<=".$db->db_add_param($datum)." - OR - (anmeldedatum is null - AND tbl_rt_person.insertamum<=".$db->db_add_param($datum).") - ) - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz ) ) AS interessentenrtanmeldung_m, (SELECT count(*) FROM public.tbl_prestudent JOIN public.tbl_prestudentstatus USING (prestudent_id) JOIN public.tbl_person USING(person_id) @@ -332,13 +320,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - AND ( - anmeldedatum<=".$db->db_add_param($datum)." - OR - (anmeldedatum is null - AND tbl_rt_person.insertamum<=".$db->db_add_param($datum).") - ) - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz ) ) AS interessentenrtanmeldung_w, @@ -841,7 +823,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz AND ( anmeldedatum<=".$db->db_add_param($datum)." OR @@ -863,7 +845,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz AND (anmeldedatum<=".$db->db_add_param($datum)." OR (anmeldedatum is null @@ -884,7 +866,7 @@ if (isset($_GET['excel'])) WHERE person_id=tbl_prestudent.person_id AND tbl_reihungstest.studiensemester_kurzbz=tbl_prestudentstatus.studiensemester_kurzbz - /*AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz*/ + AND tbl_studienordnung.studiengang_kz=tbl_prestudent.studiengang_kz AND (anmeldedatum<=".$db->db_add_param($datum)." OR (anmeldedatum is null From 7f8415e6dc78f1bd3fa8b1b8c6629f7ff2c43af1 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 6 Feb 2020 14:52:26 +0100 Subject: [PATCH 087/157] system/Variable_model: replaced concatenation of names array with ? (parameter replacement by CI) to prevent SQL injections --- application/libraries/VariableLib.php | 2 +- application/models/system/Variable_model.php | 21 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/application/libraries/VariableLib.php b/application/libraries/VariableLib.php index 3d732984f..2f038531b 100644 --- a/application/libraries/VariableLib.php +++ b/application/libraries/VariableLib.php @@ -57,7 +57,7 @@ class VariableLib if (!isEmptyString($uid) && !isEmptyString($name) && is_numeric($change)) { - $change = (int) $change; + $change = (int)$change; $varres = $this->_ci->VariableModel->getVariables($uid, array($name)); if (isSuccess($varres)) diff --git a/application/models/system/Variable_model.php b/application/models/system/Variable_model.php index 1fcb5b274..875fc8876 100644 --- a/application/models/system/Variable_model.php +++ b/application/models/system/Variable_model.php @@ -24,30 +24,32 @@ class Variable_model extends DB_Model */ public function getVariables($uid, $names = null) { - if (isEmptyString($uid) || (isset($names) && !is_array($names))) + if (isEmptyString($uid)) $result = error('wrong parameters passed'); else { $vardata = array(); + $parametersArray = array($uid); $qry = "SELECT name, wert FROM public.tbl_variable WHERE uid = ?"; - if (isset($names)) + if (!isEmptyArray($names)) { - $qry .= " AND name IN ('".implode(',', $names)."')"; + $qry .= " AND name IN ?"; + $parametersArray[] = $names; } $qry .= ";"; - $varresults = $this->execQuery($qry, array($uid)); + $varresults = $this->execQuery($qry, $parametersArray); if (hasData($varresults)) { $varresults = getData($varresults); - foreach ($varresults as $varresult) - { - if (isset($varresult->wert)) - $vardata[$varresult->name] = $varresult->wert; - } + foreach ($varresults as $varresult) + { + if (isset($varresult->wert)) + $vardata[$varresult->name] = $varresult->wert; + } } $vardefaults = $this->VariablennameModel->getDefaults($names); @@ -56,7 +58,6 @@ class Variable_model extends DB_Model { $vardefaults = getData($vardefaults); - foreach ($vardefaults as $vardefault) { if (!isset($vardata[$vardefault->name]) && isset($vardefault->defaultwert)) From 40891496b1285ae3ca9ee62a3c9341ea569b7a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 7 Feb 2020 08:40:18 +0100 Subject: [PATCH 088/157] Studienblatt RDF exportiert das Geschlecht und die Unterrichtssprache in Deutsch und Englisch --- rdf/studienblatt.xml.php | 279 +++++++++++++++++++-------------------- system/dbupdate_3.3.php | 2 +- 2 files changed, 140 insertions(+), 141 deletions(-) diff --git a/rdf/studienblatt.xml.php b/rdf/studienblatt.xml.php index 163b2749a..7756901f5 100644 --- a/rdf/studienblatt.xml.php +++ b/rdf/studienblatt.xml.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Andreas Oesterreicher - * Karl Burkhart - * Manfred Kindl + * Karl Burkhart + * Manfred Kindl */ header("Content-type: application/xhtml+xml"); require_once('../config/vilesci.config.inc.php'); @@ -36,6 +36,7 @@ require_once('../include/mitarbeiter.class.php'); require_once('../include/organisationsform.class.php'); require_once('../include/zgv.class.php'); require_once('../include/konto.class.php'); +require_once('../include/geschlecht.class.php'); $uid_arr = (isset($_REQUEST['uid'])?$_REQUEST['uid']:null); $studiensemester = (isset($_REQUEST['ss'])?$_REQUEST['ss']:null); @@ -52,33 +53,33 @@ $student_help = new student(); // an 2ter stelle da im Aufruf vom FAS ;; der erste immer '' ist if($student_help->load($uid)) { - $studiengang = new studiengang(); - $studiengang->load($student_help->studiengang_kz); + $studiengang = new studiengang(); + $studiengang->load($student_help->studiengang_kz); switch($studiengang->typ) - { - case 'b': - $studTyp = 'Bachelor'; - $titel_kurzbz = 'BSc'; - break; - case 'm': - $studTyp = 'Master'; - $titel_kurzbz ='MSc'; - break; - case 'd': - $studTyp = 'Diplom'; - break; - case 'l': - $studTyp = 'Lehrgang'; - break; - case 'k': - $studTyp = 'Kurzstudium'; - break; - default: - $studTyp =''; - $titel_kurzbz = ''; - } - echo "\t".$studTyp."\n"; - echo "\tbezeichnung."]]>\n"; + { + case 'b': + $studTyp = 'Bachelor'; + $titel_kurzbz = 'BSc'; + break; + case 'm': + $studTyp = 'Master'; + $titel_kurzbz ='MSc'; + break; + case 'd': + $studTyp = 'Diplom'; + break; + case 'l': + $studTyp = 'Lehrgang'; + break; + case 'k': + $studTyp = 'Kurzstudium'; + break; + default: + $studTyp =''; + $titel_kurzbz = ''; + } + echo "\t".$studTyp."\n"; + echo "\tbezeichnung."]]>\n"; } foreach($uid_arr as $uid) @@ -105,152 +106,150 @@ foreach($uid_arr as $uid) $staatsbuergerschaft->load($student->staatsbuergerschaft); - $svnr = ($student->svnr == '')?'Ersatzkennzeichen: '.$student->ersatzkennzeichen:$student->svnr; + $svnr = ($student->svnr == '')?'Ersatzkennzeichen: '.$student->ersatzkennzeichen:$student->svnr; - switch($student->geschlecht) - { - case 'm': - $geschlecht = 'Männlich'; - break; - case 'w': - $geschlecht = 'Weiblich'; - break; - case 'u': - $geschlecht = 'Unbekannt'; - break; - default: - $geschlecht =''; - } + $geschlecht_obj = new geschlecht(); + $geschlecht_obj->load($student->geschlecht); - //Wenn Lehrgang, dann Erhalter-KZ vor die Studiengangs-Kz hängen - if ($studienordnung->studiengang_kz<0) - { - $stg = new studiengang(); - $stg->load($studienordnung->studiengang_kz); + $geschlecht = $geschlecht_obj->bezeichnung_mehrsprachig_arr[DEFAULT_LANGUAGE]; + $geschlecht_englisch = $geschlecht_obj->bezeichnung_mehrsprachig_arr['English']; - $studiengang_kz = sprintf("%03s", $stg->erhalter_kz).sprintf("%04s", abs($studienordnung->studiengang_kz)); - } - else - $studiengang_kz = sprintf("%04s", abs($studienordnung->studiengang_kz)); + //Wenn Lehrgang, dann Erhalter-KZ vor die Studiengangs-Kz hängen + if ($studienordnung->studiengang_kz<0) + { + $stg = new studiengang(); + $stg->load($studienordnung->studiengang_kz); + + $studiengang_kz = sprintf("%03s", $stg->erhalter_kz).sprintf("%04s", abs($studienordnung->studiengang_kz)); + } + else + $studiengang_kz = sprintf("%04s", abs($studienordnung->studiengang_kz)); + + $sprache_obj = new sprache(); + $sprache_obj->load($studienplan->sprache); + $studienplan_sprache = $sprache_obj->bezeichnung_arr[DEFAULT_LANGUAGE]; + $studienplan_sprache_englisch = $sprache_obj->bezeichnung_arr['English']; echo "\t\t1\n"; - echo "\t\t".$uid."\n"; - echo "\t\t".$geschlecht."\n"; + echo "\t\t\n"; + echo "\t\t\n"; + echo "\t\t\n"; echo "\t\tanrede."]]>\n"; echo "\t\tvorname." ".$student->vornamen."]]>\n"; echo "\t\tvornamen."]]>\n"; echo "\t\tnachname."]]>\n"; echo "\t\ttitelpre."]]>\n"; echo "\t\ttitelpost."]]>\n"; - echo "\t\t".$gebdatum."\n"; + echo "\t\t\n"; echo "\t\tgebort."]]>\n"; echo "\t\tlangtext."]]>\n"; - echo "\t\t".$svnr."\n"; - echo "\t\t".trim($student->matr_nr)."\n"; - echo "\t\t".trim($student->matrikelnr)."\n"; + echo "\t\t\n"; + echo "\t\tmatr_nr)."]]>\n"; + echo "\t\tmatrikelnr)."]]>\n"; echo "\t\tstudiengangbezeichnung."]]>\n"; echo "\t\tstudiengangbezeichnung_englisch."]]>\n"; - echo "\t\tstudiengangkurzbzlang."]]>\n"; + echo "\t\tstudiengangkurzbzlang."]]>\n"; echo "\t\t\n"; - echo "\t\tsprache."]]>"; - echo "\t\t".$studienordnung->ects.""; - echo "\t\t".($studienplan->regelstudiendauer!=0?$studienordnung->ects/$studienplan->regelstudiendauer:0).""; + echo "\t\t"; + echo "\t\t"; + echo "\t\tects."]]>"; + echo "\t\tregelstudiendauer!=0?$studienordnung->ects/$studienplan->regelstudiendauer:0)."]]>"; - echo "\t\t".date('Y').""; + echo "\t\t"; - echo "\t\t".$prestudent->ausbildungssemester.""; + echo "\t\tausbildungssemester."]]>"; - $studiensemester_aktuell = new studiensemester(); - $studiensemester_aktuell->load($studiensemester); + $studiensemester_aktuell = new studiensemester(); + $studiensemester_aktuell->load($studiensemester); - echo "\t\tbezeichnung."]]>"; + echo "\t\tbezeichnung."]]>"; // check ob Oeh-Beitrag bezahlt wurde $oehbeitrag = $konto->getOehBeitragGesamt($uid, $studiensemester_aktuell->studiensemester_kurzbz); - echo "\t\t".str_replace('.', ',', $oehbeitrag).""; + echo "\t\t"; - // check ob Quereinsteiger - $ausbildungssemester = ($prestudent->getFirstStatus($student->prestudent_id, 'Student'))?$prestudent->ausbildungssemester:''; - echo "\t\t".$ausbildungssemester.""; + // check ob Quereinsteiger + $ausbildungssemester = ($prestudent->getFirstStatus($student->prestudent_id, 'Student'))?$prestudent->ausbildungssemester:''; + echo "\t\t"; - $studiensemester_beginn = new studiensemester(); - $studienbeginn = ($prestudent->getFirstStatus($student->prestudent_id, 'Student'))?$prestudent->studiensemester_kurzbz:''; - $studiensemester_beginn->load($studienbeginn); + $studiensemester_beginn = new studiensemester(); + $studienbeginn = ($prestudent->getFirstStatus($student->prestudent_id, 'Student'))?$prestudent->studiensemester_kurzbz:''; + $studiensemester_beginn->load($studienbeginn); - echo "\t\t".$studiensemester_beginn->bezeichnung.""; - echo "\t\t".date('d.m.Y',strtotime($studiensemester_beginn->start)).""; + echo "\t\tbezeichnung."]]>"; + echo "\t\tstart))."]]>"; - $prestudent->getLastStatus($student->prestudent_id,$studiensemester); - $studiensemester_abschluss = new studiensemester(); - $abschluss = $studiensemester_abschluss->jump($prestudent->studiensemester_kurzbz, $studienplan->regelstudiendauer-$prestudent->ausbildungssemester); - $studiensemester_abschluss->load($abschluss); - echo "\t\t".$studiensemester_abschluss->bezeichnung.""; - echo "\t\t".date('d.m.Y',strtotime($studiensemester_abschluss->ende)).""; + $prestudent->getLastStatus($student->prestudent_id,$studiensemester); + $studiensemester_abschluss = new studiensemester(); + $abschluss = $studiensemester_abschluss->jump($prestudent->studiensemester_kurzbz, $studienplan->regelstudiendauer-$prestudent->ausbildungssemester); + $studiensemester_abschluss->load($abschluss); + echo "\t\tbezeichnung."]]>"; + echo "\t\tende))."]]>"; - $studiensemester_endedatum = new studiensemester(); - $studiensemester_endedatum->load($studiensemester_endedatum->getaktorNext(1)); + $studiensemester_endedatum = new studiensemester(); + $studiensemester_endedatum->load($studiensemester_endedatum->getaktorNext(1)); - echo "\t\t".date('d.m.Y',strtotime($studiensemester_endedatum->ende)).""; + echo "\t\tende))."]]>"; - $status_aktuell = ($prestudent->getLastStatus($student->prestudent_id,null,null))?$prestudent->status_kurzbz:''; + $status_aktuell = ($prestudent->getLastStatus($student->prestudent_id,null,null))?$prestudent->status_kurzbz:''; switch($status_aktuell) - { - case 'Student': - $studierendenstatus_aktuell = 'Aktive/r StudentIn'; - break; - case 'Unterbrecher': - $studierendenstatus_aktuell = 'UnterbrecherIn'; - break; - case 'Absolvent': - $studierendenstatus_aktuell = 'AbsolventIn'; - break; - case 'Diplomand': - $studierendenstatus_aktuell = 'DiplomandIn'; - break; - case 'Abbrecher': - $studierendenstatus_aktuell = 'AbbrecherIn'; - break; - default: - $studierendenstatus_aktuell =''; - } + { + case 'Student': + $studierendenstatus_aktuell = 'Aktive/r StudentIn'; + break; + case 'Unterbrecher': + $studierendenstatus_aktuell = 'UnterbrecherIn'; + break; + case 'Absolvent': + $studierendenstatus_aktuell = 'AbsolventIn'; + break; + case 'Diplomand': + $studierendenstatus_aktuell = 'DiplomandIn'; + break; + case 'Abbrecher': + $studierendenstatus_aktuell = 'AbbrecherIn'; + break; + default: + $studierendenstatus_aktuell =''; + } - echo "\t\t".$studierendenstatus_aktuell."\n"; - echo "\t\t".$prestudent->zgvdatum."\n"; - $zgv = new zgv($prestudent->zgv_code); - echo "\t\tzgv_kurzbz."]]>\n"; - echo "\t\tbezeichnung."]]>\n"; - echo "\t\tanmerkung]]>\n"; + echo "\t\t\n"; + echo "\t\tzgvdatum."]]>\n"; + $zgv = new zgv($prestudent->zgv_code); + echo "\t\tzgv_kurzbz."]]>\n"; + echo "\t\tbezeichnung."]]>\n"; + echo "\t\tanmerkung]]>\n"; - $titel_kurzbz = ''; - switch($studiengang->typ) - { - case 'b': - $studTyp = 'Bachelor'; - $titel_kurzbz = 'BSc'; - break; - case 'm': - $studTyp = 'Master'; - $titel_kurzbz ='MSc'; - break; - case 'd': - $studTyp = 'Diplom'; - break; - case 'l': - $studTyp = 'Lehrgang'; - break; - case 'k': - $studTyp = 'Kurzstudium'; - break; - default: - $studTyp =''; - $titel_kurzbz = ''; - } + $titel_kurzbz = ''; + switch($studiengang->typ) + { + case 'b': + $studTyp = 'Bachelor'; + $titel_kurzbz = 'BSc'; + break; + case 'm': + $studTyp = 'Master'; + $titel_kurzbz ='MSc'; + break; + case 'd': + $studTyp = 'Diplom'; + break; + case 'l': + $studTyp = 'Lehrgang'; + break; + case 'k': + $studTyp = 'Kurzstudium'; + break; + default: + $studTyp =''; + $titel_kurzbz = ''; + } - echo "\t\t\n"; + echo "\t\t\n"; echo "\t\t\n"; echo "\t\tsprache."]]>\n"; - echo "\t\t".$studienplan->regelstudiendauer."\n"; + echo "\t\tregelstudiendauer."]]>\n"; $akadgrad = new akadgrad(); $akadgrad->getAkadgradStudent($student->uid); @@ -272,15 +271,15 @@ foreach($uid_arr as $uid) $lv_studiengang=new studiengang(); $lv_studiengang->load($lv_studiengang_kz); $lv_studiengang_bezeichnung=$lv_studiengang->bezeichnung; - $stg_typ->getStudiengangTyp($lv_studiengang->typ); + $stg_typ->getStudiengangTyp($lv_studiengang->typ); $lv_studiengang_typ=$stg_typ->bezeichnung; } - echo "\t\t".sprintf('%04s', $lv_studiengang_kz).""; + echo "\t\t"; echo "\t\t"; echo "\t\t"; - echo "\t\t".$datum_aktuell."\n"; + echo "\t\t\n"; $adresse = new adresse(); $adresse->load_pers($student->person_id); diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 6b11698ec..5b588f6f1 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3688,7 +3688,7 @@ $tabellen=array( "public.tbl_firmatag" => array("firma_id","tag","insertamum","insertvon"), "public.tbl_fotostatus" => array("fotostatus_kurzbz","beschreibung"), "public.tbl_funktion" => array("funktion_kurzbz","beschreibung","aktiv","fachbereich","semester"), - "public.tbl_geschlecht" => array("geschlecht","bezeichnung_mehrsprachig"), + "public.tbl_geschlecht" => array("geschlecht","bezeichnung_mehrsprachig","sort"), "public.tbl_geschaeftsjahr" => array("geschaeftsjahr_kurzbz","start","ende","bezeichnung"), "public.tbl_gruppe" => array("gruppe_kurzbz","studiengang_kz","semester","bezeichnung","beschreibung","sichtbar","lehre","aktiv","sort","mailgrp","generiert","updateamum","updatevon","insertamum","insertvon","ext_id","orgform_kurzbz","gid","content_visible","gesperrt","zutrittssystem","aufnahmegruppe","direktinskription"), "public.tbl_kontakt" => array("kontakt_id","person_id","kontakttyp","anmerkung","kontakt","zustellung","updateamum","updatevon","insertamum","insertvon","ext_id","standort_id"), From e724f7159fe4f2a017ea7fd0c8b8af66ec9de297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 7 Feb 2020 11:31:08 +0100 Subject: [PATCH 089/157] Datentyp der Offsetpunkte auf Numeric korrigiert --- system/dbupdate_3.3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index af529bab4..703e40857 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3452,7 +3452,7 @@ if(!$result = @$db->db_query("SELECT 1 FROM fue.tbl_projekttyp LIMIT 1")) // Add column offset to testtool.tbl_gebiet if(!$result = @$db->db_query("SELECT offsetpunkte FROM testtool.tbl_gebiet LIMIT 1")) { - $qry = "ALTER TABLE testtool.tbl_gebiet ADD COLUMN offsetpunkte smallint"; + $qry = "ALTER TABLE testtool.tbl_gebiet ADD COLUMN offsetpunkte numeric(8,4)"; if(!$db->db_query($qry)) echo 'testtool.tbl_gebiet: '.$db->db_last_error().'
'; From b0380f4b64cafefe704b04b2b5d9c9c2643d129a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 7 Feb 2020 13:16:55 +0100 Subject: [PATCH 090/157] FilterWidget and TableWidget Pages can now also be access with Readonly Permission --- application/controllers/lehre/lehrauftrag/Lehrauftrag.php | 2 +- application/libraries/FilterWidgetLib.php | 2 +- application/libraries/TableWidgetLib.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php index 62a12742d..dade1fb21 100644 --- a/application/controllers/lehre/lehrauftrag/Lehrauftrag.php +++ b/application/controllers/lehre/lehrauftrag/Lehrauftrag.php @@ -26,7 +26,7 @@ class Lehrauftrag extends Auth_Controller array( 'index' => 'lehre/lehrauftrag_bestellen:r', 'orderLehrauftrag' => 'lehre/lehrauftrag_bestellen:rw', - 'Dashboard' => array('lehre/lehrauftrag_bestellen:r', 'lehre/lehrauftrag_erteilen:rw'), + 'Dashboard' => array('lehre/lehrauftrag_bestellen:r', 'lehre/lehrauftrag_erteilen:r'), 'LehrendeUebersicht' => array('lehre/lehrauftrag_erteilen:r') ) ); diff --git a/application/libraries/FilterWidgetLib.php b/application/libraries/FilterWidgetLib.php index c2e57eed2..6e87833bd 100644 --- a/application/libraries/FilterWidgetLib.php +++ b/application/libraries/FilterWidgetLib.php @@ -101,7 +101,7 @@ class FilterWidgetLib const FILTER_UNIQUE_ID = 'filterUniqueId'; // Filter page parameter name const PERMISSION_FILTER_METHOD = 'FilterWidget'; // Name for fake method to be checked by the PermissionLib - const PERMISSION_TYPE = 'rw'; + const PERMISSION_TYPE = 'r'; // Name and array keys of the filters menu array const NAV_MENU_FILTER_KEY = 'filters'; diff --git a/application/libraries/TableWidgetLib.php b/application/libraries/TableWidgetLib.php index 139e5d6cb..dc746b6d5 100644 --- a/application/libraries/TableWidgetLib.php +++ b/application/libraries/TableWidgetLib.php @@ -66,7 +66,7 @@ class TableWidgetLib const DATASET_REP_TABULATOR = 'tabulator'; const PERMISSION_TABLE_METHOD = 'TableWidget'; // Name for fake method to be checked by the PermissionLib - const PERMISSION_TYPE = 'rw'; + const PERMISSION_TYPE = 'r'; private $_ci; // Code igniter instance private $_tableUniqueId; // unique id for this table widget From 7fdaaace50f6bc74554f3bb004f948eccb15c217 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 7 Feb 2020 17:46:29 +0100 Subject: [PATCH 091/157] If Prestudent is freigegeben for RT and has already a Bewerber with reihungstestangetreten = true, a new Bewerber for the prestudent is created, reihungstestangetreten and teilgenommen are set to true --- .../system/infocenter/InfoCenter.php | 67 ++++++++++++++++++- application/models/person/Person_model.php | 19 ++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d085e7db0..e4d2c4e21 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -69,6 +69,7 @@ class InfoCenter extends Auth_Controller // Name of Interessentenstatus const INTERESSENTSTATUS = 'Interessent'; const ABGEWIESENERSTATUS = 'Abgewiesener'; + const BEWERBERSTATUS = 'Bewerber'; // Statusgruende for which no Studiengangsfreigabemessage should be sent private $_statusgruendeNoStgFreigabeMessage = array('FIT Programm', 'FIT program', 'FIT programme'); @@ -493,7 +494,9 @@ class InfoCenter extends Auth_Controller $logdata = $this->_getPersonAndStudiengangFromPrestudent($prestudent_id); - $akteresult = $this->AkteModel->loadWhere(array('person_id' => $logdata['person_id'], 'formal_geprueft_amum !=' => NULL)); + $person_id = $logdata['person_id']; + + $akteresult = $this->AkteModel->loadWhere(array('person_id' => $person_id, 'formal_geprueft_amum !=' => NULL)); if (hasData($lastStatus) && isSuccess($akteresult)) { @@ -554,8 +557,68 @@ class InfoCenter extends Auth_Controller if (hasData($statusgrund_kurzbz)) $logparams[2] = ', confirmation type '.$statusgrund_kurzbz->retval[0]->bezeichnung_mehrsprachig[0]; } + else + { + // check if there is already a Bewerberstatus and Reihungsverfahren already absolviert + $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz); - $this->_log($logdata['person_id'], 'freigegeben', $logparams); + if (hasData($bewerber)) + { + $bewerbercnt = getData($bewerber); + + if (is_numeric($bewerbercnt[0]->anzahl_bewerber) && $bewerbercnt[0]->anzahl_bewerber > 0) + { + // then insert Bewerberstatus and rt absolviert, teilgenommen for prestudent + $bewerberresult = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => self::BEWERBERSTATUS, + 'studiensemester_kurzbz' => $lastStatus->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->ausbildungssemester, + 'datum' => date('Y-m-d'), + 'orgform_kurzbz' => $lastStatus->orgform_kurzbz, + 'studienplan_id' => $lastStatus->studienplan_id, + 'insertvon' => $this->_uid, + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + + if (isError($bewerberresult)) + $json->retval['nonCriticalErrors'] = 'error when inserting Bewerberstatus'; + + $rtangetretenres = $this->PrestudentModel->update( + $prestudent_id, + array( + 'reihungstestangetreten' => true + ) + ); + + if (isError($rtangetretenres)) + { + $json->retval['nonCriticalErrors'] = 'error when setting reihungstestangetreten'; + } + else + { + $this->load->model('crm/RtPerson_model', 'RtPersonModel'); + + $rtteilgenommenres = $this->RtPersonModel->update( + array( + 'person_id' => $person_id, + 'studienplan_id' => $lastStatus->studienplan_id + ), + array( + 'teilgenommen' => true + ) + ); + + if (isError($rtteilgenommenres)) + $json->retval['nonCriticalErrors'] = 'error when setting reihungstest teilgenommen'; + } + } + } + } + + $this->_log($person_id, 'freigegeben', $logparams); $this->_sendFreigabeMail($prestudent_id); } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 388f77b0a..4f826dac1 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -213,4 +213,23 @@ class Person_model extends DB_Model return $this->loadWhere(array('uid' => $uid, 'content' => true)); } + + /** + * Checks if a person has a Bewerberstatus and reihungstestangetreten = true + * @param $person_id + * @param $studiensemester_kurzbz + * @return array + */ + public function hasBewerber($person_id, $studiensemester_kurzbz) + { + $qry = "SELECT count(*) AS anzahl_bewerber FROM public.tbl_person + JOIN public.tbl_prestudent USING (person_id) + JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id + WHERE person_id = ? + AND studiensemester_kurzbz = ? + AND status_kurzbz = 'Bewerber' + AND reihungstestangetreten"; + + return $this->execQuery($qry, array($person_id, $studiensemester_kurzbz)); + } } From 5953b6932f45c67d6d596ec0617c36929947fe14 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 10 Feb 2020 15:42:34 +0100 Subject: [PATCH 092/157] Bufixed Chromes autofilling username in random input field If no username input field is required, Chorme is autofilling a random inputfield with username. This is a Chrome bug. Workaround by adding a hidden username field. Also setting autocomplete= new-password should help stopping random autofill in some browsers. --- .../views/lehre/lehrauftrag/acceptLehrauftrag.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php index 14ebacecb..3f2575ec1 100644 --- a/application/views/lehre/lehrauftrag/acceptLehrauftrag.php +++ b/application/views/lehre/lehrauftrag/acceptLehrauftrag.php @@ -166,12 +166,13 @@ $this->load->view(
-
- - - - -
+
+ + + + + +

From d5e8d33adcc3b0447cd65f90a819cfdd84a62e1d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 11 Feb 2020 10:28:43 +0100 Subject: [PATCH 093/157] public.vw_msg_vars: added orgform_kurzbz for tbl_bankverbindung --- system/dbupdate_3.3.php | 107 +++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 7721fefa4..a7d4011cc 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3449,6 +3449,18 @@ if(!$result = @$db->db_query("SELECT 1 FROM fue.tbl_projekttyp LIMIT 1")) echo '
fue.tbl_projekttyp hinzugefuegt.'; } +// Add column orgform_kurzbz to tbl_bankverbindung +if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindung LIMIT 1")) +{ + $qry = "ALTER TABLE public.tbl_bankverbindung ADD COLUMN orgform_kurzbz varchar(3); + ALTER TABLE public.tbl_bankverbindung ADD CONSTRAINT fk_bankverbindung_orgform FOREIGN KEY (orgform_kurzbz) REFERENCES bis.tbl_orgform (orgform_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;"; + + if(!$db->db_query($qry)) + echo 'public.tbl_bankverbindung: '.$db->db_last_error().'
'; + else + echo '
public.tbl_bankverbindung: Spalte orgform_kurzbz hinzugefuegt'; +} + // iban und bic zu vw_msg_vars hinzufügen if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM public.vw_msg_vars LIMIT 1')) { @@ -3469,53 +3481,60 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM s.bezeichnung AS "Studiengang DE", s.english AS "Studiengang EN", st.bezeichnung AS "Typ", - orgform_kurzbz AS "Orgform", + last_prestudent_status.orgform_kurzbz AS "Orgform", p.zugangscode AS "Zugangscode", bk.iban AS "IBAN Studiengang", bk.bic AS "BIC Studiengang" FROM public.tbl_person p - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp = \'email\' - ORDER BY kontakt_id DESC - ) ke USING(person_id) - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp IN (\'telefon\', \'mobil\') - ORDER BY kontakt_id DESC - ) kt USING(person_id) - LEFT JOIN ( - SELECT person_id, - strasse, - ort, - plz, - gemeinde, - langtext - FROM public.tbl_adresse - LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) - WHERE public.tbl_adresse.heimatadresse = TRUE - ORDER BY adresse_id DESC - ) a USING(person_id) - LEFT JOIN public.tbl_prestudent pr USING(person_id) - INNER JOIN public.tbl_studiengang s USING(studiengang_kz) - INNER JOIN public.tbl_studiengangstyp st USING(typ) - LEFT JOIN ( SELECT DISTINCT ON (prestudent_id) - tbl_prestudent.prestudent_id, - tbl_bankverbindung.iban, - tbl_bankverbindung.bic, - tbl_studiengang.oe_kurzbz - FROM public.tbl_bankverbindung - JOIN public.tbl_studiengang USING(oe_kurzbz) - JOIN public.tbl_prestudent USING (studiengang_kz) - ORDER BY prestudent_id, tbl_bankverbindung.insertamum DESC, iban) bk USING (prestudent_id) - WHERE p.aktiv = TRUE - ORDER BY p.person_id ASC, pr.prestudent_id ASC + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp = \'email\' + ORDER BY kontakt_id DESC + ) ke USING(person_id) + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp IN (\'telefon\', \'mobil\') + ORDER BY kontakt_id DESC + ) kt USING(person_id) + LEFT JOIN ( + SELECT person_id, + strasse, + ort, + plz, + gemeinde, + langtext + FROM public.tbl_adresse + LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) + WHERE public.tbl_adresse.heimatadresse = TRUE + ORDER BY adresse_id DESC + ) a USING(person_id) + LEFT JOIN public.tbl_prestudent pr USING(person_id) + INNER JOIN public.tbl_studiengang s USING(studiengang_kz) + INNER JOIN public.tbl_studiengangstyp st USING(typ) + LEFT JOIN ( + SELECT DISTINCT ON (ps.prestudent_id) tbl_studienplan.orgform_kurzbz, ps.prestudent_id + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN lehre.tbl_studienplan USING(studienplan_id) + ORDER BY ps.prestudent_id DESC, + tbl_prestudentstatus.datum DESC, + tbl_prestudentstatus.insertamum DESC, + tbl_prestudentstatus.ext_id DESC + ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id + LEFT JOIN ( + SELECT DISTINCT ON (oe_kurzbz, orgform_kurzbz) oe_kurzbz, orgform_kurzbz, iban, bic + FROM tbl_bankverbindung + WHERE oe_kurzbz IS NOT NULL + ORDER BY oe_kurzbz, orgform_kurzbz, tbl_bankverbindung.insertamum DESC,tbl_bankverbindung.iban + )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) + WHERE p.aktiv = TRUE + ORDER BY p.person_id ASC, pr.prestudent_id ASC );'; if(!$db->db_query($qry)) @@ -3682,7 +3701,7 @@ $tabellen=array( "public.tbl_aufnahmeschluessel" => array("aufnahmeschluessel"), "public.tbl_aufnahmetermin" => array("aufnahmetermin_id","aufnahmetermintyp_kurzbz","prestudent_id","termin","teilgenommen","bewertung","protokoll","insertamum","insertvon","updateamum","updatevon","ext_id"), "public.tbl_aufnahmetermintyp" => array("aufnahmetermintyp_kurzbz","bezeichnung"), - "public.tbl_bankverbindung" => array("bankverbindung_id","person_id","name","anschrift","bic","blz","iban","kontonr","typ","verrechnung","updateamum","updatevon","insertamum","insertvon","ext_id","oe_kurzbz"), + "public.tbl_bankverbindung" => array("bankverbindung_id","person_id","name","anschrift","bic","blz","iban","kontonr","typ","verrechnung","updateamum","updatevon","insertamum","insertvon","ext_id","oe_kurzbz", "orgform_kurzbz"), "public.tbl_benutzer" => array("uid","person_id","aktiv","alias","insertamum","insertvon","updateamum","updatevon","ext_id","updateaktivvon","updateaktivam","aktivierungscode"), "public.tbl_benutzerfunktion" => array("benutzerfunktion_id","fachbereich_kurzbz","uid","oe_kurzbz","funktion_kurzbz","semester", "datum_von","datum_bis", "updateamum","updatevon","insertamum","insertvon","ext_id","bezeichnung","wochenstunden"), "public.tbl_benutzergruppe" => array("uid","gruppe_kurzbz","studiensemester_kurzbz","updateamum","updatevon","insertamum","insertvon","ext_id"), From ba7b4cf3ade316824d9004b0b2cab0887a4820bc Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:41:21 +0100 Subject: [PATCH 094/157] New Unique Index unq_idx_ablauf_gebiet_studiengang_semester MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester in testtool.tbl_ablauf löschen und durch neuen INDEX ersetzen, der auch den Studienplan einschließt --- system/dbupdate_3.3.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index f100f2115..09d5e000a 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3525,6 +3525,20 @@ if($result = $db->db_query("SELECT * FROM pg_proc WHERE proname = 'transform_ges echo '
Function transform_geschlecht hinzugefügt.'; } } +// UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester in testtool.tbl_ablauf löschen und durch neuen INDEX ersetzen, der auch den Studienplan einschließt +if ($result = $db->db_query("SELECT 1 FROM pg_class WHERE relname = 'unq_idx_ablauf_gebiet_studiengang_semester'")) +{ + if ($db->db_num_rows($result) == 1) + { + $qry = 'DROP INDEX testtool.unq_idx_ablauf_gebiet_studiengang_semester;'; + $qry .= 'CREATE UNIQUE INDEX unq_idx_ablauf_gebiet_studiengang_semester_studienplan ON testtool.tbl_ablauf USING btree (gebiet_id, studiengang_kz, semester, studienplan_id);'; + if (!$db->db_query($qry)) + echo 'unq_idx_ablauf_gebiet_studiengang_semester_studienplan '.$db->db_last_error().'
'; + else + echo '
Dropped index "unq_idx_ablauf_gebiet_studiengang_semester" and created unique index "unq_idx_ablauf_gebiet_studiengang_semester_studienplan"'; + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; From 11231b99c2d9a97ebb3885c5dfb0e6bdfa20157e Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:41:59 +0100 Subject: [PATCH 095/157] Fallback Sprache --- cis/testtool/frage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index f15c2c2d2..a760d00aa 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -460,6 +460,12 @@ if($frage->frage_id!='') $frage_id = $frage->frage_id; $frage->getFrageSprache($frage_id, $_SESSION['sprache_user']); + // Fallback auf DEFAULT_LANGUAGE wenn keine Frage in der $_SESSION['sprache_user'] vorhanden ist + if ($frage->text == '' && $frage->bild == '' && $frage->audio == '') + { + $frage->getFrageSprache($frage_id, DEFAULT_LANGUAGE); + } + if(!$demo) { //Nachschauen ob diese Frage bereits angesehen wurde From 58a67ead5d0420beda1ad78326ba244be203c5a2 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Tue, 11 Feb 2020 14:42:45 +0100 Subject: [PATCH 096/157] =?UTF-8?q?Ber=C3=BCcksichtigung=20von=20Studienpl?= =?UTF-8?q?an=20bei=20Ablauf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + Kleine GUI-Anpassungen --- cis/testtool/index.html | 2 +- cis/testtool/login.php | 14 +- cis/testtool/menu.php | 305 ++++++++++++++++++++++------------------ 3 files changed, 174 insertions(+), 147 deletions(-) diff --git a/cis/testtool/index.html b/cis/testtool/index.html index ac39c5deb..02044a4bc 100644 --- a/cis/testtool/index.html +++ b/cis/testtool/index.html @@ -10,7 +10,7 @@ - + <body> diff --git a/cis/testtool/login.php b/cis/testtool/login.php index 477901803..a1bb7b517 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -66,6 +66,7 @@ $gebdatum=''; $date = new datum(); $reload_menu=false; +$alertmsg = ''; $sg_var = new studiengang(); @@ -189,7 +190,7 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) // * 1. Sprache über Ablauf Vorgaben ermitteln $ablauf = new Ablauf(); - $ablauf->getAblaufVorgabeStudiengang($firstPrio_studiengang_kz); + $ablauf->getAblaufGebiete($firstPrio_studiengang_kz, $firstPrio_studienplan_id); $rt_sprache = ''; if(!empty($ablauf->result[0])) @@ -224,17 +225,17 @@ if (isset($_POST['prestudent']) && isset($gebdatum)) } else { - echo '<span class="error">'.$p->t('testtool/reihungstestNichtFreigeschalten').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/reihungstestNichtFreigeschalten').'</div>'; } } else { - echo '<span class="error">'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/reihungstestKannNichtGeladenWerden').'</div>'; } } else { - echo '<span class="error">'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'</span>'; + $alertmsg .= '<div class="alert alert-danger">'.$p->t('testtool/geburtsdatumStimmtNichtUeberein').'</div>'; } } @@ -499,7 +500,7 @@ if (isset($prestudent_id)) } elseif($ps_obj->ausbildungssemester == '3') { - echo '<td>'. $p->t('testtool/quereinstieg'). ' (3.Semester)</td>'; + echo '<td>'. $p->t('testtool/quereinstieg'). ' (3. Semester)</td>'; } } // wenn letzter Status \'Abgewiesener\' ist, dann als solchen kennzeichnen @@ -564,7 +565,8 @@ else // LOGIN Site (vor Login) echo '<div class="col-xs-11">'; // Welcome text - echo ' + echo $alertmsg; + echo ' <div class="row" style="margin-bottom: 10%; margin-top: 3%;"> <div class="col-xs-6 text-center" style="border-right: 1px solid lightgrey;"> <h1 style="white-space: normal">Herzlich Willkommen zum Reihungstest</h1><br><br> diff --git a/cis/testtool/menu.php b/cis/testtool/menu.php index 4d075ee9a..8a8c245de 100644 --- a/cis/testtool/menu.php +++ b/cis/testtool/menu.php @@ -69,7 +69,7 @@ if (isset($_SESSION['pruefling_id'])) $result = $db->db_query($qry); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right-width:1px;border-right-color:#BCBCBC; border-collapse: separate; - border-spacing: 0 3px;">'; + border-spacing: 0 3px;">'; // Link zur Startseite echo '<tr><td class="ItemTesttool" style="margin-left: 20px;" nowrap> @@ -78,16 +78,16 @@ if (isset($_SESSION['pruefling_id'])) // Link zur Einleitung if ($content_id = $db->db_fetch_object($result)) - { + { if($content_id->content_id!='') - { + { echo ' - <tr id="tr-einleitung"><td class="ItemTesttool" style="margin-left: 20px;" nowrap> - <a class="ItemTesttool navButton" href="../../cms/content.php?content_id='.$content_id->content_id.'&sprache='.$sprache_user.'" target="content">'.$p->t('testtool/einleitung').'</a> - </td></tr> - '; - } - } + <tr id="tr-einleitung"><td class="ItemTesttool" style="margin-left: 20px;" nowrap> + <a class="ItemTesttool navButton" href="../../cms/content.php?content_id='.$content_id->content_id.'&sprache='.$sprache_user.'" target="content">'.$p->t('testtool/einleitung').'</a> + </td></tr> + '; + } + } echo '<tr><td style="padding-left: 20px;" nowrap>'; $studiengang_kz = (isset($_SESSION['studiengang_kz'])) ? $_SESSION['studiengang_kz'] : ''; @@ -98,78 +98,78 @@ if (isset($_SESSION['pruefling_id'])) /** * Spaltennamen-Aliase extrahieren um sie im Outer-Select verwenden zu können - * $bezeichnung_mehrsprachig liefert: bezeichnung_mehrsprachig[1] as bezeichnung_mehrsprachig_1,... - * $bezeichnung_mehrsprachig_sel liefert: bezeichnung_mehrsprachig_1, bezeichnung_mehrsprachig_2,... + * $bezeichnung_mehrsprachig liefert: bezeichnung_mehrsprachig[1] as bezeichnung_mehrsprachig_1,... + * $bezeichnung_mehrsprachig_sel liefert: bezeichnung_mehrsprachig_1, bezeichnung_mehrsprachig_2,... */ $bezeichnung_mehrsprachig_sel = explode(",", $bezeichnung_mehrsprachig); foreach ($bezeichnung_mehrsprachig_sel as &$bm) - { - $bm = strrchr($bm, ' as '); - } + { + $bm = strrchr($bm, ' as '); + } $bezeichnung_mehrsprachig_sel = implode(', ', $bezeichnung_mehrsprachig_sel); /** * Reihungstestgebiete der Person ermitteln; Zusammenfassen, falls RT für mehrere Studien - * 1. Aktuelle Prestudenten zur Person über den Prüfling ermitteln, - * 2. Einstiegssemester (Erstsemester/Quereinsteiger) und Studienplan pro Prestudent ermitteln, - * 3. RT-Gebiete falls vorhanden über Studienplan, sonst über STG ermitteln - * 4. Für Quereinsteiger zusätzlich auch Erstsemestrigen-Gebiete + * 1. Aktuelle Prestudenten zur Person über den Prüfling ermitteln, + * 2. Einstiegssemester (Erstsemester/Quereinsteiger) und Studienplan pro Prestudent ermitteln, + * 3. RT-Gebiete falls vorhanden über Studienplan, sonst über STG ermitteln + * 4. Für Quereinsteiger zusätzlich auch Erstsemestrigen-Gebiete */ $qry = " - WITH prestudent_data AS - ( - SELECT DISTINCT ON (prestudent_id) - prestudent_id, - studienplan_id, - studiengang_kz, - typ, + WITH prestudent_data AS + ( + SELECT DISTINCT ON (prestudent_id) + prestudent_id, + studienplan_id, + studiengang_kz, + typ, tbl_studiengangstyp.bezeichnung AS typ_bz, - ausbildungssemester AS semester - FROM - public.tbl_prestudentstatus AS ps_status - JOIN - public.tbl_prestudent USING (prestudent_id) - JOIN - public.tbl_studiengang USING (studiengang_kz) - JOIN - public.tbl_studiengangstyp USING (typ) - WHERE - tbl_prestudent.person_id = ( - SELECT - person_id - FROM - public.tbl_prestudent - WHERE - prestudent_id = ".$db->db_add_param($_SESSION['prestudent_id'])." - ) + ausbildungssemester AS semester + FROM + public.tbl_prestudentstatus AS ps_status + JOIN + public.tbl_prestudent USING (prestudent_id) + JOIN + public.tbl_studiengang USING (studiengang_kz) + JOIN + public.tbl_studiengangstyp USING (typ) + WHERE + tbl_prestudent.person_id = ( + SELECT + person_id + FROM + public.tbl_prestudent + WHERE + prestudent_id = ".$db->db_add_param($_SESSION['prestudent_id'])." + ) - /* Filter only future studiensemester (incl. actual one) */ - AND - studiensemester_kurzbz IN ( - SELECT - studiensemester_kurzbz - FROM - public.tbl_studiensemester - WHERE - ende > now() - ) + /* Filter only future studiensemester (incl. actual one) */ + AND + studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende > now() + ) - /* Filter out all Abgewiesene */ - AND NOT EXISTS ( - SELECT - 1 - FROM - tbl_prestudentstatus - WHERE - status_kurzbz = 'Abgewiesener' - AND - prestudent_id = ps_status.prestudent_id - ) + /* Filter out all Abgewiesene */ + AND NOT EXISTS ( + SELECT + 1 + FROM + tbl_prestudentstatus + WHERE + status_kurzbz = 'Abgewiesener' + AND + prestudent_id = ps_status.prestudent_id + ) - AND - status_kurzbz = 'Interessent'"; + AND + status_kurzbz = 'Interessent'"; - /* If the logged-in prestudents study is a Bachelor-study, filter only Bachelor-studies */ + /* If the logged-in prestudents study is a Bachelor-study, filter only Bachelor-studies */ if ($stg->typ == 'b') { $qry .= " @@ -184,86 +184,95 @@ if (isset($_SESSION['pruefling_id'])) $qry .= " - /* Order to get last semester when using distinct on */ - ORDER BY - prestudent_id, - datum DESC, - ps_status.insertamum DESC, - ps_status.ext_id DESC - ) + /* Order to get last semester when using distinct on */ + ORDER BY + prestudent_id, + datum DESC, + ps_status.insertamum DESC, + ps_status.ext_id DESC + ) - SELECT DISTINCT ON - (gebiet_id, semester) - semester, - gebiet_id, - STRING_AGG(studiengang_kz::TEXT, ', ' ORDER BY studiengang_kz) AS studiengang_kz_list, - bezeichnung, - MIN(reihung) AS reihung, - ". $bezeichnung_mehrsprachig_sel. " - FROM ( - SELECT - * - FROM ( - (SELECT - prestudent_data.semester AS ps_sem, - gebiet_id, - bezeichnung, - tbl_ablauf.studienplan_id, - tbl_ablauf.studiengang_kz, - tbl_ablauf.semester, - tbl_ablauf.reihung, - ".$bezeichnung_mehrsprachig. " - FROM - prestudent_data - JOIN - testtool.tbl_ablauf USING (studiengang_kz) - JOIN - testtool.tbl_gebiet USING (gebiet_id) - WHERE - (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) - OR - (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) - ) + SELECT DISTINCT ON + (gebiet_id, semester, reihung) + semester, + gebiet_id, + STRING_AGG(studiengang_kz::TEXT, ', ' ORDER BY studiengang_kz) AS studiengang_kz_list, + bezeichnung, + MIN(reihung) AS reihung, + ". $bezeichnung_mehrsprachig_sel. " + FROM ( + SELECT + * + FROM ( + (SELECT + prestudent_data.semester AS ps_sem, + gebiet_id, + bezeichnung, + tbl_ablauf.studienplan_id, + tbl_ablauf.studiengang_kz, + tbl_ablauf.semester, + tbl_ablauf.reihung, + ".$bezeichnung_mehrsprachig. " + FROM + prestudent_data + JOIN + testtool.tbl_ablauf USING (studiengang_kz) + JOIN + testtool.tbl_gebiet USING (gebiet_id) + WHERE + ( + (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) + OR + (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) + ) + AND ( + prestudent_data.studienplan_id = tbl_ablauf.studienplan_id + OR + tbl_ablauf.studienplan_id IS NULL + ) + ) - UNION + UNION - ( - SELECT - prestudent_data.semester AS ps_sem, - gebiet_id, - bezeichnung, - tbl_ablauf.studienplan_id, - tbl_ablauf.studiengang_kz, - tbl_ablauf.semester, - tbl_ablauf.reihung, - ". $bezeichnung_mehrsprachig. " - FROM - prestudent_data - JOIN - testtool.tbl_ablauf USING (studienplan_id) - JOIN - testtool.tbl_gebiet USING (gebiet_id) - WHERE - (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) - OR - (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) - ) - ) temp - ) temp2 + ( + SELECT + prestudent_data.semester AS ps_sem, + gebiet_id, + bezeichnung, + tbl_ablauf.studienplan_id, + tbl_ablauf.studiengang_kz, + tbl_ablauf.semester, + tbl_ablauf.reihung, + ". $bezeichnung_mehrsprachig. " + FROM + prestudent_data + JOIN + testtool.tbl_ablauf USING (studienplan_id) + JOIN + testtool.tbl_gebiet USING (gebiet_id) + WHERE + (prestudent_data.semester= 1 AND tbl_ablauf.semester = 1) + OR + (prestudent_data.semester= 3 AND tbl_ablauf.semester IN (1,3)) + ) + ) temp + ) temp2 - GROUP BY - semester, - gebiet_id, - bezeichnung, + GROUP BY + semester, + gebiet_id, + bezeichnung, ". $bezeichnung_mehrsprachig_sel ." - ORDER BY - semester, - gebiet_id - "; + ORDER BY + semester, + reihung, + gebiet_id + "; $result = $db->db_query($qry); + $anzahlGebiete = $db->db_num_rows($result); $lastsemester = ''; $quereinsteiger_stg = ''; while($row = $db->db_fetch_object($result)) @@ -355,10 +364,22 @@ if (isset($_SESSION['pruefling_id'])) $class='ItemTesttool'; } + // Fallback für Gebietbezeichnung, falls nicht in gewählter Sprache vorhanden + $gebietbezeichnung = $sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[$sprache_user]; + if ($gebietbezeichnung == '') + { + $gebietbezeichnung = $sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[DEFAULT_LANGUAGE]; + + if ($gebietbezeichnung == '') + { + $gebietbezeichnung = $row->bezeichnung; + } + } + echo '<tr> <!--<td width="10" class="ItemTesttoolLeft" nowrap>&nbsp;</td>--> <td class="'.$class.'"> - <a class="'.$class.'" href="frage.php?gebiet_id='.$row->gebiet_id.'" onclick="document.location.reload()" target="content" style="'.$style.'">'.$sprache_mehrsprachig->parseSprachResult("bezeichnung_mehrsprachig", $row)[$sprache_user].'</a> + <a class="'.$class.'" href="frage.php?gebiet_id='.$row->gebiet_id.'" onclick="document.location.reload()" target="content" style="'.$style.'">'.$gebietbezeichnung.'</a> </td> <!--<td width="10" class="ItemTesttoolRight" nowrap>&nbsp;</td>--> </tr>'; @@ -368,9 +389,13 @@ if (isset($_SESSION['pruefling_id'])) $invalid_gebiete = true; } } - echo '</table>'; + if ($anzahlGebiete > 0) + { + echo '</table>'; + } // Link zum Logout + echo '<tr><td class="ItemTesttool" style="margin-left: 20px;" nowrap> <a class="ItemTesttool navButton" href="login.php?logout=true" target="content">Logout</a> </td></tr>'; From 8f915d3c3945dfdee9f9018c613daea2f8393c2b Mon Sep 17 00:00:00 2001 From: Manfred Kindl <kindlm@technikum-wien.at> Date: Tue, 11 Feb 2020 14:44:23 +0100 Subject: [PATCH 097/157] Initial File --- application/controllers/jobs/Priorisation.php | 787 ++++++++++++++++++ 1 file changed, 787 insertions(+) create mode 100644 application/controllers/jobs/Priorisation.php diff --git a/application/controllers/jobs/Priorisation.php b/application/controllers/jobs/Priorisation.php new file mode 100644 index 000000000..7e63eb9b1 --- /dev/null +++ b/application/controllers/jobs/Priorisation.php @@ -0,0 +1,787 @@ +<?php +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +class Priorisation extends CLI_Controller +{ + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + + // Load models + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + //$this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + //$this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + // Load helpers + //$this->load->helper('hlp_sancho_helper'); + } + + /** + * runReihungstestJob + */ + public function runReihungstestJob() + { + // Get study plans that have no assigned placement tests yet + $result = $this->ReihungstestModel->checkMissingReihungstest(); + + $missing_rt_arr = array(); + if (hasData($result)) + { + $missing_rt_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + // Get free places + $result = $this->ReihungstestModel->getFreePlaces(); + + $free_places_arr = array(); + if (hasData($result)) + { + $free_places_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + // Prepare data for mail template 'ReihungstestJob' + $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); + + // Send email in Sancho design + if (!empty($missing_rt_arr) || !empty($free_places_arr)) + { + sendSanchoMail( + 'ReihungstestJob', + $content_data_arr, + MAIL_INFOCENTER, + 'Support für die Reihungstest-Verwaltung'); + } + } + + /* + * Sends an email to all assistants of a placement test when an anmeldeschluss has been reached + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function runZentraleReihungstestAnmeldefristAssistenzJob($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get placement tests where registration date was yesterday + $result = $this->ReihungstestModel->checkReachedRegistrationDate($degreeProgram); + + $reachedRegistration_rt_arr = array(); + + if (hasData($result)) + { + $reachedRegistration_rt_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + $applicants_arr = array(); + + foreach ($reachedRegistration_rt_arr as $reihungstest) + { + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); + + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } + + // Get all Bachelor-Degree-Programs with Mailadress + $bachelorStudiengeange = $this->StudiengangModel->loadStudiengaengeFromTyp('b'); + $bachelorStudiengeange_arr = array(); + + if (hasData($bachelorStudiengeange)) + { + $bachelorStudiengeange_arr = $bachelorStudiengeange->retval; + } + elseif (isError($bachelorStudiengeange)) + { + show_error(getError($bachelorStudiengeange)); + } + + // If a person ist an applicant of this degree-program send mail with application data + // Otherwise inform assistant, that no applicant is registered in this test + foreach ($bachelorStudiengeange_arr as $bachelorStudiengang) + { + $studiengang_kuerzel = strtoupper($bachelorStudiengang->typ.$bachelorStudiengang->kurzbz); + $applicantCounter = 0; + $mailcontent_data_arr = array(); + foreach ($applicants_arr as $applicant) + { + if ($bachelorStudiengang->studiengang_kz == $applicant->studiengang_kz) + { + $applicantCounter ++; + } + } + if ($applicantCounter == 0) + { + $mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"><b>Für den Studiengang '.$studiengang_kuerzel.' nehmen keine InteressentInnen an diesem Reihungstest teil</b></p>'; + } + else + { + $mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>'; + $mailcontent .= ' + <p style="font-family: verdana, sans-serif;"><b>' . $applicantCounter . '</b> InteressentIn(nen) des Studiengangs ' . $studiengang_kuerzel . ' nehmen daran teil:</p> + <p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$reihungstest->reihungstest_id.'&studiengang='.$bachelorStudiengang->studiengang_kz.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + } + $mailcontent_data_arr['table'] = $mailcontent; + + // Send email in Sancho design + if (!isEmptyString($mailcontent)) + { + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->email, + 'Anmeldeschluss Reihungstest ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' ' . $reihungstest->uhrzeit . ' Uhr', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + } + } + + /* + * Checks, if an applicant was assigned to a test after Anmeldefrist and sends an email to all responsible assistants + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function runZentraleReihungstestNachtraeglichHinzugefuegtJob($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get applicants that have been added to a test after Anmeldefrist + $result = $this->ReihungstestModel->getApplicantAssignedAfterDate($degreeProgram); + + $applicants_after_anmeldefrist_arr = array(); + + if (hasData($result)) + { + $applicants_after_anmeldefrist_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } + + $studiengang = ''; + $mailReceipients = ''; // String with all mailadresses + $mailcontent_data_arr = array(); + $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; + $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; + $mailcontent = ''; + $applicants_list = ''; + + if (count($applicants_after_anmeldefrist_arr) > 0) + { + foreach ($applicants_after_anmeldefrist_arr as $applicant) + { + if ($studiengang != $applicant->studiengang_kz) + { + if ($studiengang != '' && $studiengang != $applicant->studiengang_kz) + { + $bachelorStudiengang = $this->StudiengangModel->load($studiengang); + $mailcontent .= $applicants_list; + $mailcontent .= '</tbody></table>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + $mailcontent_data_arr['table'] = $mailcontent; + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->retval[0]->email, + 'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + $applicants_list = ''; + $mailcontent_data_arr = array(); + } + + $mailcontent = '<p style="font-family: verdana, sans-serif;">Folgende InteressentInnen wurden <b>nach</b> der Anmeldefrist zu einem Reihungstest hinzugefügt.<br>Details siehe Link</p>'; + $mailcontent .= ' + <table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;"> + <thead> + <th ' . $headerstyle . '>Datum des Tests</th> + <th ' . $headerstyle . '>Uhrzeit des Tests</th> + <th ' . $headerstyle . '>OrgForm</th> + <th ' . $headerstyle . '>Semester</th> + <th ' . $headerstyle . '>Nachname</th> + <th ' . $headerstyle . '>Vorname</th> + </thead> + <tbody> + '; + } + + $studiengang = $applicant->studiengang_kz; + $mailReceipients .= $applicant->email . ';'; + $applicants_list .= ' + <tr ' . $rowstyle . '> + <td>' . date_format(date_create($applicant->datum), 'd.m.Y') . '</td> + <td>' . $applicant->uhrzeit . '</td> + <td>' . $applicant->orgform_kurzbz . '</td> + <td>' . $applicant->ausbildungssemester . '</td> + <td>' . $applicant->nachname . '</td> + <td>' . $applicant->vorname . '</td> + </tr> + '; + }; + $bachelorStudiengang = $this->StudiengangModel->load($studiengang); + $mailcontent .= $applicants_list; + $mailcontent .= '</tbody></table>'; + $mailcontent .= '<p style="font-family: verdana, sans-serif;"> + <a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank"> + Liste der Anmeldungen + </a> + </p>'; + $mailcontent_data_arr['table'] = $mailcontent; + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $bachelorStudiengang->retval[0]->email, + 'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + + /* + * Sends an email to all applicants of a placement test to remind them 3 working days before + * + * @param integer $degreeProgram. Kennzahl of Degree Program to check + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function remindApplicantsOfPlacementTest($degreeProgram, $bcc = null, $from = null) + { + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + // Get placement tests with testdate within the next 2 weeks + $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); + if (hasData($resultNextTestDates)) + { + $nextTestDates = $resultNextTestDates->retval; + $enddate = ''; + // Loop through the dates + foreach ($nextTestDates as $testDates) + { + $workingdays = 0; + $testsOndate = array(); + + // Deduct days till 3 working days are reached + for ($i = 1; ; $i++) + { + if (isDateWorkingDay($testDates->datum, $i) === true) + { + $workingdays++; + } + if ($workingdays == 3) + { + $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); + break; + } + else + { + continue; + } + } + + // If $enddate is today -> load all tests of $testDates->datum + if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) + { + $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); + + if (hasData($resultTestsOnDate)) + { + $testsOndate = $resultTestsOnDate->retval; + } + elseif (isError($resultTestsOnDate)) + { + show_error(getError($resultTestsOnDate)); + } + } + + if (!isEmptyArray($testsOndate)) + { + foreach ($testsOndate as $reihungstest) + { + // Loads applicants of a test + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); + + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } + + foreach ($applicants_arr as $applicant) + { + $mailcontent_data_arr = array(); + $mailcontent_data_arr['anrede'] = $applicant->anrede; + $mailcontent_data_arr['nachname'] = $applicant->nachname; + $mailcontent_data_arr['vorname'] = $applicant->vorname; + $mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y'); + $mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i'); + $mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung; + if ($applicant->lageplan == '') + { + $mailcontent_data_arr['wegbeschreibung'] = 'Für diesen Raum liegt noch keine Wegbeschreibung vor.<br><br>No directions were found for this room'; + } + else + { + $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan; + } + + sendSanchoMail( + 'Sancho_RemindApplicantsOfTest', + $mailcontent_data_arr, + $applicant->email, + 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', + DEFAULT_SANCHO_HEADER_IMG, + DEFAULT_SANCHO_FOOTER_IMG, + $from, + '', + $bcc); + } + } + } + } + } + } + + /** + * This job sends eMail(s) to the relevant stg assistance(s) informing about: + * All applicants, who have sent new applications AFTER they had absolved a + * placement test in the actual studiensemester + * AND who have been confirmed yesterday. + */ + public function mailNewApplicants() + { + // Get yesterdays confirmed applicants for Bachelor-studies + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->PrestudentstatusModel->addSelect(' + tbl_person.person_id, + tbl_prestudentstatus.prestudent_id, + tbl_prestudent.studiengang_kz, + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudentstatus.bestaetigtam, + tbl_prestudentstatus.bewerbung_abgeschicktamum + '); + $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); + + $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' + status_kurzbz = \'Interessent\' AND + typ = \'b\' AND + bestaetigtam = current_date - 1 + '); + + // Retrieve the person_ids of yesterdays confirmed applicants + $person_id_arr = array(); + if (hasData($yesterdays_applicants_arr)) + { + foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + if (isset($yesterdays_applicant->person_id)) { + $person_id_arr[] = $yesterdays_applicant->person_id; + } + } + } + elseif (isError($yesterdays_applicants_arr)) + { + show_error(getError($yesterdays_applicants_arr)); + } + + // Get all other prestudenten of the given persons. + if (!isEmptyArray($person_id_arr)) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->PrestudentModel->addDistinct(); + $this->PrestudentModel->addSelect(' + person_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_reihungstest.reihungstest_id, + (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp + '); + $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); + + // Store them, if they have already absolved a placement test in the same study term they have applied for. + $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' + person_id IN (' . implode(', ', $person_id_arr) . ') AND + typ = \'b\' AND + teilgenommen = \'t\' AND + tbl_reihungstest.studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende >= now() + ) + '); + } + + // Store data to be send in the email-link + $result_arr = array(); + foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + foreach ($placement_absolvents_arr->retval as $placement_absolvent) + { + if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && + $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && + $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) + { + $obj = new stdClass(); + $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant + $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant + $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person + + $result_arr[]= $obj; + } + } + } + + // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. + usort($result_arr, function ($a, $b) + { + if ($a->studiengang_kz == $b->studiengang_kz) { + return 0; + } + return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; + }); + + $to = ''; // mail recipient (stg assistance) + $content_arr = array(); // url paths to the new applicants + $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); + + $i = 0; // loop counter + $len = count($result_arr); + + // Loop trough list of new applicants + foreach($result_arr as $result) + { + $studiengang = $this->StudiengangModel->load($result->studiengang_kz); + $mail_stg_assistance = $studiengang->retval[0]->email; + + // If first loop + if ($i == 0) + { + $to = $mail_stg_assistance; // set recipient initially + } + + // If new study is encountered but is not the first loop + if ($to != $mail_stg_assistance && $i != 0) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + + // Reset content for new study applicants & reset recipient (new stg assistance) + $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); + $to = $mail_stg_assistance; + } + // If same study + else + { + // just add content + $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content + } + + // If last loop + if (($i == $len - 1)) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + $i++; // iterate counter + } + } + + // ------------------------------------------------------------------------ + // Private methods + /** + * Returns associative array with data as needed in the reihungstest job template. + * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. + * @param array $free_places_arr Array with info and amount of free placement test places. + * @return array + */ + private function _getContentData($missing_rt_arr, $free_places_arr) + { + $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + + // Prepare HTML table with study plans that have no placement tests yet + if (!empty($missing_rt_arr)) { + $studienplan_list + = ' + <table' . $style_tbl2 . '> + '; + + foreach ($missing_rt_arr as $rt) { + $studienplan_list .= ' + <tr><td>' . $rt->bezeichnung . '</td></tr> + '; + } + + $studienplan_list .= ' + </table> + '; + } else { + $studienplan_list = ' + <table' . $style_tbl1 . '> + <tr><td>Alles okay! Alle Studienpläne haben zumindest einen Reihungstest.</td></tr> + </table> + '; + } + + // Prepare HTML table with information and amount of free places + if (!empty($free_places_arr)) { + $freie_plaetze_list = ' + <table' . $style_tbl2 . '> + <tr> + <th>Fakultät</th> + <th>Reihungstesttermine</th> + <th>Freie Plätze</th> + </tr> + '; + + foreach ($free_places_arr as $free_place) { + $datum = new DateTime($free_place->datum); + $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places + + $freie_plaetze_list .= ' + <tr> + <td width="350">' . $free_place->fakultaet . '</td> + <td align="center">' . $datum->format('d.m.Y') . '</td> + <td align="center"' . $style_alarm . '>' . $free_place->freie_plaetze . '</td> + </tr> + '; + } + + $freie_plaetze_list .= ' + </table> + '; + } else { + $freie_plaetze_list = ' + <table' . $style_tbl1 . '> + <tr><td>Es gibt heute keine Ergebnisse zu freien Reihungstestplätze.</td></tr> + </table> + '; + } + + // Set associative array with the prepared HTML tables and URL be used by the template's variables + $content_data_arr['studienplan_list'] = $studienplan_list; + $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; + $content_data_arr['link'] = site_url('/organisation/Reihungstest'); + + return $content_data_arr; + } + + /** + * Returns associative array with data as needed in the BewerberNachReihungstest-template. + * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. + * @return array + */ + private function _getContentDataNewApplicant($content_arr) + { + $content = ''; + $counter = 1; + foreach ($content_arr as $row) + { + $content .= '<br>Link zu: <a href="'. $row. '">Bewerber '. $counter. '</a>'; + $counter++; + } + + $content_data_arr['link'] = $content; + return $content_data_arr; + } + + + /** + * Checks the upcoming placement tests if there are correct studyplans assigned + * If there are invalid studyplans assigned (outdated because there exists a new version), + * it tries to find a better one and assigns it additionaly + */ + public function correctStudienplan() + { + // get all placement tests with incorrect studyplan + $qry = " + SELECT + tbl_reihungstest.reihungstest_id, + tbl_studienplan.studienplan_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_studienordnung.studiengang_kz + FROM + public.tbl_reihungstest + JOIN public.tbl_rt_studienplan ON(tbl_rt_studienplan.reihungstest_id=tbl_reihungstest.reihungstest_id) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + WHERE + NOT EXISTS( + SELECT 1 FROM lehre.tbl_studienplan_semester + WHERE studienplan_id=tbl_rt_studienplan.studienplan_id + AND tbl_studienplan_semester.studiensemester_kurzbz=tbl_reihungstest.studiensemester_kurzbz + ) + AND tbl_reihungstest.datum >= now() + AND NOT EXISTS( + SELECT + 1 + FROM + public.tbl_rt_studienplan rtstp + JOIN lehre.tbl_studienplan stp USING(studienplan_id) + JOIN lehre.tbl_studienordnung sto USING(studienordnung_id) + JOIN lehre.tbl_studienplan_semester stpsem USING(studienplan_id) + WHERE + sto.studiengang_kz=tbl_studienordnung.studiengang_kz + AND rtstp.reihungstest_id=tbl_reihungstest.reihungstest_id + AND stpsem.studiensemester_kurzbz=tbl_reihungstest.studiensemester_kurzbz + ) + "; + + $db = new DB_Model(); + $result_rt = $db->execReadOnlyQuery($qry); + + if (hasdata($result_rt)) { + foreach ($result_rt->retval as $row_rt) { + // find an active studyplan for the same degree program with is valid in this semester + $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( + $row_rt->studiengang_kz, + $row_rt->studiensemester_kurzbz + ); + + if (hasData($result_stpl)) { + foreach ($result_stpl->retval as $row_stpl) { + // Add new Studyplan to RtStudienplan if missing + $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + + if (!hasData($rt_studienplan)) { + echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; + echo " to ReihungstestId: $row_rt->reihungstest_id"; + + $this->RtStudienplanModel->insert(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + } + } + } + } + } + } +} From a63f6bd256ac422d26a46bcb0dac6969d8544eae Mon Sep 17 00:00:00 2001 From: raab <raab@technikum-wien.at> Date: Tue, 11 Feb 2020 15:25:17 +0100 Subject: [PATCH 098/157] Filter InfoCenterNotSentApplicationAll Spalten getauscht --- system/filtersupdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/filtersupdate.php b/system/filtersupdate.php index 42ac64571..d05a39aab 100644 --- a/system/filtersupdate.php +++ b/system/filtersupdate.php @@ -106,8 +106,8 @@ $filters = array( {"name": "Nachname"}, {"name": "Nation"}, {"name": "LastAction"}, - {"name": "User/Operator"}, {"name": "LastActionType"}, + {"name": "User/Operator"}, {"name": "LockUser"}, {"name": "StgNichtAbgeschickt"}, {"name": "StgAbgeschickt"}, From c7b33fe160b67202d359f1b400238da918c8c291 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:04:08 +0100 Subject: [PATCH 099/157] Bugfix: FAS write page person id and prestudent id are swapped --- application/models/CL/Messages_model.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 87eff0f99..3c8217e73 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -687,9 +687,18 @@ class Messages_model extends CI_Model foreach (getData($info) as $receiver) { $recipient = new stdClass(); - $recipient->id = $receiver->person_id; $recipient->description = $receiver->Vorname.' '.$receiver->Nachname; + // If it is a prestudent then + if (isset($receiver->prestudent_id) && is_numeric($receiver->prestudent_id)) + { + $recipient->id = $receiver->prestudent_id; + } + else // otherwise it is a person + { + $recipient->id = $receiver->person_id; + } + $recipientsArray[] = $recipient; $recipientsList .= $receiver->Vorname.' '.$receiver->Nachname.'; '; $persons .= '<input type="hidden" name="persons[]" value="'.$receiver->person_id.'">'."\n"; @@ -723,7 +732,7 @@ class Messages_model extends CI_Model // If data contains a prestudent id // NOTE: // - info is checked at the beginning of this method so it is safe to use getData($info)[0] - // - the provided data inside info are all persons or prestudents, so it is safe to check only the first one + // - the provided data inside info are all persons or all prestudents, so it is safe to check only the first one if (isset(getData($info)[0]->prestudent_id) && is_numeric(getData($info)[0]->prestudent_id)) { $variablesResult = $this->messagelib->getMessageVarsPrestudent(); From 1b9693e316656d06a3a6032fedcfd8768dca646d Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:10:39 +0100 Subject: [PATCH 100/157] Bugfix: Infocenter write page person id and prestudent id are swapped --- public/js/messaging/messageWrite.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index 04a262cbc..cc9d40730 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -21,14 +21,18 @@ function parseMessageText(receiver_id, text) { var data = {text: text}; - if ($("#type").val() == 'person_id') + if ($("#type").val() == 'persons') { data.person_id = receiver_id; } - else + else if ($("#type").val() == 'prestudents') { data.prestudent_id = receiver_id; } + else + { + return; + } FHC_AjaxClient.ajaxCallGet( "system/messages/Messages/parseMessageText", From b41ef00b3d395e66505dfcae6cbb6ebd5e26fb88 Mon Sep 17 00:00:00 2001 From: alex <karpen_ko@hotmail.com> Date: Tue, 11 Feb 2020 16:42:04 +0100 Subject: [PATCH 101/157] crm/Prestudent_model: hasBewerber can optionally check bewerber only for a Studiengangtyp. In InfoCenter, only Bachelors are checked after Freigabe (for setting Bewerber and Reihungstestbooleans) --- .../system/infocenter/InfoCenter.php | 4 +-- application/models/person/Person_model.php | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index e4d2c4e21..d5a751b05 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -560,7 +560,7 @@ class InfoCenter extends Auth_Controller else { // check if there is already a Bewerberstatus and Reihungsverfahren already absolviert - $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz); + $bewerber = $this->PersonModel->hasBewerber($person_id, $lastStatus->studiensemester_kurzbz, 'b'); if (hasData($bewerber)) { @@ -1559,7 +1559,7 @@ class InfoCenter extends Auth_Controller } /** - * Sends infomail with prestudent and person data when Prestudent is freigegeben + * Sends infomail to Studiengang with prestudent and person data when Prestudent is freigegeben * @param $prestudent_id */ private function _sendFreigabeMail($prestudent_id) diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 4f826dac1..d8ddb381c 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -220,16 +220,32 @@ class Person_model extends DB_Model * @param $studiensemester_kurzbz * @return array */ - public function hasBewerber($person_id, $studiensemester_kurzbz) + public function hasBewerber($person_id, $studiensemester_kurzbz, $studiengangtyp = null) { + $parametersArray = array($person_id, $studiensemester_kurzbz); + $qry = "SELECT count(*) AS anzahl_bewerber FROM public.tbl_person JOIN public.tbl_prestudent USING (person_id) - JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id - WHERE person_id = ? + JOIN public.tbl_prestudentstatus ON tbl_prestudentstatus.prestudent_id = tbl_prestudent.prestudent_id"; + + if (isset($studiengangtyp)) + { + $qry .= " JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + JOIN public.tbl_studiengang ON tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz"; + } + + $qry .= " WHERE person_id = ? AND studiensemester_kurzbz = ? - AND status_kurzbz = 'Bewerber' + AND tbl_prestudentstatus.status_kurzbz = 'Bewerber' AND reihungstestangetreten"; - return $this->execQuery($qry, array($person_id, $studiensemester_kurzbz)); + if (isset($studiengangtyp)) + { + $parametersArray[] = $studiengangtyp; + $qry .= " AND tbl_studiengang.typ = ?"; + } + + return $this->execQuery($qry, $parametersArray); } } From 16cb4a0d4ca4175b7d80a8011f706a78fa9f59b6 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 16:49:25 +0100 Subject: [PATCH 102/157] - Replace "This is a notice to notice you that you have been noticed..." with: EN: "This message will be delivered to the Infocenter of UAS Technikum Wien" DE: "Diese Nachricht wird an das Infocenter der FHTW zugestellt " - Bugfix: fixed phrases in system/messages/MessageClient/write --- application/views/system/messages/ajaxWrite.php | 10 +++++----- system/phrasesupdate.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index df6c1bfcb..5a0a3f7b9 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -23,13 +23,13 @@ <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> - <h3 class="page-header"><?php echo $this->p->t('ui', 'sendMessage'); ?></h3> + <h3 class="page-header"><?php echo $this->p->t('ui', 'nachrichtSenden'); ?></h3> </div> </div> <div class="row"> <div class="form-group"> <div class="col-lg-1 msgfieldcol-left"> - <label><?php echo $this->p->t('ui', 'receiver'); ?>:</label> + <label><?php echo $this->p->t('global', 'empfaenger'); ?>:</label> </div> <div class="col-lg-11 msgfieldcol-right"> <select id="organisationUnit"> @@ -43,7 +43,7 @@ <div class="row"> <div class="form-group"> <div class="col-lg-1 msgfield msgfieldcol-left"> - <label><?php echo $this->p->t('ui', 'subject'); ?>:</label> + <label><?php echo $this->p->t('global', 'betreff'); ?>:</label> </div> &nbsp; <div class="col-lg-7"> @@ -54,7 +54,7 @@ <br> <div class="row"> <div class="col-lg-12"> - <label><?php echo $this->p->t('ui', 'message'); ?>:</label> + <label><?php echo $this->p->t('global', 'nachricht'); ?>:</label> <textarea id="body"></textarea> <br> @@ -68,7 +68,7 @@ <div class="row"> <div class="col-lg-12 text-right"> <button id="sendButton" class="btn btn-default" type="button"> - <?php echo $this->p->t('ui', 'send'); ?> + <?php echo $this->p->t('ui', 'senden'); ?> </button> </div> </div> diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index d53d87dbb..3766f976d 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4383,13 +4383,13 @@ When on hold, the date is only a reminder.', 'phrases' => array( array( 'sprache' => 'German', - 'text' => '* This is a notice to notice you that you have been noticed DE', + 'text' => '* Diese Nachricht wird an das Infocenter der FHTW zugestellt', 'description' => '', 'insertvon' => 'system' ), array( 'sprache' => 'English', - 'text' => '* This is a notice to notice you that you have been noticed', + 'text' => '* This message will be delivered to the Infocenter of UAS Technikum Wien', 'description' => '', 'insertvon' => 'system' ) From 98918bc3362c269a596bfaa8e20577370f523628 Mon Sep 17 00:00:00 2001 From: Paolo <bison@technikum-wien.at> Date: Tue, 11 Feb 2020 18:05:26 +0100 Subject: [PATCH 103/157] - Bugfix: fixed phrases in views/system/messages/* - Added new phrases where missing or hard coded - Fixed windowz new lines in /application/* --- .../controllers/api/v1/person/Person.php | 534 +++++++++--------- application/views/crm/statusEdit.php | 178 +++--- application/views/crm/statusgrund.php | 64 +-- application/views/crm/statusgrundEdit.php | 214 +++---- application/views/crm/statusgrundNew.php | 132 ++--- application/views/system/fas_udf.php | 300 +++++----- application/views/system/infocenter/logs.php | 36 +- .../views/system/infocenter/messageList.php | 74 +-- .../views/system/infocenter/notizen.php | 38 +- .../views/system/messages/ajaxRead.php | 6 +- .../views/system/messages/ajaxWrite.php | 180 +++--- .../views/system/messages/ajaxWriteReply.php | 182 +++--- .../views/system/messages/htmlRead.php | 192 ++++--- .../views/system/messages/htmlWriteReply.php | 30 +- .../system/messages/htmlWriteTemplate.php | 20 +- application/views/system/phrases/phrases.php | 40 +- .../views/system/phrases/phrasesEdit.php | 34 +- .../system/phrases/phrasesinhaltList.php | 108 ++-- .../views/system/vorlage/templates.php | 40 +- .../system/vorlage/templatetextPreview.php | 4 +- application/views/templates/vilesci.php | 82 +-- application/widgets/Dropdown_widget.php | 38 +- .../widgets/MultipleDropdown_widget.php | 40 +- application/widgets/Nation_widget.php | 42 +- application/widgets/Zgv_widget.php | 42 +- 25 files changed, 1368 insertions(+), 1282 deletions(-) diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php index c8c95ae06..ca8a66bea 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -1,267 +1,267 @@ -<?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 Person extends APIv1_Controller -{ - /** - * Person API constructor. - */ - public function __construct() - { - parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r')); - // Load model PersonModel - $this->load->model('person/person_model', 'PersonModel'); - } - - /** - * @return void - */ - public function getPerson() - { - $person_id = $this->get('person_id'); - $code = $this->get('code'); - $email = $this->get('email'); - - if (isset($code) || isset($email) || isset($person_id)) - { - if (isset($code) && isset($email)) - { - $result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email); - } - else - { - $parametersArray = array(); - - if (isset($code)) - { - $parametersArray['zugangscode'] = $code; - } - else - { - $parametersArray['person_id'] = $person_id; - } - - $result = $this->PersonModel->loadWhere($parametersArray); - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function getCheckBewerbung() - { - $email = $this->get('email'); - $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); - - if (isset($email)) - { - $result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz); - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function postPerson() - { - $person = $this->post(); - $validation = $this->_validate($person); - - if (isSuccess($validation)) - { - if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != '')) - { - $result = $this->PersonModel->updatePerson($person); - } - else - { - $result = $this->PersonModel->insert($person); - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response($validation, REST_Controller::HTTP_OK); - } - } - - private function _validate($person) - { - // If $person is consistent - if (!isset($person) || (isset($person) && !is_array($person))) - { - return error('Any parameters posted'); - } - - // Trim all the values - foreach($person as $key => $value) - { - if (gettype($value) == 'string') - { - $person[$key] = trim($value); - } - } - - if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16) - { - return error('Sprache darf nicht laenger als 16 Zeichen sein'); - } - if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16) - { - return error('Anrede darf nicht laenger als 16 Zeichen sein'); - } - if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32) - { - return error('Titelpost darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64) - { - return error('Titelpre darf nicht laenger als 64 Zeichen sein'); - } - if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64) - { - return error('Nachname darf nicht laenger als 64 Zeichen sein'); - } - if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname']))) - { - return error('Nachname muss eingegeben werden'); - } - if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32) - { - return error('Vorname darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128) - { - return error('Vornamen darf nicht laenger als 128 Zeichen sein'); - } - if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128) - { - return error('Geburtsort darf nicht laenger als 128 Zeichen sein'); - } - if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256) - { - return error('Homepage darf nicht laenger als 256 Zeichen sein'); - } - if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32) - { - return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10) - { - return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein'); - } - if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1) - { - return error('Familienstand ist ungueltig'); - } - if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder'])) - { - return error('Anzahl der Kinder ist ungueltig'); - } - if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false)) - { - return error('Aktiv ist ungueltig'); - } - if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32) - { - return error('Insertvon darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32) - { - return error('Updatevon darf nicht laenger als 32 Zeichen sein'); - } - if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3) - { - return error('Geburtsnation darf nicht laenger als 3 Zeichen sein'); - } - if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3) - { - return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein'); - } - if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1)) - { - return error('Geschlecht darf nicht laenger als 1 Zeichen sein'); - } - if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u') - { - return error('Geschlecht muss w, m oder u sein!'); - } - - if (isset($person['svnr'])) - { - if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 - && mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10) - { - return error('SVNR muss 10, 12 oder 16 Zeichen lang sein'); - } - if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12) - { - //SVNR mit Pruefziffer pruefen - //Die 4. Stelle in der SVNR ist die Pruefziffer - //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer - //Falls nicht, ist die SVNR ungueltig - $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6); - $erg = 0; - $tmpSvnr = substr($person['svnr'], 0, 10); - //Quersumme bilden - for ($i = 0; $i < 10; $i++) - { - $erg += $gewichtung[$i] * $tmpSvnr{$i}; - } - - if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 - { - return error('SVNR ist ungueltig'); - } - - if (mb_strlen($person['svnr']) == 12) - { - $last = substr($person['svnr'], 10, 12); - if ($last{0} != 'v' || !is_numeric($last{1})) - { - return error('SVNR ist ungueltig'); - } - } - } - - //Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt. - if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '') - { - if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum']) - && !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum'])) - { - return error('Format des Geburtsdatums ist ungueltig'); - } - } - } - - return success('Input data are valid'); - } -} +<?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 Person extends APIv1_Controller +{ + /** + * Person API constructor. + */ + public function __construct() + { + parent::__construct(array('Person' => 'basis/person:rw', 'CheckBewerbung' => 'basis/person:r')); + // Load model PersonModel + $this->load->model('person/person_model', 'PersonModel'); + } + + /** + * @return void + */ + public function getPerson() + { + $person_id = $this->get('person_id'); + $code = $this->get('code'); + $email = $this->get('email'); + + if (isset($code) || isset($email) || isset($person_id)) + { + if (isset($code) && isset($email)) + { + $result = $this->PersonModel->getPersonKontaktByZugangscode($code, $email); + } + else + { + $parametersArray = array(); + + if (isset($code)) + { + $parametersArray['zugangscode'] = $code; + } + else + { + $parametersArray['person_id'] = $person_id; + } + + $result = $this->PersonModel->loadWhere($parametersArray); + } + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + /** + * @return void + */ + public function getCheckBewerbung() + { + $email = $this->get('email'); + $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); + + if (isset($email)) + { + $result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + /** + * @return void + */ + public function postPerson() + { + $person = $this->post(); + $validation = $this->_validate($person); + + if (isSuccess($validation)) + { + if(isset($person['person_id']) && !(is_null($person['person_id'])) && ($person['person_id'] != '')) + { + $result = $this->PersonModel->updatePerson($person); + } + else + { + $result = $this->PersonModel->insert($person); + } + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response($validation, REST_Controller::HTTP_OK); + } + } + + private function _validate($person) + { + // If $person is consistent + if (!isset($person) || (isset($person) && !is_array($person))) + { + return error('Any parameters posted'); + } + + // Trim all the values + foreach($person as $key => $value) + { + if (gettype($value) == 'string') + { + $person[$key] = trim($value); + } + } + + if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16) + { + return error('Sprache darf nicht laenger als 16 Zeichen sein'); + } + if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16) + { + return error('Anrede darf nicht laenger als 16 Zeichen sein'); + } + if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32) + { + return error('Titelpost darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64) + { + return error('Titelpre darf nicht laenger als 64 Zeichen sein'); + } + if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64) + { + return error('Nachname darf nicht laenger als 64 Zeichen sein'); + } + if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname']))) + { + return error('Nachname muss eingegeben werden'); + } + if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32) + { + return error('Vorname darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128) + { + return error('Vornamen darf nicht laenger als 128 Zeichen sein'); + } + if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128) + { + return error('Geburtsort darf nicht laenger als 128 Zeichen sein'); + } + if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256) + { + return error('Homepage darf nicht laenger als 256 Zeichen sein'); + } + if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32) + { + return error('Matrikelnummer darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10) + { + return error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein'); + } + if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1) + { + return error('Familienstand ist ungueltig'); + } + if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder'])) + { + return error('Anzahl der Kinder ist ungueltig'); + } + if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] !== true && $person['aktiv'] !== false)) + { + return error('Aktiv ist ungueltig'); + } + if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32) + { + return error('Insertvon darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32) + { + return error('Updatevon darf nicht laenger als 32 Zeichen sein'); + } + if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3) + { + return error('Geburtsnation darf nicht laenger als 3 Zeichen sein'); + } + if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3) + { + return error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein'); + } + if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1)) + { + return error('Geschlecht darf nicht laenger als 1 Zeichen sein'); + } + if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u') + { + return error('Geschlecht muss w, m oder u sein!'); + } + + if (isset($person['svnr'])) + { + if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 + && mb_strlen($person['svnr']) != 12 && mb_strlen($person['svnr']) != 10) + { + return error('SVNR muss 10, 12 oder 16 Zeichen lang sein'); + } + if (mb_strlen($person['svnr']) == 10 || mb_strlen($person['svnr']) == 12) + { + //SVNR mit Pruefziffer pruefen + //Die 4. Stelle in der SVNR ist die Pruefziffer + //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer + //Falls nicht, ist die SVNR ungueltig + $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6); + $erg = 0; + $tmpSvnr = substr($person['svnr'], 0, 10); + //Quersumme bilden + for ($i = 0; $i < 10; $i++) + { + $erg += $gewichtung[$i] * $tmpSvnr{$i}; + } + + if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 + { + return error('SVNR ist ungueltig'); + } + + if (mb_strlen($person['svnr']) == 12) + { + $last = substr($person['svnr'], 10, 12); + if ($last{0} != 'v' || !is_numeric($last{1})) + { + return error('SVNR ist ungueltig'); + } + } + } + + //Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt. + if (isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '') + { + if (!mb_ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $person['gebdatum']) + && !mb_ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $person['gebdatum'])) + { + return error('Format des Geburtsdatums ist ungueltig'); + } + } + } + + return success('Input data are valid'); + } +} diff --git a/application/views/crm/statusEdit.php b/application/views/crm/statusEdit.php index 5fee3ee92..5f0353acf 100644 --- a/application/views/crm/statusEdit.php +++ b/application/views/crm/statusEdit.php @@ -1,89 +1,89 @@ -<?php - $this->load->view('templates/header', array('title' => 'StatusEdit')); - - $s = $status; -?> - - <div class="row"> - <div class="span4"> - <h2>Status: <?php echo $s->status_kurzbz; ?></h2> - <form method="post" action="../saveStatus"> - <table> - <tr> - <td colspan="2"> - beschreibung:<br/><br/> - <input type="text" name="beschreibung" value="<?php echo $s->beschreibung; ?>" /><br/> - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2"> - Anmerkung:<br/><br/> - <textarea name="anmerkung"><?php echo $s->anmerkung; ?></textarea><br/> - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2"> - Bezeichnung mehrsprachig:<br/><br/> - - <?php - $val = ''; - $i = 0; - ?> - - <?php foreach ($sprache as $sp): ?> - <?php echo $sp->sprache; ?>:<br/> - <?php - if (!isset($s->bezeichnung_mehrsprachig[$i])) - { - $val = ''; - } - else - { - $val = $s->bezeichnung_mehrsprachig[$i]; - } - $i++; - ?> - <input type="text" name="bezeichnung_mehrsprachig[]" value="<?php echo $val; ?>" /><br/> - <?php endforeach ?> - - </td> - </tr> - <tr> - <td colspan="2"> - &nbsp; - </td> - </tr> - <tr> - <td colspan="2" align="center"> - <button type="submit">Save</button> - </td> - </tr> - </table> - <input type="hidden" name="status_kurzbz" value="<?php echo $s->status_kurzbz; ?>" /> - </form> - </div> - </div> - </body> - - <?php - if (!is_null($update)) - { - ?> - <script> - parent.document.getElementById("StatusgrundLeft").contentWindow.location.reload(true); - </script> - <?php - } - ?> - -</html> +<?php + $this->load->view('templates/header', array('title' => 'StatusEdit')); + + $s = $status; +?> + + <div class="row"> + <div class="span4"> + <h2>Status: <?php echo $s->status_kurzbz; ?></h2> + <form method="post" action="../saveStatus"> + <table> + <tr> + <td colspan="2"> + beschreibung:<br/><br/> + <input type="text" name="beschreibung" value="<?php echo $s->beschreibung; ?>" /><br/> + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2"> + Anmerkung:<br/><br/> + <textarea name="anmerkung"><?php echo $s->anmerkung; ?></textarea><br/> + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2"> + Bezeichnung mehrsprachig:<br/><br/> + + <?php + $val = ''; + $i = 0; + ?> + + <?php foreach ($sprache as $sp): ?> + <?php echo $sp->sprache; ?>:<br/> + <?php + if (!isset($s->bezeichnung_mehrsprachig[$i])) + { + $val = ''; + } + else + { + $val = $s->bezeichnung_mehrsprachig[$i]; + } + $i++; + ?> + <input type="text" name="bezeichnung_mehrsprachig[]" value="<?php echo $val; ?>" /><br/> + <?php endforeach ?> + + </td> + </tr> + <tr> + <td colspan="2"> + &nbsp; + </td> + </tr> + <tr> + <td colspan="2" align="center"> + <button type="submit">Save</button> + </td> + </tr> + </table> + <input type="hidden" name="status_kurzbz" value="<?php echo $s->status_kurzbz; ?>" /> + </form> + </div> + </div> + </body> + + <?php + if (!is_null($update)) + { + ?> + <script> + parent.document.getElementById("StatusgrundLeft").contentWindow.location.reload(true); + </script> + <?php + } + ?> + +</html> diff --git a/application/views/crm/statusgrund.php b/application/views/crm/statusgrund.php index e79fa5d05..d4a31aa53 100644 --- a/application/views/crm/statusgrund.php +++ b/application/views/crm/statusgrund.php @@ -1,32 +1,32 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"> -<html lang="de_AT"> - - <head> - <title>VileSci - Statusgrund</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - </head> - - <frameset cols="30%, *"> - <frame src="Statusgrund/listStatus" id="StatusgrundLeft" name="StatusgrundLeft" frameborder="1" /> - <noframes> - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - </body> - - - - - + + + + + VileSci - Statusgrund + + + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + + diff --git a/application/views/crm/statusgrundEdit.php b/application/views/crm/statusgrundEdit.php index ddbd1ff0a..9fa91b6d5 100644 --- a/application/views/crm/statusgrundEdit.php +++ b/application/views/crm/statusgrundEdit.php @@ -1,107 +1,107 @@ -load->view('templates/header', array('title' => 'StatusgrundEdit')); - - $sg = $statusgrund; -?> - -
-
-

Statusgrund: status_kurzbz; ?>

-
"> - - - - - - - - - - - - - - - - - - - - - - - -
- Bezeichnung mehrsprachig:

- - - sprache; ?>:
- bezeichnung_mehrsprachig[$i])) - { - $val = ""; - } - else - { - $val = $sg->bezeichnung_mehrsprachig[$i]; - } - $i++; - ?> -
- - -
-   -
- Beschreibung:

- - - sprache; ?>:
- beschreibung[$i])) - { - $val = ""; - } - else - { - $val = $sg->beschreibung[$i]; - } - $i++; - ?> -
- -
-   -
- Aktiv: - - aktiv) && $sg->aktiv === true ? "checked" : ""; ?> /> -
-   -
- -
- " /> -
-
-
- - - - - - - +load->view('templates/header', array('title' => 'StatusgrundEdit')); + + $sg = $statusgrund; +?> + +
+
+

Statusgrund: status_kurzbz; ?>

+
"> + + + + + + + + + + + + + + + + + + + + + + + +
+ Bezeichnung mehrsprachig:

+ + + sprache; ?>:
+ bezeichnung_mehrsprachig[$i])) + { + $val = ""; + } + else + { + $val = $sg->bezeichnung_mehrsprachig[$i]; + } + $i++; + ?> +
+ + +
+   +
+ Beschreibung:

+ + + sprache; ?>:
+ beschreibung[$i])) + { + $val = ""; + } + else + { + $val = $sg->beschreibung[$i]; + } + $i++; + ?> +
+ +
+   +
+ Aktiv: + + aktiv) && $sg->aktiv === true ? "checked" : ""; ?> /> +
+   +
+ +
+ " /> +
+
+
+ + + + + + + diff --git a/application/views/crm/statusgrundNew.php b/application/views/crm/statusgrundNew.php index bd2ebe7d7..ffcd18429 100644 --- a/application/views/crm/statusgrundNew.php +++ b/application/views/crm/statusgrundNew.php @@ -1,66 +1,66 @@ -load->view('templates/header', array('title' => 'StatusgrundNew')); -?> - -
-
-

Neuer Statusgrund

-
"> - - - - - - - - - - - - - - - - - - - - - - - -
- Bezeichnung mehrsprachig:

- - - sprache; ?>:
-
- - -
-   -
- Beschreibung:

- - - sprache; ?>:
-
- -
-   -
- Aktiv: - - -
-   -
- -
- -
-
-
- - - +load->view('templates/header', array('title' => 'StatusgrundNew')); +?> + +
+
+

Neuer Statusgrund

+
"> + + + + + + + + + + + + + + + + + + + + + + + +
+ Bezeichnung mehrsprachig:

+ + + sprache; ?>:
+
+ + +
+   +
+ Beschreibung:

+ + + sprache; ?>:
+
+ +
+   +
+ Aktiv: + + +
+   +
+ +
+ +
+
+
+ + + diff --git a/application/views/system/fas_udf.php b/application/views/system/fas_udf.php index d4a01b9e9..3efc61abc 100644 --- a/application/views/system/fas_udf.php +++ b/application/views/system/fas_udf.php @@ -1,150 +1,150 @@ -load->view("templates/header", array("title" => "UDF", "widgetsCSS" => true)); ?> - - - - -
- Saved! -
- -
- -
- Error while saving! -
-
-
-retval; - if(is_array($errors)) - { - foreach ($errors as $error) - { - foreach ($error as $fieldError) - { - echo $fieldError->code . ': ' . $fieldError->retval . '
'; - } - } - } - else - echo $result->retval; -?> -
- -
-
-
- -
- -
-
-
- Zusatzfelder -
-
-
-
-   -
-
-
- -
- udflib->UDFWidget( - array( - UDFLib::SCHEMA_ARG_NAME => 'public', - UDFLib::TABLE_ARG_NAME => 'tbl_person', - UDFLib::UDFS_ARG_NAME => $personUdfs - ) - ); - ?> -
-
-   -
- - -
- udflib->UDFWidget( - array( - UDFLib::SCHEMA_ARG_NAME => 'public', - UDFLib::TABLE_ARG_NAME => 'tbl_prestudent', - UDFLib::UDFS_ARG_NAME => $prestudentUdfs - ) - ); - ?> -
- -
-
-
-   -
-
-
- -
-   -
-
-   -
- -
- -
-
-
- - - - - - - - -
- - - -load->view("templates/footer"); ?> +load->view("templates/header", array("title" => "UDF", "widgetsCSS" => true)); ?> + + + + +
+ Saved! +
+ +
+ +
+ Error while saving! +
+
+
+retval; + if(is_array($errors)) + { + foreach ($errors as $error) + { + foreach ($error as $fieldError) + { + echo $fieldError->code . ': ' . $fieldError->retval . '
'; + } + } + } + else + echo $result->retval; +?> +
+ +
+
+
+ +
+ +
+
+
+ Zusatzfelder +
+
+
+
+   +
+
+
+ +
+ udflib->UDFWidget( + array( + UDFLib::SCHEMA_ARG_NAME => 'public', + UDFLib::TABLE_ARG_NAME => 'tbl_person', + UDFLib::UDFS_ARG_NAME => $personUdfs + ) + ); + ?> +
+
+   +
+ + +
+ udflib->UDFWidget( + array( + UDFLib::SCHEMA_ARG_NAME => 'public', + UDFLib::TABLE_ARG_NAME => 'tbl_prestudent', + UDFLib::UDFS_ARG_NAME => $prestudentUdfs + ) + ); + ?> +
+ +
+
+
+   +
+
+
+ +
+   +
+
+   +
+ +
+ +
+
+
+ + + + + + + + +
+ + + +load->view("templates/footer"); ?> diff --git a/application/views/system/infocenter/logs.php b/application/views/system/infocenter/logs.php index de97d5055..8005bf4f7 100644 --- a/application/views/system/infocenter/logs.php +++ b/application/views/system/infocenter/logs.php @@ -1,19 +1,19 @@ - - - - - - - - - - - - - - - - - +
p->t('global', 'datum')) ?>p->t('global', 'aktivitaet')) ?>User
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
+ + + + + + + + + + + + + + + +
p->t('global', 'datum')) ?>p->t('global', 'aktivitaet')) ?>User
zeitpunkt), 'd.m.Y H:i:s') ?>logdata->name) ? $log->logdata->name : '' ?>insertvon ?>
\ No newline at end of file diff --git a/application/views/system/infocenter/messageList.php b/application/views/system/infocenter/messageList.php index d666e32fe..18b859314 100644 --- a/application/views/system/infocenter/messageList.php +++ b/application/views/system/infocenter/messageList.php @@ -1,37 +1,37 @@ - 0; -$widthColumn = $msgExists === true ? 8 : 12; -?> -
- - - - - - - - - - - - - - - - - - - - - -
p->t('global','gesendetAm')) ?>p->t('global','sender')) ?>p->t('global','empfaenger')) ?>p->t('global','betreff')) ?>p->t('global','gelesenAm')) ?>
insertamum) ? date_format(date_create($message->insertamum), 'd.m.Y H:i:s') : '' ?>sevorname.' '.$message->senachname ?>revorname.' '.$message->renachname ?>subject ?>statusamum) ? date_format(date_create($message->statusamum), 'd.m.Y H:i:s') : '' ?>
-
- -
-
-
-
- -
-
- + 0; +$widthColumn = $msgExists === true ? 8 : 12; +?> +
+ + + + + + + + + + + + + + + + + + + + + +
p->t('global','gesendetAm')) ?>p->t('global','sender')) ?>p->t('global','empfaenger')) ?>p->t('global','betreff')) ?>p->t('global','gelesenAm')) ?>
insertamum) ? date_format(date_create($message->insertamum), 'd.m.Y H:i:s') : '' ?>sevorname.' '.$message->senachname ?>revorname.' '.$message->renachname ?>subject ?>statusamum) ? date_format(date_create($message->statusamum), 'd.m.Y H:i:s') : '' ?>
+
+ +
+
+
+
+ +
+
+ diff --git a/application/views/system/infocenter/notizen.php b/application/views/system/infocenter/notizen.php index 13f7bb6e1..b28f7939a 100644 --- a/application/views/system/infocenter/notizen.php +++ b/application/views/system/infocenter/notizen.php @@ -1,20 +1,20 @@ - - - - - - - - - - - - - - - - - - +
p->t('global', 'datum')) ?>p->t('global', 'notiz')) ?>User
insertamum), 'd.m.Y H:i:s') ?>titel) ?>verfasser_uid ?>
+ + + + + + + + + + + + + + + + +
p->t('global', 'datum')) ?>p->t('global', 'notiz')) ?>User
insertamum), 'd.m.Y H:i:s') ?>titel) ?>verfasser_uid ?>
\ No newline at end of file diff --git a/application/views/system/messages/ajaxRead.php b/application/views/system/messages/ajaxRead.php index 2ff1f6cbb..1ed1b7f40 100644 --- a/application/views/system/messages/ajaxRead.php +++ b/application/views/system/messages/ajaxRead.php @@ -27,12 +27,16 @@ @@ -40,7 +44,7 @@ - + diff --git a/application/views/system/messages/ajaxWrite.php b/application/views/system/messages/ajaxWrite.php index 5a0a3f7b9..fe9b9e897 100644 --- a/application/views/system/messages/ajaxWrite.php +++ b/application/views/system/messages/ajaxWrite.php @@ -1,80 +1,100 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Write a new message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'phrases' => array('global', 'ui'), - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-   -
- -
-
-
-
-
-
- - - -
- -
- p->t('ui', 'altRecipientNote'); ?> -
-
-
-
-
-
- -
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Write a new message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'phrases' => array('global', 'ui'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/write.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+   +
+ +
+
+
+
+
+
+ + + +
+ +
+ + p->t('ui', 'altRecipientNote'); ?> + +
+
+
+
+
+
+ +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 36d999fc0..2fdaea907 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -1,81 +1,101 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Reply to a message', - 'jquery' => true, - 'jqueryui' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'ajaxlib' => true, - 'dialoglib' => true, - 'tinymce' => true, - 'phrases' => array('global', 'ui'), - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), - 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
- -
-
- - - -
-
-
-
-
-
- -
-   -
- - - -
-
-
-
-
-
- - -
-
-
-
-
- - - - - - -
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Reply to a message', + 'jquery' => true, + 'jqueryui' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tinymce' => true, + 'phrases' => array('global', 'ui'), + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/messaging/writeReply.js') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+ +
+   +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 390e84ccc..ed184f7c5 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -1,88 +1,104 @@ -load->view( - 'templates/FHC-Header', - array( - 'title' => 'Read a message', - 'jquery' => true, - 'bootstrap' => true, - 'fontawesome' => true, - 'sbadmintemplate' => true, - 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') - ) - ); -?> - -
-
-
-
-
- -
-
-
-
-
-
- - subject; ?> - -
-
- - - - - - - - - - - - - -
- From: - - - vorname.' '.$sender->nachname; ?> - -
- Subject: - - - subject; ?> - -
- Message: - - - body; ?> - -
-
- -
-
-
-
-
-
- - -load->view("templates/FHC-Footer"); ?> +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Read a message', + 'jquery' => true, + 'bootstrap' => true, + 'fontawesome' => true, + 'sbadmintemplate' => true, + 'customCSSs' => array('public/css/sbadmin2/admintemplate_contentonly.css', 'public/css/messaging/message.css') + ) + ); +?> + +
+
+
+
+
+ +
+
+
+
+
+
+ + subject; ?> + +
+
+ + + + + + + + + + + + + +
+ + + p->t('ui', 'from')); ?>: + + + + + vorname.' '.$sender->nachname; ?> + +
+ + + p->t('global', 'betreff')); ?>: + + + + + subject; ?> + +
+ + + p->t('global', 'nachricht')); ?>: + + + + + body; ?> + +
+
+ +
+
+
+
+
+
+ + +load->view("templates/FHC-Footer"); ?> diff --git a/application/views/system/messages/htmlWriteReply.php b/application/views/system/messages/htmlWriteReply.php index 8e1ef7d7f..fa3390bfa 100644 --- a/application/views/system/messages/htmlWriteReply.php +++ b/application/views/system/messages/htmlWriteReply.php @@ -19,14 +19,22 @@
- +
- +
@@ -38,7 +46,11 @@
- +
 
@@ -49,14 +61,22 @@
- +

- +
diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 5309e0cb5..d26ec534c 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -36,7 +36,7 @@
@@ -50,7 +50,7 @@
@@ -65,7 +65,7 @@
+<<<<<<< Updated upstream +======= + +>>>>>>> Stashed changes diff --git a/public/js/messaging/messageWrite.js b/public/js/messaging/messageWrite.js index cc9d40730..0676329de 100644 --- a/public/js/messaging/messageWrite.js +++ b/public/js/messaging/messageWrite.js @@ -19,24 +19,13 @@ function tinymcePreviewSetContent() function parseMessageText(receiver_id, text) { - var data = {text: text}; - - if ($("#type").val() == 'persons') - { - data.person_id = receiver_id; - } - else if ($("#type").val() == 'prestudents') - { - data.prestudent_id = receiver_id; - } - else - { - return; - } - FHC_AjaxClient.ajaxCallGet( "system/messages/Messages/parseMessageText", - data, + { + receiver_id: receiver_id, + text: text, + type: $("#type").val() + }, { successCallback: function(data, textStatus, jqXHR) { From 937db42e1187ca1e91e0d5c4999e4d3f6a4a7ff4 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Feb 2020 16:14:50 +0100 Subject: [PATCH 109/157] - Allow to change the subject in all reply pages - Remove tabs and/or blanks from subject when replying --- application/views/system/messages/ajaxWriteReply.php | 4 ++-- application/views/system/messages/htmlRead.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/system/messages/ajaxWriteReply.php b/application/views/system/messages/ajaxWriteReply.php index 2fdaea907..a43131d1d 100644 --- a/application/views/system/messages/ajaxWriteReply.php +++ b/application/views/system/messages/ajaxWriteReply.php @@ -56,9 +56,9 @@
  -
+
- +
diff --git a/application/views/system/messages/htmlRead.php b/application/views/system/messages/htmlRead.php index 985eee326..5413af9f4 100644 --- a/application/views/system/messages/htmlRead.php +++ b/application/views/system/messages/htmlRead.php @@ -85,7 +85,7 @@ From c54579ef7de80e0ab64a5ce78f474b36567ef582 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 12 Feb 2020 16:39:00 +0100 Subject: [PATCH 110/157] /system/messages/MessageClient/read sent messages: read them all --- application/models/system/Recipient_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index c2acd2d56..8e2e46513 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -464,7 +464,7 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) - JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) + LEFT JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? AND mr.sent IS NOT NULL AND mr.sentinfo IS NULL From a4bfdfb4a0e590ffdbb9c48b3acc5b26245984b0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Feb 2020 12:49:57 +0100 Subject: [PATCH 111/157] Fixed merge with stashed files in system/messages/htmlWriteTemplate.php --- application/views/system/messages/htmlWriteTemplate.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 77bc168a7..64a8c8236 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -162,12 +162,7 @@
-<<<<<<< Updated upstream - - -======= ->>>>>>> Stashed changes From 21da8dfb51e94004dbecc04153658c3b1efd06aa Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 13 Feb 2020 18:49:01 +0100 Subject: [PATCH 112/157] - Added offsetpunkte Berechnung for Suggestions on admin/edit_gebiet page - offsetpunkte are validated before saving --- cis/testtool/admin/edit_gebiet.php | 8 +- include/gebiet.class.php | 135 ++++++++++++++++++++++++++++- 2 files changed, 141 insertions(+), 2 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 474546d4a..80a205574 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -258,7 +258,13 @@ if ($gebiet_id != '') $hinweis = ''; echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; - echo 'Offsetpunkte (minimale Punkteanzahl)'; + // empfohlene offsetpunkte berechnen und anzeigen + $offsetpunkte = $gebiet->berechneOffsetpunkte($gebiet_id); + if ($gebiet->offsetpunkte != $offsetpunkte) + $hinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte?' ('.$offsetpunkte.' gerundet)':'').''; + else + $hinweis = ''; + echo 'Offsetpunkte (minimale Punkteanzahl)'.$hinweis.''; echo ''; echo 'Maximale Fragenanzahl'; echo ''; diff --git a/include/gebiet.class.php b/include/gebiet.class.php index a83c3319c..0268944cc 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -171,6 +171,11 @@ class gebiet extends basis_db $this->errormsg = 'Maxpunkte muss eine gueltige Zahl sein'; return false; } + if(!is_numeric($this->offsetpunkte) && $this->offsetpunkte!='') + { + $this->errormsg = 'Offsetpunkte muss eine gueltige Zahl sein'; + return false; + } if(!is_numeric($this->antwortenprozeile) || $this->antwortenprozeile<=0) { $this->errormsg = 'AntortenProZeile muss eine gueltige Zahl und groesser als 0 sein'; @@ -571,7 +576,8 @@ class gebiet extends basis_db ( SELECT level, frage_id, sum(punkte) as punkte FROM testtool.tbl_frage JOIN testtool.tbl_vorschlag USING(frage_id) - WHERE gebiet_id=".$this->db_add_param($gebiet_id, FHC_INTEGER)." AND punkte>0 AND level>=".$this->db_add_param($this->level_start)." AND NOT demo + WHERE gebiet_id=".$this->db_add_param($gebiet_id, FHC_INTEGER)." AND punkte>0 + AND level>=".$this->db_add_param($this->level_start)." AND NOT demo GROUP BY level, frage_id ) as a GROUP by level, punkte ORDER BY level"; @@ -616,6 +622,133 @@ class gebiet extends basis_db } } + /** + * Berechnet die offsetpunkte fuer das Gebiet + * + * @param $gebiet_id + */ + public function berechneOffsetpunkte($gebiet_id) + { + if(!$this->load($gebiet_id)) + return false; + + $qry = " + WITH fragen AS ( + SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv + ), + fragenanzahl AS ( + SELECT gebiet_id, level, levelgleichverteilung, + CASE WHEN levelgleichverteilung + THEN + ROUND(COALESCE(maxfragen + * ((SELECT count(*) FROM testtool.tbl_frage f WHERE f.level = tbl_frage.level AND f.gebiet_id = tbl_frage.gebiet_id)::decimal) + / (SELECT count(*) FROM testtool.tbl_frage f WHERE f.gebiet_id = tbl_frage.gebiet_id)::decimal + , (SELECT count(*) FROM testtool.tbl_frage f WHERE f.level = tbl_frage.level AND f.gebiet_id = tbl_frage.gebiet_id) + )) + ELSE + COALESCE(maxfragen, count(*)) + END + AS anzahl + FROM testtool.tbl_frage + JOIN testtool.tbl_gebiet USING (gebiet_id) + WHERE tbl_frage.aktiv + AND tbl_frage.demo = false + GROUP BY gebiet_id, level, levelgleichverteilung, maxfragen + ) + SELECT + tbl_gebiet.gebiet_id, tbl_gebiet.bezeichnung, + tbl_gebiet.multipleresponse, + tbl_gebiet.maxpunkte, tbl_gebiet.maxfragen, + tbl_gebiet.levelgleichverteilung, + tbl_gebiet.level_start, + ( + CASE WHEN tbl_gebiet.levelgleichverteilung THEN + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (min(punkte) + * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + ELSE + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (sum(punkte) + * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + END) *(-1) + WHEN tbl_gebiet.level_start IS NOT NULL THEN + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT min(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND fragen.level = tbl_gebiet.level_start + ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ELSE + (SELECT sum(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) + AND fragen.level = tbl_gebiet.level_start + )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + END) *(-1) + ELSE + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT min(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ELSE + (SELECT sum(punkte) + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) + )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + END) *(-1) + + END) AS offsetpunkte + FROM + testtool.tbl_gebiet + WHERE + EXISTS( + SELECT 1 FROM fragen WHERE fragen.gebiet_id=tbl_gebiet.gebiet_id + ) + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + "; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + { + return $row->offsetpunkte; + } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Offsetpunkte'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Offsetpunkte'; + return false; + } + } + /** * Prueft ob das Gebiet bereits gestartet wurde. Wahlweise pruefling_id oder prestudent_id * From b60e7ed43927332c4cf307696691a452a1c291e0 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Thu, 13 Feb 2020 19:08:37 +0100 Subject: [PATCH 113/157] =?UTF-8?q?Option=20zur=20Ausgabe=20der=20Fragen?= =?UTF-8?q?=20ohne=20L=C3=B6sungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/admin/uebersichtFragen.php | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/cis/testtool/admin/uebersichtFragen.php b/cis/testtool/admin/uebersichtFragen.php index 71d154a1b..50963a337 100644 --- a/cis/testtool/admin/uebersichtFragen.php +++ b/cis/testtool/admin/uebersichtFragen.php @@ -35,7 +35,7 @@ if (!$db = new basis_db()) Testool Fragen Übersicht - + isBerechtigt('basis/testtool', null, 's')) $gebiet = new gebiet(); $gebiet->getAll(); $sprache = (isset($_REQUEST['Sprache'])?$_REQUEST['Sprache']:'German'); -$Auswahlgebiet = (isset($_REQUEST['AuswahlGebiet'])?$_REQUEST['AuswahlGebiet']:''); +$Auswahlgebiet = (isset($_REQUEST['AuswahlGebiet'])?$_REQUEST['AuswahlGebiet']:''); +$loesungen = (isset($_REQUEST['loesungen']) && $_REQUEST['loesungen'] != '' ? true:false); echo ' @@ -76,6 +77,13 @@ else echo' + + + + +
+Mit Lösungen +

'; @@ -208,8 +216,17 @@ if(isset($_REQUEST['AuswahlGebiet'])) $vorschlag = new vorschlag(); $vorschlag->loadVorschlagSprache($vor->vorschlag_id, $sprache); - if($vorschlag->bild =='') - echo ''.$vor->punkte.' '.$vorschlag->text.''; + if($vorschlag->bild == '') + { + if ($loesungen) + { + echo ''.$vor->nummer.''.$vor->punkte.' '.$vorschlag->text.''; + } + else + { + echo ''.$vor->nummer.' '.$vorschlag->text.''; + } + } if($vorschlag->bild!='') { // zeilenumbruch nach 4 bilder @@ -217,7 +234,15 @@ if(isset($_REQUEST['AuswahlGebiet'])) echo ""; echo ""; echo "
"; - echo "
".$vor->punkte.""; + if ($loesungen) + { + echo "
".$vor->punkte.""; + } + else + { + echo ""; + } + $anzahlBild++; } if($vorschlag->audio!='') From 1ac14fca24de1a9c55aec14c3d586e41d02a3d51 Mon Sep 17 00:00:00 2001 From: Nikolaus Krondraf Date: Fri, 14 Feb 2020 07:33:28 +0100 Subject: [PATCH 114/157] =?UTF-8?q?Pr=C3=BCfungstermine=20werden=20nicht?= =?UTF-8?q?=20mehr=20doppelt=20angezeigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/lehre/pruefung/pruefung.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cis/private/lehre/pruefung/pruefung.js.php b/cis/private/lehre/pruefung/pruefung.js.php index b207c94e5..aafcf9710 100644 --- a/cis/private/lehre/pruefung/pruefung.js.php +++ b/cis/private/lehre/pruefung/pruefung.js.php @@ -337,10 +337,10 @@ function writePruefungsTable(e, data, anmeldung) { var row = ""; var teilnehmer = ""; - var button = ""; row += ""+e.organisationseinheit+""+e.lehrveranstaltung[0].bezeichnung+"
("+e.lehrveranstaltung[0].lehrform_kurzbz+", "+e.lehrveranstaltung[0].ects+" ECTS, "+e.pruefung.mitarbeiter_uid+")"; e.pruefung.termine.forEach(function(d){ - var storno = false; + var button = ""; + var storno = false; var anmeldung_id = null; data.result.anmeldungen.forEach(function(anmeldung){ if((anmeldung.pruefungstermin_id === d.pruefungstermin_id) && (anmeldung.lehrveranstaltung_id === e.lehrveranstaltung[0].lehrveranstaltung_id)) From c81a25988e30affe25bb3950b716a030a1c97a15 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Fri, 14 Feb 2020 15:31:20 +0100 Subject: [PATCH 115/157] Historie-Feld nebeneinander --- content/student/studentdetailoverlay.xul.php | 326 ++++++++++--------- 1 file changed, 164 insertions(+), 162 deletions(-) diff --git a/content/student/studentdetailoverlay.xul.php b/content/student/studentdetailoverlay.xul.php index aabe442d4..0a014b20a 100644 --- a/content/student/studentdetailoverlay.xul.php +++ b/content/student/studentdetailoverlay.xul.php @@ -504,170 +504,172 @@ echo '';
diff --git a/public/js/messaging/writeReply.js b/public/js/messaging/writeReply.js index aeb13dc2c..c78748889 100644 --- a/public/js/messaging/writeReply.js +++ b/public/js/messaging/writeReply.js @@ -13,7 +13,7 @@ function sendReply() receiver_id: $('#receiver_id').val(), relationmessage_id: $('#relationmessage_id').val(), token: $('#token').val(), - subject: $('#subject').html(), + subject: $('#subject').val(), body: tinyMCE.get("body").getContent() }, { From a063a73c412f234d8f265e7015440770cceb745d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Feb 2020 19:26:55 +0100 Subject: [PATCH 120/157] reihungst admin edit_gebiet.php: checking that there are same negativpoints for one gebiet and one level before showing offsetpunkte suggestion for RT gebiete --- cis/testtool/admin/edit_gebiet.php | 14 ++++--- include/gebiet.class.php | 59 ++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 80a205574..5610679b4 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -259,12 +259,16 @@ if ($gebiet_id != '') echo 'Maximale Punkteanzahl'.$hinweis.''; echo ''; // empfohlene offsetpunkte berechnen und anzeigen + $offsethinweis = ''; $offsetpunkte = $gebiet->berechneOffsetpunkte($gebiet_id); - if ($gebiet->offsetpunkte != $offsetpunkte) - $hinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte?' ('.$offsetpunkte.' gerundet)':'').''; - else - $hinweis = ''; - echo 'Offsetpunkte (minimale Punkteanzahl)'.$hinweis.''; + if ($offsetpunkte) + { + $offsetwarnung = strlen($gebiet->errormsg) > 0 ? ' (HINWEIS: '.$gebiet->errormsg.')' : ''; + + if ($gebiet->offsetpunkte != $offsetpunkte) + $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').$offsetwarnung.''; + } + echo 'Offsetpunkte (minimale Punkteanzahl)'.$offsethinweis.''; echo ''; echo 'Maximale Fragenanzahl'; echo ''; diff --git a/include/gebiet.class.php b/include/gebiet.class.php index 0268944cc..dbdd50b3d 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -632,6 +632,49 @@ class gebiet extends basis_db if(!$this->load($gebiet_id)) return false; + $checkqry = "SELECT COUNT (uniquepoints) AS count_uniquepoints + FROM ( + SELECT gebiet_id, + level, + count(DISTINCT punkte), + CASE WHEN count(DISTINCT punkte) > 1 THEN FALSE ELSE TRUE END AS uniquepoints + FROM ( + SELECT tbl_frage.gebiet_id, + tbl_frage.level, + CASE WHEN multipleresponse THEN sum(punkte) ELSE min(punkte) END AS punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + JOIN testtool.tbl_gebiet USING (gebiet_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + GROUP BY tbl_frage.gebiet_id, multipleresponse, tbl_frage.level, tbl_frage.frage_id + ) p + GROUP BY gebiet_id, level + ) pu + WHERE uniquepoints = FALSE"; + + if($this->db_query($checkqry)) + { + if($row = $this->db_fetch_object()) + { + if (!is_numeric($row->count_uniquepoints) || $row->count_uniquepoints > 0) + $this->errormsg = 'Negativpunkte sind nicht für alle Fragen gleich hoch!'; + } + else + { + $this->errormsg = 'Fehler beim Prüfen der Offsetpunkte'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Prüfen der Offsetpunkte'; + return false; + } + $qry = " WITH fragen AS ( SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte @@ -688,7 +731,7 @@ class gebiet extends basis_db AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) GROUP BY fragen.gebiet_id, level ) pkteprolevel) - END) *(-1) + END) WHEN tbl_gebiet.level_start IS NOT NULL THEN (CASE WHEN tbl_gebiet.multipleresponse=false THEN ( @@ -696,31 +739,31 @@ class gebiet extends basis_db FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND fragen.level = tbl_gebiet.level_start - ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) ELSE (SELECT sum(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) AND fragen.level = tbl_gebiet.level_start - )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - END) *(-1) + )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + END) ELSE (CASE WHEN tbl_gebiet.multipleresponse=false THEN ( SELECT min(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - ) * (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) ELSE (SELECT sum(punkte) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - )* (SELECT fragenanzahl.anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - END) *(-1) + )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + END) - END) AS offsetpunkte + END) * (-1) AS offsetpunkte FROM testtool.tbl_gebiet WHERE From 0db611ed270d2128cc80b37f0707a8cdf8dc2dd5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 18 Feb 2020 15:19:58 +0100 Subject: [PATCH 121/157] - Added new config entry in mail config file called enable_debug - If enable_debug is true then info about the mail are logged into the CI error logs - Fixed queries to get sent and received messages with Recipient_model, now messages for which a notice email was not sent are retrieved and messages are sorted by insertamum - CL/Messages_model: - Before setting a message as read check if a record is already present - If the recipient is a prestudent then in table tbl_msg_message oe_kurzbz is set with the ou of the prestudent - The sender id (person_id) now is get from the currently logged user also when replying - MessageLib->_sendNoticeEmails checks that the message was sent only from FAS (NOT from infocenter) --- application/config/mail.php | 3 + application/libraries/MailLib.php | 50 ++++++++++----- application/libraries/MessageLib.php | 7 ++- application/models/CL/Messages_model.php | 61 +++++++++++++++---- application/models/system/Recipient_model.php | 22 +++---- 5 files changed, 100 insertions(+), 43 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index 2163bc122..9d577720d 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -29,3 +29,6 @@ $config['wrapchars'] = 76; // Character count to wrap at. $config['mailtype'] = 'html'; // html or text $config['priority'] = 3; // Email Priority. 1 = highest. 5 = lowest. 3 = normal $config['validate'] = false; // If true then the email address will be validated + +// If enabled will be logged info about emails in Codeigniter error logs +$config['enable_debug'] = false; diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php index e9e571f6c..dbbc22f08 100644 --- a/application/libraries/MailLib.php +++ b/application/libraries/MailLib.php @@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class MailLib { + const ENABLE_DEBUG = 'enable_debug'; + private $sended; // Sended email counter // Properties for storing the configuration @@ -15,6 +17,8 @@ class MailLib private $email_time_range; private $email_from_system; + private $_ci; // Codeigniter instance + /** * Class constructor */ @@ -24,16 +28,16 @@ class MailLib $this->sended = 0; // Get CI instance - $this->ci =& get_instance(); + $this->_ci =& get_instance(); // The second parameter is used to avoiding name collisions in the config array - $this->ci->config->load('mail', true); + $this->_ci->config->load('mail', true); // CI Email library - $this->ci->load->library('email'); + $this->_ci->load->library('email'); // Initializing email library with the loaded configurations - $this->ci->email->initialize($this->ci->config->config['mail']); + $this->_ci->email->initialize($this->_ci->config->config['mail']); // Set the configuration properties with the standard configuration values $this->email_number_to_sent = $this->getEmailCfgItem('email_number_to_sent'); @@ -48,6 +52,22 @@ class MailLib */ public function send($from, $to, $subject, $message, $alias = '', $cc = null, $bcc = null, $altMessage = '', $bulk = false, $autogenerated = false) { + // If it is configured then log mail info into the CI error logs + if ($this->getEmailCfgItem(self::ENABLE_DEBUG) === true) + { + $this->_ci->load->library('LogLib'); // Loads logging library + + // Log them all! + $this->_ci->loglib->logError('From: '.$from); + $this->_ci->loglib->logError('To: '.$to); + $this->_ci->loglib->logError('Subject: '.$subject); + $this->_ci->loglib->logError('Message: '.$message); + $this->_ci->loglib->logError('Alias: '.$alias); + $this->_ci->loglib->logError('CC: '.$cc); + $this->_ci->loglib->logError('BCC: '.$bcc); + $this->_ci->loglib->logError('Alternative message: '.$altMessage); + } + // If from is not specified then use the standard one if (is_null($from) || $from == '') { @@ -67,7 +87,7 @@ class MailLib } } - $this->ci->email->from($from, $alias); + $this->_ci->email->from($from, $alias); // Check if the email address of the debug recipient is a valid one $recipient = $to; @@ -83,20 +103,20 @@ class MailLib $recipientBCC = MAIL_DEBUG; } - $this->ci->email->to($recipient); - if (!is_null($recipientCC)) $this->ci->email->cc($recipientCC); - if (!is_null($recipientBCC)) $this->ci->email->bcc($recipientBCC); - $this->ci->email->subject($subject); - $this->ci->email->message($message); - if (!isEmptyString($altMessage)) $this->ci->email->set_alt_message($altMessage); + $this->_ci->email->to($recipient); + if (!is_null($recipientCC)) $this->_ci->email->cc($recipientCC); + if (!is_null($recipientBCC)) $this->_ci->email->bcc($recipientBCC); + $this->_ci->email->subject($subject); + $this->_ci->email->message($message); + if (!isEmptyString($altMessage)) $this->_ci->email->set_alt_message($altMessage); if($bulk) - $this->ci->email->set_header('Precedence', 'bulk'); + $this->_ci->email->set_header('Precedence', 'bulk'); if($autogenerated) - $this->ci->email->set_header('Auto-Submitted', 'auto-generated'); + $this->_ci->email->set_header('Auto-Submitted', 'auto-generated'); // Avoid printing on standard output ugly error messages - $result = @$this->ci->email->send(); + $result = @$this->_ci->email->send(); // If the email was succesfully sended then increment the counter // and checks if it has to wait until the sending of the next @@ -171,6 +191,6 @@ class MailLib */ private function getEmailCfgItem($itemName) { - return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX); + return $this->_ci->config->item($itemName, EMAIL_CONFIG_INDEX); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 240055978..3a8f133cf 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -575,8 +575,9 @@ class MessageLib // Use the degree program email if (hasData($studiengangResult)) $message->receiverContact = getData($studiengangResult)[0]->email; } - // If message was sent from FAS - elseif (!isEmptyString($message->sender_ou)) + // If message was sent from FAS and NOT from infocenter + elseif (!isEmptyString($message->sender_ou) + && !array_search($message->sender_ou, $this->_ci->config->item(self::CFG_OU_RECEIVERS_NO_NOTICE))) { // If the recipient organisation unit is NOT in the list of organisation units that sent only to private emails if (array_search($message->receiver_ou, $this->_ci->config->item(self::CFG_OU_RECEIVERS_PRIVATE)) === false) @@ -592,7 +593,7 @@ class MessageLib } // Otherwise try with the private email - if ($message->receiverContact == null) + if (isEmptyString($message->receiverContact)) { $privateEmailResult = $this->_getPrivateEmail($message->receiver_id); if (isError($privateEmailResult)) return $privateEmailResult; // if an error occured then return it diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index e2c5c34c2..a841e266a 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -62,15 +62,31 @@ class Messages_model extends CI_Model // Loads needed models $this->load->model('system/MsgStatus_model', 'MsgStatusModel'); - // Set date used to insert - $statusData = array( - 'message_id' => $message_id, - 'person_id' => $person_id, - 'status' => MSG_STATUS_READ, - 'insertvon' => getAuthUID() + $statuResult = $this->MsgStatusModel->loadWhere( + array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ + ) ); - return $this->MsgStatusModel->insert($statusData); // insert and return result + if (isError($statuResult)) return $statuResult; + if (!hasData($statuResult)) + { + // Set date used to insert + return $this->MsgStatusModel->insert( + array( + 'message_id' => $message_id, + 'person_id' => $person_id, + 'status' => MSG_STATUS_READ, + 'insertvon' => getAuthUID() + ) + ); // insert and return result + } + else + { + return success('Already set as read'); + } } /** @@ -348,23 +364,43 @@ class Messages_model extends CI_Model elseif ($type == self::TYPE_PRESTUDENTS) // otherwise prestudents were given { $msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($recipients_ids); + + // Retrieve organisation unit for the recipients + $organisationUnitsResult = $this->PrestudentModel->getOrganisationunits($recipients_ids); + if (isError($organisationUnitsResult)) return $organisationUnitsResult; + if (hasData($organisationUnitsResult)) $senderOUArray = getData($organisationUnitsResult); } if (isError($msgVarsData)) show_error(getError($msgVarsData)); if (!hasData($msgVarsData)) show_error('No recipients were given'); + $senderOU = null; // sender organisation unit only for presetudents + $receiversCounter = 0; // a counter + + // Looping on receivers data foreach (getData($msgVarsData) as $receiver) { $msgVarsDataArray = $this->_lowerReplaceSpaceArrayKeys((array)$receiver); // replaces array keys - $parsedSubject = parseText($subject, $msgVarsDataArray); $parsedBody = parseText($body, $msgVarsDataArray); + // If exist an organisation unit for this prestudent and it is valid + if (isset($senderOUArray[$receiversCounter]) + && isset($senderOUArray[$receiversCounter]->oe_kurzbz) + && !isEmptyString($senderOUArray[$receiversCounter]->oe_kurzbz)) + { + $senderOU = $senderOUArray[$receiversCounter]->oe_kurzbz; + } + else + { + $senderOU = null; + } + $message = $this->messagelib->sendMessageUser( $msgVarsDataArray['person_id'], // receiverPersonId $parsedSubject, // subject $parsedBody, // body $sender_id, // sender_id - null, // senderOU + $senderOU, // senderOU $relationmessage_id, // relationmessage_id MSG_PRIORITY_NORMAL // priority ); @@ -378,6 +414,8 @@ class Messages_model extends CI_Model $personLog = $this->_personLog($sender_id, $msgVarsDataArray['person_id'], getData($message)[0]); if (isError($personLog)) return $personLog; } + + $receiversCounter++; // increment the counter } return success('Messages sent successfully'); @@ -452,7 +490,8 @@ class Messages_model extends CI_Model show_error('An error occurred while sending your message, please contact the site administrator'); } - $sender_id = getData($messageResult)[0]->receiver_id; + $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); $message = $this->messagelib->sendMessageUser( $receiver_id, // receiverPersonId @@ -484,6 +523,7 @@ class Messages_model extends CI_Model if (isEmptyString($body)) return error('Body is an empty string'); $sender_id = getAuthPersonId(); + if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); $message = $this->messagelib->sendMessageOU( $receiverOU, // receiverPersonId @@ -672,7 +712,6 @@ class Messages_model extends CI_Model */ private function _prepareHtmlWriteTemplate($info, $message_id, $recipient_id) { - // Checks that info parameter is valid if (isError($info)) show_error(getError($info)); if (!hasData($info)) show_error('No recipients were given'); diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index bc7ab246f..cea11a7a7 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -314,7 +314,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent AS sent, + mm.insertamum AS sent, p.vorname, p.nachname, MAX(ms.status) AS status, @@ -325,13 +325,11 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_status ms ON (ms.message_id = mr.message_id AND ms.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mm.person_id) WHERE mr.person_id = ? - AND mr.sent IS NOT NULL - AND mr.sentinfo IS NULL GROUP BY mr.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum, p.vorname, p.nachname, ms.person_id, @@ -342,7 +340,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mrou.sent AS sent, + mm.insertamum AS sent, pr.vorname, pr.nachname, MAX(ms.status) AS status, @@ -362,13 +360,11 @@ class Recipient_model extends DB_Model JOIN public.tbl_msg_status ms ON (ms.message_id = mrou.message_id AND ms.person_id = mrou.person_id) JOIN public.tbl_person pr ON (pr.person_id = mm.person_id) WHERE p.person_id = ? - AND mrou.sent IS NOT NULL - AND mrou.sentinfo IS NULL GROUP BY mrou.message_id, mm.relationmessage_id, mm.subject, mm.body, - mrou.sent, + mm.insertamum, pr.vorname, pr.nachname, ms.person_id, @@ -387,7 +383,7 @@ class Recipient_model extends DB_Model mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum AS sent, p.person_id, p.vorname, p.nachname, @@ -397,24 +393,22 @@ class Recipient_model extends DB_Model mr.token FROM public.tbl_msg_message mm JOIN public.tbl_msg_recipient mr ON (mr.message_id = mm.message_id) - JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND mr.person_id = mr.person_id) + JOIN public.tbl_msg_status ms ON (ms.message_id = mm.message_id AND ms.person_id = mr.person_id) JOIN public.tbl_person p ON (p.person_id = mr.person_id) LEFT JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = mr.oe_kurzbz) WHERE mm.person_id = ? - AND mr.sent IS NOT NULL - AND mr.sentinfo IS NULL GROUP BY mm.message_id, mm.relationmessage_id, mm.subject, mm.body, - mr.sent, + mm.insertamum, p.person_id, p.vorname, p.nachname, ms.person_id, oe.bezeichnung, mr.token - ORDER BY mr.sent DESC'; + ORDER BY sent DESC'; return $this->execQuery($sql, array($person_id)); } From d74a516202a776cbc0752810f6ca54dd835ec1e6 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Feb 2020 17:33:44 +0100 Subject: [PATCH 122/157] - testtool edit_gebiet.php: hinweis for suggestion offsetpunkteanzahl is always shown --- cis/testtool/admin/edit_gebiet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cis/testtool/admin/edit_gebiet.php b/cis/testtool/admin/edit_gebiet.php index 5610679b4..68c502577 100644 --- a/cis/testtool/admin/edit_gebiet.php +++ b/cis/testtool/admin/edit_gebiet.php @@ -265,8 +265,8 @@ if ($gebiet_id != '') { $offsetwarnung = strlen($gebiet->errormsg) > 0 ? ' (HINWEIS: '.$gebiet->errormsg.')' : ''; - if ($gebiet->offsetpunkte != $offsetpunkte) - $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').$offsetwarnung.''; + $offsethinweis = ' empfohlene Offsetpunkteanzahl: '.round($offsetpunkte).(round($offsetpunkte) != $offsetpunkte ? ' ('.$offsetpunkte.' gerundet)' : '').''; + $offsethinweis .= ''.$offsetwarnung.''; } echo 'Offsetpunkte (minimale Punkteanzahl)'.$offsethinweis.''; echo ''; From 0b3d5e19a37fcde97901874a7d3436648c993f72 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 20 Feb 2020 14:39:37 +0100 Subject: [PATCH 123/157] CL/Messages_model->sendReply now uses as sender id the logged user person id or the previous message recipient id --- application/models/CL/Messages_model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index a841e266a..dd9655131 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -472,6 +472,7 @@ class Messages_model extends CI_Model /** * Send a reply to a single recipient for a message identified by a token (no templates are used) + * NOTE: this method could be also called from not authenticated controllers */ public function sendReply($receiver_id, $subject, $body, $relationmessage_id, $token) { @@ -490,8 +491,9 @@ class Messages_model extends CI_Model show_error('An error occurred while sending your message, please contact the site administrator'); } - $sender_id = getAuthPersonId(); - if (!is_numeric($sender_id)) return error('The current logged user person_id is not defined'); + // If the user is logged then use its person id as sender id, otherwise get the receiver id of the previous message + $sender_id = isLogged() ? getAuthPersonId() : getData($messageResult)[0]->receiver_id; + if (!is_numeric($sender_id)) return error('The sender id is not valid'); $message = $this->messagelib->sendMessageUser( $receiver_id, // receiverPersonId From 1ac1c118d530efb7e28729297a31aa2f154b6c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 15:53:43 +0100 Subject: [PATCH 124/157] Fixed Message Reply --- application/models/CL/Messages_model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index dd9655131..de6ec5a10 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -271,9 +271,9 @@ class Messages_model extends CI_Model if (isError($isEmployeeResult)) show_error(getError($isEmployeeResult)); if (hasData($isEmployeeResult)) $isEmployee = true; - // If the sender is an employee and are present configurations to reply + // If the sender is not an employee and are present configurations to reply $hrefReply = ''; - if ($isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) + if (!$isEmployee && !isEmptyString($this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL))) { $hrefReply = $this->config->item(MessageLib::CFG_MESSAGE_SERVER). $this->config->item(MessageLib::CFG_REDIRECT_VIEW_MESSAGE_URL). From 9a9b847138ba5c32842ae43b4775adc731c41775 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 20 Feb 2020 16:21:31 +0100 Subject: [PATCH 125/157] Fixed Tabulator include in FHC-Header --- application/views/templates/FHC-Header.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index c569d2389..5eec10f43 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -182,7 +182,11 @@ } // Tabulator JS - if ($tabulator === true) generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + if ($tabulator === true) + { + generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/tabulator.min.js'); + generateJSsInclude('vendor/olifolkerd/tabulator/dist/js/jquery_wrapper.min.js'); + } // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); From fc9ae760b5a7849c2287d2678eca3140cd2ca209 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Feb 2020 17:07:57 +0100 Subject: [PATCH 126/157] public.vw_msg_vars: added variables semester, Studiengangsassistenz, relative Prio --- system/dbupdate_3.3.php | 174 ++++++++++++++++++++++++++-------------- 1 file changed, 116 insertions(+), 58 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index a7d4011cc..de3df43c0 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3462,77 +3462,135 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu } // iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM public.vw_msg_vars LIMIT 1')) +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Priorität" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( SELECT DISTINCT ON(p.person_id, pr.prestudent_id) p.person_id, - pr.prestudent_id AS prestudent_id, - p.nachname AS "Nachname", - p.vorname AS "Vorname", - p.anrede AS "Anrede", - a.strasse AS "Strasse", - a.ort AS "Ort", - a.plz AS "PLZ", - a.gemeinde AS "Gemeinde", - a.langtext AS "Nation", - ke.kontakt AS "Email", - kt.kontakt AS "Telefon", - s.bezeichnung AS "Studiengang DE", - s.english AS "Studiengang EN", - st.bezeichnung AS "Typ", - last_prestudent_status.orgform_kurzbz AS "Orgform", - p.zugangscode AS "Zugangscode", - bk.iban AS "IBAN Studiengang", - bk.bic AS "BIC Studiengang" - FROM public.tbl_person p - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp = \'email\' - ORDER BY kontakt_id DESC - ) ke USING(person_id) - LEFT JOIN ( - SELECT person_id, - kontakt - FROM public.tbl_kontakt - WHERE zustellung = TRUE - AND kontakttyp IN (\'telefon\', \'mobil\') - ORDER BY kontakt_id DESC - ) kt USING(person_id) - LEFT JOIN ( - SELECT person_id, - strasse, - ort, - plz, - gemeinde, - langtext - FROM public.tbl_adresse + pr.prestudent_id AS prestudent_id, + p.nachname AS "Nachname", + p.vorname AS "Vorname", + p.anrede AS "Anrede", + a.strasse AS "Strasse", + a.ort AS "Ort", + a.plz AS "PLZ", + a.gemeinde AS "Gemeinde", + a.langtext AS "Nation", + ke.kontakt AS "Email", + kt.kontakt AS "Telefon", + s.bezeichnung AS "Studiengang DE", + s.english AS "Studiengang EN", + st.bezeichnung AS "Typ", + last_prestudent_status.orgform_kurzbz AS "Orgform", + p.zugangscode AS "Zugangscode", + bk.iban AS "IBAN Studiengang", + bk.bic AS "BIC Studiengang", + s.studiengang_kz AS "Studiengangskennzahl", + first_prestudent_status.ausbildungssemester AS "Einstiegssemester", + first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", + ass.vorname AS "Vorname Studiengangsassistenz", + ass.nachname AS "Nachname Studiengangsassistenz", + ass.telefonklappe AS "Durchwahl Studiengangsassistenz", + (SELECT count(*) + FROM ( + SELECT pss.prestudent_id, pss.person_id, priorisierung, + ( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pss.prestudent_id + ORDER BY datum DESC, + tbl_prestudentstatus.insertamum DESC LIMIT 1 + ) AS laststatus + FROM public.tbl_prestudent pss + JOIN public.tbl_prestudentstatus USING (prestudent_id) + WHERE person_id = ( + SELECT person_id + FROM public.tbl_prestudent + WHERE prestudent_id = pr.prestudent_id + ) + AND studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pr.prestudent_id + AND status_kurzbz = \'Interessent\' LIMIT 1 + ) + AND status_kurzbz = \'Interessent\' + ) prest + WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') + AND priorisierung <= pr.priorisierung) AS "Relative Priorität" + FROM public.tbl_person p + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp = \'email\' + ORDER BY kontakt_id DESC + ) ke USING(person_id) + LEFT JOIN ( + SELECT person_id, + kontakt + FROM public.tbl_kontakt + WHERE zustellung = TRUE + AND kontakttyp IN (\'telefon\', \'mobil\') + ORDER BY kontakt_id DESC + ) kt USING(person_id) + LEFT JOIN ( + SELECT person_id, + strasse, + ort, + plz, + gemeinde, + langtext + FROM public.tbl_adresse LEFT JOIN bis.tbl_nation ON(bis.tbl_nation.nation_code = public.tbl_adresse.nation) - WHERE public.tbl_adresse.heimatadresse = TRUE - ORDER BY adresse_id DESC - ) a USING(person_id) + WHERE public.tbl_adresse.heimatadresse = TRUE + ORDER BY adresse_id DESC + ) a USING(person_id) LEFT JOIN public.tbl_prestudent pr USING(person_id) INNER JOIN public.tbl_studiengang s USING(studiengang_kz) INNER JOIN public.tbl_studiengangstyp st USING(typ) LEFT JOIN ( - SELECT DISTINCT ON (ps.prestudent_id) tbl_studienplan.orgform_kurzbz, ps.prestudent_id - FROM public.tbl_prestudent ps - JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id - JOIN lehre.tbl_studienplan USING(studienplan_id) - ORDER BY ps.prestudent_id DESC, - tbl_prestudentstatus.datum DESC, - tbl_prestudentstatus.insertamum DESC, - tbl_prestudentstatus.ext_id DESC - ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id + SELECT DISTINCT ON (ps.prestudent_id) ps.prestudent_id, tbl_studienplan.orgform_kurzbz + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN lehre.tbl_studienplan USING(studienplan_id) + ORDER BY ps.prestudent_id DESC, + tbl_prestudentstatus.datum DESC, + tbl_prestudentstatus.insertamum DESC, + tbl_prestudentstatus.ext_id DESC + ) last_prestudent_status ON pr.prestudent_id = last_prestudent_status.prestudent_id LEFT JOIN ( + SELECT DISTINCT ON (ps.prestudent_id) ps.prestudent_id, tbl_prestudentstatus.ausbildungssemester, + studiensemester_kurzbz, tbl_studiensemester.bezeichnung AS studiensemester, + tbl_studienordnung.studiengang_kz + FROM public.tbl_prestudent ps + JOIN public.tbl_prestudentstatus ON ps.prestudent_id = tbl_prestudentstatus.prestudent_id + JOIN public.tbl_studiensemester USING (studiensemester_kurzbz) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + WHERE tbl_prestudentstatus.status_kurzbz = \'Interessent\' + ORDER BY ps.prestudent_id ASC, + tbl_prestudentstatus.datum ASC, + tbl_prestudentstatus.insertamum ASC, + tbl_prestudentstatus.ext_id ASC + ) first_prestudent_status ON pr.prestudent_id = first_prestudent_status.prestudent_id + LEFT JOIN ( + SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe + FROM public.tbl_benutzerfunktion + JOIN public.tbl_benutzer USING (uid) + JOIN public.tbl_person USING (person_id) + JOIN public.tbl_mitarbeiter on tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid + WHERE tbl_benutzerfunktion.funktion_kurzbz = \'ass\' + AND NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()) + ORDER BY tbl_benutzerfunktion.oe_kurzbz, tbl_benutzerfunktion.insertamum DESC NULLS LAST, datum_von DESC NULLS LAST + ) ass ON s.oe_kurzbz = ass.oe_kurzbz + LEFT JOIN ( SELECT DISTINCT ON (oe_kurzbz, orgform_kurzbz) oe_kurzbz, orgform_kurzbz, iban, bic FROM tbl_bankverbindung WHERE oe_kurzbz IS NOT NULL ORDER BY oe_kurzbz, orgform_kurzbz, tbl_bankverbindung.insertamum DESC,tbl_bankverbindung.iban - )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) + )bk ON s.oe_kurzbz = bk.oe_kurzbz AND (last_prestudent_status.orgform_kurzbz = bk.orgform_kurzbz OR bk.orgform_kurzbz IS NULL) WHERE p.aktiv = TRUE ORDER BY p.person_id ASC, pr.prestudent_id ASC );'; @@ -3540,7 +3598,7 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang" FROM if(!$db->db_query($qry)) echo 'public.vw_msg_vars: '.$db->db_last_error().'
'; else - echo '
public.vw_msg_vars iban und bic added'; + echo '
public.vw_msg_vars IBAN Studiengang, BIC Studiengang, Studiengangskennzahl, Einstiegssemester, Einstiegsstudiensemester, Vorname Studiengangsassistenz, Nachname Studiengangsassistenz, Durchwahl Studiengangsassistenz, Relative Priorität added'; } // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen From 7043422fe9c96d7a443bb4bb75dd4eac6ef86d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 18:11:37 +0100 Subject: [PATCH 127/157] Zahlenformat bei Lehrauftragsexport korrigiert --- content/statistik/lehrauftragsliste_mail.xls.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/statistik/lehrauftragsliste_mail.xls.php b/content/statistik/lehrauftragsliste_mail.xls.php index 6c701c4f5..853be72fe 100644 --- a/content/statistik/lehrauftragsliste_mail.xls.php +++ b/content/statistik/lehrauftragsliste_mail.xls.php @@ -125,15 +125,15 @@ $format_colored =& $workbook->addFormat(); $format_colored->setFgColor(10); $format_number_colored =& $workbook->addFormat(); -$format_number_colored->setNumFormat('0, 0.00'); +$format_number_colored->setNumFormat('0,0.00'); //$format_number_colored->setNumFormat('0.00'); $format_number_colored->setFgColor(10); $format_number =& $workbook->addFormat(); -$format_number->setNumFormat('0, 0.00'); +$format_number->setNumFormat('0,0.00'); $format_number_bold =& $workbook->addFormat(); -$format_number_bold->setNumFormat('0, 0.00'); +$format_number_bold->setNumFormat('0,0.00'); //$format_number_bold->setNumFormat('0.00'); $format_number_bold->setBold(); From f1cf82c107267f606e61599dac64cd28a9a30211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Feb 2020 18:48:15 +0100 Subject: [PATCH 128/157] =?UTF-8?q?Spalte=20Alias=20hinzugef=C3=BCgt,=20Sp?= =?UTF-8?q?alte=20Prio=20umbenannt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/dbupdate_3.3.php | 107 ++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index de3df43c0..a3965780a 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3462,62 +3462,63 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu } // iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Priorität" FROM public.vw_msg_vars LIMIT 1')) +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( SELECT DISTINCT ON(p.person_id, pr.prestudent_id) p.person_id, - pr.prestudent_id AS prestudent_id, - p.nachname AS "Nachname", - p.vorname AS "Vorname", - p.anrede AS "Anrede", - a.strasse AS "Strasse", - a.ort AS "Ort", - a.plz AS "PLZ", - a.gemeinde AS "Gemeinde", - a.langtext AS "Nation", - ke.kontakt AS "Email", - kt.kontakt AS "Telefon", - s.bezeichnung AS "Studiengang DE", - s.english AS "Studiengang EN", - st.bezeichnung AS "Typ", - last_prestudent_status.orgform_kurzbz AS "Orgform", - p.zugangscode AS "Zugangscode", - bk.iban AS "IBAN Studiengang", - bk.bic AS "BIC Studiengang", - s.studiengang_kz AS "Studiengangskennzahl", - first_prestudent_status.ausbildungssemester AS "Einstiegssemester", - first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", - ass.vorname AS "Vorname Studiengangsassistenz", - ass.nachname AS "Nachname Studiengangsassistenz", - ass.telefonklappe AS "Durchwahl Studiengangsassistenz", - (SELECT count(*) - FROM ( - SELECT pss.prestudent_id, pss.person_id, priorisierung, - ( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus - WHERE prestudent_id = pss.prestudent_id - ORDER BY datum DESC, - tbl_prestudentstatus.insertamum DESC LIMIT 1 - ) AS laststatus - FROM public.tbl_prestudent pss - JOIN public.tbl_prestudentstatus USING (prestudent_id) - WHERE person_id = ( - SELECT person_id - FROM public.tbl_prestudent - WHERE prestudent_id = pr.prestudent_id - ) - AND studiensemester_kurzbz = ( - SELECT studiensemester_kurzbz - FROM public.tbl_prestudentstatus - WHERE prestudent_id = pr.prestudent_id - AND status_kurzbz = \'Interessent\' LIMIT 1 - ) - AND status_kurzbz = \'Interessent\' - ) prest - WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') - AND priorisierung <= pr.priorisierung) AS "Relative Priorität" + pr.prestudent_id AS prestudent_id, + p.nachname AS "Nachname", + p.vorname AS "Vorname", + p.anrede AS "Anrede", + a.strasse AS "Strasse", + a.ort AS "Ort", + a.plz AS "PLZ", + a.gemeinde AS "Gemeinde", + a.langtext AS "Nation", + ke.kontakt AS "Email", + kt.kontakt AS "Telefon", + s.bezeichnung AS "Studiengang DE", + s.english AS "Studiengang EN", + st.bezeichnung AS "Typ", + last_prestudent_status.orgform_kurzbz AS "Orgform", + p.zugangscode AS "Zugangscode", + bk.iban AS "IBAN Studiengang", + bk.bic AS "BIC Studiengang", + s.studiengang_kz AS "Studiengangskennzahl", + first_prestudent_status.ausbildungssemester AS "Einstiegssemester", + first_prestudent_status.studiensemester AS "Einstiegsstudiensemester", + ass.vorname AS "Vorname Studiengangsassistenz", + ass.nachname AS "Nachname Studiengangsassistenz", + ass.telefonklappe AS "Durchwahl Studiengangsassistenz", + ass.alias AS "Alias Studiengangsassistenz", + (SELECT count(*) + FROM ( + SELECT pss.prestudent_id, pss.person_id, priorisierung, + ( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pss.prestudent_id + ORDER BY datum DESC, + tbl_prestudentstatus.insertamum DESC LIMIT 1 + ) AS laststatus + FROM public.tbl_prestudent pss + JOIN public.tbl_prestudentstatus USING (prestudent_id) + WHERE person_id = ( + SELECT person_id + FROM public.tbl_prestudent + WHERE prestudent_id = pr.prestudent_id + ) + AND studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id = pr.prestudent_id + AND status_kurzbz = \'Interessent\' LIMIT 1 + ) + AND status_kurzbz = \'Interessent\' + ) prest + WHERE laststatus NOT IN (\'Abbrecher\', \'Abgewiesener\', \'Absolvent\') + AND priorisierung <= pr.priorisierung) AS "Relative Prio" FROM public.tbl_person p LEFT JOIN ( SELECT person_id, @@ -3576,7 +3577,7 @@ if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Stu tbl_prestudentstatus.ext_id ASC ) first_prestudent_status ON pr.prestudent_id = first_prestudent_status.prestudent_id LEFT JOIN ( - SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe + SELECT DISTINCT ON (tbl_benutzerfunktion.oe_kurzbz) vorname, nachname, oe_kurzbz, telefonklappe, alias FROM public.tbl_benutzerfunktion JOIN public.tbl_benutzer USING (uid) JOIN public.tbl_person USING (person_id) From ff7f150cb63612e1ecd14f3b8cee7429ac54d424 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Thu, 20 Feb 2020 20:42:37 +0100 Subject: [PATCH 129/157] prioritizationJob created --- .../controllers/jobs/ReihungstestJob.php | 994 +++++++++++------- 1 file changed, 619 insertions(+), 375 deletions(-) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 84a5fe614..948eeb0b8 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -3,30 +3,32 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class ReihungstestJob extends CLI_Controller { - /** - * Constructor - */ - public function __construct() - { - parent::__construct(); + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); - // Load models - $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); - $this->load->model('crm/RtStudienplan_model', 'RtStudienplanModel'); - $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); - $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + // Load models + $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); + $this->load->model('crm/RtStudienplan_model', 'RtStudienplanModel'); + $this->load->model('crm/Konto_model', 'KontoModel'); + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); - // Load helpers - $this->load->helper('hlp_sancho_helper'); - } + // Load helpers + $this->load->helper('hlp_sancho_helper'); + } - /** - * runReihungstestJob - */ - public function runReihungstestJob() - { - // Get study plans that have no assigned placement tests yet - $result = $this->ReihungstestModel->checkMissingReihungstest(); + /** + * runReihungstestJob + */ + public function runReihungstestJob() + { + // Get study plans that have no assigned placement tests yet + $result = $this->ReihungstestModel->checkMissingReihungstest(); $missing_rt_arr = array(); if (hasData($result)) @@ -38,8 +40,8 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - // Get free places - $result = $this->ReihungstestModel->getFreePlaces(); + // Get free places + $result = $this->ReihungstestModel->getFreePlaces(); $free_places_arr = array(); if (hasData($result)) @@ -51,8 +53,8 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - // Prepare data for mail template 'ReihungstestJob' - $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); + // Prepare data for mail template 'ReihungstestJob' + $content_data_arr = $this->_getContentData($missing_rt_arr, $free_places_arr); // Send email in Sancho design if (!empty($missing_rt_arr) || !empty($free_places_arr)) @@ -95,7 +97,7 @@ class ReihungstestJob extends CLI_Controller // Get placement tests where registration date was yesterday $result = $this->ReihungstestModel->checkReachedRegistrationDate($degreeProgram); - $reachedRegistration_rt_arr = array(); + $reachedRegistration_rt_arr = array(); if (hasData($result)) { @@ -106,11 +108,11 @@ class ReihungstestJob extends CLI_Controller show_error(getError($result)); } - $applicants_arr = array(); + $applicants_arr = array(); - foreach ($reachedRegistration_rt_arr as $reihungstest) - { - $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); + foreach ($reachedRegistration_rt_arr as $reihungstest) + { + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTestForCronjob($reihungstest->reihungstest_id); if (hasData($applicants)) { @@ -214,24 +216,24 @@ class ReihungstestJob extends CLI_Controller // Get applicants that have been added to a test after Anmeldefrist $result = $this->ReihungstestModel->getApplicantAssignedAfterDate($degreeProgram); - $applicants_after_anmeldefrist_arr = array(); + $applicants_after_anmeldefrist_arr = array(); - if (hasData($result)) - { - $applicants_after_anmeldefrist_arr = $result->retval; - } - elseif (isError($result)) - { - show_error(getError($result)); - } + if (hasData($result)) + { + $applicants_after_anmeldefrist_arr = $result->retval; + } + elseif (isError($result)) + { + show_error(getError($result)); + } - $studiengang = ''; - $mailReceipients = ''; // String with all mailadresses - $mailcontent_data_arr = array(); - $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; - $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; - $mailcontent = ''; - $applicants_list = ''; + $studiengang = ''; + $mailReceipients = ''; // String with all mailadresses + $mailcontent_data_arr = array(); + $headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"'; + $rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"'; + $mailcontent = ''; + $applicants_list = ''; if (count($applicants_after_anmeldefrist_arr) > 0) { @@ -277,11 +279,11 @@ class ReihungstestJob extends CLI_Controller '; - } + } - $studiengang = $applicant->studiengang_kz; - $mailReceipients .= $applicant->email . ';'; - $applicants_list .= ' + $studiengang = $applicant->studiengang_kz; + $mailReceipients .= $applicant->email . ';'; + $applicants_list .= ' ' . date_format(date_create($applicant->datum), 'd.m.Y') . ' ' . $applicant->uhrzeit . ' @@ -315,7 +317,7 @@ class ReihungstestJob extends CLI_Controller } /* - * Sends an email to all applicants of a placement test to remind them 3 working days before + * Sends an email to all applicants of a placement test to remind them 2 working days before * * @param integer $degreeProgram. Kennzahl of Degree Program to check * @param string $bcc. Optional. BCC-Mailadress to send the Mails to @@ -341,66 +343,66 @@ class ReihungstestJob extends CLI_Controller $from = urldecode($from); } - // Get placement tests with testdate within the next 2 weeks - $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); - if (hasData($resultNextTestDates)) - { - $nextTestDates = $resultNextTestDates->retval; - $enddate = ''; - // Loop through the dates - foreach ($nextTestDates as $testDates) - { - $workingdays = 0; - $testsOndate = array(); + // Get placement tests with testdate within the next 2 weeks + $resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14); + if (hasData($resultNextTestDates)) + { + $nextTestDates = $resultNextTestDates->retval; + $enddate = ''; + // Loop through the dates + foreach ($nextTestDates as $testDates) + { + $workingdays = 0; + $testsOndate = array(); - // Deduct days till 3 working days are reached - for ($i = 1; ; $i++) - { - if (isDateWorkingDay($testDates->datum, $i) === true) - { - $workingdays++; - } - if ($workingdays == 3) - { - $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); - break; - } - else - { - continue; - } - } + // Deduct days till 2 working days are reached + for ($i = 1; ; $i++) + { + if (isDateWorkingDay($testDates->datum, $i) === true) + { + $workingdays++; + } + if ($workingdays == 2) + { + $enddate = date("Y-m-d", strtotime("$testDates->datum -" . $i . " days")); + break; + } + else + { + continue; + } + } - // If $enddate is today -> load all tests of $testDates->datum - if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) - { - $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); + // If $enddate is today -> load all tests of $testDates->datum + if (date("Y-m-d", strtotime($enddate)) == date('Y-m-d')) + { + $resultTestsOnDate = $this->ReihungstestModel->getTestsOnDate($testDates->datum, $degreeProgram); - if (hasData($resultTestsOnDate)) - { - $testsOndate = $resultTestsOnDate->retval; - } - elseif (isError($resultTestsOnDate)) - { - show_error(getError($resultTestsOnDate)); - } - } + if (hasData($resultTestsOnDate)) + { + $testsOndate = $resultTestsOnDate->retval; + } + elseif (isError($resultTestsOnDate)) + { + show_error(getError($resultTestsOnDate)); + } + } - if (!isEmptyArray($testsOndate)) - { - foreach ($testsOndate as $reihungstest) - { - // Loads applicants of a test - $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); + if (!isEmptyArray($testsOndate)) + { + foreach ($testsOndate as $reihungstest) + { + // Loads applicants of a test + $applicants = $this->ReihungstestModel->getApplicantsOfPlacementTest($reihungstest->reihungstest_id); - if (hasData($applicants)) - { - $applicants_arr = $applicants->retval; - } - elseif (isError($applicants)) - { - show_error(getError($applicants)); - } + if (hasData($applicants)) + { + $applicants_arr = $applicants->retval; + } + elseif (isError($applicants)) + { + show_error(getError($applicants)); + } foreach ($applicants_arr as $applicant) { @@ -420,237 +422,237 @@ class ReihungstestJob extends CLI_Controller $mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan; } - sendSanchoMail( - 'Sancho_RemindApplicantsOfTest', - $mailcontent_data_arr, - $applicant->email, - 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', - DEFAULT_SANCHO_HEADER_IMG, - DEFAULT_SANCHO_FOOTER_IMG, - $from, - '', - $bcc); - } - } - } - } - } - } + sendSanchoMail( + 'Sancho_RemindApplicantsOfTest', + $mailcontent_data_arr, + $applicant->email, + 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', + DEFAULT_SANCHO_HEADER_IMG, + DEFAULT_SANCHO_FOOTER_IMG, + $from, + '', + $bcc); + } + } + } + } + } + } - /** - * This job sends eMail(s) to the relevant stg assistance(s) informing about: - * All applicants, who have sent new applications AFTER they had absolved a - * placement test in the actual studiensemester - * AND who have been confirmed yesterday. - */ - public function mailNewApplicants() - { - // Get yesterdays confirmed applicants for Bachelor-studies - $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); - $this->PrestudentstatusModel->addSelect(' - tbl_person.person_id, - tbl_prestudentstatus.prestudent_id, - tbl_prestudent.studiengang_kz, - tbl_prestudentstatus.studiensemester_kurzbz, - tbl_prestudentstatus.bestaetigtam, - tbl_prestudentstatus.bewerbung_abgeschicktamum - '); - $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); - $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); - $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); - $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); + /** + * This job sends eMail(s) to the relevant stg assistance(s) informing about: + * All applicants, who have sent new applications AFTER they had absolved a + * placement test in the actual studiensemester + * AND who have been confirmed yesterday. + */ + public function mailNewApplicants() + { + // Get yesterdays confirmed applicants for Bachelor-studies + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->PrestudentstatusModel->addSelect(' + tbl_person.person_id, + tbl_prestudentstatus.prestudent_id, + tbl_prestudent.studiengang_kz, + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudentstatus.bestaetigtam, + tbl_prestudentstatus.bewerbung_abgeschicktamum + '); + $this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentstatusModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentstatusModel->addJoin('public.tbl_person', 'person_id'); - $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' - status_kurzbz = \'Interessent\' AND - typ = \'b\' AND - bestaetigtam = current_date - 1 - '); + $yesterdays_applicants_arr = $this->PrestudentstatusModel->loadWhere(' + status_kurzbz = \'Interessent\' AND + typ = \'b\' AND + bestaetigtam = current_date - 1 + '); - // Retrieve the person_ids of yesterdays confirmed applicants - $person_id_arr = array(); - if (hasData($yesterdays_applicants_arr)) - { - foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) - { - if (isset($yesterdays_applicant->person_id)) { - $person_id_arr[] = $yesterdays_applicant->person_id; - } - } - } - elseif (isError($yesterdays_applicants_arr)) - { - show_error(getError($yesterdays_applicants_arr)); - } + // Retrieve the person_ids of yesterdays confirmed applicants + $person_id_arr = array(); + if (hasData($yesterdays_applicants_arr)) + { + foreach ($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + if (isset($yesterdays_applicant->person_id)) { + $person_id_arr[] = $yesterdays_applicant->person_id; + } + } + } + elseif (isError($yesterdays_applicants_arr)) + { + show_error(getError($yesterdays_applicants_arr)); + } - // Get all other prestudenten of the given persons. - if (!isEmptyArray($person_id_arr)) - { - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $this->PrestudentModel->addDistinct(); - $this->PrestudentModel->addSelect(' - person_id, - tbl_reihungstest.studiensemester_kurzbz, - tbl_reihungstest.reihungstest_id, - (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp - '); - $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); - $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); + // Get all other prestudenten of the given persons. + if (!isEmptyArray($person_id_arr)) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->PrestudentModel->addDistinct(); + $this->PrestudentModel->addSelect(' + person_id, + tbl_reihungstest.studiensemester_kurzbz, + tbl_reihungstest.reihungstest_id, + (SELECT(tbl_reihungstest.datum::text || \' \' || tbl_reihungstest.uhrzeit::text)::timestamp) AS reihungstest_timestamp + '); + $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->PrestudentModel->addJoin('public.tbl_studiengangstyp', 'typ'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_rt_person', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_reihungstest', 'tbl_reihungstest.reihungstest_id = tbl_rt_person.rt_id'); - // Store them, if they have already absolved a placement test in the same study term they have applied for. - $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' - person_id IN (' . implode(', ', $person_id_arr) . ') AND - typ = \'b\' AND - teilgenommen = \'t\' AND - tbl_reihungstest.studiensemester_kurzbz IN ( - SELECT - studiensemester_kurzbz - FROM - public.tbl_studiensemester - WHERE - ende >= now() - ) - '); - } + // Store them, if they have already absolved a placement test in the same study term they have applied for. + $placement_absolvents_arr = $this->PrestudentModel->loadWhere(' + person_id IN (' . implode(', ', $person_id_arr) . ') AND + typ = \'b\' AND + teilgenommen = \'t\' AND + tbl_reihungstest.studiensemester_kurzbz IN ( + SELECT + studiensemester_kurzbz + FROM + public.tbl_studiensemester + WHERE + ende >= now() + ) + '); + } - // Store data to be send in the email-link - $result_arr = array(); - foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) - { - foreach ($placement_absolvents_arr->retval as $placement_absolvent) - { - if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && - $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && - $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) - { - $obj = new stdClass(); - $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant - $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant - $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person + // Store data to be send in the email-link + $result_arr = array(); + foreach($yesterdays_applicants_arr->retval as $yesterdays_applicant) + { + foreach ($placement_absolvents_arr->retval as $placement_absolvent) + { + if ($yesterdays_applicant->person_id == $placement_absolvent->person_id && + $yesterdays_applicant->studiensemester_kurzbz == $placement_absolvent->studiensemester_kurzbz && + $yesterdays_applicant->bewerbung_abgeschicktamum >= $placement_absolvent->reihungstest_timestamp) + { + $obj = new stdClass(); + $obj->prestudent_id = $yesterdays_applicant->prestudent_id; // prestudent_id of the yesterdays applicant + $obj->studiengang_kz = $yesterdays_applicant->studiengang_kz; // study program of interest of the yesterdays applicant + $obj->reihungstest_id = $placement_absolvent->reihungstest_id; // reihungstest_id of absolved reihungstest of that person - $result_arr[]= $obj; - } - } - } + $result_arr[]= $obj; + } + } + } - // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. - usort($result_arr, function ($a, $b) - { - if ($a->studiengang_kz == $b->studiengang_kz) { - return 0; - } - return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; - }); + // Sort by STG. This is important to send the mails clustered by STG to the different STG assistances. + usort($result_arr, function ($a, $b) + { + if ($a->studiengang_kz == $b->studiengang_kz) { + return 0; + } + return ($a->studiengang_kz < $b->studiengang_kz) ? -1 : 1; + }); - $to = ''; // mail recipient (stg assistance) - $content_arr = array(); // url paths to the new applicants - $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); + $to = ''; // mail recipient (stg assistance) + $content_arr = array(); // url paths to the new applicants + $base_link = base_url('vilesci/stammdaten/auswertung_fhtw.php'); - $i = 0; // loop counter - $len = count($result_arr); + $i = 0; // loop counter + $len = count($result_arr); - // Loop trough list of new applicants - foreach($result_arr as $result) - { - $studiengang = $this->StudiengangModel->load($result->studiengang_kz); - $mail_stg_assistance = $studiengang->retval[0]->email; + // Loop trough list of new applicants + foreach($result_arr as $result) + { + $studiengang = $this->StudiengangModel->load($result->studiengang_kz); + $mail_stg_assistance = $studiengang->retval[0]->email; - // If first loop - if ($i == 0) - { - $to = $mail_stg_assistance; // set recipient initially - } + // If first loop + if ($i == 0) + { + $to = $mail_stg_assistance; // set recipient initially + } - // If new study is encountered but is not the first loop - if ($to != $mail_stg_assistance && $i != 0) - { - // Prepare content for mail template - $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + // If new study is encountered but is not the first loop + if ($to != $mail_stg_assistance && $i != 0) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - // Send mail - sendSanchoMail( - 'BewerberNachReihungstest', - $content_data_arr, - $to, - 'Neue Bewerbungen nach absolviertem Reihungstest', - 'sancho_header_min_bw.jpg', - 'sancho_footer_min_bw.jpg' - ); + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); - // Reset content for new study applicants & reset recipient (new stg assistance) - $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); - $to = $mail_stg_assistance; - } - // If same study - else - { - // just add content - $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content - } + // Reset content for new study applicants & reset recipient (new stg assistance) + $content_arr = array($base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id); + $to = $mail_stg_assistance; + } + // If same study + else + { + // just add content + $content_arr[]= $base_link. '?reihungstest='. $result->reihungstest_id. '&prestudent_id='. $result->prestudent_id; // add to content + } - // If last loop - if (($i == $len - 1)) - { - // Prepare content for mail template - $content_data_arr = $this->_getContentDataNewApplicant($content_arr); + // If last loop + if (($i == $len - 1)) + { + // Prepare content for mail template + $content_data_arr = $this->_getContentDataNewApplicant($content_arr); - // Send mail - sendSanchoMail( - 'BewerberNachReihungstest', - $content_data_arr, - $to, - 'Neue Bewerbungen nach absolviertem Reihungstest', - 'sancho_header_min_bw.jpg', - 'sancho_footer_min_bw.jpg' - ); - } - $i++; // iterate counter - } - } + // Send mail + sendSanchoMail( + 'BewerberNachReihungstest', + $content_data_arr, + $to, + 'Neue Bewerbungen nach absolviertem Reihungstest', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg' + ); + } + $i++; // iterate counter + } + } - // ------------------------------------------------------------------------ - // Private methods - /** - * Returns associative array with data as needed in the reihungstest job template. - * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. - * @param array $free_places_arr Array with info and amount of free placement test places. - * @return array - */ - private function _getContentData($missing_rt_arr, $free_places_arr) - { - $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; - $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + // ------------------------------------------------------------------------ + // Private methods + /** + * Returns associative array with data as needed in the reihungstest job template. + * @param array $missing_rt_arr Array with studienpläne, which have no assigned placement tests. + * @param array $free_places_arr Array with info and amount of free placement test places. + * @return array + */ + private function _getContentData($missing_rt_arr, $free_places_arr) + { + $style_tbl1 = ' cellpadding="0" cellspacing="10" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; + $style_tbl2 = ' cellpadding="0" cellspacing="20" width="100%" style="font-family: courier, verdana, sans-serif; font-size: 0.95em; border: 1px solid #000000;" '; - // Prepare HTML table with study plans that have no placement tests yet - if (!empty($missing_rt_arr)) { - $studienplan_list - = ' + // Prepare HTML table with study plans that have no placement tests yet + if (!empty($missing_rt_arr)) { + $studienplan_list + = ' '; - foreach ($missing_rt_arr as $rt) { - $studienplan_list .= ' + foreach ($missing_rt_arr as $rt) { + $studienplan_list .= ' ' . $rt->bezeichnung . ' '; - } + } - $studienplan_list .= ' + $studienplan_list .= ' '; - } else { - $studienplan_list = ' + } else { + $studienplan_list = ' Alles okay! Alle Studienpläne haben zumindest einen Reihungstest. '; - } + } - // Prepare HTML table with information and amount of free places - if (!empty($free_places_arr)) { - $freie_plaetze_list = ' + // Prepare HTML table with information and amount of free places + if (!empty($free_places_arr)) { + $freie_plaetze_list = ' Fakultät @@ -659,67 +661,67 @@ class ReihungstestJob extends CLI_Controller '; - foreach ($free_places_arr as $free_place) { - $datum = new DateTime($free_place->datum); - $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places + foreach ($free_places_arr as $free_place) { + $datum = new DateTime($free_place->datum); + $style_alarm = ($free_place->freie_plaetze <= 5) ? ' style=" color: red; font-weight: bold" ' : ''; // mark if <=5 free places - $freie_plaetze_list .= ' + $freie_plaetze_list .= ' ' . $free_place->fakultaet . ' ' . $datum->format('d.m.Y') . ' ' . $free_place->freie_plaetze . ' '; - } + } - $freie_plaetze_list .= ' + $freie_plaetze_list .= ' '; - } else { - $freie_plaetze_list = ' + } else { + $freie_plaetze_list = ' Es gibt heute keine Ergebnisse zu freien Reihungstestplätze. '; - } + } - // Set associative array with the prepared HTML tables and URL be used by the template's variables - $content_data_arr['studienplan_list'] = $studienplan_list; - $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; - $content_data_arr['link'] = site_url('/organisation/Reihungstest'); + // Set associative array with the prepared HTML tables and URL be used by the template's variables + $content_data_arr['studienplan_list'] = $studienplan_list; + $content_data_arr['freie_plaetze_list'] = $freie_plaetze_list; + $content_data_arr['link'] = site_url('/organisation/Reihungstest'); - return $content_data_arr; - } + return $content_data_arr; + } - /** - * Returns associative array with data as needed in the BewerberNachReihungstest-template. - * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. - * @return array - */ - private function _getContentDataNewApplicant($content_arr) - { - $content = ''; - $counter = 1; - foreach ($content_arr as $row) - { - $content .= '
Link zu: Bewerber '. $counter. ''; - $counter++; - } + /** + * Returns associative array with data as needed in the BewerberNachReihungstest-template. + * @param array $content_arr Array with links to the testtool evaluation page of the new applicants. + * @return array + */ + private function _getContentDataNewApplicant($content_arr) + { + $content = ''; + $counter = 1; + foreach ($content_arr as $row) + { + $content .= '
Link zu: Bewerber '. $counter. ''; + $counter++; + } - $content_data_arr['link'] = $content; - return $content_data_arr; - } + $content_data_arr['link'] = $content; + return $content_data_arr; + } - /** - * Checks the upcoming placement tests if there are correct studyplans assigned - * If there are invalid studyplans assigned (outdated because there exists a new version), - * it tries to find a better one and assigns it additionaly - */ - public function correctStudienplan() - { - // get all placement tests with incorrect studyplan - $qry = " + /** + * Checks the upcoming placement tests if there are correct studyplans assigned + * If there are invalid studyplans assigned (outdated because there exists a new version), + * it tries to find a better one and assigns it additionaly + */ + public function correctStudienplan() + { + // get all placement tests with incorrect studyplan + $qry = " SELECT tbl_reihungstest.reihungstest_id, tbl_studienplan.studienplan_id, @@ -752,37 +754,279 @@ class ReihungstestJob extends CLI_Controller ) "; - $db = new DB_Model(); - $result_rt = $db->execReadOnlyQuery($qry); + $db = new DB_Model(); + $result_rt = $db->execReadOnlyQuery($qry); - if (hasdata($result_rt)) { - foreach ($result_rt->retval as $row_rt) { - // find an active studyplan for the same degree program with is valid in this semester - $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( - $row_rt->studiengang_kz, - $row_rt->studiensemester_kurzbz - ); + if (hasdata($result_rt)) { + foreach ($result_rt->retval as $row_rt) { + // find an active studyplan for the same degree program with is valid in this semester + $result_stpl = $this->StudienplanModel->getStudienplaeneBySemester( + $row_rt->studiengang_kz, + $row_rt->studiensemester_kurzbz + ); - if (hasData($result_stpl)) { - foreach ($result_stpl->retval as $row_stpl) { - // Add new Studyplan to RtStudienplan if missing - $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( - "reihungstest_id" => $row_rt->reihungstest_id, - "studienplan_id" => $row_stpl->studienplan_id - )); + if (hasData($result_stpl)) { + foreach ($result_stpl->retval as $row_stpl) { + // Add new Studyplan to RtStudienplan if missing + $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); - if (!hasData($rt_studienplan)) { - echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; - echo " to ReihungstestId: $row_rt->reihungstest_id"; + if (!hasData($rt_studienplan)) { + echo "\nAdding StudienplanId: $row_stpl->studienplan_id"; + echo " to ReihungstestId: $row_rt->reihungstest_id"; - $this->RtStudienplanModel->insert(array( - "reihungstest_id" => $row_rt->reihungstest_id, - "studienplan_id" => $row_stpl->studienplan_id - )); - } - } - } - } - } - } + $this->RtStudienplanModel->insert(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $row_stpl->studienplan_id + )); + } + } + } + } + } + } + + /* + * Cronjob for priorisation process of FHTW + * + * Wenn ein Student in einer höheren Prio aufgenommen wird, werden die anderen Bewerbungen auf "Abgewiesen" gesetzt, + * solang diese noch im Status "Bewerber" sind. + * Andernfalls wird eine Mail an die niedrigeren Prios verschickt, dass eine höhere Prio aufgenommen hat + * Die Kaution wird automatisch gebucht + * + * @param string $bcc. Optional. BCC-Mailadress to send the Mails to + * @param string $from. Optional. Sender-Mailadress shown to recipient + */ + public function prioritizationJob($bcc = null, $from = null) + { + $qry = " + SELECT DISTINCT + get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') AS laststatus, /* Studiensemester dynamisch ermitteln oder als Parameter */ + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudent.* + FROM PUBLIC.tbl_person + JOIN PUBLIC.tbl_prestudent USING (person_id) + JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + JOIN PUBLIC.tbl_studiengang ON (tbl_studienordnung.studiengang_kz = tbl_studiengang.studiengang_kz) + WHERE tbl_prestudentstatus.datum >= (SELECT CURRENT_DATE -1) + AND get_rolle_prestudent (tbl_prestudent.prestudent_id, 'WS2020') IN ('Aufgenommener','Bewerber','Wartender') + AND studiensemester_kurzbz = 'WS2020' /* Studiensemester dynamisch ermitteln oder als Parameter */ + AND tbl_studiengang.typ = 'b' + ORDER BY studiengang_kz, laststatus + "; + + // Encode Params + if ($bcc != '') + { + // $bcc can be given as null-string, so check that too + if ($bcc == 'null') + { + $bcc = ''; + } + else + { + $bcc = urldecode($bcc); + } + } + if ($from != '') + { + $from = urldecode($from); + } + + $db = new DB_Model(); + $result_prestudents = $db->execReadOnlyQuery($qry); + $mailArray = array(); + + if (hasdata($result_prestudents)) + { + foreach ($result_prestudents->retval as $row_ps) + { + // Wenn der letzte Status "Aufgenommener" ist, alle niedrigeren Prios auf "Abgewiesen" setzen + // falls diese Bewerber oder Warteliste sind + // Danach Kaution einbuchen + if ($row_ps->laststatus == 'Aufgenommener') + { + // Alle niedrigeren Prios laden + $qryNiedrPrios = " + SELECT DISTINCT + get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') AS laststatus, + tbl_studienplan.orgform_kurzbz, + tbl_person.nachname, + tbl_person.vorname, + tbl_prestudent.* + FROM PUBLIC.tbl_person + JOIN PUBLIC.tbl_prestudent USING (person_id) + JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN PUBLIC.tbl_studiengang ON (tbl_prestudent.studiengang_kz = tbl_studiengang.studiengang_kz) + WHERE tbl_prestudent.person_id = ".$row_ps->person_id." + AND tbl_prestudent.prestudent_id != ".$row_ps->prestudent_id." + AND get_rolle_prestudent (tbl_prestudent.prestudent_id, '".$row_ps->studiensemester_kurzbz."') IN ('Aufgenommener','Bewerber','Wartender') + AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."' + AND tbl_studiengang.typ = 'b' + AND priorisierung > ".$row_ps->priorisierung." + ORDER BY studiengang_kz, laststatus + "; + + $resultNiedrPrios = $db->execReadOnlyQuery($qryNiedrPrios); + + if (hasdata($resultNiedrPrios)) + { + foreach ($resultNiedrPrios->retval as $rowNiedrPrios) + { + if ($rowNiedrPrios->laststatus == 'Bewerber') + { + // Abgewiesenen-Status mit Statusgrund "Aufnahme anderer Studiengang" (ID 5) setzen + $lastStatus = $this->PrestudentstatusModel->getLastStatus($rowNiedrPrios->prestudent_id); + + $result = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $rowNiedrPrios->prestudent_id, + 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester, + 'datum' => date('Y-m-d'), + 'orgform_kurzbz' => $lastStatus->retval[0]->orgform_kurzbz, + 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, + 'status_kurzbz' => 'Abgewiesener', + 'statusgrund_id' => 5, + 'insertvon' => 'prioritizationJob', + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + if (isSuccess($result)) + { + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + elseif ($rowNiedrPrios->laststatus == 'Wartender') + { + // Abgewiesenen-Status mit Statusgrund "Aufnahme anderer Studiengang" (ID 5) setzen + // Mail zur Info an Assistenz schicken + $lastStatus = $this->PrestudentstatusModel->getLastStatus($rowNiedrPrios->prestudent_id); + + $result = $this->PrestudentstatusModel->insert( + array( + 'prestudent_id' => $rowNiedrPrios->prestudent_id, + 'studiensemester_kurzbz' => $lastStatus->retval[0]->studiensemester_kurzbz, + 'ausbildungssemester' => $lastStatus->retval[0]->ausbildungssemester, + 'datum' => date('Y-m-d'), + 'orgform_kurzbz' => $lastStatus->retval[0]->orgform_kurzbz, + 'studienplan_id' => $lastStatus->retval[0]->studienplan_id, + 'status_kurzbz' => 'Abgewiesener', + 'statusgrund_id' => 5, + 'insertvon' => 'prioritizationJob', + 'insertamum' => date('Y-m-d H:i:s') + ) + ); + if (isSuccess($result)) + { + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + elseif ($rowNiedrPrios->laststatus == 'Aufgenommener') + { + // Mail zur Info an Assistenz schicken, dass in höherer Prio aufgenommen wurde + $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AufnahmeHoeherePrio'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + } + } + } + echo '
', var_dump($mailArray), '
'; + // Kaution einbuchen für $row_ps->prestudent_id + // Vorher prüfen, ob schon eine Kaution gebucht ist + // Todo: Betrag automatisch aus tbl_buchungstyp laden + + $qryKautionExists = " + SELECT count(*) as anzahl + FROM public.tbl_konto + WHERE person_id = ".$row_ps->person_id." + AND studiensemester_kurzbz = '".$row_ps->studiensemester_kurzbz."' + AND buchungstyp_kurzbz = 'Kaution'"; + + $resultKautionExists = $db->execReadOnlyQuery($qryKautionExists); + if (hasdata($resultKautionExists)) + { + if ($resultKautionExists->retval[0]->anzahl == '0') + { + // Todo: Zahlungsreferenz generieren (StudiengangsOE+Buchungsnummer) + $this->KontoModel->insert(array( + "person_id" => $row_ps->person_id, + "studiengang_kz" => $row_ps->studiengang_kz, + "studiensemester_kurzbz" => $row_ps->studiensemester_kurzbz, + "betrag" => -150, + "buchungsdatum" => date('Y-m-d'), + "buchungstext" => 'Kaution', + "buchungstyp_kurzbz" => 'Kaution', + "insertvon" => 'prioritizationJob', + "insertamum" => date('Y-m-d H:i:s') + )); + } + } + } + } + } + // Mails senden + if (!isEmptyArray($mailArray)) + { + foreach ($mailArray AS $stg=>$orgform) + { + $studiengang = $this->StudiengangModel->load($stg); + + $mailcontent = '

+ Folgende BewerberInnen wurden in einem höher priorisierten Studiengang aufgenommen und haben deshalb einen Status "Abgewiesen" erhalten:

'; + + foreach ($orgform AS $art=>$value) + { + $mailcontent .= '

Orgform '.$art.'

'; + if (isset($value['AbgewiesenGesetzt']) && !isEmptyArray($value['AbgewiesenGesetzt'])) + { + $mailcontent .= ' + + '; + sort($value['AbgewiesenGesetzt']); + foreach ($value['AbgewiesenGesetzt'] AS $key=>$bewerber) + { + $mailcontent .= ''; + } + $mailcontent .= '
Zuvor Warteliste
'.$bewerber.'


'; + } + if (isset($value['AufnahmeHoeherePrio']) && !isEmptyArray($value['AufnahmeHoeherePrio'])) + { + $mailcontent .= ' + + '; + sort($value['AufnahmeHoeherePrio']); + foreach ($value['AufnahmeHoeherePrio'] AS $key=>$bewerber) + { + $mailcontent .= ''; + } + $mailcontent .= '
Zuvor BewerberIn
'.$bewerber.'
'; + } + } + + $mailcontent_data_arr['table'] = $mailcontent; + + // Send email in Sancho design + if (!isEmptyString($mailcontent)) + { + sendSanchoMail( + 'Sancho_ReihungstestteilnehmerJob', + $mailcontent_data_arr, + $studiengang->retval[0]->email, + 'Status Abgewiesen gesetzt', + 'sancho_header_min_bw.jpg', + 'sancho_footer_min_bw.jpg', + $from, + '', + $bcc); + } + } + } + } } From 304d7727f000fc30a051b4d4235f21df7764e6d0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 21 Feb 2020 16:59:25 +0100 Subject: [PATCH 130/157] - CL/Messages_model-> sendReply applied workaround for Infocenter - MailJob now extends JOB_Controller and writes logs in DB - MailJob->sendMessages renamed to sendAllMessageEmailNotices - sendAllMessageEmailNotices now accept new parameter since to restrict number of messages - MessageLib->sendAllEmailNotices now accept new parameter since and adapted to use new MessageLib->_sendNoticeEmails - Recipient_model->getMessages renamed to getNotSentMessages - Now accepts only limit and since as parameters - Changed query to retrieve only message ids --- application/controllers/jobs/MailJob.php | 42 ++++++----- application/libraries/MessageLib.php | 26 ++++--- application/models/CL/Messages_model.php | 3 +- application/models/system/Recipient_model.php | 69 ++++--------------- 4 files changed, 55 insertions(+), 85 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index 721db0068..b4b772f78 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -1,20 +1,8 @@ messagelib->sendAllNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + $this->logInfo('Send all message email notices started'); + + // Send them all! + $sendAllEmailNotices = $this->messagelib->sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + if (isError($sendAllEmailNotices)) + { + $optionalParameters = new stdClass(); + $optionalParameters->$since = $since; + $optionalParameters->$numberToSent = $numberToSent; + $optionalParameters->$numberPerTimeRange = $numberPerTimeRange; + $optionalParameters->$emailTimeRange = $emailTimeRange; + $optionalParameters->$emailFromSystem = $emailFromSystem; + + $this->logError($sendAllEmailNotices->retval, $optionalParameters); + } + elseif (!hasData($sendAllEmailNotices)) + { + $this->logInfo('There were no unsent messages'); + } + + $this->logInfo('Send all message email notices ended'); } } diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 3a8f133cf..cfd450f98 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -139,27 +139,31 @@ class MessageLib // Public methods called by a job /** - * Gets all NOT sent messages from DB and sends for each of them the notice email - * Does not return anything, it logs info and errors on CI logs and in tbl_msg_recipient table + * Gets all messages for which notice emails are still not sent from DB and sends for each of them the notice email * Wrapper for _sendNoticeEmail. */ - public function sendAllEmailNotices($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) + public function sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem) { // Overrides MailLib configs with the given parameters $this->_ci->maillib->overrideConfigs($numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); - // Retrieves a certain amount of NOT sent messages, the amount is given by maillib->email_number_to_sent - $messagesResult = $this->_ci->RecipientModel->getMessages( - self::EMAIL_KONTAKT_TYPE, - null, - $this->_ci->maillib->getEmailNumberToSent() + // Retrieves a certain amount of NOT sent messages + $messagesResult = $this->_ci->RecipientModel->getNotSentMessages( + $this->_ci->maillib->getEmailNumberToSent(), + $since ); - if (isError($messagesResult)) terminateWithError(getData($messagesResult)); // If an error occurred then log it and terminate + if (isError($messagesResult) || !hasData($messagesResult)) return $messagesResult; - $sendNotice = $this->_sendNoticeEmails(getData($messagesResult)); + // Collects all the message ids in an array + $messageIds = array(); + foreach (getData($messagesResult) as $message) + { + $messageIds[] = $message->message_id; + } - if (isError($sendNotice)) terminateWithError(getData($sendNotice)); // If an error occurred then log it and terminate + // Send'em all + return $this->_sendNoticeEmails($messageIds); } //------------------------------------------------------------------------------------------------------------------ diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index de6ec5a10..9cc4a76da 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -509,7 +509,8 @@ class Messages_model extends CI_Model if (!hasData($message)) return error('No messages were saved in database'); // Write log entry - $personLog = $this->_personLog($sender_id, $receiver_id, getData($message)[0]); + // NOTE: $receiver_id and $sender_id are switched!!! Currently this is a workaround + $personLog = $this->_personLog($receiver_id, $sender_id, getData($message)[0]); if (isError($personLog)) return $personLog; return success('Messages sent successfully'); diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index cea11a7a7..ad1c1e850 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -199,66 +199,23 @@ class Recipient_model extends DB_Model } /** - * getMessages + * Gets all messages for which notice emails are still not sent * - * Gets all the messages to be sent - * - * @param kontaktType specifies the type of the kontakt to get - * @param sent specifies the status of the messages to get (NULL never sent, otherwise the shipping date) - * @param limit specifies the number of messages to get - * @param message_id specifies a single message + * @param kontaktType specifies the type of the kontakt to get (email,...) + * @param limit specifies the max number of messages to get + * @param since specifies from which date messages have to be retrieved */ - public function getMessages($kontaktType, $message_id = null, $limit = 1) + public function getNotSentMessages($limit, $since = '1970-01-01') { - $query = 'SELECT mm.message_id, - ks.kontakt as sender, - kr.kontakt as receiver, - mu.mitarbeiter_uid as employeeContact, - ms.mitarbeiter_uid as senderemployeeContact, - mr.person_id as receiver_id, - mr.token, - mm.subject, - mm.body, - mr.sentinfo, - mr.oe_kurzbz - FROM public.tbl_msg_recipient mr INNER JOIN public.tbl_msg_message mm USING (message_id) - LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? - ) ks ON (ks.person_id = mm.person_id) - LEFT JOIN ( - SELECT person_id, kontakt FROM public.tbl_kontakt WHERE zustellung = true AND kontakttyp = ? - ) kr ON (kr.person_id = mr.person_id) - LEFT JOIN ( - SELECT b.person_id, - m.mitarbeiter_uid - FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) - WHERE b.aktiv = TRUE - ) mu ON (mu.person_id = mr.person_id) - LEFT JOIN ( - SELECT b.person_id, - m.mitarbeiter_uid - FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) - WHERE b.aktiv = TRUE - ) ms ON (ms.person_id = mm.person_id) - WHERE mr.sent IS NULL'; + $query = 'SELECT mm.message_id + FROM public.tbl_msg_recipient mr + JOIN public.tbl_msg_message mm USING (message_id) + WHERE mr.sent IS NULL + AND mm.insertamum > ? + ORDER BY mr.insertamum ASC + LIMIT ?'; - $parametersArray = array($kontaktType, $kontaktType); - - if (is_numeric($message_id)) - { - array_push($parametersArray, $message_id); - $query .= ' AND mm.message_id = ?'; - } - - $query .= ' ORDER BY mr.insertamum ASC'; - - if (is_numeric($limit)) - { - $query .= ' LIMIT ?'; - array_push($parametersArray, $limit); - } - - return $this->execQuery($query, $parametersArray); + return $this->execQuery($query, array($since, $limit)); } /** From 0addc4ffb59108aa384e4791c19d1e668c67721f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 21 Feb 2020 17:22:50 +0100 Subject: [PATCH 131/157] gebiet.class.php: improved offset calculation, LIMIT maxfragen instead multiplication --- include/gebiet.class.php | 138 +++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 56 deletions(-) diff --git a/include/gebiet.class.php b/include/gebiet.class.php index 7f622c299..a4df72338 100644 --- a/include/gebiet.class.php +++ b/include/gebiet.class.php @@ -677,13 +677,13 @@ class gebiet extends basis_db $qry = " WITH fragen AS ( - SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, punkte - FROM testtool.tbl_frage - JOIN testtool.tbl_vorschlag USING (frage_id) - WHERE tbl_vorschlag.aktiv - AND tbl_vorschlag.punkte < 0 - AND tbl_frage.demo = false - AND tbl_frage.aktiv + SELECT tbl_frage.frage_id, tbl_frage.gebiet_id, tbl_frage.level, tbl_frage.nummer, punkte + FROM testtool.tbl_frage + JOIN testtool.tbl_vorschlag USING (frage_id) + WHERE tbl_vorschlag.aktiv + AND tbl_vorschlag.punkte < 0 + AND tbl_frage.demo = false + AND tbl_frage.aktiv ), fragenanzahl AS ( SELECT gebiet_id, level, levelgleichverteilung, @@ -712,57 +712,83 @@ class gebiet extends basis_db tbl_gebiet.level_start, ( CASE WHEN tbl_gebiet.levelgleichverteilung THEN - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - (SELECT sum(frprolevel) FROM - ( - SELECT fragen.level, (min(punkte) - * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - GROUP BY fragen.gebiet_id, level - ) pkteprolevel) - ELSE - (SELECT sum(frprolevel) FROM - ( - SELECT fragen.level, (sum(punkte) - * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) AS frprolevel - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen fr WHERE fr.gebiet_id = fragen.gebiet_id AND fr.level = fragen.level) - GROUP BY fragen.gebiet_id, level - ) pkteprolevel) - END) + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, (SELECT sum(punkte) FROM (SELECT min(punkte) AS punkte FROM fragen lvlfr WHERE lvlfr.gebiet_id = fragen.gebiet_id and lvlfr.level = fragen.level + GROUP BY lvlfr.frage_id, lvlfr.nummer + ORDER BY lvlfr.nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) fr) + AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + ELSE + (SELECT sum(frprolevel) FROM + ( + SELECT fragen.level, + (SELECT sum(punkte) FROM (SELECT sum(punkte) AS punkte FROM fragen lvlfr WHERE lvlfr.gebiet_id = fragen.gebiet_id and lvlfr.level = fragen.level + GROUP by lvlfr.frage_id, lvlfr.nummer + ORDER BY lvlfr.nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = fragen.gebiet_id and fragenanzahl.level = fragen.level LIMIT 1)) fr) + AS frprolevel + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY fragen.gebiet_id, level + ) pkteprolevel) + END) WHEN tbl_gebiet.level_start IS NOT NULL THEN - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - ( - SELECT min(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + (SELECT sum(pkte) + FROM ( + SELECT min(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id AND fragen.level = tbl_gebiet.level_start - ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - ELSE - (SELECT sum(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - AND fragen.level = tbl_gebiet.level_start - )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) - END) + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) minpkte + ) + ELSE + ( + SELECT sum(pkte) + FROM (SELECT sum(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + AND fragen.level = tbl_gebiet.level_start + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id AND fragenanzahl.level = tbl_gebiet.level_start LIMIT 1) + ) sumpkte + ) + END) ELSE - (CASE WHEN tbl_gebiet.multipleresponse=false THEN - ( - SELECT min(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - ) * (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - ELSE - (SELECT sum(punkte) - FROM fragen - WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id - AND frage_id = (SELECT min(frage_id) FROM fragen WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id) - )* (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) - END) - + (CASE WHEN tbl_gebiet.multipleresponse=false THEN + ( + SELECT sum(pkte) + FROM (SELECT min(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) minpkte + ) + ELSE + ( + SELECT sum(pkte) + FROM (SELECT sum(punkte) AS pkte + FROM fragen + WHERE fragen.gebiet_id = tbl_gebiet.gebiet_id + GROUP BY frage_id, nummer + ORDER BY nummer + LIMIT (SELECT anzahl FROM fragenanzahl WHERE fragenanzahl.gebiet_id = tbl_gebiet.gebiet_id LIMIT 1) + ) sumpkte + ) + END) + END) * (-1) AS offsetpunkte FROM testtool.tbl_gebiet @@ -770,7 +796,7 @@ class gebiet extends basis_db EXISTS( SELECT 1 FROM fragen WHERE fragen.gebiet_id=tbl_gebiet.gebiet_id ) - AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." + AND gebiet_id = ".$this->db_add_param($gebiet_id, FHC_INTEGER)." "; if($this->db_query($qry)) From b8b36e975e8baa57b4362faab684217fd3646bbf Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 18:18:14 +0100 Subject: [PATCH 132/157] Orgform_kurzbz in bankverbindung.class und zahlungen_details.php --- cis/private/profile/zahlungen_details.php | 93 ++++++++++++++--------- include/bankverbindung.class.php | 49 +++++++----- 2 files changed, 88 insertions(+), 54 deletions(-) diff --git a/cis/private/profile/zahlungen_details.php b/cis/private/profile/zahlungen_details.php index a6d35cc72..650ee81c0 100644 --- a/cis/private/profile/zahlungen_details.php +++ b/cis/private/profile/zahlungen_details.php @@ -26,6 +26,8 @@ require_once('../../../include/organisationseinheit.class.php'); require_once('../../../include/addon.class.php'); require_once('../../../include/benutzer.class.php'); require_once('../../../include/benutzerberechtigung.class.php'); +require_once('../../../include/student.class.php'); +require_once('../../../include/prestudent.class.php'); $uid = get_uid(); @@ -66,7 +68,19 @@ $studiengang=new studiengang(); $studiengang->load($konto->studiengang_kz); $bankverbindung=new bankverbindung(); -$kontodaten = getBankverbindung($studiengang->oe_kurzbz); +// Wenn Person StudentIn ist, auch die OrgForm laden um die richtige Kontonummer anzeigen zu können +$student = new student(); +$orgform = ''; +if ($student->load($uid)) +{ + $laststatus = new prestudent(); + if ($laststatus->getLastStatus($student->prestudent_id)) + { + $orgform = $laststatus->orgform_kurzbz; + } +} + +$kontodaten = getBankverbindung($studiengang->oe_kurzbz, $orgform); $iban=$kontodaten["iban"]; $bic=$kontodaten["bic"]; @@ -156,56 +170,63 @@ $addon = new addon(); $addon->loadAddons(); foreach($addon->result as $a) { - if($a->kurzbz === "eps") - { + if($a->kurzbz === "eps") + { echo ' - + - - + + - - + + - - + + - +
Zahlung anweisenZahlung anweisen
EPS - EPS Überweisung - EPS + EPS Überweisung +
'; - } - + } + } echo ''; -function getBankverbindung($oe_kurzbz) +function getBankverbindung($oe_kurzbz, $orgform_kurzbz = null) { - $iban = ""; - $bic = ""; - $result = array(); - $bankverbindung=new bankverbindung(); - if($bankverbindung->load_oe($oe_kurzbz) && count($bankverbindung->result)>0) - { - $result["iban"]=$bankverbindung->result[0]->iban; - $result["bic"]=$bankverbindung->result[0]->bic; - return $result; - } - else - { - $organisationseinheit = new organisationseinheit(); - $organisationseinheit->load($oe_kurzbz); - if($organisationseinheit->oe_parent_kurzbz !== NULL) + $iban = ""; + $bic = ""; + $result = array(); + $bankverbindung=new bankverbindung(); + if($bankverbindung->load_oe($oe_kurzbz, $orgform_kurzbz) && count($bankverbindung->result) > 0) { - $result = getBankverbindung($organisationseinheit->oe_parent_kurzbz); - return $result; + $result["iban"] = $bankverbindung->result[0]->iban; + $result["bic"] = $bankverbindung->result[0]->bic; + return $result; + } + // Nochmal ohne $orgform_kurzbz versuchen + elseif($bankverbindung->load_oe($oe_kurzbz) && count($bankverbindung->result) > 0) + { + $result["iban"] = $bankverbindung->result[0]->iban; + $result["bic"] = $bankverbindung->result[0]->bic; + return $result; } else { - $result["iban"]=""; - $result["bic"]=""; + $organisationseinheit = new organisationseinheit(); + $organisationseinheit->load($oe_kurzbz); + if($organisationseinheit->oe_parent_kurzbz !== NULL) + { + $result = getBankverbindung($organisationseinheit->oe_parent_kurzbz, $orgform_kurzbz); + return $result; + } + else + { + $result["iban"] = ""; + $result["bic"] = ""; + } } - } } ?> diff --git a/include/bankverbindung.class.php b/include/bankverbindung.class.php index b9056f3b8..44139375e 100644 --- a/include/bankverbindung.class.php +++ b/include/bankverbindung.class.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Christian Paminger , - * Andreas Oesterreicher and - * Rudolf Hangl . + * Andreas Oesterreicher and + * Rudolf Hangl . */ /** * Klasse bankverbindung @@ -47,6 +47,7 @@ class bankverbindung extends basis_db public $updateamum; // timestamp public $updatevon; // bigint public $oe_kurzbz; // string + public $orgform_kurzbz; // string /** * Konstruktor @@ -95,6 +96,7 @@ class bankverbindung extends basis_db $this->insertvon = $row->insertvon; $this->ext_id = $row->ext_id; $this->oe_kurzbz = $row->oe_kurzbz; + $this->orgform_kurzbz = $row->orgform_kurzbz; return true; } else @@ -176,19 +178,20 @@ class bankverbindung extends basis_db //Neuen Datensatz einfuegen $qry = 'BEGIN;INSERT INTO public.tbl_bankverbindung (person_id, name, anschrift, blz, bic, - kontonr, iban, typ, oe_kurzbz, verrechnung, insertamum, insertvon, updateamum, updatevon) VALUES('. - $this->db_add_param($this->person_id, FHC_INTEGER).', '. - $this->db_add_param($this->name).', '. - $this->db_add_param($this->anschrift).', '. - $this->db_add_param($this->blz).', '. - $this->db_add_param($this->bic).', '. - $this->db_add_param($this->kontonr).', '. - $this->db_add_param($this->iban).', '. - $this->db_add_param($this->typ).', '. - $this->db_add_param($this->oe_kurzbz).', '. - $this->db_add_param($this->verrechnung, FHC_BOOLEAN).', now(), '. - $this->db_add_param($this->insertvon).', now(), '. - $this->db_add_param($this->updatevon).');'; + kontonr, iban, typ, oe_kurzbz, orgform_kurzbz, verrechnung, insertamum, insertvon, updateamum, updatevon) VALUES('. + $this->db_add_param($this->person_id, FHC_INTEGER).', '. + $this->db_add_param($this->name).', '. + $this->db_add_param($this->anschrift).', '. + $this->db_add_param($this->blz).', '. + $this->db_add_param($this->bic).', '. + $this->db_add_param($this->kontonr).', '. + $this->db_add_param($this->iban).', '. + $this->db_add_param($this->typ).', '. + $this->db_add_param($this->oe_kurzbz).', '. + $this->db_add_param($this->orgform_kurzbz).', '. + $this->db_add_param($this->verrechnung, FHC_BOOLEAN).', now(), '. + $this->db_add_param($this->insertvon).', now(), '. + $this->db_add_param($this->updatevon).');'; } else { @@ -212,6 +215,7 @@ class bankverbindung extends basis_db 'typ='.$this->db_add_param($this->typ).', '. 'verrechnung='.$this->db_add_param($this->verrechnung,FHC_BOOLEAN).', '. 'oe_kurzbz='.$this->db_add_param($this->oe_kurzbz).', '. + 'orgform_kurzbz='.$this->db_add_param($this->orgform_kurzbz).', '. 'updateamum='.$this->db_add_param($this->updateamum).','. 'updatevon='.$this->db_add_param($this->updatevon).' '. 'WHERE bankverbindung_id='.$this->db_add_param($this->bankverbindung_id).';'; @@ -315,6 +319,7 @@ class bankverbindung extends basis_db $obj->insertvon = $row->insertvon; $obj->ext_id = $row->ext_id; $obj->oe_kurzbz = $row->oe_kurzbz; + $obj->orgform_kurzbz = $row->orgform_kurzbz; $this->result[] = $obj; } @@ -328,11 +333,12 @@ class bankverbindung extends basis_db } /** - * Laedt die Bankverbindung einer Organisationseinheit - * @param $person_id + * Laedt die Bankverbindung einer Organisationseinheit und optional einer OrgForm + * @param string $oe_kurzbz + * @param string $orgform_kurzbz * @return true wenn ok, false im Fehlerfall */ - public function load_oe($oe_kurzbz) + public function load_oe($oe_kurzbz, $orgform_kurzbz = null) { if($oe_kurzbz==null || $oe_kurzbz=='') { @@ -342,6 +348,11 @@ class bankverbindung extends basis_db $qry = "SELECT * FROM public.tbl_bankverbindung WHERE oe_kurzbz=".$this->db_add_param($oe_kurzbz); + if($orgform_kurzbz != '') + { + $qry .= " AND orgform_kurzbz=".$this->db_add_param($orgform_kurzbz); + } + if($this->db_query($qry)) { while($row = $this->db_fetch_object()) @@ -364,6 +375,7 @@ class bankverbindung extends basis_db $obj->insertvon = $row->insertvon; $obj->ext_id = $row->ext_id; $obj->oe_kurzbz = $row->oe_kurzbz; + $obj->orgform_kurzbz = $row->orgform_kurzbz; $this->result[] = $obj; } @@ -412,6 +424,7 @@ class bankverbindung extends basis_db $this->insertvon = $row->insertvon; $this->ext_id = $row->ext_id; $this->oe_kurzbz = $row->oe_kurzbz; + $this->orgform_kurzbz = $row->orgform_kurzbz; return true; } From d07b0684c3fc005c2060a4412d19aedbb28de0d5 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 20:47:54 +0100 Subject: [PATCH 133/157] Orgform nur dazu schreiben, wenn es mehr als Eine gibt --- application/controllers/jobs/ReihungstestJob.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 948eeb0b8..c548d2495 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -899,8 +899,8 @@ class ReihungstestJob extends CLI_Controller ); if (isSuccess($result)) { - $mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] - = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')'; + /*$mailArray[$rowNiedrPrios->studiengang_kz][$rowNiedrPrios->orgform_kurzbz]['AbgewiesenGesetzt'][] + = $rowNiedrPrios->nachname.' '.$rowNiedrPrios->vorname.' ('.$rowNiedrPrios->prestudent_id.')';*/ } } elseif ($rowNiedrPrios->laststatus == 'Wartender') @@ -937,7 +937,8 @@ class ReihungstestJob extends CLI_Controller } } } - echo '
', var_dump($mailArray), '
'; + + // Kaution einbuchen für $row_ps->prestudent_id // Vorher prüfen, ob schon eine Kaution gebucht ist // Todo: Betrag automatisch aus tbl_buchungstyp laden @@ -971,6 +972,7 @@ class ReihungstestJob extends CLI_Controller } } } + echo '
', var_dump($mailArray), '
'; // Mails senden if (!isEmptyArray($mailArray)) { @@ -983,7 +985,11 @@ class ReihungstestJob extends CLI_Controller foreach ($orgform AS $art=>$value) { - $mailcontent .= '

Orgform '.$art.'

'; + // Orgform nur dazu schreiben, wenn es mehr als Eine gibt + if (count($orgform) > 1) + { + $mailcontent .= '

Orgform '.$art.'

'; + } if (isset($value['AbgewiesenGesetzt']) && !isEmptyArray($value['AbgewiesenGesetzt'])) { $mailcontent .= ' From 8507f639366fd74deb574b8e11a5bbafa414948b Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Sun, 23 Feb 2020 20:51:16 +0100 Subject: [PATCH 134/157] GUI-changes in writeTemplate - Show only "bezeichnung" of template in select for regular users - New styled "Preview"-Button. - Click on "Preview" automatically scrolls to Preview-Div --- .../system/messages/htmlWriteTemplate.php | 28 ++++++++----------- application/widgets/Vorlage_widget.php | 3 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index 64a8c8236..bb031a370 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -129,34 +129,30 @@ -
+
-
-
- +
+
+
widgetlib->widget( 'Dropdown_widget', - array('elements' => success($recipientsArray), 'emptyElement' => 'Select...'), + array('elements' => success($recipientsArray), 'emptyElement' => ucfirst($this->p->t('global', 'empfaenger')).'...'), array( - 'title' => ucfirst($this->p->t('global', 'empfaenger')).': ', + /*'title' => ucfirst($this->p->t('global', 'empfaenger')).': ',*/ 'name' => 'recipients[]', 'id' => 'recipients' ) ); ?> - + + + p->t('ui', 'refresh')); ?> + + +
-

diff --git a/application/widgets/Vorlage_widget.php b/application/widgets/Vorlage_widget.php index 9c9abe430..1c05db9e3 100644 --- a/application/widgets/Vorlage_widget.php +++ b/application/widgets/Vorlage_widget.php @@ -63,7 +63,8 @@ class Vorlage_widget extends DropdownWidget FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz) ) templates'; $alias = 'templates'; - $fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"); + //$fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"); + $fields = array("templates.vorlage_kurzbz AS id", "templates.bezeichnung AS description"); $where = 'templates.aktiv = TRUE AND templates.subject IS NOT NULL AND templates.text IS NOT NULL From 166a4a76e84ba5c65b6364fa236e4ed61a7a6d8d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 24 Feb 2020 16:44:57 +0100 Subject: [PATCH 135/157] stammdaten/auswertung_fhtw.php: - added column "Punkte mit offset" - removed commented code concerning RT-punkte without Physik --- vilesci/stammdaten/auswertung_fhtw.php | 83 +++++++++++--------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/vilesci/stammdaten/auswertung_fhtw.php b/vilesci/stammdaten/auswertung_fhtw.php index a47230087..18b783e8e 100644 --- a/vilesci/stammdaten/auswertung_fhtw.php +++ b/vilesci/stammdaten/auswertung_fhtw.php @@ -1211,7 +1211,11 @@ if (isset($_REQUEST['reihungstest'])) } $gebiet[$row->gebiet_id]->name = $row->gebiet; $gebiet[$row->gebiet_id]->gebiet_id = $row->gebiet_id; - $gebiet[$row->gebiet_id]->gewicht = $row->gewicht; + //gewicht ist meist für alle Studiengänge gleich (Bachelor, Master und Distance haben jeweilsandere Gebiete) + if (!isset($gebiet[$row->gebiet_id]->gewicht)) + { + $gebiet[$row->gebiet_id]->gewicht = $row->gewicht; + } } // Alle Ergebnisse laden @@ -1476,18 +1480,22 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = null; $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punkte = $punkte; + $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset = null; // Punkte berechnen if (isset($punkte)) { + //offset zur Vermeidung negativer Prozentzahlen + $punkte_positiv = $punkte + $row->offsetpunkte; + $maxpunkte_positiv = $row->maxpunkte + $row->offsetpunkte; + $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset = $punkte_positiv; + if ($row->punkte >= $row->maxpunkte) + { $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = 100; + } else { - //offset zur Vermeidung negativer Prozentzahlen - $punkte_positiv = $punkte + $row->offsetpunkte; - $maxpunkte_positiv = $row->maxpunkte + $row->offsetpunkte; - //Formel: Summe(Punkte/Maxpunkte * Gewicht) $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->prozent = $maxpunkte_positiv > 0 ? $punkte_positiv / $maxpunkte_positiv * /*$row->gewicht **/ 100 : null; } } @@ -1518,6 +1526,15 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gesamtpunkte = $punkte; } + if (isset($ergebnis[$row->prestudent_id]->gesamtoffsetpunkte)) + { + $ergebnis[$row->prestudent_id]->gesamtoffsetpunkte += $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset; + } + else + { + $ergebnis[$row->prestudent_id]->gesamtoffsetpunkte = $ergebnis[$row->prestudent_id]->gebiet[$row->gebiet_id]->punktemitoffset; + } + if (isset($row->punkte)) { if (isset($ergebnis[$row->prestudent_id]->gesamtgewicht)) @@ -1529,28 +1546,6 @@ if (isset($_REQUEST['reihungstest'])) $ergebnis[$row->prestudent_id]->gesamtgewicht = $row->gewicht; } } - - // Gesamtpunkte ohne Physik -/* if ($row->gebiet_id != 10) - { - if (isset($ergebnis[$row->prestudent_id]->gesamt_ohne_physik)) - { - $ergebnis[$row->prestudent_id]->gesamt_ohne_physik += $prozent * $row->gewicht; - } - else - { - $ergebnis[$row->prestudent_id]->gesamt_ohne_physik = $prozent * $row->gewicht; - } - - if (isset($ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik)) - { - $ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik += $punkte; - } - else - { - $ergebnis[$row->prestudent_id]->gesamtpunkte_ohne_physik = $punkte; - } - }*/ } } @@ -1703,7 +1698,7 @@ if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'xls') foreach ($gebiet AS $gbt) { ++$spalte; - $worksheet->write($zeile, ++$spalte, strip_tags($gbt->name) . (isset($gbt->gewicht) ? " (Gew: $gbt->gewicht)" : ""), $format_bold_border); + $worksheet->write($zeile, ++$spalte, strip_tags($gbt->name) . ( isset($gbt->gewicht) ? " (Gew: $gbt->gewicht)" : ""), $format_bold_border); $worksheet->mergeCells($zeile, $spalte, 0, $spalte + 1); $maxlength[$spalte] = 10; } @@ -2142,7 +2137,7 @@ else $("#auswertung_table").tablesorter( { widgets: ["zebra", "filter", "columnSelector"], - sortList: [[15,1],[17,1],[3,0],[4,0]],//16th fake hidden column for correct sort with colspan + sortList: [[15,1],[18,1],[3,0],[4,0]],//16th (index 15) fake hidden column for correct sort with colspan headers: {0: { sorter: false, filter: false}, 2: { sorter: false, filter: false}, 4: { dateFormat: "ddmmyyyy" }, 15: { sorter: false, filter: false}} /*widgetOptions : { columnSelector_container : $("#columnSelector"), @@ -2940,22 +2935,24 @@ else
- '; + '; foreach ($gebiet AS $gbt) { - echo ''; + echo ''; } echo ' + '; foreach ($gebiet AS $gbt) { echo ""; + echo ""; echo ""; } @@ -3010,25 +3007,16 @@ else echo ' ' . ($erg->gesamtpunkte != '' ? number_format($erg->gesamtpunkte, 2, ',', ' ') : '') . ''; } echo ' '; -/* if (!isset($erg->gesamtpunkte_ohne_physik)) - { - $erg->gesamtpunkte_ohne_physik = ''; - }*/ -/* if (!isset($erg->gesamt_ohne_physik)) - { - $erg->gesamt_ohne_physik = ''; - }*/ + + echo ' '; + echo ' '; -/* echo ' ';*/ -/* echo ' ';*/ + foreach ($gebiet AS $gbt) { if (isset($erg->gebiet[$gbt->gebiet_id])) @@ -3060,11 +3048,12 @@ else echo ' ' . ($erg->gebiet[$gbt->gebiet_id]->punkte != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->punkte, 2, ',', ' ') : '') . ''; } echo ''; + echo ''; echo ''; } else { - echo ''; + echo ''; } } From 8c3066604360b09def5969a69528142f03c5f4b0 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 18:43:38 +0100 Subject: [PATCH 136/157] =?UTF-8?q?Testtool=20Login=20shows=20applicants?= =?UTF-8?q?=20only=20once=20(Only=20application=20of=20first=20priority)?= =?UTF-8?q?=20->=20Only=20for=20FHTW!=20New=20function=20getFirstPrioPrest?= =?UTF-8?q?udentRT=20in=20prestudent.class.php=20Link=20to=20pivot-table?= =?UTF-8?q?=20in=20mail=20to=20assistants=20auswertung=5Ffhtw=20ber=C3=BCc?= =?UTF-8?q?ksichtigt=20nun=20orgformen=20(studienpl=C3=A4ne)=20aus=20tbl?= =?UTF-8?q?=5Fablauf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/testtool/login.php | 15 ++++++- include/prestudent.class.php | 56 ++++++++++++++++++++++++++ vilesci/stammdaten/auswertung_fhtw.php | 27 ++++++++++--- 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/cis/testtool/login.php b/cis/testtool/login.php index fac890bc8..f69065aa0 100644 --- a/cis/testtool/login.php +++ b/cis/testtool/login.php @@ -276,7 +276,15 @@ else //$prestudent_id=null; $ps=new prestudent(); $datum=date('Y-m-d'); - $ps->getPrestudentRT($datum); + // An der FHTW wird ein Bewerber nur einmal ausgegeben (1. Prio) falls es mehrere Bewerbungen gibt + if (CAMPUS_NAME == 'FH Technikum Wien') + { + $ps->getFirstPrioPrestudentRT($datum); + } + else + { + $ps->getPrestudentRT($datum); + } } @@ -491,7 +499,10 @@ if (isset($prestudent_id)) echo ''; $stg = new Studiengang($ps_obj->studiengang_kz); - if($ps_obj->lastStatus == "Interessent") + if($ps_obj->lastStatus == "Interessent" + || $ps_obj->lastStatus == "Bewerber" + || $ps_obj->lastStatus == "Wartender" + || $ps_obj->lastStatus == "Aufgenommener") { echo ''; if($ps_obj->ausbildungssemester == '1') diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 4304e5341..923ca81be 100644 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -420,6 +420,62 @@ class prestudent extends person return true; } + /** + * Laden aller Prestudenten, die an $datum zum Reihungstest geladen sind. + * Wenn es mehrere Bewerbungen für ein Person gibt, wird nur die höchste Prestudent_id zurückgeliefert + * @param string $datum Datum in der Form YYYY-MM-DD an dem der Reihungstest stattfindet + * @return true wenn erfolgreich, false im Fehlerfall + */ + public function getFirstPrioPrestudentRT($datum) + { + $sql_query='SELECT DISTINCT + ps.prestudent_id, + pers.vorname, pers.nachname, pers.person_id, pers.titelpre, + pers.titelpost, pers.gebdatum, + tbl_reihungstest.*, + ps.studiengang_kz as studiengang_kz + FROM + public.tbl_prestudent ps + JOIN public.tbl_person pers USING(person_id) + JOIN public.tbl_rt_person USING(person_id) + JOIN public.tbl_reihungstest ON(tbl_reihungstest.reihungstest_id=tbl_rt_person.rt_id) + WHERE + tbl_reihungstest.datum='.$this->db_add_param($datum).' + AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id) + AND EXISTS(SELECT * FROM public.tbl_prestudentstatus JOIN public.tbl_studiensemester USING(studiensemester_kurzbz) + WHERE prestudent_id=ps.prestudent_id AND tbl_studiensemester.ende>'.$this->db_add_param($datum).') + AND priorisierung = (SELECT priorisierung FROM public.tbl_prestudent + WHERE person_id = pers.person_id + AND get_rolle_prestudent (ps.prestudent_id,NULL) IN (\'Interessent\',\'Bewerber\',\'Wartender\',\'Aufgenommener\') + ORDER BY priorisierung ASC LIMIT 1) + ORDER BY nachname,vorname'; + + if(!$this->db_query($sql_query)) + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + + $this->num_rows=0; + + while($row = $this->db_fetch_object()) + { + $ps=new prestudent(); + $ps->prestudent_id = $row->prestudent_id; + $ps->person_id = $row->person_id; + $ps->reihungstest_id = $row->reihungstest_id; + $ps->titelpost = $row->titelpost; + $ps->titelpre = $row->titelpre; + $ps->nachname = $row->nachname; + $ps->vorname = $row->vorname; + $ps->gebdatum = $row->gebdatum; + $ps->studiengang_kz = $row->studiengang_kz; + $this->result[]=$ps; + $this->num_rows++; + } + return true; + } + /** * Laedt über einen Prestudenten alle anderen Prestudenten einer Person, die aktuell an STG interessiert sind. * @integer $prestudent_id Prestudent ID, über die alle weiteren Prestudenten ermittelt werden sollen. diff --git a/vilesci/stammdaten/auswertung_fhtw.php b/vilesci/stammdaten/auswertung_fhtw.php index a47230087..e38be43bf 100644 --- a/vilesci/stammdaten/auswertung_fhtw.php +++ b/vilesci/stammdaten/auswertung_fhtw.php @@ -562,10 +562,9 @@ if ($testende) @@ -643,7 +642,7 @@ if (isset($_POST['method']) && $_POST['method'] == 'addPerson') if ($row->bewerbung_abgeschicktamum != '' && $row->bestaetigtam != '' && $row->studienplan_id != '') { $studienplan = $row->studienplan_id; - $break; + break; } } @@ -1154,7 +1153,7 @@ if (isset($_REQUEST['reihungstest'])) JOIN PUBLIC.tbl_person ON (tbl_rt_person.person_id = tbl_person.person_id) JOIN PUBLIC.tbl_prestudent ps ON (ps.person_id = tbl_rt_person.person_id) JOIN PUBLIC.tbl_reihungstest rt ON (tbl_rt_person.rt_id = rt.reihungstest_id) - JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + JOIN PUBLIC.tbl_prestudentstatus pss USING (prestudent_id) JOIN public.tbl_studiengang ON (ps.studiengang_kz = tbl_studiengang.studiengang_kz) LEFT JOIN bis.tbl_zgv ON (ps.zgv_code = tbl_zgv.zgv_code) LEFT JOIN PUBLIC.tbl_ort ON (tbl_rt_person.ort_kurzbz = tbl_ort.ort_kurzbz) @@ -1196,6 +1195,20 @@ if (isset($_REQUEST['reihungstest'])) { $query .= " AND ps.prestudent_id=" . $db->db_add_param($prestudent_id, FHC_INTEGER); } + if ($orgform_kurzbz != '' && $studiengang != '') + { + $query .= " AND tbl_ablauf.studienplan_id=( + SELECT studienplan_id FROM lehre.tbl_studienplan + JOIN lehre.tbl_studienordnung USING (studienordnung_id) + WHERE studiengang_kz=".$db->db_add_param($studiengang, FHC_INTEGER)." + AND tbl_studienplan.orgform_kurzbz = ".$db->db_add_param($orgform_kurzbz)." + AND tbl_studienplan.aktiv + AND tbl_studienordnung.status_kurzbz='approved' + AND ((SELECT start FROM public.tbl_studiensemester WHERE studiensemester_kurzbz=tbl_studienordnung.gueltigvon) <= now() + OR tbl_studienordnung.gueltigvon IS NULL) + AND ((SELECT ende FROM public.tbl_studiensemester WHERE studiensemester_kurzbz=tbl_studienordnung.gueltigbis) >= now() OR tbl_studienordnung.gueltigbis IS NULL) + ORDER BY studienplan_id DESC LIMIT 1)"; + } //$query .= " AND nachname='Al-Mafrachi'"; $query .= " ORDER BY tbl_ablauf.studiengang_kz, tbl_ablauf.semester, reihung"; @@ -1403,6 +1416,9 @@ if (isset($_REQUEST['reihungstest'])) } if ($orgform_kurzbz != '') { + //$query .= " AND tbl_prestudentstatus.orgform_kurzbz=" . $db->db_add_param($orgform_kurzbz); + //$query .= " AND tbl_ablauf.studienplan_id = tbl_prestudentstatus.studienplan_id"; + //$query .= " AND tbl_ablauf.studienplan_id = 5"; $query .= " AND tbl_studienplan.orgform_kurzbz=" . $db->db_add_param($orgform_kurzbz); } //$query .= " AND nachname='Al-Mafrachi'"; @@ -1410,6 +1426,7 @@ if (isset($_REQUEST['reihungstest'])) vorname, person_id ";/*print_r($query);*/ + //echo '
', var_dump($query), '
'; if (!($result = $db->db_query($query))) { die($db->db_last_error()); From 9586a3e55121d274ea537d9f5231af6ef32031ab Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 21:01:41 +0100 Subject: [PATCH 137/157] Updated function getFirstPrioPrestudentRT --- include/prestudent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 923ca81be..16ed8857d 100644 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -441,7 +441,7 @@ class prestudent extends person JOIN public.tbl_reihungstest ON(tbl_reihungstest.reihungstest_id=tbl_rt_person.rt_id) WHERE tbl_reihungstest.datum='.$this->db_add_param($datum).' - AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id) + /*AND tbl_rt_person.studienplan_id IN (SELECT studienplan_id FROM public.tbl_prestudentstatus WHERE prestudent_id=ps.prestudent_id)*/ AND EXISTS(SELECT * FROM public.tbl_prestudentstatus JOIN public.tbl_studiensemester USING(studiensemester_kurzbz) WHERE prestudent_id=ps.prestudent_id AND tbl_studiensemester.ende>'.$this->db_add_param($datum).') AND priorisierung = (SELECT priorisierung FROM public.tbl_prestudent From ed78f7c7af46287f6d28a5d0177a527c856bddb1 Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Mon, 24 Feb 2020 22:03:06 +0100 Subject: [PATCH 138/157] frage.php: Fallback auf DEFAULT_LANGUAGE wenn kein Vorschlag in der Sessionsprache vorhanden ist --- cis/testtool/frage.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index a760d00aa..86ed76252 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -581,6 +581,14 @@ if($frage->frage_id!='') //Vorschlaege laden $vs = new vorschlag(); $vs->getVorschlag($frage->frage_id, $_SESSION['sprache_user'], $gebiet->zufallvorschlag); + + // Fallback auf DEFAULT_LANGUAGE wenn kein Vorschlag in der $_SESSION['sprache_user'] vorhanden ist + if (isset($vs->result[0]) && $vs->result[0]->text == '' && $vs->result[0]->bild == '' && $vs->result[0]->audio == '') + { + $vs = new vorschlag(); + $vs->getVorschlag($frage->frage_id, DEFAULT_LANGUAGE, $gebiet->zufallvorschlag); + } + $letzte = $frage->getNextFrage($gebiet_id, $_SESSION['pruefling_id'], $frage_id, $demo); echo "frage_id\" method=\"POST\" ".(!$letzte && !$levelgebiet?"onsubmit=\"letzteFrage()\"":"").">"; echo ' From a50cc6cba87c1ff25abc1d84032437e4248c1ef6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 25 Feb 2020 16:41:27 +0100 Subject: [PATCH 139/157] - jobs/MailJob->sendAllMessageEmailNotices changed since parameter default value - Moved ALT_OE from MessageLib to CL/Messages_model - MessageLib->_setSentError renamed to _updatedRecipientNoticeEmailInfo - MessageLib->_sendNoticeEmail changed to have more information about a not sent notice email - Recipient_model->getNotSentMessages now does not retrieve messages with notice email send failure --- application/controllers/jobs/MailJob.php | 3 +- application/libraries/MessageLib.php | 33 +++++++++++++++---- application/models/CL/Messages_model.php | 4 ++- application/models/system/Recipient_model.php | 3 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/application/controllers/jobs/MailJob.php b/application/controllers/jobs/MailJob.php index b4b772f78..f459d4d3e 100644 --- a/application/controllers/jobs/MailJob.php +++ b/application/controllers/jobs/MailJob.php @@ -19,12 +19,13 @@ class MailJob extends JOB_Controller * Send all the NOT sent notice emails for messaging system * The parameters are all not mandatory, they could be used to overrides the configs for testing, debug or one shot purposes */ - public function sendAllMessageEmailNotices($since = null, $numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) + public function sendAllMessageEmailNotices($since = '1970-01-01', $numberToSent = null, $numberPerTimeRange = null, $emailTimeRange = null, $emailFromSystem = null) { $this->logInfo('Send all message email notices started'); // Send them all! $sendAllEmailNotices = $this->messagelib->sendAllEmailNotices($since, $numberToSent, $numberPerTimeRange, $emailTimeRange, $emailFromSystem); + if (isError($sendAllEmailNotices)) { $optionalParameters = new stdClass(); diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index cfd450f98..f2ede9cef 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -26,8 +26,6 @@ class MessageLib const EMAIL_KONTAKT_TYPE = 'email'; // Email kontakt type const SENT_INFO_NEWLINE = '\n'; // tbl_msg_recipient->sentInfo separator - const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent - private $_ci; /** @@ -498,7 +496,7 @@ class MessageLib * Stores the type of error in 'sentinfo' column keeping en eventual previous error * sent column is set to null */ - private function _setSentError($message_id, $receiver_id, $sentInfo, $prevSentInfo) + private function _updatedRecipientNoticeEmailInfo($message_id, $receiver_id, $sentInfo, $prevSentInfo) { if (!isEmptyString($prevSentInfo)) { @@ -763,15 +761,15 @@ class MessageLib if (!$sent) { // Set in database why this email is NOT going to be send - $sse = $this->_setSentError( + $sse = $this->_updatedRecipientNoticeEmailInfo( $messageData->message_id, $messageData->receiver_id, - 'An error occurred while sending the notice email', - $messageData->sentinfo + 'An error occurred while sending the notice email', // current info + $messageData->sentinfo // previous info ); // If database error occurred then return it, otherwise return a logic error - return isError($sse) ? $sse : error('An error occurred while sending the notice email'); + return isError($sse) ? $sse : error('An error occurred while updating the recipient notice email info'); } else // success! { @@ -780,6 +778,27 @@ class MessageLib if (isError($sss)) return $sss; // If database error occurred then return it } } + else // Because was not possible to find a valid contact + { + $reason = 'Was not possible to find a valid contact for this user'; // default reason + + // In case that the organisation unit does not receive any email notices + if (!isEmptyString($messageData->receiver_ou)) $reason = 'This organization unit does not receive email notices'; + + // In case that a degree program sent a message to a user without a valid contact or UID + if (!isEmptyString($messageData->sender_ou)) $reason = 'Sent from a degree program to a user that does not have a valid UID or a valid contact'; + + // Set in database why this email is NOT going to be send + $sse = $this->_updatedRecipientNoticeEmailInfo( + $messageData->message_id, + $messageData->receiver_id, + $reason, // current info + $messageData->sentinfo // previous info + ); + + // If database error occurred then return it + if (isError($sse)) return $sse; + } } return success('Notice emails sent successfully'); diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 9cc4a76da..cbb42543f 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -26,6 +26,8 @@ class Messages_model extends CI_Model const TYPE_PERSONS = 'persons'; const TYPE_PRESTUDENTS = 'prestudents'; + const ALT_OE = 'infocenter'; // alternative organisation unit when no one is found for a presetudent + /** * Constructor */ @@ -106,7 +108,7 @@ class Messages_model extends CI_Model { $ouOptions .= sprintf( "\n".'', - is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : MessageLib::ALT_OE, + is_numeric($ou->prestudent_id) ? $ou->oe_kurzbz : self::ALT_OE, $ou->bezeichnung . (is_numeric($ou->prestudent_id) ? '' : ' *') ); } diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index ad1c1e850..d74d03243 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,12 +205,13 @@ class Recipient_model extends DB_Model * @param limit specifies the max number of messages to get * @param since specifies from which date messages have to be retrieved */ - public function getNotSentMessages($limit, $since = '1970-01-01') + public function getNotSentMessages($limit, $since) { $query = 'SELECT mm.message_id FROM public.tbl_msg_recipient mr JOIN public.tbl_msg_message mm USING (message_id) WHERE mr.sent IS NULL + AND mr.sentinfo IS NULL AND mm.insertamum > ? ORDER BY mr.insertamum ASC LIMIT ?'; From 34afbe9f63ce69c18b2eb0f2cdcd18512b45e9ec Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 26 Feb 2020 13:53:05 +0100 Subject: [PATCH 140/157] system/dbupdate_3.3: added "Alias Studienassistenz" to check for creation of vs_msg_vars in dbupdate --- system/dbupdate_3.3.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 43be48715..623ea7ac7 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3687,8 +3687,8 @@ if(!$result = @$db->db_query("SELECT orgform_kurzbz FROM public.tbl_bankverbindu echo '
public.tbl_bankverbindung: Spalte orgform_kurzbz hinzugefuegt'; } -// iban und bic zu vw_msg_vars hinzufügen -if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) +// iban, bic und weitere Variablen zu vw_msg_vars hinzufügen +if(!$result = @$db->db_query('SELECT "IBAN Studiengang", "BIC Studiengang", "Studiengangskennzahl", "Einstiegssemester", "Einstiegsstudiensemester", "Vorname Studiengangsassistenz", "Nachname Studiengangsassistenz", "Durchwahl Studiengangsassistenz", "Alias Studiengangsassistenz", "Relative Prio" FROM public.vw_msg_vars LIMIT 1')) { $qry = ' CREATE OR REPLACE VIEW public.vw_msg_vars AS ( From 6509d74f4b4f5c47a3780c8fe006486808d061ba Mon Sep 17 00:00:00 2001 From: Manfred Kindl Date: Wed, 26 Feb 2020 15:20:08 +0100 Subject: [PATCH 141/157] Fix height of Prestudent-Statuslist on smaller Screens --- content/student/studentdetailoverlay.xul.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/student/studentdetailoverlay.xul.php b/content/student/studentdetailoverlay.xul.php index 0a014b20a..7f45342dc 100644 --- a/content/student/studentdetailoverlay.xul.php +++ b/content/student/studentdetailoverlay.xul.php @@ -509,7 +509,7 @@ echo '';
Raum TG GesamtGesamt' . $gbt->name . '' . $gbt->name . '
PunktePunkte mit Offset ProzentPunktePunkte mit OffsetProzent + ' . ($erg->gesamtoffsetpunkte != '' ? number_format($erg->gesamtoffsetpunkte, 2, ',', ' ') : '') . ' + ' . $gesamtprozent . ' - ' . ($erg->gesamtpunkte_ohne_physik != '' ? number_format($erg->gesamtpunkte_ohne_physik, 2, ',', ' ') : '') . ' - - ' . ($erg->gesamt_ohne_physik != '' ? number_format($erg->gesamt_ohne_physik, 2, ',', ' ') : '') . ' - - ' . ($erg->gebiet[$gbt->gebiet_id]->punktemitoffset != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->punktemitoffset, 2, ',', ' ') : '') . '' . ($erg->gebiet[$gbt->gebiet_id]->prozent != '' ? number_format($erg->gebiet[$gbt->gebiet_id]->prozent, 2, ',', ' ') . ' %' : '') . '
'. $ps_obj->typ_bz .' '. ($sprache_user == 'English' ? $stg->english : $stg->bezeichnung). '
'; $mailtext .= 'Der Reihungstest vom ' . $datum_obj->convertISODate($reihungstest->datum) . ' um ' . $datum_obj->formatDatum($reihungstest->uhrzeit, 'H:i') . ' Uhr ist beendet.'; - $mailtext .= '
Es haben '.$anzahl.' Person(en) aus dem Studiengang '.$stg->kuerzel.'-'.$orgForm.' teilgenommen'; - $mailtext .= '
Sie finden die Auswertung unter dem folgendem Link:'; + $mailtext .= '
Es haben '.$anzahl.' Person(en) aus dem Studiengang '.$stg->kuerzel.'-'.$orgForm.' teilgenommen.'; $mailtext .= '

Link zur Auswertung'; - + $mailtext .= '

Link zur Pivot-Tabelle für die Priorisierung'; $mailtext .= '
Date: Wed, 26 Feb 2020 17:11:11 +0100 Subject: [PATCH 142/157] Bugfix Fallback Bild Bugfix Loginliste --- cis/testtool/frage.php | 157 ++++++++++++++++++----------------- cis/testtool/login.php | 6 +- include/prestudent.class.php | 27 ++++-- 3 files changed, 104 insertions(+), 86 deletions(-) diff --git a/cis/testtool/frage.php b/cis/testtool/frage.php index 86ed76252..e2c87ed67 100644 --- a/cis/testtool/frage.php +++ b/cis/testtool/frage.php @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Christian Paminger , - * Andreas Oesterreicher , - * Rudolf Hangl , + * Andreas Oesterreicher , + * Rudolf Hangl , * Gerald Simane-Sequens , * Manfred Kindl */ @@ -48,8 +48,8 @@ session_start(); // If language is changed by language select menu, reset language variables if (isset($_GET['sprache_user']) && !empty($_GET['sprache_user'])) { - $_SESSION['sprache_user'] = $_GET['sprache_user']; - $sprache_user = $_GET['sprache_user']; + $_SESSION['sprache_user'] = $_GET['sprache_user']; + $sprache_user = $_GET['sprache_user']; } // Set language variable, which impacts the question language @@ -78,10 +78,10 @@ echo ' - + - - + +