From cec2bb1a279b0251b8ef2cac60353b2bab14e845 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 13:27:55 +0200 Subject: [PATCH 01/10] - Added field status in the primary key array of model MsgStatus_model - Changes in the logic of the messaging system, now every message status is a new entry in the table tbl_msg_status --- application/libraries/MessageLib.php | 396 +++++++++--------- application/models/system/Message_model.php | 115 +++-- application/models/system/MsgStatus_model.php | 2 +- application/models/system/Recipient_model.php | 4 +- 4 files changed, 264 insertions(+), 253 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 253d4abc1..14dea1439 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -1,10 +1,9 @@ ci->load->library("parser"); // Loads LogLib - $this->ci->load->library('LogLib'); + $this->ci->load->library("LogLib"); // Loads VorlageLib - $this->ci->load->library('VorlageLib'); + $this->ci->load->library("VorlageLib"); // Initializing email library with the loaded configurations $this->ci->email->initialize($this->ci->config->config["mail"]); // Loading 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'); + $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 fhc helper - $this->ci->load->helper('fhc'); + $this->ci->load->helper("fhc"); //$this->ci->load->helper('language'); - $this->ci->lang->load('message'); + $this->ci->lang->load("message"); } // ------------------------------------------------------------------------ @@ -52,19 +51,22 @@ class MessageLib * @param integer $msg_id REQUIRED * @return array */ - function getMessage($msg_id) + public function getMessage($msg_id) { if (!is_numeric($msg_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); - $this->ci->MessageModel->addJoin('public.tbl_person', 'person_id'); - $msg = $this->ci->MessageModel->loadWhere(array('message_id' => $msg_id)); - //$msg = $this->ci->MessageModel->getMessage($msg_id); - $stat = $this->ci->MsgStatusModel->loadWhere(array('message_id' => $msg_id)); + $this->ci->MessageModel->addJoin("public.tbl_person", "person_id"); + $msg = $this->ci->MessageModel->loadWhere(array("message_id" => $msg_id)); + + // Sorts the statuses by the insert date, so the first in the array is the most updated + $this->ci->MsgStatusModel->addOrder("insertamum", "DESC"); + $stat = $this->ci->MsgStatusModel->loadWhere(array("message_id" => $msg_id)); $msg->retval[0]->stat = $stat->retval; - $recp = $this->ci->RecipientModel->loadWhere(array('message_id' => $msg_id)); + + $recp = $this->ci->RecipientModel->loadWhere(array("message_id" => $msg_id)); $msg->retval[0]->recp = $recp->retval; - $attm = $this->ci->AttachmentModel->loadWhere(array('message_id' => $msg_id)); + $attm = $this->ci->AttachmentModel->loadWhere(array("message_id" => $msg_id)); $msg->retval[0]->attm = $attm->retval; return $msg; @@ -76,7 +78,7 @@ class MessageLib * @param string $uid REQUIRED * @return array */ - function getMessagesByUID($uid, $all = false) + public function getMessagesByUID($uid, $all = false) { if (empty($uid)) return $this->_error(MSG_ERR_INVALID_MSG_ID); @@ -92,7 +94,7 @@ class MessageLib * @param bigint $person_id REQUIRED * @return array */ - function getMessagesByPerson($person_id, $all = false) + public function getMessagesByPerson($person_id, $all = false) { if (empty($person_id)) return $this->_error(MSG_ERR_INVALID_MSG_ID); @@ -110,7 +112,7 @@ class MessageLib * @param integer $msg_id REQUIRED * @return array */ - function getSubMessages($msg_id) + public function getSubMessages($msg_id) { if (!is_numeric($msg_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); @@ -124,7 +126,7 @@ class MessageLib * @param token string * @return array */ - function getMessagesByToken($token) + public function getMessagesByToken($token) { if (empty($token)) return $this->_error(MSG_ERR_INVALID_MSG_ID); @@ -132,31 +134,33 @@ class MessageLib $result = $this->ci->MessageModel->getMessagesByToken($token); if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) { - if ($result->retval[0]->status == MSG_STATUS_UNREAD) + // 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; + } + } + + // 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_UNREAD + "message_id" => $result->retval[0]->message_id, + "person_id" => $result->retval[0]->receiver_id, + "status" => MSG_STATUS_READ ); - $resTmp = $this->ci->MsgStatusModel->update($statusKey, array('status' => MSG_STATUS_READ)); - if (!is_object($resTmp) || (is_object($resTmp) && $resTmp->error != EXIT_SUCCESS)) - { - $result = $resTmp; - } - else - { - $result->retval[0]->status = MSG_STATUS_READ; - } + + $result = $this->ci->MsgStatusModel->insert($statusKey); } } return $result; } - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ /** @@ -167,7 +171,7 @@ class MessageLib * @param integer $status_id REQUIRED - should come from config/message.php list of constants * @return array */ - function updateMessageStatus($message_id, $person_id, $status) + public function updateMessageStatus($message_id, $person_id, $status) { if (empty($message_id)) { @@ -185,10 +189,23 @@ class MessageLib return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID); } - $result = $this->ci->MsgStatusModel->update( - array('message_id' => $message_id, 'person_id' => $person_id), - array('status' => $status) - ); + // Searches if the status is already present + $result = $this->ci->MsgStatusModel->load(array($message_id, $person_id, $status)); + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) + { + // status already present + } + else + { + // Insert the new status + $statusKey = array( + "message_id" => $message_id, + "person_id" => $person_id, + "status" => $status + ); + + $result = $this->ci->MsgStatusModel->insert($statusKey); + } return $result; } @@ -202,7 +219,7 @@ class MessageLib * @param integer $user_id REQUIRED * @return array */ - function addRecipient($person_id) + public function addRecipient($person_id) { if (!is_numeric($person_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); @@ -212,8 +229,6 @@ class MessageLib return true; } - - // ------------------------------------------------------------------------ /** @@ -226,7 +241,7 @@ class MessageLib * @param integer $priority * @return array */ - function sendMessage($sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null) + public function sendMessage($sender_id, $subject = "", $body = "", $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null) { if (!is_numeric($sender_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); @@ -235,12 +250,12 @@ class MessageLib $this->ci->db->trans_start(false); //save Message $data = array( - 'person_id' => $sender_id, - 'subject' => $subject, - 'body' => $body, - 'priority' => $priority, - 'relationmessage_id' => $relationmessage_id, - 'oe_kurzbz' => $oe_kurzbz + "person_id" => $sender_id, + "subject" => $subject, + "body" => $body, + "priority" => $priority, + "relationmessage_id" => $relationmessage_id, + "oe_kurzbz" => $oe_kurzbz ); $result = $this->ci->MessageModel->insert($data); @@ -251,9 +266,9 @@ class MessageLib */ $msg_id = $result->retval; $statusData = array( - 'message_id' => $msg_id, - 'person_id' => $sender_id, - 'status' => MSG_STATUS_UNREAD + "message_id" => $msg_id, + "person_id" => $sender_id, + "status" => MSG_STATUS_UNREAD ); $result = $this->ci->MsgStatusModel->insert($statusData); } @@ -282,13 +297,13 @@ class MessageLib * @param integer $priority * @return array */ - function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null) + public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null) { if (!is_numeric($sender_id) || !is_numeric($receiver_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); // Load reveiver data to get its relative language - $this->ci->load->model('person/Person_model', 'PersonModel'); + $this->ci->load->model("person/Person_model", "PersonModel"); $result = $this->ci->PersonModel->load($receiver_id); if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) { @@ -314,12 +329,12 @@ class MessageLib $this->ci->db->trans_start(false); // Save Message $msgData = array( - 'person_id' => $sender_id, - 'subject' => $result->retval[0]->subject, - 'body' => $parsedText, - 'priority' => PRIORITY_NORMAL, - 'relationmessage_id' => $relationmessage_id, - 'oe_kurzbz' => $oe_kurzbz + "person_id" => $sender_id, + "subject" => $result->retval[0]->subject, + "body" => $parsedText, + "priority" => PRIORITY_NORMAL, + "relationmessage_id" => $relationmessage_id, + "oe_kurzbz" => $oe_kurzbz ); $result = $this->ci->MessageModel->insert($msgData); if (is_object($result) && $result->error == EXIT_SUCCESS) @@ -327,18 +342,18 @@ class MessageLib // Link the message with the receiver $msg_id = $result->retval; $recipientData = array( - 'person_id' => $receiver_id, - 'message_id' => $msg_id, - 'token' => generateToken() + "person_id" => $receiver_id, + "message_id" => $msg_id, + "token" => generateToken() ); $result = $this->ci->RecipientModel->insert($recipientData); if (is_object($result) && $result->error == EXIT_SUCCESS) { // Save message status $statusData = array( - 'message_id' => $msg_id, - 'person_id' => $receiver_id, - 'status' => MSG_STATUS_UNREAD + "message_id" => $msg_id, + "person_id" => $receiver_id, + "status" => MSG_STATUS_UNREAD ); $result = $this->ci->MsgStatusModel->insert($statusData); } @@ -362,21 +377,21 @@ class MessageLib // Better message error if (!is_array($result->retval) || (is_array($result->retval) && count($result->retval) == 0)) { - $result = $this->_error('Vorlage not found', EXIT_ERROR); + $result = $this->_error("Vorlage not found", EXIT_ERROR); } else if (is_array($result->retval) && count($result->retval) > 0) { if (is_null($result->retval[0]->oe_kurzbz)) { - $result = $this->_error('Vorlage not found', EXIT_ERROR); + $result = $this->_error("Vorlage not found", EXIT_ERROR); } else if (empty($result->retval[0]->text)) { - $result = $this->_error('Vorlage has an empty text', EXIT_ERROR); + $result = $this->_error("Vorlage has an empty text", EXIT_ERROR); } else if (empty($result->retval[0]->subject)) { - $result = $this->_error('Vorlage has an empty subject', EXIT_ERROR); + $result = $this->_error("Vorlage has an empty subject", EXIT_ERROR); } } } @@ -389,123 +404,6 @@ class MessageLib return $result; } - - - // ------------------------------------------------------------------------ - // Private Functions from here out! - // ------------------------------------------------------------------------ - - /** --------------------------------------------------------------- - * Success - * - * @param mixed $retval - * @return array - */ - protected function _success($retval, $message = MSG_SUCCESS) - { - $return = new stdClass(); - $return->error = EXIT_SUCCESS; - $return->Code = $message; - $return->msg = lang('message_' . $message); - $return->retval = $retval; - return $return; - } - - /** --------------------------------------------------------------- - * General Error - * - * @return array - */ - protected function _error($retval = '', $message = MSG_ERROR) - { - $return = new stdClass(); - $return->error = EXIT_ERROR; - $return->Code = $message; - $return->msg = lang('message_' . $message); - $return->retval = $retval; - return $return; - } - /** - * Invalid ID - * - * @param integer config.php error code numbers - * @return array - */ - private function _invalid_id($error = '') - { - return array( - 'err' => 1, - 'code' => $error, - 'msg' => lang('message_'.$error) - ); - } - - /** - * Gets an item from the email configuration array - */ - private function getEmailCfgItem($itemName) - { - return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX); - } - - /** - * Sends a single email - */ - private function sendOne($from, $to, $subject, $message, $alias = "", $cc = null, $bcc = null) - { - $this->ci->email->from($from, $alias); - $this->ci->email->to($to); - if (!is_null($cc)) $this->ci->email->cc($cc); - if (!is_null($bcc)) $this->ci->email->bcc($bcc); - $this->ci->email->subject($subject); - $this->ci->email->message($message); - - // Avoid printing on standard output ugly error messages - return @$this->ci->email->send(); - } - - /** - * Update the table tbl_message_recipient - */ - private function _updateMessageRecipient($message_id, $receiver_id, $parameters) - { - $updated = false; - - // Changes the status of the message from unread to read - $resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); - // Checks if errors were occurred - if (is_object($resultUpdate) && $resultUpdate->error == EXIT_SUCCESS && is_array($resultUpdate->retval)) - { - $updated = true; - } - - return $updated; - } - - /** - * Changes the status of the message from unsent to sent - */ - private function setMessageSent($message_id, $receiver_id) - { - $parameters = array("sent" => "NOW()", "sentinfo" => null); - - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); - } - - /** - * Sets the sentInfo with the error - */ - private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null) - { - if (!is_null($prevSentInfo) && $prevSentInfo != "") - { - $sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo; - } - - $parameters = array("sent" => null, "sentinfo" => $sentInfo); - - return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); - } /** * Gets all the messages from DB and sends them via email @@ -631,4 +529,120 @@ class MessageLib return $sent; } + + // ------------------------------------------------------------------------ + // Private Functions from here out! + // ------------------------------------------------------------------------ + + /** --------------------------------------------------------------- + * Success + * + * @param mixed $retval + * @return array + */ + protected function _success($retval, $message = MSG_SUCCESS) + { + $return = new stdClass(); + $return->error = EXIT_SUCCESS; + $return->Code = $message; + $return->msg = lang("message_" . $message); + $return->retval = $retval; + return $return; + } + + /** --------------------------------------------------------------- + * General Error + * + * @return array + */ + protected function _error($retval = "", $message = MSG_ERROR) + { + $return = new stdClass(); + $return->error = EXIT_ERROR; + $return->Code = $message; + $return->msg = lang("message_" . $message); + $return->retval = $retval; + return $return; + } + /** + * Invalid ID + * + * @param integer config.php error code numbers + * @return array + */ + private function _invalid_id($error = "") + { + return array( + "err" => 1, + "code" => $error, + "msg" => lang("message_".$error) + ); + } + + /** + * Gets an item from the email configuration array + */ + private function getEmailCfgItem($itemName) + { + return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX); + } + + /** + * Sends a single email + */ + private function sendOne($from, $to, $subject, $message, $alias = "", $cc = null, $bcc = null) + { + $this->ci->email->from($from, $alias); + $this->ci->email->to($to); + if (!is_null($cc)) $this->ci->email->cc($cc); + if (!is_null($bcc)) $this->ci->email->bcc($bcc); + $this->ci->email->subject($subject); + $this->ci->email->message($message); + + // Avoid printing on standard output ugly error messages + return @$this->ci->email->send(); + } + + /** + * Update the table tbl_message_recipient + */ + private function _updateMessageRecipient($message_id, $receiver_id, $parameters) + { + $updated = false; + + // Changes the status of the message from unread to read + $resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters); + // Checks if errors were occurred + if (is_object($resultUpdate) && $resultUpdate->error == EXIT_SUCCESS && is_array($resultUpdate->retval)) + { + $updated = true; + } + + return $updated; + } + + /** + * Changes the status of the message from unsent to sent + */ + private function setMessageSent($message_id, $receiver_id) + { + $parameters = array("sent" => "NOW()", "sentinfo" => null); + + return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); + } + + /** + * Sets the sentInfo with the error + */ + private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null) + { + if (!is_null($prevSentInfo) && $prevSentInfo != "") + { + $sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo; + } + + $parameters = array("sent" => null, "sentinfo" => $sentInfo); + + return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters); + } } \ No newline at end of file diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 602a01694..c28e3a547 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -1,6 +1,6 @@ dbTable = 'public.tbl_msg_message'; - $this->pk = 'message_id'; + $this->dbTable = "public.tbl_msg_message"; + $this->pk = "message_id"; } public function getMessagesByUID($uid, $all) @@ -21,50 +21,46 @@ class Message_model extends DB_Model // if same user if ($uid === getAuthUID()) { - if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message', FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> basis/message", FHC_MODEL_ERROR); } // if different user, for reading messages from other users else { - if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message:all', FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> basis/message:all", FHC_MODEL_ERROR); } // get Data - $sql = 'SELECT uid, - person_id, - message_id, - subject, - body, - priority, - relationmessage_id, - oe_kurzbz, + $sql = "SELECT b.uid, + m.person_id, + m.message_id, + m.subject, + m.body, + m.priority, + m.relationmessage_id, + m.oe_kurzbz, m.insertamum, - anrede, - titelpost, - titelpre, - nachname, - vorname, - vornamen, - status, - statusinfo, + p.anrede, + p.titelpost, + p.titelpre, + p.nachname, + p.vorname, + p.vornamen, + s.status, + s.statusinfo, s.insertamum AS statusamum - FROM public.tbl_msg_message m JOIN public.tbl_person USING (person_id) - JOIN public.tbl_benutzer USING (person_id) - LEFT OUTER JOIN ( - SELECT message_id, person_id, status, statusinfo, tbl_msg_status.insertamum - FROM public.tbl_msg_status INNER JOIN ( - SELECT message_id, person_id, max(insertamum) AS insertamum - FROM public.tbl_msg_status - GROUP BY message_id, person_id - ) status USING (message_id, person_id) - WHERE tbl_msg_status.insertamum=status.insertamum - ) s USING (message_id, person_id) - WHERE uid = ?'; + FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) + JOIN public.tbl_person p ON (r.person_id = p.person_id) + JOIN public.tbl_benutzer b ON (r.person_id = b.person_id) + JOIN ( + SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1 + ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id) + WHERE b.uid = ?"; if (! $all) - $sql .= ' AND (status < 3 OR status IS NULL)'; + $sql .= " AND (status < 3 OR status IS NULL)"; + $result = $this->db->query($sql, array($uid)); if (is_object($result)) return $this->_success($result->result()); @@ -75,16 +71,16 @@ class Message_model extends DB_Model public function getMessagesByPerson($person_id, $all) { // Check wrights - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_recipient'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_recipient'), FHC_MODEL_ERROR); - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_message'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_message'), FHC_MODEL_ERROR); - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_person'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_person'), FHC_MODEL_ERROR); - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_status'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_status'), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_person"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_person"), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR); - $sql = 'SELECT r.message_id, + $sql = "SELECT r.message_id, m.person_id, m.subject, m.body, @@ -93,11 +89,13 @@ class Message_model extends DB_Model m.oe_kurzbz, s.status, s.statusinfo, - s.updateamum + s.insertamum AS statusamum FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) JOIN public.tbl_person p ON (p.person_id = m.person_id) - JOIN public.tbl_msg_status s USING (message_id) - WHERE r.person_id = ?'; + JOIN ( + SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1 + ) s ON (m.message_id = s.message_id AND r.person_id = s.person_id) + WHERE r.person_id = ?"; $result = $this->db->query($sql, array($person_id)); if (is_object($result)) @@ -109,14 +107,14 @@ class Message_model extends DB_Model public function getMessagesByToken($token) { // Check wrights - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_recipient'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_recipient'), FHC_MODEL_ERROR); - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_message'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_message'), FHC_MODEL_ERROR); - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_status'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_status'), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR); + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s")) + return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR); - $sql = 'SELECT r.message_id, + $sql = "SELECT r.message_id, r.person_id as receiver_id, m.person_id as sender_id, m.subject, @@ -126,11 +124,12 @@ class Message_model extends DB_Model m.oe_kurzbz, s.status, s.statusinfo, - s.updateamum + s.insertamum FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) - JOIN public.tbl_msg_status s USING (message_id) + JOIN public.tbl_msg_status s ON (r.message_id = s.message_id AND r.person_id = s.person_id) WHERE r.token = ? - AND status < ?'; + AND status < ? + ORDER BY s.insertamum DESC"; $result = $this->db->query($sql, array($token, MSG_STATUS_DELETED)); if (is_object($result)) diff --git a/application/models/system/MsgStatus_model.php b/application/models/system/MsgStatus_model.php index 81aaba06b..b6a6da286 100644 --- a/application/models/system/MsgStatus_model.php +++ b/application/models/system/MsgStatus_model.php @@ -11,7 +11,7 @@ class MsgStatus_model extends DB_Model { parent::__construct(); $this->dbTable = "public.tbl_msg_status"; - $this->pk = array("message_id", "person_id"); + $this->pk = array("message_id", "person_id", "status"); $this->hasSequence = false; } } \ No newline at end of file diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 47d6e5d57..6e6352c93 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -24,7 +24,7 @@ class Recipient_model extends DB_Model */ public function getMessages($kontaktType, $sent, $limit = null) { - // Check wrights + // Check rights if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s")) return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR); if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s")) @@ -67,8 +67,6 @@ class Recipient_model extends DB_Model array_push($parametersArray, $limit); } - - // Get data of the messages to sent $result = $this->db->query($query, $parametersArray); if (is_object($result)) From 763eaa65921fde7a988e634e917b7ebcbecc673e Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 13:36:45 +0200 Subject: [PATCH 02/10] Added migration script 013_akte.php --- application/migrations/013_akte.php | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 application/migrations/013_akte.php diff --git a/application/migrations/013_akte.php b/application/migrations/013_akte.php new file mode 100644 index 000000000..21ad85f6a --- /dev/null +++ b/application/migrations/013_akte.php @@ -0,0 +1,38 @@ +startUP(); + + // Add nachgereicht_am to public.tbl_akte + $columns = array( + "nachgereicht_am" => array( + "type" => "date", + "null" => true + ) + ); + $this->addColumn("public", "tbl_akte", $columns); + + $this->endUP(); + } + + public function down() + { + $this->startDown(); + + $this->dropColumn("public", "tbl_akte", "nachgereicht_am"); + + $this->endDown(); + } +} \ No newline at end of file From 359929423760477d7235ac534e6bf03af77e273b Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 13:50:07 +0200 Subject: [PATCH 03/10] Added method getLastStatus to controller Prestudentstatus --- .../api/v1/crm/Prestudentstatus.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/application/controllers/api/v1/crm/Prestudentstatus.php b/application/controllers/api/v1/crm/Prestudentstatus.php index 8c415f942..721e6ca8c 100644 --- a/application/controllers/api/v1/crm/Prestudentstatus.php +++ b/application/controllers/api/v1/crm/Prestudentstatus.php @@ -49,6 +49,27 @@ class Prestudentstatus extends APIv1_Controller $this->response(); } } + + /** + * @return void + */ + public function getLastStatus() + { + $prestudent_id = $this->get("prestudent_id"); + $studiensemester_kurzbz = $this->get("studiensemester_kurzbz"); + $status_kurzbz = $this->get("status_kurzbz"); + + if (isset($prestudent_id)) + { + $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } /** * @return void From 11960628c0ba85ace5d05eb2cdb6255b6600855f Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 14:16:10 +0200 Subject: [PATCH 04/10] Fixed method getMessagesByToken --- application/models/system/Message_model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index c28e3a547..a114e58b2 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -124,9 +124,11 @@ class Message_model extends DB_Model m.oe_kurzbz, s.status, s.statusinfo, - s.insertamum + s.insertamum as statusamum FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id) - JOIN public.tbl_msg_status s ON (r.message_id = s.message_id AND r.person_id = s.person_id) + JOIN ( + SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1 + ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id) WHERE r.token = ? AND status < ? ORDER BY s.insertamum DESC"; From 9ed193d9b8f55377ad4aba0db8d327712cf95e25 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 14:28:10 +0200 Subject: [PATCH 05/10] Moved methods getLastStatus from Prestudent to Prestudentstatus --- .../controllers/api/v1/crm/Prestudent.php | 21 --------- .../api/v1/crm/Prestudentstatus.php | 4 +- application/models/crm/Prestudent_model.php | 46 ------------------- .../models/crm/Prestudentstatus_model.php | 46 +++++++++++++++++++ 4 files changed, 47 insertions(+), 70 deletions(-) diff --git a/application/controllers/api/v1/crm/Prestudent.php b/application/controllers/api/v1/crm/Prestudent.php index e067a3894..e3498e9cd 100644 --- a/application/controllers/api/v1/crm/Prestudent.php +++ b/application/controllers/api/v1/crm/Prestudent.php @@ -63,27 +63,6 @@ class Prestudent extends APIv1_Controller $this->response(); } } - - /** - * @return void - */ - public function getLastStatus() - { - $prestudent_id = $this->get('prestudent_id'); - $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); - $status_kurzbz = $this->get('status_kurzbz'); - - if (isset($prestudent_id)) - { - $result = $this->PrestudentModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz); - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } /** * @return void diff --git a/application/controllers/api/v1/crm/Prestudentstatus.php b/application/controllers/api/v1/crm/Prestudentstatus.php index 721e6ca8c..7d5bc84f9 100644 --- a/application/controllers/api/v1/crm/Prestudentstatus.php +++ b/application/controllers/api/v1/crm/Prestudentstatus.php @@ -24,8 +24,6 @@ class Prestudentstatus extends APIv1_Controller parent::__construct(); // Load model PrestudentstatusModel $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); - - } /** @@ -110,4 +108,4 @@ class Prestudentstatus extends APIv1_Controller { return true; } -} +} \ No newline at end of file diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index c5896da64..9353444cd 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -11,50 +11,4 @@ class Prestudent_model extends DB_Model $this->dbTable = 'public.tbl_prestudent'; $this->pk = 'prestudent_id'; } - - /** - * @return void - */ - public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '') - { - // Checks if the operation is permitted by the API caller - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), FHC_MODEL_ERROR); - - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('lehre.tbl_studienplan'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('lehre.tbl_studienplan'), FHC_MODEL_ERROR); - - if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_status'), 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_status'), FHC_MODEL_ERROR); - - $query = "SELECT tbl_prestudentstatus.*, - bezeichnung AS studienplan_bezeichnung, - tbl_status.bezeichnung_mehrsprachig - FROM public.tbl_prestudentstatus LEFT JOIN lehre.tbl_studienplan USING (studienplan_id) - JOIN public.tbl_status USING (status_kurzbz) - WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz - AND prestudent_id = ?"; - - $parametersArray = array($prestudent_id); - - if ($studiensemester_kurzbz != '') - { - array_push($parametersArray, $studiensemester_kurzbz); - $query .= ' AND studiensemester_kurzbz = ?'; - } - if ($status_kurzbz != '') - { - array_push($parametersArray, $status_kurzbz); - $query .= ' AND status_kurzbz = ?'; - } - - $query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1'; - - $result = $this->db->query($query, $parametersArray); - - if (is_object($result)) - return $this->_success($result->result()); - else - return $this->_error($this->db->error(), FHC_DB_ERROR); - } } \ No newline at end of file diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 8f6b57a41..6d960a07b 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -12,4 +12,50 @@ class Prestudentstatus_model extends DB_Model $this->pk = array('ausbildungssemester', 'studiensemester_kurzbz', 'status_kurzbz', 'prestudent_id'); $this->hasSequence = false; } + + /** + * @return void + */ + public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '') + { + // Checks if the operation is permitted by the API caller + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), FHC_MODEL_ERROR); + + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('lehre.tbl_studienplan'), 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('lehre.tbl_studienplan'), FHC_MODEL_ERROR); + + if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_status'), 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_status'), FHC_MODEL_ERROR); + + $query = "SELECT tbl_prestudentstatus.*, + bezeichnung AS studienplan_bezeichnung, + tbl_status.bezeichnung_mehrsprachig + FROM public.tbl_prestudentstatus LEFT JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN public.tbl_status USING (status_kurzbz) + WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz + AND prestudent_id = ?"; + + $parametersArray = array($prestudent_id); + + if ($studiensemester_kurzbz != '') + { + array_push($parametersArray, $studiensemester_kurzbz); + $query .= ' AND studiensemester_kurzbz = ?'; + } + if ($status_kurzbz != '') + { + array_push($parametersArray, $status_kurzbz); + $query .= ' AND status_kurzbz = ?'; + } + + $query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1'; + + $result = $this->db->query($query, $parametersArray); + + if (is_object($result)) + return $this->_success($result->result()); + else + return $this->_error($this->db->error(), FHC_DB_ERROR); + } } \ No newline at end of file From 13145fd696db34573652cddd92927eb6ea1113fa Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 16:49:49 +0200 Subject: [PATCH 06/10] Color it!!! --- application/libraries/MigrationLib.php | 66 +++++++++++++++++++++----- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/application/libraries/MigrationLib.php b/application/libraries/MigrationLib.php index 0a9d1dfef..ac80ff351 100644 --- a/application/libraries/MigrationLib.php +++ b/application/libraries/MigrationLib.php @@ -8,11 +8,16 @@ if (! defined("BASEPATH")) exit("No direct script access allowed"); class MigrationLib extends CI_Migration { // Prefixes and separator for messages - private $MSG_PREFIX = "[-]"; - private $INFO_PREFIX = "[I]"; - private $ERROR_PREFIX = "[E]"; - private $SEPARATOR = "------------------------------"; + const MSG_PREFIX = "[-]"; + const INFO_PREFIX = "[I]"; + const ERROR_PREFIX = "[E]"; + const SEPARATOR = "------------------------------"; + // Console colors codes + const ERROR_COLOR = 31; + const INFO_COLOR = 33; + // HTML colors names + private $HTML_COLORS = array(31 => "red", 33 => "orange"); // Used to set if the migration process is called via command line or via browser private $cli; @@ -58,12 +63,42 @@ class MigrationLib extends CI_Migration } } + /** + * Returns the string needed to color the output + */ + private function getColored($color) + { + $colored = "%s"; + + if (!is_null($color)) + { + if ($this->cli === true) + { + $colored = "\033[" . $color . "m%s\033[37m"; + } + else + { + $colored = "HTML_COLORS[$color] . "\">%s"; + } + } + + return $colored; + } + + /** + * Print a message, even colored if specified + */ + private function _print($prefix, $text, $color = null) + { + printf($this->getColored($color), sprintf("%s %s" . $this->getEOL(), $prefix, $text)); + } + /** * Prints a formatted message */ private function printMessage($message) { - printf("%s %s" . $this->getEOL(), $this->MSG_PREFIX, $message); + $this->_print(MigrationLib::MSG_PREFIX, $message); } /** @@ -71,7 +106,7 @@ class MigrationLib extends CI_Migration */ private function printInfo($info) { - printf("%s %s" . $this->getEOL(), $this->INFO_PREFIX, $info); + $this->_print(MigrationLib::INFO_PREFIX, $info, MigrationLib::INFO_COLOR); } /** @@ -79,7 +114,7 @@ class MigrationLib extends CI_Migration */ private function printError($error) { - printf("%s %s" . $this->getEOL(), $this->ERROR_PREFIX, $error); + $this->_print(MigrationLib::ERROR_PREFIX, $error, MigrationLib::ERROR_COLOR); } /** @@ -102,7 +137,9 @@ class MigrationLib extends CI_Migration */ protected function startUP() { - $this->printInfo(sprintf("%s Start method up of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR)); + $this->printInfo(sprintf("%s Start method up of class %s %s", + MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR) + ); } /** @@ -110,7 +147,9 @@ class MigrationLib extends CI_Migration */ protected function endUP() { - $this->printInfo(sprintf("%s End method up of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR)); + $this->printInfo(sprintf("%s End method up of class %s %s", + MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR) + ); } /** @@ -118,7 +157,9 @@ class MigrationLib extends CI_Migration */ protected function startDown() { - $this->printInfo(sprintf("%s Start method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR)); + $this->printInfo(sprintf("%s Start method down of class %s %s", + MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR) + ); } /** @@ -126,7 +167,9 @@ class MigrationLib extends CI_Migration */ protected function endDown() { - $this->printInfo(sprintf("%s End method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR)); + $this->printInfo(sprintf("%s End method down of class %s %s", + MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR) + ); } /** @@ -477,7 +520,6 @@ class MigrationLib extends CI_Migration } } - /** * Executes the given query */ From 4edc917b3df6f673400653d7167264ba24aaa4d0 Mon Sep 17 00:00:00 2001 From: oesi Date: Wed, 27 Jul 2016 16:52:04 +0200 Subject: [PATCH 07/10] =?UTF-8?q?Men=C3=BCpunkt=20f=C3=BCr=20Bewerberakt?= =?UTF-8?q?=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/fas.xul.php | 7 +++++ content/student/studentoverlay.js.php | 39 +++++++++++++++++++++++++++ locale/de-AT/fas.dtd | 4 +++ 3 files changed, 50 insertions(+) diff --git a/content/fas.xul.php b/content/fas.xul.php index 7d7e189ff..492ca34d9 100644 --- a/content/fas.xul.php +++ b/content/fas.xul.php @@ -120,6 +120,7 @@ foreach($addon_obj->result as $addon) + @@ -475,6 +476,12 @@ foreach($addon_obj->result as $addon) + 0) + window.open('content/dokumentenakt.pdf.php?prestudent_ids='+paramList+'&output='+output+'&vorlage_kurzbz=Bewerberakt','Bewerberakt', 'height=200,width=350,left=0,top=0,hotkeys=0,resizable=yes,status=no,scrollbars=yes,toolbar=no,location=no,menubar=no,dependent=yes'); + else + alert('Bitte markieren Sie zuerst eine oder mehrere Personen'); +} + // **** // * Excel Export der Studentendaten // **** diff --git a/locale/de-AT/fas.dtd b/locale/de-AT/fas.dtd index 58783c98f..61d7aa51d 100644 --- a/locale/de-AT/fas.dtd +++ b/locale/de-AT/fas.dtd @@ -191,6 +191,10 @@ + + + + From 6d0f5d2bec2aee1cfc97ad33a09b0eceaa206a71 Mon Sep 17 00:00:00 2001 From: Andreas Moik Date: Wed, 27 Jul 2016 17:18:38 +0200 Subject: [PATCH 08/10] Dokumentenakt --- content/dokumentenakt.pdf.php | 218 +++++++++++++++++++++++++++++ include/dokument_export.class.php | 29 +++- include/pdf.class.php | 107 ++++++++++++++ system/dbupdate_3.2.php | 33 +++++ system/vorlage_zip/Bewerberakt.odt | Bin 0 -> 9434 bytes system/xsl/Bewerberakt.xsl | 14 ++ 6 files changed, 400 insertions(+), 1 deletion(-) create mode 100755 content/dokumentenakt.pdf.php create mode 100644 include/pdf.class.php create mode 100644 system/vorlage_zip/Bewerberakt.odt create mode 100644 system/xsl/Bewerberakt.xsl diff --git a/content/dokumentenakt.pdf.php b/content/dokumentenakt.pdf.php new file mode 100755 index 000000000..1b0077c74 --- /dev/null +++ b/content/dokumentenakt.pdf.php @@ -0,0 +1,218 @@ +. + */ + + +require_once(dirname(__FILE__).'/../config/vilesci.config.inc.php'); +require_once(dirname(__FILE__).'/../include/pdf.class.php'); +require_once(dirname(__FILE__).'/../include/dokument_export.class.php'); +require_once(dirname(__FILE__).'/../include/phrasen.class.php'); +require_once(dirname(__FILE__).'/../include/prestudent.class.php'); +require_once(dirname(__FILE__).'/../include/dms.class.php'); + +$sprache = getSprache(); +$p=new phrasen($sprache); + +$db = new basis_db(); + +$user = get_uid(); + +if(!isset($_GET["prestudent_ids"]) || !isset($_GET["vorlage_kurzbz"])) + die($p->t('anwesenheitsliste/fehlerhafteParameteruebergabe')); + +$prestudent_ids = explode(";", $_GET["prestudent_ids"]); + +if(count($prestudent_ids) < 1) + die($p->t('anwesenheitsliste/fehlerhafteParameteruebergabe')); + + + +/* + * Temporaeren Ordner fuer die erstellung der Dokumente generieren + */ +$tmpDir = sys_get_temp_dir() . "/dokumentenakt_" . uniqid(); + +if (!file_exists($tmpDir)) + mkdir($tmpDir, 0777, true); + +/* + * converter classes + */ +$pdf = new pdf(); +$docExp = new dokument_export(); + + +/* + * Create Documents + */ +$allDocs = array(); +foreach($prestudent_ids as $pid) +{ + $prestudent = new prestudent(); + if(!$prestudent->load($pid)) + cleanUpAndDie($p->t('tools/studentWurdeNichtGefunden')."(".$pid.")", $tmpDir); + + /* + * Deckblatt + */ + $filename = $tmpDir . "/".uniqid(); + $doc = new dokument_export('Bewerberakt'); + $doc->addDataArray(array('vorname' => $prestudent->vorname, 'nachname' => $prestudent->nachname),'bewerberakt'); + + if(!$doc->create('pdf')) + die($doc->errormsg); + $doc->temp_filename = $filename; + $doc->output(false); + //$doc->close(); + $allDocs[] = $filename; + + + /* + * Get all Documents + */ + $query= ' + SELECT + titel, dms_id, inhalt + FROM + public.tbl_dokumentstudiengang + JOIN public.tbl_prestudent USING(studiengang_kz) + JOIN public.tbl_akte USING(person_id,dokument_kurzbz) + WHERE + onlinebewerbung + AND prestudent_id='.$db->db_add_param($pid, FHC_INTEGER).'; + '; + + $result = $db->db_query($query); + while($row = $db->db_fetch_object($result)) + { + + + $filename = ""; + if($row->dms_id != null) + { + $dms = new dms(); + $dms->load($row->dms_id); + + $filename = DMS_PATH . $dms->filename; + } + else if($row->inhalt != null) + { + $filename = $tmpDir . "/".uniqid(); + $fileData = base64_decode($row->inhalt); + file_put_contents($filename, $fileData); + } + + + if($filename == "") + continue; + + + /* + * Determine the filetype + * and convert, if nessecary + */ + $explodedTitle = explode(".", $row->titel); + $type = $explodedTitle[count($explodedTitle)-1]; + if($type == "jpg" || $type = "jpeg") + { + $fullFilename = $tmpDir . "/".uniqid() . ".pdf"; + if(!$pdf->jpegToPdf($filename, $fullFilename)) + cleanUpAndDie($pdf->errormsg, $tmpDir); + } + else if($type == "odt" || $type == "doc" || $type == "docx") + { + $fullFilename = $tmpDir . "/".uniqid() . ".pdf"; + $docExp->convert($filename, $fullFilename, "pdf"); + } + else if($type == "pdf") + { + $fullFilename = $row->titel; + } + else + cleanUpAndDie("falscher typ TODO", $tmpDir); + + // only filled, if the file is supported + if($fullFilename != "") + { + $allDocs[] = $fullFilename; + } + + } +} + + +/* + * generate the merged PDF + */ +$finishedPdf = $tmpDir . "/Dokumentenakt.pdf"; +if(!$pdf->merge($allDocs, $finishedPdf)) + cleanUpAndDie($pdf->errormsg, $tmpDir); +$fsize = filesize($finishedPdf); + +if(!$handle = fopen($finishedPdf,'r')) + die('load failed'); + +header('Content-type: application/pdf'); +header('Content-Disposition: attachment; filename="'.$finishedPdf); +header('Content-Length: '.$fsize); + +while (!feof($handle)) +{ + echo fread($handle, 8192); +} +fclose($handle); + + + + +/* + * Cleanup + */ +removeFolder($tmpDir); + + + + + +/* + * Functions + */ +function cleanUpAndDie($msg, $tmpDir) +{ + removeFolder($tmpDir); + die($msg); +} + +function removeFolder($dir) +{ + + if($dir == "/") + return false; + if (is_dir($dir) === true) + { + $files = array_diff(scandir($dir), array('.', '..')); + foreach ($files as $file) + { + unlink($dir . "/" . $file); + } + return rmdir($dir); + } + return false; +} +?> diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index f60f94c3e..c24725ec1 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Authors: Andreas Oesterreicher and + * Andreas Moik . */ require_once(dirname(__FILE__).'/vorlage.class.php'); require_once(dirname(__FILE__).'/addon.class.php'); @@ -37,8 +38,11 @@ class dokument_export /** * Konstruktor */ - public function __construct($vorlage, $oe_kurzbz=0, $version=null) + public function __construct($vorlage = null, $oe_kurzbz=0, $version=null) { + if(!isset($vorlage)) + return; + //Vorlage aus der Datenbank holen $this->vorlage = new vorlage(); if(!$this->vorlage->getAktuelleVorlage($oe_kurzbz, $vorlage, $version)) @@ -389,5 +393,28 @@ class dokument_export } return $_xml_data->asXML(); } + + /** + * Konvertiert ein Dokument in ein anderes Format + * @param string $inFile Origin File Path + * @param string $outFile Output file + * @param string $format Format to export To + * @return boolean + */ + public function convert($inFile, $outFile, $format = "pdf") + { + $command = 'unoconv --format %s --output %s %s'; + $command = sprintf($command, $format, $outFile, $inFile); + + + exec($command, $out, $ret); + if($ret!=0) + { + $this->errormsg = 'Dokumentenkonvertierung ist derzeit nicht möglich. Bitte informieren Sie den Administrator'; + return false; + } + + return true; + } } ?> diff --git a/include/pdf.class.php b/include/pdf.class.php new file mode 100644 index 000000000..033c0f5a6 --- /dev/null +++ b/include/pdf.class.php @@ -0,0 +1,107 @@ +. + */ + +class Pdf +{ + public $errormsg = ""; + + /** + * Fügt beliebig viele PDF Dateien zu einer zusammen + * @param array $files Array mit Dateien + * @param string $outFile Zieldatei + * @return boolean + */ + public function merge($files, $outFile) + { + $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile "; + $finfo = finfo_open(FILEINFO_MIME_TYPE); + + // add all pdf files to the command + foreach($files as $f) + { + $cmd .= $f." "; + if(!file_exists($f)) + { + $this->errormsg = "File not found: '$f'"; + return false; + } + if(finfo_file($finfo, $f) != "application/pdf") + { + $this->errormsg = "Wrong format: '$f'"; + return false; + } + } + + finfo_close($finfo); + + exec($cmd, $out, $ret); + if($ret!=0) + { + $this->errormsg = 'PDF-zusammenfuegung ist derzeit nicht möglich. Bitte informieren Sie den Administrator'; + return false; + } + return true; + } + + + /** + * Konvertiert eine jpeg Datei zu einer PDF + * @param string $image jpeg Datei + * @param string $outFile Zieldatei + * @return boolean + */ + public function jpegToPdf($image, $outFile) + { + if(!file_exists($image)) + { + $this->errormsg = "File not found: '$image'"; + return false; + } + + $s = getimagesize($image); + + /* + * längere Seite ermitteln + * Hochformat wenn die Seiten gleich lang sind. + */ + if($s[0] > $s[1]) + { + $height = 595; + $width = 842; + } + else + { + $height = 842; + $width = 595; + } + + // -r300 = 300 ppi + $cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r100 -o '.$outFile.' viewjpeg.ps -c "('.$image.') << /PageSize [' . $width . ' ' . $height .'] /.HWMargins [18 18 18 13.5] /countspaces { [ exch { dup 32 ne { pop } if } forall ] length } bind def >> setpagedevice viewJPEG"'; + + exec($cmd, $out, $ret); + if($ret!=0) + { + $this->errormsg = 'jpegToPdf ist derzeit nicht möglich. Bitte informieren Sie den Administrator'; + return false; + } + return true; + } +} + diff --git a/system/dbupdate_3.2.php b/system/dbupdate_3.2.php index d309f81af..2ab852b18 100755 --- a/system/dbupdate_3.2.php +++ b/system/dbupdate_3.2.php @@ -1297,6 +1297,39 @@ if(!@$db->db_query("SELECT bezeichnung_mehrsprachig FROM public.tbl_status LIMIT } + + +/************************************ 07.16 Vorlage für bewerberakt ************************************/ +if($result = $db->db_query("SELECT * FROM public.tbl_vorlage WHERE vorlage_kurzbz='Bewerberakt'")) +{ + if($db->db_num_rows($result)==0) + { + $qry_oe = "SELECT oe_kurzbz FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz is null"; + if($result = $db->db_query($qry_oe)) + { + $qry = "INSERT INTO public.tbl_vorlage(vorlage_kurzbz, bezeichnung, anmerkung,mimetype) + VALUES('Bewerberakt','Bewerberakt Deckblatt', 'wird als Deckblatt fuer den Bewerberakt verwendet', 'application/vnd.oasis.opendocument.text');"; + + $text = file_get_contents('xsl/Bewerberakt.xsl'); + + while($row = $db->db_fetch_object($result)) + { + $qry.="INSERT INTO public.tbl_vorlagestudiengang(vorlage_kurzbz, studiengang_kz, version, text, + oe_kurzbz, style, berechtigung, anmerkung_vorlagestudiengang, aktiv) VALUES( + 'Bewerberakt',0,0,".$db->db_add_param($text).",".$db->db_add_param($row->oe_kurzbz).",null,null,'',true);"; + } + } + + if(!$db->db_query($qry)) + echo 'Bewerberakt Dokumentenvorlage: '.$db->db_last_error().'
'; + else + echo 'Bewerberakt Dokumentenvorlage hinzugefuegt
'; + } +} + + + + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; diff --git a/system/vorlage_zip/Bewerberakt.odt b/system/vorlage_zip/Bewerberakt.odt new file mode 100644 index 0000000000000000000000000000000000000000..88226e050c5ab24ff31988ca5b8c5c545366f1f0 GIT binary patch literal 9434 zcmeHNby!qe*B_9U6j3@Pq`O->r9ncZdl+DbPC-&qLZrI|WeDk#4(Vka-B0B8*~hqybK8#_4IS(_R|tU>l{F7{@uAY-sKm=)w;Zf^!Mbq1Q-Ls%i^ZV=VK zfdO*>6D7z1!1YE52h+522AbF#Tib!zAm5s-4)&Izst;wcFo-eWr(ns;NvXs4l>h(& z0PP06)q2sn0RY?ps48hn!w)eqF!1s5Nk~X&XlNK2896yQ1qB5qBqS6S6*V+8^!4>k zOiXNTZ6Oedr>AE?K*00o&tqd_larIPva*Vbil9(vU0q#UTU%dW-|+D8%*@Qn%F5Q( z*5Tpd<>e(D|LXtc|2^=3)dTgqU8Vp4qNTjl15LN-ozd>dSxQ_#<604*>3+vJuhHVg z0_VWTgg${4df%r=jGOzR$`!sGNH(JdYS}Uo#5{jC&Y}t`N7?T782I$290Es+-9$g? z>@veZujqZov8q*j6Ql$yXO}1QY9bto)`;V(Okx#ha(Zf>L=cU-7rq4EX(Jnr(z%~J zzClzwi&MkpO&;$1jNZ$~?gRG*jgscuC)tS|E+P8cN70e2pV@LGMT9;MDtHqRMmpEf$fI!V*|1QeooA9s*ke7ZaRVrcR|E~y-hKBYBU0nb3O|DNf z1=&Ncxxfu*x1*y5n&HLuSt!HR%m87q)U}!LxIE1wX)6(6l@>B`Ge{{W-zY{K3Y_bGP2aFG z1i6Vlm1OVCJY|Gx@RhI$iX6PHzATzx_a=HY+A#DHO#7hZR`gMAds1q_q|><9lN{UE zGl-dudu3-+@zG3iAJ)NUuMOD`-c`lUW-0j7=UZ?E!iq`B-tdg^Yp1say+|tc$>9{_ zd9-przlgW^Q`lsQjJo9bBbkXHWSl5h?GB2)63iN&@vRuH8W~rk3NhE}PQ7U7Z9^0x zIf9sy2<(we$wu5(MINMy4DDSAr+e@$*l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>;*nK*+a~#4Do{TpkVU2aiX)|Du;aL;vl~~z*9UeMTTsKaG1*Sf) z1jUHpJnvS1*9L>28oZ`UzcZ3+_a32A2b03xD~fbIBoGj91Af1%0Pf=-E~4K7>ADdqPl*U|X9c>Dt8+M;h1^Pl3B{{rVn z%J~=0w}5@E-~2_eNe*(06hF1 + + + + + + +Bewerberakt + + + + From f4d1edf80897b515dde5192d6277a9120a17fef0 Mon Sep 17 00:00:00 2001 From: oesi Date: Wed, 27 Jul 2016 17:28:19 +0200 Subject: [PATCH 09/10] =?UTF-8?q?Bugfixes=20f=C3=BCr=20Dokumentenakt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/dokumentenakt.pdf.php | 8 +++++--- include/dokument_export.class.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/content/dokumentenakt.pdf.php b/content/dokumentenakt.pdf.php index 1b0077c74..8755bf3b3 100755 --- a/content/dokumentenakt.pdf.php +++ b/content/dokumentenakt.pdf.php @@ -77,9 +77,11 @@ foreach($prestudent_ids as $pid) if(!$doc->create('pdf')) die($doc->errormsg); - $doc->temp_filename = $filename; - $doc->output(false); - //$doc->close(); +// $doc->temp_filename = $filename; + $document = $doc->output(false); + $filename = $tmpDir.'/'.uniqid(); + file_put_contents($filename, $document); + $doc->close(); $allDocs[] = $filename; diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index c24725ec1..c06f29abb 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -325,7 +325,7 @@ class dokument_export } else { - $data = fread($handle, filesize($file)); + $data = fread($handle, $fsize); fclose($handle); return $data; } From fd826ae1fe855102095a0adf56e837a49a05372f Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 27 Jul 2016 19:09:42 +0200 Subject: [PATCH 10/10] Extended codeception tests --- tests/codeception/tests/api/v1/MessageCept.php | 10 ++++++++++ .../codeception/tests/api/v1/PrestudentstatusCept.php | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/tests/codeception/tests/api/v1/MessageCept.php b/tests/codeception/tests/api/v1/MessageCept.php index 6a4146a29..64b129687 100644 --- a/tests/codeception/tests/api/v1/MessageCept.php +++ b/tests/codeception/tests/api/v1/MessageCept.php @@ -8,4 +8,14 @@ $I->haveHttpHeader("FHC-API-KEY", "testapikey@fhcomplete.org"); $I->sendGET("v1/system/message/MessagesByPersonID", array("person_id" => "1")); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); +$I->seeResponseContainsJson(["error" => 0]); + +$I->sendGET("v1/system/message/MessagesByUID", array("uid" => "mckenzie")); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(["error" => 0]); + +$I->sendGET("v1/system/message/MessagesByToken", array("token" => "token")); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); $I->seeResponseContainsJson(["error" => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/PrestudentstatusCept.php b/tests/codeception/tests/api/v1/PrestudentstatusCept.php index c74f30aea..2c31f76e6 100644 --- a/tests/codeception/tests/api/v1/PrestudentstatusCept.php +++ b/tests/codeception/tests/api/v1/PrestudentstatusCept.php @@ -8,4 +8,9 @@ $I->haveHttpHeader("FHC-API-KEY", "testapikey@fhcomplete.org"); $I->sendGET("v1/crm/Prestudentstatus/Prestudentstatus", array("ausbildungssemester" => "0", "studiensemester_kurzbz" => "0", "status_kurzbz" => "0", "prestudent_id" => "0")); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); +$I->seeResponseContainsJson(["error" => 0]); + +$I->sendGET("v1/crm/Prestudentstatus/LastStatus", array("prestudent_id" => 3)); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); $I->seeResponseContainsJson(["error" => 0]); \ No newline at end of file