From 699aca74d18b59eaed7cf83deca758551bc1a5e5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 25 Apr 2019 12:09:31 +0200 Subject: [PATCH] - Changed helper and language autoload - Changed language config - Removed never used constants - Changed rest_language in rest config file - Adapted models that where extending FHC_Model - Adapted code to load hlp_return_object - Adapted code to use exit status codes constants --- application/config/autoload.php | 5 +- application/config/config.php | 2 +- application/config/constants.php | 58 ++++--------------- application/config/rest.php | 2 +- .../controllers/api/v1/CheckUserAuth.php | 2 +- application/controllers/api/v1/Test.php | 4 +- application/core/DB_Model.php | 42 +++++++------- application/core/FHC_Controller.php | 2 +- application/core/FS_Model.php | 46 +++++++-------- application/core/REST_Controller.php | 2 +- application/libraries/DmsLib.php | 2 +- application/libraries/MessageLib.php | 13 ++--- application/libraries/PhrasesLib.php | 6 +- application/libraries/VorlageLib.php | 13 ++--- application/models/CL/Messages_model.php | 4 +- application/models/person/Notiz_model.php | 32 +++++----- application/models/system/Message_model.php | 4 +- application/views/system/udf.php | 2 +- 18 files changed, 97 insertions(+), 144 deletions(-) diff --git a/application/config/autoload.php b/application/config/autoload.php index aa6a8b40a..b30845f67 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -83,8 +83,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -//$autoload['helper'] = array(); -$autoload['helper'] = array('url', 'language', 'hlp_session'); +$autoload['helper'] = array('url'); /* | ------------------------------------------------------------------- @@ -112,7 +111,7 @@ $autoload['config'] = array(); | "codeigniter_lang.php" would be referenced as array('codeigniter'); | */ -$autoload['language'] = array('fhcomplete'); +$autoload['language'] = array(); /* | ------------------------------------------------------------------- diff --git a/application/config/config.php b/application/config/config.php index d0bca14b9..1c0993c92 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -70,7 +70,7 @@ $config['url_suffix'] = ''; | than english. | */ -$config['language'] = 'de-AT'; +$config['language'] = ''; /* |-------------------------------------------------------------------------- diff --git a/application/config/constants.php b/application/config/constants.php index 26f2d655e..77f28b830 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -2,47 +2,23 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); -/* -|-------------------------------------------------------------------------- -| FH-Complete constants -|-------------------------------------------------------------------------- -| -| These constants are used for internal messages. It are also be used -| and translated in the language files. -| -*/ -define('FHC_SUCCESS', 0); // General Success Message -define('FHC_ERROR', 1); // General Error Message -define('FHC_MODEL_ERROR', 2); // Model Error -define('FHC_DB_ERROR', 3); // Database Error -define('FHC_NODBTABLE', 4); // No DB-Table is set -define('FHC_NORIGHT', 5); // No rights -define('FHC_INVALIDID', 6); // Invalid or no ID (key) -define('FHC_NOPK', 7); // No primary key - /* |-------------------------------------------------------------------------- | Exit status codes |-------------------------------------------------------------------------- | | Used to indicate the conditions under which the script is exit()ing. -| While there is no universal standard for error codes, there are some -| broad conventions. Three such conventions are mentioned below, for -| those who wish to make use of them. The CodeIgniter defaults were -| chosen for the least overlap with these conventions, while still -| leaving room for others to be defined in future versions and user -| applications. | */ -define('EXIT_SUCCESS', 0); // no errors -define('EXIT_ERROR', 1); // generic error -define('EXIT_MODEL', 2); // model error -define('EXIT_CONFIG', 3); // configuration error -define('EXIT_UNKNOWN_FILE', 4); // file not found -define('EXIT_UNKNOWN_CLASS', 5); // unknown class -define('EXIT_UNKNOWN_METHOD', 6); // unknown class member -define('EXIT_USER_INPUT', 7); // invalid user input -define('EXIT_DATABASE', 8); // database error +define('EXIT_SUCCESS', 0); // no errors +define('EXIT_ERROR', 1); // generic error +define('EXIT_MODEL', 2); // model error +define('EXIT_CONFIG', 3); // configuration error +define('EXIT_UNKNOWN_FILE', 4); // file not found +define('EXIT_UNKNOWN_CLASS', 5); // unknown class +define('EXIT_UNKNOWN_METHOD', 6); // unknown class method +define('EXIT_USER_INPUT', 7); // invalid user input +define('EXIT_DATABASE', 8); // database error define('EXIT_VALIDATION_UDF', 10); // UDF validation has been failed define('EXIT_VALIDATION_UDF_MIN_VALUE', 11); // UDF validation has been failed -> MIN VALUE define('EXIT_VALIDATION_UDF_MAX_VALUE', 12); // UDF validation has been failed -> MAX VALUE @@ -52,8 +28,8 @@ define('EXIT_VALIDATION_UDF_REGEX', 15); // UDF validation has been failed -> define('EXIT_VALIDATION_UDF_REQUIRED', 16); // UDF validation has been failed -> REQUIRED define('EXIT_VALIDATION_UDF_NOT_VALID_VAL', 17); // UDF validation has been failed -> Not valid value, object or array -define('EXIT_AUTO_MIN', 1000); // lowest automatically-assigned error code -define('EXIT_AUTO_MAX', 2000); // highest automatically-assigned error code +define('EXIT_AUTO_MIN', 1000); // lowest automatically-assigned error code +define('EXIT_AUTO_MAX', 2000); // highest automatically-assigned error code /* |-------------------------------------------------------------------------- @@ -158,18 +134,6 @@ define('PRIORITY_NORMAL', 2); define('PRIORITY_HIGH', 3); define('PRIORITY_URGENT', 4); -// Status return message codes -define('MSG_SUCCESS', 0); -define('MSG_ERROR', 1); - -define('MSG_MESSAGE_SENT', 10); -define('MSG_STATUS_UPDATE', 11); - -define('MSG_PARTICIPANT_ADDED', 30); -define('MSG_ERR_PARTICIPANT_EXISTS', 31); -define('MSG_ERR_PARTICIPANT_NONSYSTEM', 32); -define('MSG_PARTICIPANT_REMOVED', 33); - define('MSG_ERR_SUBJECT_EMPTY', 40); define('MSG_ERR_BODY_EMPTY', 41); define('MSG_ERR_TEMPLATE_NOT_FOUND', 42); diff --git a/application/config/rest.php b/application/config/rest.php index 4f3a78972..9bbbf40ef 100644 --- a/application/config/rest.php +++ b/application/config/rest.php @@ -516,4 +516,4 @@ $config['rest_ajax_only'] = FALSE; | Language file to load from the language directory | */ -$config['rest_language'] = 'en-US'; +$config['rest_language'] = 'english'; diff --git a/application/controllers/api/v1/CheckUserAuth.php b/application/controllers/api/v1/CheckUserAuth.php index 69dc9cda6..4d6522fe2 100644 --- a/application/controllers/api/v1/CheckUserAuth.php +++ b/application/controllers/api/v1/CheckUserAuth.php @@ -13,7 +13,7 @@ class CheckUserAuth extends REST_Controller // Loads helper message to manage returning messages // NOTE: loaded here because it does not extend the APIv1_Controller - $this->load->helper('hlp_message'); + $this->load->helper('hlp_return_object'); } /** diff --git a/application/controllers/api/v1/Test.php b/application/controllers/api/v1/Test.php index 010314013..41feb1a16 100644 --- a/application/controllers/api/v1/Test.php +++ b/application/controllers/api/v1/Test.php @@ -2,8 +2,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -require_once APPPATH.'/libraries/REST_Controller.php'; - /** * Testing class for REST calls and authentication */ @@ -14,7 +12,7 @@ class Test extends REST_Controller parent::__construct(); // Loads helper message to manage returning messages - $this->load->helper('hlp_message'); + $this->load->helper('hlp_return_object'); } /** diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 16b9f2da9..199f81162 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -1,6 +1,6 @@ dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); // If this table has UDF and the validation of them is ok if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate; @@ -100,7 +100,7 @@ class DB_Model extends FHC_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } @@ -114,8 +114,8 @@ class DB_Model extends FHC_Model public function update($id, $data) { // Check class properties - if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK); - if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); + if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); // If this table has UDF and the validation of them is ok if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate; @@ -148,7 +148,7 @@ class DB_Model extends FHC_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } @@ -161,8 +161,8 @@ class DB_Model extends FHC_Model public function delete($id) { // Check class properties - if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); - if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); + if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK); $tmpId = $id; @@ -190,7 +190,7 @@ class DB_Model extends FHC_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } @@ -203,8 +203,8 @@ class DB_Model extends FHC_Model public function load($id = null) { // Check class properties - if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK); - if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); + if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); $tmpId = $id; @@ -232,7 +232,7 @@ class DB_Model extends FHC_Model public function loadWhere($where = null) { // Check class properties - if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); // Execute query $result = $this->db->get_where($this->dbTable, $where); @@ -245,7 +245,7 @@ class DB_Model extends FHC_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } @@ -264,7 +264,7 @@ class DB_Model extends FHC_Model public function loadTree($mainTable, $sideTables, $where = null, $sideTablesAliases = null) { // Check class properties - if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE); + if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE); // List of tables on which it will work $tables = array_merge(array($mainTable), $sideTables); @@ -405,7 +405,7 @@ class DB_Model extends FHC_Model || is_null($cond) || !in_array($type, array('', 'LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'))) { - return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + return error(EXIT_MODEL, EXIT_MODEL); } $this->db->join($joinTable, $cond, $type); @@ -421,7 +421,7 @@ class DB_Model extends FHC_Model public function addOrder($field = null, $type = 'ASC') { // Check class properties and parameters - if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(EXIT_MODEL, EXIT_MODEL); $this->db->order_by($field, $type); @@ -436,7 +436,7 @@ class DB_Model extends FHC_Model public function addSelect($select, $escape = true) { // Check class properties and parameters - if (is_null($select) || $select == '') return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + if (is_null($select) || $select == '') return error(EXIT_MODEL, EXIT_MODEL); $this->db->select($select, $escape); @@ -461,7 +461,7 @@ class DB_Model extends FHC_Model public function addLimit($start = null, $end = null) { // Check class properties and parameters - if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(EXIT_MODEL, EXIT_MODEL); if (is_numeric($end) && $end > $start) { @@ -485,7 +485,7 @@ class DB_Model extends FHC_Model $tmpTable = trim($table); // Check parameters - if (isEmptyString($tmpTable)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + if (isEmptyString($tmpTable)) return error(EXIT_MODEL, EXIT_MODEL); if (!isEmptyString($alias)) { @@ -509,7 +509,7 @@ class DB_Model extends FHC_Model || (is_array($fields) && count($fields) == 0) || (is_string($fields) && $fields == '')) { - return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR); + return error(EXIT_MODEL, EXIT_MODEL); } $this->db->group_by($fields); @@ -772,7 +772,7 @@ class DB_Model extends FHC_Model } else { - $result = error($this->db->error(), FHC_DB_ERROR); + $result = error($this->db->error(), EXIT_DATABASE); } } diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 7b29b43e7..db02be3c4 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -21,7 +21,7 @@ class FHC_Controller extends CI_Controller $this->_controllerId = null; // set _controllerId as null by default // Loads helper message to manage returning messages - $this->load->helper('hlp_message'); + $this->load->helper('hlp_return_object'); // Loads helper with generic utility function $this->load->helper('hlp_common'); diff --git a/application/core/FS_Model.php b/application/core/FS_Model.php index 7e2b2d7e2..bd3275110 100644 --- a/application/core/FS_Model.php +++ b/application/core/FS_Model.php @@ -1,6 +1,6 @@ filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR); // Check method parameters - if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR); if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename))) { @@ -36,7 +36,7 @@ class FS_Model extends FHC_Model } else { - return error(FHC_MODEL_ERROR, FHC_ERROR); + return error(EXIT_MODEL, EXIT_ERROR); } } @@ -49,19 +49,19 @@ class FS_Model extends FHC_Model public function write($filename, $content) { // Check Class-Attributes - if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR); // Check method parameters - if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); - if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR); + if (is_null($content)) return error(EXIT_MODEL, EXIT_ERROR); if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true) { - return success(FHC_SUCCESS); + return success(); } else { - return error(FHC_MODEL_ERROR, FHC_ERROR); + return error(EXIT_MODEL, EXIT_ERROR); } } @@ -74,19 +74,19 @@ class FS_Model extends FHC_Model public function append($filename, $content) { // Check Class-Attributes - if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR); // Check method parameters - if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR); - if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($content)) return error(EXIT_MODEL, EXIT_ERROR); + if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR); if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true) { - return success(FHC_SUCCESS); + return success(); } else { - return error(FHC_MODEL_ERROR, FHC_ERROR); + return error(EXIT_MODEL, EXIT_ERROR); } } @@ -99,18 +99,18 @@ class FS_Model extends FHC_Model public function remove($filename) { // Check Class-Attributes - if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR); // Check method parameters - if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR); if ($this->filesystemlib->remove($this->filepath, $filename) === true) { - return success(FHC_SUCCESS); + return success(); } else { - return error(FHC_MODEL_ERROR, FHC_ERROR); + return error(EXIT_MODEL, EXIT_ERROR); } } @@ -123,19 +123,19 @@ class FS_Model extends FHC_Model public function rename($filename, $newFilename) { // Check Class-Attributes - if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($this->filepath)) return error(EXIT_MODEL, EXIT_ERROR); // Check method parameters - if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); - if (is_null($newFilename)) return error(FHC_MODEL_ERROR, FHC_ERROR); + if (is_null($filename)) return error(EXIT_MODEL, EXIT_ERROR); + if (is_null($newFilename)) return error(EXIT_MODEL, EXIT_ERROR); if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true) { - return success(FHC_SUCCESS); + return success(); } else { - return error(FHC_MODEL_ERROR, FHC_ERROR); + return error(EXIT_MODEL, EXIT_ERROR); } } } diff --git a/application/core/REST_Controller.php b/application/core/REST_Controller.php index 488892b60..0bcfe8276 100644 --- a/application/core/REST_Controller.php +++ b/application/core/REST_Controller.php @@ -361,7 +361,7 @@ abstract class REST_Controller extends CI_Controller { protected function early_checks() { // Loads helper message to manage returning messages - $this->load->helper('hlp_message'); + $this->load->helper('hlp_return_object'); // Loads helper with generic utility function $this->load->helper('hlp_common'); diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index 317b02157..6b86ce7f8 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -199,7 +199,7 @@ class DmsLib if ($this->ci->db->trans_status() === false || isError($result)) { $this->ci->db->trans_rollback(); - $result = error($result->msg, EXIT_ERROR); + $result = error('An error occurred while performing a delete operation', EXIT_ERROR); } else { diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index cb691ec93..0ccbfbefb 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -36,9 +36,6 @@ class MessageLib $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 phrases - $this->_ci->lang->load('message'); } //------------------------------------------------------------------------------------------------------------------ @@ -970,7 +967,7 @@ class MessageLib if ($this->_ci->db->trans_status() === false || isError($result)) { $this->_ci->db->trans_rollback(); - $result = $this->_error($result->msg, EXIT_ERROR); + $result = $this->_error('An error occurred while saving a message', EXIT_ERROR); } else { @@ -984,16 +981,16 @@ class MessageLib /** * Wrapper for function error */ - private function _error($retval = '', $code = null) + private function _error($retval, $code) { - return error($retval, $code, MessageLib::MSG_INDX_PREFIX); + return error($retval, $code); } /** * Wrapper for function success */ - private function _success($retval = '', $code = null) + private function _success($retval, $code = null) { - return success($retval, $code, MessageLib::MSG_INDX_PREFIX); + return success($retval, $code); } } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index 6793f38e0..110e5b0c8 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -82,8 +82,7 @@ class PhrasesLib */ public function getPhrasentextById($phrasentext_id) { - if (isEmptyString($phrasentext_id)) - return error($this->_ci->lang->line('fhc_'.FHC_INVALIDID, false)); + if (isEmptyString($phrasentext_id)) return error('Not a valid phrasentext_id'); return $this->_ci->PhrasentextModel->load($phrasentext_id); } @@ -170,8 +169,7 @@ class PhrasesLib */ public function parseVorlagetext($text, $data = array()) { - if (isEmptyString($text)) - return error($this->_ci->lang->line('fhc_'.FHC_INVALIDID, false)); + if (isEmptyString($text)) return error('Not a valid text'); return $this->_ci->parser->parse_string($text, $data, true); } diff --git a/application/libraries/VorlageLib.php b/application/libraries/VorlageLib.php index 97ba591c9..d6c9d6a98 100644 --- a/application/libraries/VorlageLib.php +++ b/application/libraries/VorlageLib.php @@ -72,8 +72,7 @@ class VorlageLib */ public function getVorlagetextByVorlage($vorlage_kurzbz) { - if (isEmptyString($vorlage_kurzbz)) - return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); + if (isEmptyString($vorlage_kurzbz)) return error('Not a valid vorlage_kurzbz'); $vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz)); return $vorlage; @@ -90,8 +89,7 @@ class VorlageLib */ public function loadVorlagetext($vorlage_kurzbz, $oe_kurzbz = null, $orgform_kurzbz = null, $sprache = null) { - if (isEmptyString($vorlage_kurzbz)) - return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); + if (isEmptyString($vorlage_kurzbz)) return error('Not a valid vorlage_kurzbz'); // Try to search the template with the given vorlage_kurzbz and other parameters if present $queryParameters = array("vorlage_kurzbz" => $vorlage_kurzbz, "aktiv" => true); @@ -200,9 +198,8 @@ class VorlageLib */ public function parseVorlagetext($text, $data = array()) { - if (isEmptyString($text)) - return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); - $text = $this->ci->parser->parse_string($text, $data, true); - return $text; + if (isEmptyString($text)) return error('Not a valid text'); + + return $this->ci->parser->parse_string($text, $data, true); } } diff --git a/application/models/CL/Messages_model.php b/application/models/CL/Messages_model.php index 5a0a77a31..5f3f40e6d 100644 --- a/application/models/CL/Messages_model.php +++ b/application/models/CL/Messages_model.php @@ -1,10 +1,10 @@ dbTable = 'public.tbl_notiz'; $this->pk = 'notiz_id'; } - + // ------------------------------------------------------------------------------------------------------ /** * Get a specialization for a prestudent @@ -20,10 +20,10 @@ class Notiz_model extends DB_Model { // Join with the table public.tbl_notizzuordnung using notiz_id $this->addJoin('public.tbl_notizzuordnung', 'notiz_id'); - + return $this->NotizModel->loadWhere(array('prestudent_id' => $prestudent_id, 'titel' => $titel)); } - + /** * Remove a specialization */ @@ -31,31 +31,31 @@ class Notiz_model extends DB_Model { // Loads model Notizzuordnung_model $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); - + // Start DB transaction $this->db->trans_start(false); - + $result = $this->delete(array('notiz_id' => $notiz_id)); if (isSuccess($result)) { $result = $this->NotizzuordnungModel->delete(array('notiz_id' => $notiz_id)); } - + // Transaction complete! $this->db->trans_complete(); - + // Check if everything went ok during the transaction if ($this->db->trans_status() === false || isError($result)) { $this->db->trans_rollback(); - $result = error($result->msg, EXIT_ERROR); + $result = error('An error occurred while removing a specialization', EXIT_ERROR); } else { $this->db->trans_commit(); $result = success('Specialization successfully removed'); } - + return $result; } @@ -66,32 +66,32 @@ class Notiz_model extends DB_Model { // Loads model Notizzuordnung_model $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); - + // Start DB transaction $this->db->trans_start(false); - + $result = $this->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => true)); $notiz_id = $result->retval; if (isSuccess($result)) { $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'prestudent_id' => $prestudent_id)); } - + // Transaction complete! $this->db->trans_complete(); - + // Check if everything went ok during the transaction if ($this->db->trans_status() === false || isError($result)) { $this->db->trans_rollback(); - $result = error($result->msg, EXIT_ERROR); + $result = error('An error occurred while adding a specialization', EXIT_ERROR); } else { $this->db->trans_commit(); $result = success($notiz_id); } - + return $result; } @@ -122,7 +122,7 @@ class Notiz_model extends DB_Model if ($this->db->trans_status() === false || isError($result)) { $this->db->trans_rollback(); - $result = error($result->msg, EXIT_ERROR); + $result = error('An error occurred while adding a note for a person', EXIT_ERROR); } else { diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 764c3ae14..6f2ad01e2 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -151,7 +151,7 @@ class Message_model extends DB_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } @@ -168,7 +168,7 @@ class Message_model extends DB_Model } else { - return error($this->db->error(), FHC_DB_ERROR); + return error($this->db->error(), EXIT_DATABASE); } } diff --git a/application/views/system/udf.php b/application/views/system/udf.php index b2facc38c..10ba15698 100644 --- a/application/views/system/udf.php +++ b/application/views/system/udf.php @@ -31,7 +31,7 @@ { foreach ($error as $fieldError) { - echo $fieldError->msg . ' -> ' . $fieldError->retval . '
'; + echo $fieldError->code . ': ' . $fieldError->retval . '
'; } } }