diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index a5d5f2c2f..380a629e9 100755 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -231,6 +231,8 @@ $config['fhc_acl'] = array 'wawi.tbl_rechnungsbetrag' => 'basis/rechnungsbetrag', 'wawi.tbl_rechnungstyp' => 'basis/rechnungstyp', 'wawi.tbl_zahlungstyp' => 'basis/zahlungstyp', + + DMS_PATH => 'fs/dms', 'public.tbl_sprache' => 'admin' ); diff --git a/application/controllers/api/v1/content/Dms.php b/application/controllers/api/v1/content/Dms.php index 6d37bc5db..5800832f1 100644 --- a/application/controllers/api/v1/content/Dms.php +++ b/application/controllers/api/v1/content/Dms.php @@ -23,9 +23,13 @@ class Dms extends APIv1_Controller { parent::__construct(); // Load model PersonModel - $this->load->model('content/dms_model', 'DmsModel'); - // Load set the uid of the model to let to check the permissions + $this->load->model('content/Dms_model', 'DmsModel'); + $this->load->model('content/DmsVersion_model', 'DmsVersionModel'); + $this->load->model('content/DmsFS_model', 'DmsFSModel'); + // Set the uid of the model to let to check the permissions $this->DmsModel->setUID($this->_getUID()); + $this->DmsVersionModel->setUID($this->_getUID()); + $this->DmsFSModel->setUID($this->_getUID()); } /** @@ -41,9 +45,52 @@ class Dms extends APIv1_Controller $result = $this->_getDms($dms_id, $version); if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) { - if (($fileContent = $this->_readFile($result->retval[0]->filename)) != false) + $resultFS = $this->DmsFSModel->read($result->retval[0]->filename); + if (is_object($resultFS) && $resultFS->error == EXIT_SUCCESS) { - $result->retval[0]->file_content = $fileContent; + $result->retval[0]->file_content = $resultFS->retval; + } + } + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + + /** + * + */ + public function postDms() + { + $dms = $this->_parseData($this->post()); + + if ($this->_validate($dms)) + { + $result = null; + + if (isset($dms['dms_id'])) + { + if ($this->_saveFileOnUpdate($dms)) + { + $result = $this->DmsModel->update($dms['dms_id'], $this->DmsModel->filterFields($dms)); + if ($result->error == EXIT_SUCCESS) + { + $result = $this->DmsVersionModel->update(array($dms['dms_id'], $dms['version']), $this->DmsVersionModel->filterFields($dms)); + } + } + } + else + { + if (($filename = $this->_saveFileOnInsert($dms)) !== false) + { + $result = $this->DmsModel->insert($this->DmsModel->filterFields($dms)); + if ($result->error == EXIT_SUCCESS) + { + $result = $this->DmsVersionModel->insert($this->DmsVersionModel->filterFields($dms, $result->retval, $filename)); + } } } @@ -89,102 +136,6 @@ class Dms extends APIv1_Controller return $result; } - /** - * - */ - public function postDms() - { - $dms = $this->_parseData($this->post()); - if ($this->_validate($dms)) - { - if (isset($dms['dms_id'])) - { - if ($this->_saveFileOnUpdate($dms)) - { - $result = $this->DmsModel->update($dms['dms_id'], $this->_dmsFieldsArray($dms)); - if ($result->error == EXIT_SUCCESS) - { - $result = $this->DmsModel->updateDmsVersion($dms['dms_id'], $this->_dmsVersionFieldsArray($dms)); - } - } - } - else - { - if (($fileName = $this->_saveFileOnInsert($dms)) !== false) - { - $result = $this->DmsModel->insert($this->_dmsFieldsArray($dms)); - if ($result->error == EXIT_SUCCESS) - { - $result = $this->DmsModel->insertDmsVersion($this->_dmsVersionFieldsArray($dms, $result->retval, $fileName)); - } - } - } - - $this->response($result, REST_Controller::HTTP_OK); - } - else - { - $this->response(); - } - } - - /** - * - */ - private function _dmsFieldsArray($dms) - { - $fieldsArray = array('oe_kurzbz', 'dokument_kurzbz', 'kategorie_kurzbz'); - $returnArray = array(); - - foreach ($fieldsArray as $value) - { - if (isset($dms[$value])) - { - $returnArray[$value] = $dms[$value]; - } - } - - return $returnArray; - } - - /** - * - */ - private function _dmsVersionFieldsArray($dms, $dms_id = null, $fileName = null) - { - $fieldsArray = array( - 'version', - 'mimetype', - 'name', - 'beschreibung', - 'letzterzugriff', - 'insertamum', - 'insertvon', - 'updateamum', - 'updatevon' - ); - $returnArray = array(); - - foreach ($fieldsArray as $value) - { - if (isset($dms[$value])) - { - $returnArray[$value] = $dms[$value]; - } - } - - if (isset($dms_id)) - { - $returnArray['dms_id'] = $dms_id; - } - if (isset($fileName)) - { - $returnArray['filename'] = $fileName; - } - - return $returnArray; - } - /** * */ @@ -193,19 +144,11 @@ class Dms extends APIv1_Controller if(isset($dms['version'])) { $result = $this->_getDms($dms['dms_id'], $dms['version']); - } - else - { - $result = $this->_getDms($dms['dms_id']); - } - if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) - { - $fileName = DMS_PATH . $result->retval[0]->filename; - - if (($fileContent = base64_decode($dms['file_content']))) + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0) { - if (file_put_contents($fileName, $fileContent)) + $result = $this->DmsFSModel->write($result->retval[0]->filename, $dms['file_content']); + if (is_object($result) && $result->error == EXIT_SUCCESS) { return true; } @@ -220,47 +163,17 @@ class Dms extends APIv1_Controller */ private function _saveFileOnInsert($dms) { - $fileName = uniqid() . '.' . pathinfo($dms['name'], PATHINFO_EXTENSION); - $FileNamePath = DMS_PATH . $fileName; + $filename = uniqid() . '.' . pathinfo($dms['name'], PATHINFO_EXTENSION); - if (($fileContent = base64_decode($dms['file_content']))) + $result = $this->DmsFSModel->write($filename, $dms['file_content']); + if (is_object($result) && $result->error == EXIT_SUCCESS) { - if ($fileHandle = fopen($FileNamePath, 'w')) - { - if(fwrite($fileHandle, $fileContent)) - { - fclose($fileHandle); - return $fileName; - } - } + return $filename; } return false; } - /** - * - */ - private function _readFile($fileName) - { - $fileNamePath = DMS_PATH . $fileName; - if (file_exists($fileNamePath)) - { - if ($fileHandle = fopen($fileNamePath, 'r')) - { - $cTmpHEX = ''; - while (!feof($fileHandle)) - { - $cTmpHEX .= fread($fileHandle, 8192); - } - fclose($fileHandle); - return base64_encode($cTmpHEX); - } - } - - return false; - } - private function _validate($dms = NULL) { if (!isset($dms['file_content']) || (isset($dms['file_content']) && $dms['file_content'] == '')) @@ -274,4 +187,4 @@ class Dms extends APIv1_Controller return true; } -} +} \ No newline at end of file diff --git a/application/controllers/api/v1/system/Message.php b/application/controllers/api/v1/system/Message.php index b7f70e187..a0f7d469f 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,39 @@ 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'], + PRIORITY_NORMAL, + NULL, + $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']) || !isset($message['oe_kurzbz'])) + { + return false; + } + return true; } } \ No newline at end of file diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 4c203e478..c61fd5e75 100755 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -1,34 +1,43 @@ load->library('messaging'); + $this->load->library('MessageLib'); //$this->load->model('person/Person_model'); //$this->load->model('system/Message_model'); } public function index() { - //$messages = $this->Message_model->getMessages(); - $msg = $this->Message_model->load(1); + $this->load->view('system/messages.php'); + } + + public function table() + { + $person_id = $this->input->post('person_id', TRUE); + if ($person_id) + $msg = $this->messagelib->getMessagesByPerson($person_id); + else + $msg = $this->messagelib->getMessagesByUID($this->getUID()); if ($msg->error) show_error($msg->retval); $data = array ( - 'message' => $msg->retval[0] + 'messages' => $msg->retval ); - $v = $this->load->view('message.php', $data); + var_dump ($data); + $this->load->view('system/messagesList.php', $data); } public function view($msg_id) { - $msg = $this->messaging->getMessage($msg_id); + $msg = $this->messagelib->getMessage($msg_id); //var_dump($msg); if ($msg->error) show_error($msg->retval); @@ -57,9 +66,9 @@ class Messages extends FHC_Controller { $body = $this->input->post('body', TRUE); $subject = $this->input->post('subject', TRUE); - if (! $this->messaging->addRecipient(1)) + if (! $this->messagelib->addRecipient(1)) show_error('Error: AddRecipient'); - $msg = $this->messaging->sendMessage(1,$body ,$subject); + $msg = $this->messagelib->sendMessage(1,$body ,$subject); if ($msg->error) show_error($msg->retval); $msg_id = $msg->retval; diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index f0e224914..4e5f2474d 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -2,11 +2,11 @@ class DB_Model extends FHC_Model { - protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ... - protected $pk; // Name of the PrimaryKey for DB-Update, Load, ... + protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ... + protected $pk; // Name of the PrimaryKey for DB-Update, Load, ... protected $hasSequence; // False if this table has a composite primary key that is not using a sequence // True if this table has a primary key that uses a sequence - protected $acl; // Name of the PrimaryKey for DB-Update, Load, ... + protected $acl; // Name of the PrimaryKey for DB-Update, Load, ... function __construct($dbTable = null, $pk = null, $hasSequence = true) { diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index e3026dbb8..3216bbb63 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -3,21 +3,23 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class FHC_Controller extends CI_Controller { - public $uid; - - function __construct() + protected $_uid; // needs to be changed to protected $_uid + + public 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'); + $this->load->helper('fhcauth'); + + $this->_uid = getAuthUID(); + } + public function getUID() + { + if (empty($this->_uid)) + return false; + else + return $this->_uid; } } diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php index 485678c94..13457057f 100644 --- a/application/core/FHC_Model.php +++ b/application/core/FHC_Model.php @@ -40,6 +40,16 @@ class FHC_Model extends CI_Model { return $this->fhc_db_acl->setUID($uid); } + + /** --------------------------------------------------------------- + * get UID + * + * @return string or (bool)false + */ + public function getUID() + { + return $this->fhc_db_acl->getUID(); + } /** --------------------------------------------------------------- * Success @@ -61,4 +71,4 @@ class FHC_Model extends CI_Model { return error($retval, $message); } -} \ No newline at end of file +} diff --git a/application/core/FS_Model.php b/application/core/FS_Model.php new file mode 100644 index 000000000..1bcaaa251 --- /dev/null +++ b/application/core/FS_Model.php @@ -0,0 +1,170 @@ +load->library('FilesystemLib'); + $this->acl = $this->config->item('fhc_acl'); + $this->filepath = $filepath; + } + + /** --------------------------------------------------------------- + * Read data from file system + * + * @return array + */ + public function read($filename) + { + // Check Class-Attributes + if (is_null($this->filepath)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check method parameters + if (is_null($filename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check rights + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR); + + if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename))) + { + return $this->_success(base64_encode($data)); + } + else + { + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + } + } + + /** --------------------------------------------------------------- + * Writing data to file system + * + * @param string $fileContent File content + * @return object + */ + public function write($filename, $content) + { + // Check Class-Attributes + if (is_null($this->filepath)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check method parameters + if (is_null($filename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + if (is_null($content)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check rights + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'i')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR); + + if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true) + { + return $this->_success(FHC_SUCCESS); + } + else + { + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + } + } + + /** --------------------------------------------------------------- + * Append data to a file + * + * @param array $data File content + * @return array + */ + public function append($filename, $content) + { + // Check Class-Attributes + if (is_null($this->filepath)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check method parameters + if (is_null($filename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + if (is_null($content)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check rights + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'i')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR); + + if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true) + { + return $this->_success(FHC_SUCCESS); + } + else + { + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + } + } + + /** --------------------------------------------------------------- + * Delete data from file system + * + * @param string $id Primary Key for DELETE + * @return array + */ + public function remove($filename) + { + // Check Class-Attributes + if (is_null($this->filepath)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check method parameters + if (is_null($filename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check rights + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'd')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR); + + if ($this->filesystemlib->remove($this->filepath, $filename) === true) + { + return $this->_success(FHC_SUCCESS); + } + else + { + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + } + } + + /** --------------------------------------------------------------- + * Rename a file + * + * @param string $id Primary Key for DELETE + * @return array + */ + public function rename($filename, $newFilename) + { + // Check Class-Attributes + if (is_null($this->filepath)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check method parameters + if (is_null($filename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + if (is_null($newFilename)) + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + + // Check rights + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->filepath], 'u')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->filepath], FHC_MODEL_ERROR); + + if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true) + { + return $this->_success(FHC_SUCCESS); + } + else + { + return $this->_error(lang('fhc_'.FHC_ERROR), FHC_MODEL_ERROR); + } + } +} \ No newline at end of file diff --git a/application/helpers/fhcauth_helper.php b/application/helpers/fhcauth_helper.php index 1a904ee55..7a5f782b0 100644 --- a/application/helpers/fhcauth_helper.php +++ b/application/helpers/fhcauth_helper.php @@ -48,4 +48,20 @@ if ( ! function_exists('auth')) return false; } } + + /** + * Look if User is logged in and return uid + * Otherwise return false + * + * @return string or (bool)false + */ + function getAuthUID() + { + // look if User is logged in and return uid + if (isset($_SERVER['PHP_AUTH_USER'])) + return $_SERVER['PHP_AUTH_USER']; + if (isset($_SESSION['uid'])) + return $_SESSION['uid']; + return false; + } } diff --git a/application/libraries/FHC_DB_ACL.php b/application/libraries/FHC_DB_ACL.php index 702b193e7..0c88af34d 100644 --- a/application/libraries/FHC_DB_ACL.php +++ b/application/libraries/FHC_DB_ACL.php @@ -68,4 +68,14 @@ class FHC_DB_ACL { return $this->_uid = $uid; } + + /** --------------------------------------------------------------- + * get UID + * + * @return string or (bool)false + */ + public function getUID() + { + return $this->_uid; + } } diff --git a/application/libraries/FilesystemLib.php b/application/libraries/FilesystemLib.php new file mode 100644 index 000000000..0b1dbc5d0 --- /dev/null +++ b/application/libraries/FilesystemLib.php @@ -0,0 +1,148 @@ +checkParameters($filepath, $filename)) + { + $resource = $filepath . DIRECTORY_SEPARATOR . $filename; + if (file_exists($resource) && $fileHandle = fopen($resource, 'r')) + { + $result = ''; + while (!feof($fileHandle)) + { + $result .= fread($fileHandle, 8192); + } + fclose($fileHandle); + } + } + + return $result; + } + + /* + * + */ + public function write($filepath, $filename, $content) + { + $result = null; + + if ($this->checkParameters($filepath, $filename) && isset($content)) + { + $resource = $filepath . DIRECTORY_SEPARATOR . $filename; + if (is_writable($filepath) && $fileHandle = fopen($resource, 'w')) + { + if (fwrite($fileHandle, $content) !== false) + { + $result = true; + } + fclose($fileHandle); + } + } + + return $result; + } + + /* + * + */ + public function append($filepath, $filename, $content) + { + $result = null; + + if ($this->checkParameters($filepath, $filename) && isset($content)) + { + $resource = $filepath . DIRECTORY_SEPARATOR . $filename; + if (is_writable($resource) && $fileHandle = fopen($resource, 'a')) + { + if (fwrite($fileHandle, $content) !== false) + { + $result = true; + } + fclose($fileHandle); + } + } + + return $result; + } + + /* + * + */ + public function remove($filepath, $filename) + { + $result = null; + + if ($this->checkParameters($filepath, $filename)) + { + if (is_writable($filepath)) + { + $resource = $filepath . DIRECTORY_SEPARATOR . $filename; + $result = unlink($resource); + } + } + + return $result; + } + + /* + * + */ + public function rename($filepath, $filename, $newFilepath, $newFilename) + { + $result = null; + + if ($this->checkParameters($filepath, $filename) && $this->checkParameters($newFilepath, $newFilename)) + { + $resource = $filepath . DIRECTORY_SEPARATOR . $filename; + if (is_writable($filepath) && is_writable($newFilepath) && file_exists($resource)) + { + $destination = $newFilepath . DIRECTORY_SEPARATOR . $newFilename; + $result = rename($resource, $destination); + } + } + + return $result; + } +} \ No newline at end of file diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index fa280938a..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'); @@ -53,6 +58,40 @@ class MessageLib return $msg; } + /** + * getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * + * @param string $uid REQUIRED + * @return array + */ + function getMessagesByUID($uid, $all = false) + { + if (empty($uid)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + + $msg = $this->ci->MessageModel->getMessagesByUID($uid, $all); + + // General Error Occurred + return $msg; + } + + /** + * getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments. + * + * @param bigint $person_id REQUIRED + * @return array + */ + function getMessagesByPerson($person_id, $all = false) + { + if (empty($person_id)) + return $this->_error(MSG_ERR_INVALID_MSG_ID); + + $msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all); + + // General Error Occurred + return $msg; + } + // ------------------------------------------------------------------------ /** @@ -66,8 +105,7 @@ class MessageLib if (!is_numeric($msg_id)) return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID); - $msg = $this->getMessage($msg_id); - return $msg; + return $this->getMessage($msg_id); } // ------------------------------------------------------------------------ diff --git a/application/migrations/010_vorlage.php b/application/migrations/010_vorlage.php index f6b7b7cd5..0fda6823c 100755 --- a/application/migrations/010_vorlage.php +++ b/application/migrations/010_vorlage.php @@ -8,17 +8,37 @@ class Migration_Vorlage extends CI_Migration { { if (! @$this->db->simple_query('SELECT attribute FROM public.tbl_vorlage')) { + $this->db->insert('system.tbl_berechtigung', array( + 'berechtigung_kurzbz' => 'basis/vorlage', + 'beschreibung' => 'Vorlagen fuer Dokumente (DOC, PDF, eMail, ...')); + $this->db->insert('system.tbl_rolleberechtigung', array( + 'berechtigung_kurzbz' => 'basis/vorlage', + 'rolle_kurzbz' => 'admin', + 'art' => 'suid')); $query= "ALTER TABLE public.tbl_vorlage ADD COLUMN attribute json; "; if ($this->db->simple_query($query)) + { echo 'Column public.tbl_vorlage.attribute added!'; + // Insert Demo Data + $query= "INSERT INTO public.tbl_vorlage VALUES ('MailRegistration', 'eMail zur Registrierung', NULL, 'text/html', '{ \"\$schema\": \"http://json-schema.org/draft-03/schema#\", \"title\": \"Person\", \"type\": \"object\", \"properties\": { \"anrede\": { \"type\": \"string\", \"enum\": [ \"Herr\", \"Frau\" ], \"default\": \"Herr\" }, \"vorname\": { \"type\": \"string\", \"description\": \"Firstname\", \"minLength\": 2, \"default\": \"Vorname\" }, \"nachname\": { \"type\": \"string\", \"description\": \"Surename\", \"minLength\": 2, \"default\": \"Nachname\" }, \"code\": { \"type\": \"string\", \"description\": \"Accesscode\", \"minLength\": 6, \"default\": \"1q2w3e4r5t6z7u8i9o0\" }, \"link\": { \"type\": \"string\", \"description\": \"LoginURL\", \"minLength\": 6, \"default\": \"https://cis.fhcomplete.org/addon/aufnahme/cis/login/\" } }}'); + "; + $this->db->simple_query($query); + } else echo "Error adding public.tbl_vorlage.attribute!"; } if (! @$this->db->simple_query('SELECT subject FROM public.tbl_vorlagestudiengang')) { + $this->db->insert('system.tbl_berechtigung', array( + 'berechtigung_kurzbz' => 'basis/vorlagestudiengang', + 'beschreibung' => 'Vorlagen fuer Dokumente (DOC, PDF, eMail, ...')); + $this->db->insert('system.tbl_rolleberechtigung', array( + 'berechtigung_kurzbz' => 'basis/vorlagestudiengang', + 'rolle_kurzbz' => 'admin', + 'art' => 'suid')); $query= "ALTER TABLE public.tbl_vorlagestudiengang ADD COLUMN subject text; "; @@ -34,7 +54,17 @@ class Migration_Vorlage extends CI_Migration { ADD COLUMN orgform_kurzbz varchar(3) references bis.tbl_orgform(orgform_kurzbz); "; if ($this->db->simple_query($query)) + { echo 'Column public.tbl_vorlagestudiengang.orgform_kurzbz added!'; + // Insert Demo Data + $query= "INSERT INTO public.tbl_vorlagestudiengang VALUES ('MailRegistration', 0, 1, '
Sehr geehrte/r {anrede} {vorname} {nachname},
+vielen Dank für Ihre Registrierung an unserer Hochschule. Im Anhang senden wir ihnen den Zugangscode.
+Code: {code}
Unter folgenden Link können sie sich direkt für unser Service einloggen: {link}{code}
+Mit freundlichen Grüßen,
FH Technikum Wien
| Vorlage | +Bezeichnung | +Anmerkung | MimeType | ++ |
|---|---|---|---|---|
| vorlage_kurzbz; ?> | +bezeichnung; ?> | +anmerkung; ?> | +mimetype; ?> | +View | +