From 5a5472257ab0c0da620def230d0d206f0fe13980 Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 21 Jun 2016 15:07:51 +0200 Subject: [PATCH 1/4] - Modified MessageLib constructor to allow to give the parameter UID from a Controller - Controller Message now works with MessageLib - Added getMessagesByPersonID method to controller Message - Added permissions basis/message and fs/system to dump.sql --- .../controllers/api/v1/system/Message.php | 69 ++++++++++--------- application/libraries/MessageLib.php | 7 +- application/models/system/Message_model.php | 2 +- tests/codeception/_data/dump.sql | 12 +++- 4 files changed, 53 insertions(+), 37 deletions(-) diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index b7f70e187..7cfbc7737 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -23,45 +23,20 @@ class Message extends APIv1_Controller { parent::__construct(); // Load model MessageModel - $this->load->model('system/message_model', 'MessageModel'); - // Load set the uid of the model to let to check the permissions - $this->MessageModel->setUID($this->_getUID()); + $this->load->library('MessageLib', array('uid' => $this->_getUID())); } /** * @return void */ - public function getMessage() + public function getMessagesByPersonID() { - $messageID = $this->get('message_id'); + $person_id = $this->get('person_id'); + $all = $this->get('all'); - if (isset($messageID)) + if (isset($person_id)) { - $result = $this->MessageModel->load($messageID); - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * @return void - */ - public function postMessage() - { - if ($this->_validate($this->post())) - { - if (isset($this->post()['message_id'])) - { - $result = $this->MessageModel->update($this->post()['message_id'], $this->post()); - } - else - { - $result = $this->MessageModel->insert($this->post()); - } + $result = $this->messagelib->getMessagesByPerson($person_id, $all); $this->response($result, REST_Controller::HTTP_OK); } @@ -71,8 +46,38 @@ class Message extends APIv1_Controller } } - private function _validate($message = NULL) + /** + * @return void + */ + public function postMessage() { + if ($this->_validate($this->post())) + { + $this->messagelib->addRecipient($this->post()['person_id']); + $result = $this->messagelib->sendMessage( + $this->post()['person_id'], + $this->post()['subject'], + $this->post()['body'], + $this->post()['priority'], + $this->post()['relationmessage_id'], + $this->post()['oe_kurzbz'] + ); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + private function _validate($message = null) + { + if (!isset($message['person_id']) || !isset($message['subject']) || !isset($message['body'])) + { + return false; + } + return true; } } \ No newline at end of file diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 2bb04ff2f..9d1cb1ce1 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -11,13 +11,18 @@ class MessageLib { private $recipients = array(); - public function __construct() + public function __construct($params) { require_once APPPATH.'config/message.php'; $this->ci =& get_instance(); //$this->ci->load->model('person/Person_model', 'PersonModel'); $this->ci->load->model('system/Message_model', 'MessageModel'); + if (is_array($params) && isset($params['uid'])) + { + $this->ci->MessageModel->setUID($params['uid']); + } + $this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel'); $this->ci->load->model('system/Recipient_model', 'RecipientModel'); $this->ci->load->model('system/Attachment_model', 'AttachmentModel'); diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 4412c4078..cc7d2e930 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -92,7 +92,7 @@ WHERE person_id = ?'; if (! $all) $sql .= ' AND status<2'; $result = $this->db->query($sql, array($person_id)); - var_dump($result); + //var_dump($result); if (is_object($result)) return $this->_success($result->result()); else diff --git a/tests/codeception/_data/dump.sql b/tests/codeception/_data/dump.sql index 3090a1504..3a6fcb774 100644 --- a/tests/codeception/_data/dump.sql +++ b/tests/codeception/_data/dump.sql @@ -343,7 +343,8 @@ DELETE FROM system.tbl_rolleberechtigung WHERE berechtigung_kurzbz IN ( 'basis/lehrverband', 'basis/log', 'basis/mitarbeiter', - 'basis/msg_message', + 'basis/msg_message', + 'basis/message', 'basis/msg_thread', 'basis/notiz', 'basis/notizzuordnung', @@ -419,7 +420,8 @@ DELETE FROM system.tbl_rolleberechtigung WHERE berechtigung_kurzbz IN ( 'basis/vw_studiensemester', 'lehre/reservierung', 'lehre/reihungstest', - 'wawi/inventar:begrenzt' + 'wawi/inventar:begrenzt', + 'fs/dms' ); -- DELETE FROM system.tbl_berechtigung @@ -569,6 +571,7 @@ DELETE FROM system.tbl_berechtigung WHERE berechtigung_kurzbz IN ( 'basis/log', 'basis/mitarbeiter', 'basis/msg_message', + 'basis/message', 'basis/msg_thread', 'basis/notiz', 'basis/notizzuordnung', @@ -644,7 +647,8 @@ DELETE FROM system.tbl_berechtigung WHERE berechtigung_kurzbz IN ( 'basis/vw_studiensemester', 'lehre/reservierung', 'lehre/reihungstest', - 'wawi/inventar:begrenzt' + 'wawi/inventar:begrenzt', + 'fs/dms' ); -- INSERT Permissions @@ -870,6 +874,7 @@ INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES(' INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('lehre/reihungstest', ''); INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('wawi/inventar:begrenzt', ''); INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('fs/dms', ''); +INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('basis/message', ''); -- INSERT link between user admin and permissions INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('basis/archiv', 'admin', 'suid'); @@ -1094,6 +1099,7 @@ INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('lehre/reihungstest', 'admin', 'suid'); INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('wawi/inventar:begrenzt', 'admin', 'suid'); INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('fs/dms', 'admin', 'suid'); +INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('basis/message', 'admin', 'suid'); -- EMPTY public.tbl_statistik DELETE FROM public.tbl_statistik; From 971e4ed6de0eb10d5152a042f5dd34f4a995d544 Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 21 Jun 2016 15:21:51 +0200 Subject: [PATCH 2/4] Fixed controller message parameters validation --- application/controllers/api/v1/system/Message.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index 7cfbc7737..a0f7d469f 100644 --- a/application/controllers/api/v1/system/Message.php +++ b/application/controllers/api/v1/system/Message.php @@ -58,8 +58,8 @@ class Message extends APIv1_Controller $this->post()['person_id'], $this->post()['subject'], $this->post()['body'], - $this->post()['priority'], - $this->post()['relationmessage_id'], + PRIORITY_NORMAL, + NULL, $this->post()['oe_kurzbz'] ); @@ -73,7 +73,8 @@ class Message extends APIv1_Controller private function _validate($message = null) { - if (!isset($message['person_id']) || !isset($message['subject']) || !isset($message['body'])) + if (!isset($message['person_id']) || !isset($message['subject']) || + !isset($message['body']) || !isset($message['oe_kurzbz'])) { return false; } From ca83b2f59dd362c9020949a5055ebe2547036295 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jun 2016 16:25:55 +0200 Subject: [PATCH 3/4] phrases system --- application/config/migration.php | 2 +- application/controllers/system/Phrases.php | 155 +++++++++++++++++ application/core/FHC_Controller.php | 8 +- application/libraries/PhrasesLib.php | 159 ++++++++++++++++++ application/migrations/003_add_apikey.php | 1 - application/migrations/009_phrase.php | 7 +- .../models/system/Phrase_inhalt_model.php | 15 ++ application/models/system/Phrase_model.php | 15 ++ application/views/system/phrases.php | 20 +++ application/views/system/phrasesList.php | 37 ++++ .../views/system/phrasesinhaltList.php | 40 +++++ ci_hack.php | 13 +- 12 files changed, 459 insertions(+), 13 deletions(-) create mode 100644 application/controllers/system/Phrases.php create mode 100644 application/libraries/PhrasesLib.php create mode 100644 application/models/system/Phrase_inhalt_model.php create mode 100644 application/models/system/Phrase_model.php create mode 100644 application/views/system/phrases.php create mode 100644 application/views/system/phrasesList.php create mode 100644 application/views/system/phrasesinhaltList.php diff --git a/application/config/migration.php b/application/config/migration.php index 65e90ad2e..102054bae 100755 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -23,7 +23,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 009; +$config['migration_version'] = '009'; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php new file mode 100644 index 000000000..eedb4bb1e --- /dev/null +++ b/application/controllers/system/Phrases.php @@ -0,0 +1,155 @@ +load->library('PhrasesLib'); + } + + public function index() + { + $this->load->view('system/phrases.php'); + } + + public function table() + { + $phrases = $this->phraseslib->getPhraseByApp('aufnahme'); + if ($phrases->error) + show_error($phrases->retval); + //var_dump($vorlage); + + $data = array + ( + 'app' => 'aufnahme', + 'phrases' => $phrases->retval + ); + $v = $this->load->view('system/phrasesList.php', $data); + } + + public function view($phrase_id = null) + { + if (empty($phrase_id)) + exit; + $phrase_inhalt = $this->phraseslib->getPhraseInhalt($phrase_id); + if ($phrase_inhalt->error) + show_error($phrase_inhalt->retval); + //var_dump($vorlage); + + $data = array + ( + 'phrase_id' => $phrase_id, + 'phrase_inhalt' => $phrase_inhalt->retval + ); + $v = $this->load->view('system/phrasesinhaltList.php', $data); + } + + public function edit($vorlage_kurzbz = null) + { + if (empty($vorlage_kurzbz)) + exit; + $vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz); + //var_dump($vorlage); + if ($vorlage->error) + show_error($vorlage->retval); + if (count($vorlage->retval) != 1) + show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz); + + $data = array + ( + 'vorlage' => $vorlage->retval[0] + ); + //var_dump($data['message']); + $v = $this->load->view('system/templatesEdit', $data); + } + + public function write($vorlage_kurzbz = null) + { + $data = array + ( + 'subject' => 'TestSubject', + 'body' => 'TestDevelopmentBodyText' + ); + $v = $this->load->view('system/messageWrite', $data); + } + + public function save() + { + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE); + $data['bezeichnung'] = $this->input->post('bezeichnung', TRUE); + $data['anmerkung'] = $this->input->post('anmerkung', TRUE); + $data['mimetype'] = $this->input->post('mimetype', TRUE); + $data['attribute'] = $this->input->post('attribute', TRUE); + $vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data); + if ($vorlage->error) + show_error($vorlage->retval); + $vorlage_kurzbz = $vorlage->retval; + + redirect('/system/Templates/edit/'.$vorlage_kurzbz); + } + + public function newText() + { + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE); + $data = array + ( + 'vorlage_kurzbz' => $vorlage_kurzbz, + 'studiengang_kz' => 0, + 'version' => 1, + 'oe_kurzbz' => 'etw' + ); + $vorlagetext = $this->vorlagelib->insertVorlagetext($data); + if ($vorlagetext->error) + show_error($vorlagetext->retval); + $vorlagestudiengang_id = $vorlagetext->retval; + + redirect('/system/Templates/editText/'.$vorlagestudiengang_id); + } + + public function editText($vorlagestudiengang_id) + { + $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); + if ($vorlagetext->error) + show_error($vorlagetext->retval); + $data = $vorlagetext->retval[0]; + + // Preview-Data + $schema = $this->vorlagelib->getVorlage($data->vorlage_kurzbz); + $data->schema = $schema->retval[0]->attribute; + + $this->load->view('system/templatetextEdit', $data); + } + + public function saveText() + { + $vorlagestudiengang_id = $this->input->post('vorlagestudiengang_id', TRUE); + $data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE); + $data['version'] = $this->input->post('version', TRUE); + $data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE); + $data['text'] = $this->input->post('text', TRUE); + $data['aktiv'] = $this->input->post('aktiv', TRUE); + $vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data); + if ($vorlagetext->error) + show_error($vorlagetext->retval); + $data['vorlagestudiengang_id'] = $vorlagestudiengang_id; + redirect('/system/Templates/editText/'.$vorlagestudiengang_id); + //$this->load->view('system/templatetextEdit', $data); + } + + public function preview($vorlagestudiengang_id) + { + $formdata = $this->input->post('formdata', FALSE); + $daten = json_decode($formdata, TRUE); + $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); + if ($vorlagetext->error) + show_error($vorlagetext->retval); + $data = array + ( + 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $daten) + ); + $this->load->view('system/templatetextPreview', $data); + } +} diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 7921455cb..e3026dbb8 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -4,18 +4,20 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class FHC_Controller extends CI_Controller { public $uid; - - function __construct() + + function __construct() { parent::__construct(); $this->load->library('session'); //$this->load->helper('language'); - + // look if User is logged in and set uid if (isset($_SERVER['PHP_AUTH_USER'])) $this->uid = $_SERVER['PHP_AUTH_USER']; if (isset($_SESSION['uid'])) $this->uid = $_SESSION['uid']; $this->session->set_userdata('uid', 'pam'); + } + } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php new file mode 100644 index 000000000..1fad64e56 --- /dev/null +++ b/application/libraries/PhrasesLib.php @@ -0,0 +1,159 @@ +ci =& get_instance(); + $this->ci->load->library('parser'); + $this->ci->load->model('system/Phrase_model', 'PhraseModel'); + $this->ci->load->model('system/Phrase_inhalt_model', 'PhraseInhaltModel'); + $this->ci->load->helper('language'); + //$this->ci->lang->load('fhcomplete'); + } + + /** + * getPhrase() - will load a spezific Phrase + * + * @param integer $vorlage_kurzbz REQUIRED + * @return struct + */ + function getPhrase($phrase_id) + { + if (empty($vorlage_kurzbz)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + + $Phrase = $this->ci->PhraseModel->load($phrase_id); + return $phrase; + } + + /** + * getSubMessages() - will return all Messages subordinated from a specified message. + * + * @param integer $msg_id REQUIRED + * @return array + */ + function getPhraseByApp($app = null) + { + $phrases = $this->ci->PhraseModel->loadWhere(array('app' => $app)); + return $phrases; + } + + function getPhraseInhalt($phrase_id) + { + if (empty($phrase_id)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + + $phrase_inhalt = $this->ci->PhraseInhaltModel->loadWhere(array('phrase_id' => $phrase_id)); + return $phrase_inhalt; + } + + /** + * saveVorlage() - will save a spezific Template. + * + * @param array $data REQUIRED + * @return array + */ + function saveVorlage($vorlage_kurzbz, $data) + { + if (empty($data)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + + $vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data); + return $vorlage; + } + + + /** + * getVorlagetextByVorlage() - will load tbl_vorlagestudiengang for a spezific Template. + * + * @param string $vorlage_kurzbz REQUIRED + * @return array + */ + function getVorlagetextByVorlage($vorlage_kurzbz) + { + if (empty($vorlage_kurzbz)) + return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); + + $vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' =>$vorlage_kurzbz)); + return $vorlage; + } + + /** + * loadVorlagetext() - will load the best fitting Template. + * + * @param string $vorlage_kurzbz REQUIRED + * @param string $oe_kurzbz OPTIONAL + * @param string $orgform_kurzbz OPTIONAL + * @return array + */ + function loadVorlagetext($vorlage_kurzbz, $oe_kurzbz=null, $orgform_kurzbz=null) + { + if (empty($vorlage_kurzbz)) + return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); + + $vorlage = $this->ci->VorlageStudiengangModel->getVorlageStudiengang($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz); + return $vorlage; + } + + /** + * insertVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template. + * + * @param string $vorlage_kurzbz REQUIRED + * @return array + */ + function insertVorlagetext($data) + { + $vorlagetext = $this->ci->VorlageStudiengangModel->insert($data); + return $vorlagetext; + } + + /** + * loadVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template. + * + * @param string $vorlage_kurzbz REQUIRED + * @return array + */ + function getVorlagetextById($vorlagestudiengang_id) + { + $vorlagetext = $this->ci->VorlageStudiengangModel->load($vorlagestudiengang_id); + return $vorlagetext; + } + + /** + * saveVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template. + * + * @param string $vorlage_kurzbz REQUIRED + * @return array + */ + function updateVorlagetext($vorlagestudiengang_id, $data) + { + $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 + */ + function parseVorlagetext($text, $data = array()) + { + if (empty($text)) + return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); + $text = $this->ci->parser->parse_string($text, $data, TRUE); + return $text; + } +} diff --git a/application/migrations/003_add_apikey.php b/application/migrations/003_add_apikey.php index 06ea42d65..c7bc4b578 100644 --- a/application/migrations/003_add_apikey.php +++ b/application/migrations/003_add_apikey.php @@ -54,4 +54,3 @@ class Migration_Add_apikey extends CI_Migration { $this->dbforge->drop_table('ci_apikey'); } } - diff --git a/application/migrations/009_phrase.php b/application/migrations/009_phrase.php index 708f1e6b6..ea354b5f9 100755 --- a/application/migrations/009_phrase.php +++ b/application/migrations/009_phrase.php @@ -44,9 +44,10 @@ class Migration_Phrase extends CI_Migration { phrase_inhalt_id serial, phrase_id bigint NOT NULL, sprache varchar(32) NOT NULL, - orgeinheit_kurzbz varchar(32) NOT NULL, - orgform_kurzbz varchar(32) NOT NULL, + orgeinheit_kurzbz varchar(32), + orgform_kurzbz varchar(32), text text, + description text, insertamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, insertvon varchar(32), PRIMARY KEY (phrase_inhalt_id) @@ -64,7 +65,7 @@ class Migration_Phrase extends CI_Migration { } } } - + public function down() { try diff --git a/application/models/system/Phrase_inhalt_model.php b/application/models/system/Phrase_inhalt_model.php new file mode 100644 index 000000000..806915bca --- /dev/null +++ b/application/models/system/Phrase_inhalt_model.php @@ -0,0 +1,15 @@ +dbTable = 'public.tbl_phrase_inhalt'; + $this->pk = 'phrase_inhalt_id'; + } + +} diff --git a/application/models/system/Phrase_model.php b/application/models/system/Phrase_model.php new file mode 100644 index 000000000..051ef170c --- /dev/null +++ b/application/models/system/Phrase_model.php @@ -0,0 +1,15 @@ +dbTable = 'public.tbl_phrase'; + $this->pk = 'phrase_id'; + } + +} diff --git a/application/views/system/phrases.php b/application/views/system/phrases.php new file mode 100644 index 000000000..2409fcc83 --- /dev/null +++ b/application/views/system/phrases.php @@ -0,0 +1,20 @@ + + + + + VileSci - Phrasen + + + + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + <a href="PhrasesList">Use without frames</a> + </body> + + + + diff --git a/application/views/system/phrasesList.php b/application/views/system/phrasesList.php new file mode 100644 index 000000000..6cfa3d17c --- /dev/null +++ b/application/views/system/phrasesList.php @@ -0,0 +1,37 @@ +load->view('templates/header', array('title' => 'PhrasesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '2:{sorter:false}')); +?> +
+
+

Phrasen

+ + + + + + + + + + + + + + + + + +
IDPhrase
phrase_id; ?>phrase; ?>View
+
+
+ + diff --git a/application/views/system/phrasesinhaltList.php b/application/views/system/phrasesinhaltList.php new file mode 100644 index 000000000..4e6b5fe43 --- /dev/null +++ b/application/views/system/phrasesinhaltList.php @@ -0,0 +1,40 @@ +load->view('templates/header', array('title' => 'PhrasenInhaltList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '5:{sorter:false}')); +?> + +
+
+

Phrase Inhalt -

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
IDSpracheOrgEinheitOrgFormTextBeschreibung
phrase_inhalt_id; ?>sprache; ?>orgeinheit_kurzbz; ?>orgform_kurzbz; ?>text; ?>description; ?>
+
+
+ +load->view('templates/footer'); +?> diff --git a/ci_hack.php b/ci_hack.php index a7cfe5d02..dc1261eb8 100755 --- a/ci_hack.php +++ b/ci_hack.php @@ -347,10 +347,13 @@ if (isset($assign_to_config) && is_array($assign_to_config)) */ $LANG =& load_class('Lang', 'core'); -define('FHC_INTEGER',1); -define('FHC_STRING',2); -define('FHC_BOOLEAN',3); -define('FHC_LANG_ARRAY',4); +if (!defined('FHC_INTEGER')) +{ + define('FHC_INTEGER',1); + define('FHC_STRING',2); + define('FHC_BOOLEAN',3); + define('FHC_LANG_ARRAY',4); +} function &get_instance() { @@ -369,4 +372,4 @@ require_once(dirname(__FILE__).'/application/core/FHC_Model.php'); $model=new CI_Model(); // Traits -require_once(dirname(__FILE__).'/ci_db_extra.php'); \ No newline at end of file +require_once(dirname(__FILE__).'/ci_db_extra.php'); From 25e0ba9407462ecf7a71d448d591b0fec663ec69 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Jun 2016 01:24:59 +0200 Subject: [PATCH 4/4] basic phrases editing --- application/controllers/system/Phrases.php | 70 ++++++++----------- application/libraries/PhrasesLib.php | 26 +++---- application/views/system/phraseinhaltEdit.php | 31 ++++++++ application/views/system/phrasesEdit.php | 17 +++++ .../views/system/phrasesinhaltList.php | 2 + include/tw/vilesci_menu_main.inc.php | 3 +- 6 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 application/views/system/phraseinhaltEdit.php create mode 100644 application/views/system/phrasesEdit.php diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index eedb4bb1e..28e186014 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -47,23 +47,23 @@ class Phrases extends FHC_Controller $v = $this->load->view('system/phrasesinhaltList.php', $data); } - public function edit($vorlage_kurzbz = null) + public function edit($phrase_id = null) { - if (empty($vorlage_kurzbz)) + if (empty($phrase_id)) exit; - $vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz); + $phrase = $this->phraseslib->getPhrase($phrase_id); //var_dump($vorlage); - if ($vorlage->error) - show_error($vorlage->retval); - if (count($vorlage->retval) != 1) - show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz); + if ($phrase->error) + show_error($phrase->retval); + if (count($phrase->retval) != 1) + show_error('Phrase nicht vorhanden! ID: '.$phrase_id); $data = array ( - 'vorlage' => $vorlage->retval[0] + 'phrase' => $phrase->retval[0] ); //var_dump($data['message']); - $v = $this->load->view('system/templatesEdit', $data); + $v = $this->load->view('system/phrasesEdit', $data); } public function write($vorlage_kurzbz = null) @@ -78,17 +78,14 @@ class Phrases extends FHC_Controller public function save() { - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE); - $data['bezeichnung'] = $this->input->post('bezeichnung', TRUE); - $data['anmerkung'] = $this->input->post('anmerkung', TRUE); - $data['mimetype'] = $this->input->post('mimetype', TRUE); - $data['attribute'] = $this->input->post('attribute', TRUE); - $vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data); - if ($vorlage->error) - show_error($vorlage->retval); - $vorlage_kurzbz = $vorlage->retval; + $phrase_id = $this->input->post('phrase_id', TRUE); + $data['phrase'] = $this->input->post('phrase', TRUE); + $phrase = $this->phraseslib->savePhrase($phrase_id, $data); + if ($phrase->error) + show_error($phrase->retval); + $phrase_id = $phrase->retval; - redirect('/system/Templates/edit/'.$vorlage_kurzbz); + redirect('/system/Phrases/edit/'.$phrase_id); } public function newText() @@ -109,33 +106,28 @@ class Phrases extends FHC_Controller redirect('/system/Templates/editText/'.$vorlagestudiengang_id); } - public function editText($vorlagestudiengang_id) + public function editText($phrase_inhalt_id) { - $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); - if ($vorlagetext->error) - show_error($vorlagetext->retval); - $data = $vorlagetext->retval[0]; + $phrase_inhalt = $this->phraseslib->getPhraseInhaltById($phrase_inhalt_id); + if ($phrase_inhalt->error) + show_error($phrase_inhalt->retval); + $data = $phrase_inhalt->retval[0]; - // Preview-Data - $schema = $this->vorlagelib->getVorlage($data->vorlage_kurzbz); - $data->schema = $schema->retval[0]->attribute; - - $this->load->view('system/templatetextEdit', $data); + $this->load->view('system/phraseinhaltEdit', $data); } public function saveText() { - $vorlagestudiengang_id = $this->input->post('vorlagestudiengang_id', TRUE); - $data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE); - $data['version'] = $this->input->post('version', TRUE); - $data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE); + $phrase_inhalt_id = $this->input->post('phrase_inhalt_id', TRUE); + $data['orgeinheit_kurzbz'] = $this->input->post('oe_kurzbz', TRUE); $data['text'] = $this->input->post('text', TRUE); - $data['aktiv'] = $this->input->post('aktiv', TRUE); - $vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data); - if ($vorlagetext->error) - show_error($vorlagetext->retval); - $data['vorlagestudiengang_id'] = $vorlagestudiengang_id; - redirect('/system/Templates/editText/'.$vorlagestudiengang_id); + $data['description'] = $this->input->post('description', TRUE); + $data['sprache'] = $this->input->post('sprache', TRUE); + $phrase_inhalt = $this->phraseslib->updatePhraseInhalt($phrase_inhalt_id, $data); + if ($phrase_inhalt->error) + show_error($phrase_inhalt->retval); + $data['phrase_inhalt_id'] = $phrase_inhalt_id; + redirect('/system/Phrases/editText/'.$phrase_inhalt_id); //$this->load->view('system/templatetextEdit', $data); } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index 1fad64e56..1cc023863 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -30,10 +30,10 @@ class PhrasesLib */ function getPhrase($phrase_id) { - if (empty($vorlage_kurzbz)) + if (empty($phrase_id)) return $this->_error(MSG_ERR_INVALID_MSG_ID); - $Phrase = $this->ci->PhraseModel->load($phrase_id); + $phrase = $this->ci->PhraseModel->load($phrase_id); return $phrase; } @@ -59,18 +59,18 @@ class PhrasesLib } /** - * saveVorlage() - will save a spezific Template. + * savePhrase() - will save a spezific Phrase. * * @param array $data REQUIRED * @return array */ - function saveVorlage($vorlage_kurzbz, $data) + function savePhrase($phrase_id, $data) { if (empty($data)) return $this->_error(MSG_ERR_INVALID_MSG_ID); - $vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data); - return $vorlage; + $phrase = $this->ci->PhraseModel->update($phrase_id, $data); + return $phrase; } @@ -80,13 +80,13 @@ class PhrasesLib * @param string $vorlage_kurzbz REQUIRED * @return array */ - function getVorlagetextByVorlage($vorlage_kurzbz) + function getPhraseInhaltById($phrase_inhalt_id) { - if (empty($vorlage_kurzbz)) + if (empty($phrase_inhalt_id)) return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); - $vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' =>$vorlage_kurzbz)); - return $vorlage; + $phrase_inhalt = $this->ci->PhraseInhaltModel->loadWhere(array('phrase_inhalt_id' =>$phrase_inhalt_id)); + return $phrase_inhalt; } /** @@ -136,10 +136,10 @@ class PhrasesLib * @param string $vorlage_kurzbz REQUIRED * @return array */ - function updateVorlagetext($vorlagestudiengang_id, $data) + function updatePhraseInhalt($phrase_inhalt_id, $data) { - $vorlagetext = $this->ci->VorlageStudiengangModel->update($vorlagestudiengang_id, $data); - return $vorlagetext; + $phrase_inhalt = $this->ci->PhraseInhaltModel->update($phrase_inhalt_id, $data); + return $phrase_inhalt; } /** diff --git a/application/views/system/phraseinhaltEdit.php b/application/views/system/phraseinhaltEdit.php new file mode 100644 index 000000000..2e2d39ded --- /dev/null +++ b/application/views/system/phraseinhaltEdit.php @@ -0,0 +1,31 @@ +load->view('templates/header', array('title' => 'TemplateEdit', 'tinymce' => true, 'jsonforms' => true)); +?> + +
+
+

Phrase Inhalt:

+ +
+ + + + + + + templatelib->widget("tinymce_widget", array('name' => 'text', 'text' => $text)); + ?> + +
OEtemplatelib->widget("organisationseinheit_widget", array('oe_kurzbz' => $orgeinheit_kurzbz)); ?>
Sprache
Text
Beschreibung
+
+ +
+
+ + + + diff --git a/application/views/system/phrasesEdit.php b/application/views/system/phrasesEdit.php new file mode 100644 index 000000000..d967dee83 --- /dev/null +++ b/application/views/system/phrasesEdit.php @@ -0,0 +1,17 @@ +load->view('templates/header', array('title' => 'PhrasesEdit')); +?> +
+
+

Phrase: phrase_id; ?>

+
+ Bezeichnung: + + +
+ +
+
+ + + diff --git a/application/views/system/phrasesinhaltList.php b/application/views/system/phrasesinhaltList.php index 4e6b5fe43..bcc046031 100644 --- a/application/views/system/phrasesinhaltList.php +++ b/application/views/system/phrasesinhaltList.php @@ -18,6 +18,7 @@ OrgForm Text Beschreibung + @@ -28,6 +29,7 @@ orgform_kurzbz; ?> text; ?> description; ?> + edit diff --git a/include/tw/vilesci_menu_main.inc.php b/include/tw/vilesci_menu_main.inc.php index cd0a36009..2d27ed56d 100644 --- a/include/tw/vilesci_menu_main.inc.php +++ b/include/tw/vilesci_menu_main.inc.php @@ -225,7 +225,8 @@ $menu=array 'link'=>'left.php?categorie=Admin', 'target'=>'nav', 'Cronjobs'=>array('name'=>'Cronjobs', 'link'=>'stammdaten/cronjobverwaltung.php', 'target'=>'main','permissions'=>array('basis/cronjob')), 'Vorlagen'=>array('name'=>'Vorlagen', 'link'=>'../index.ci.php/system/Templates', 'target'=>'main','permissions'=>array('basis/cronjob')), - 'Messages'=>array('name'=>'Nachrichten', 'link'=>'../index.ci.php/system/Messages', 'target'=>'main','permissions'=>array('basis/cronjob')) + 'Messages'=>array('name'=>'Nachrichten', 'link'=>'../index.ci.php/system/Messages', 'target'=>'main','permissions'=>array('basis/cronjob')), + 'Phrasen'=>array('name'=>'Phrasen', 'link'=>'../index.ci.php/system/Phrases', 'target'=>'main','permissions'=>array('basis/cronjob')) ), 'SD-Tools'=> array (