From d8bcc25ac2fbd068e63d4aba8966df3923808670 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 27 Jun 2018 11:10:40 +0200 Subject: [PATCH] Now the helper message is loaded only by these controllers and models: - APIv1_Controller - FHC_Controller - MessageToken_model --- application/controllers/Redirect.php | 3 - application/controllers/system/Phrases.php | 3 - .../system/aufnahme/PrestudentMultiAssign.php | 57 +++++++++---------- application/core/FHC_Controller.php | 4 ++ application/core/FHC_Model.php | 3 - application/core/FS_Model.php | 27 ++++----- .../models/system/MessageToken_model.php | 1 + application/widgets/html/HTMLWidget.php | 29 +++++----- 8 files changed, 57 insertions(+), 70 deletions(-) diff --git a/application/controllers/Redirect.php b/application/controllers/Redirect.php index 660709b6f..e372683a4 100644 --- a/application/controllers/Redirect.php +++ b/application/controllers/Redirect.php @@ -26,9 +26,6 @@ class Redirect extends FHC_Controller // Loads config file fhcomplete $this->config->load('fhcomplete'); - // Loads message helper - $this->load->helper('message'); - // Loads model MessageTokenModel $this->load->model('system/MessageToken_model', 'MessageTokenModel'); } diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php index d1f4ce98a..8f640928b 100644 --- a/application/controllers/system/Phrases.php +++ b/application/controllers/system/Phrases.php @@ -16,9 +16,6 @@ class Phrases extends FHC_Controller // Loads the widget library $this->load->library('WidgetLib'); - - // Loads helper message to manage returning messages - $this->load->helper('message'); } /** diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php index 242dd693f..d539fe342 100644 --- a/application/controllers/system/aufnahme/PrestudentMultiAssign.php +++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php @@ -7,14 +7,11 @@ class PrestudentMultiAssign extends VileSci_Controller public function __construct() { parent::__construct(); - - // Loads helper message to manage returning messages - $this->load->helper('message'); - + // Loads the widget library $this->load->library('WidgetLib'); } - + public function index() { $studiengang = $this->input->post('studiengang'); @@ -22,27 +19,27 @@ class PrestudentMultiAssign extends VileSci_Controller $aufnahmegruppe = $this->input->post('aufnahmegruppe'); $reihungstest = $this->input->post('reihungstest'); $stufe = $this->input->post('stufe'); - + // Converts string 'null' to a null value $stufe = ($stufe == 'null' ? null : $stufe); $studiengang = ($studiengang == 'null' ? null : $studiengang); $reihungstest = ($reihungstest == 'null' ? null : $reihungstest); $aufnahmegruppe = ($aufnahmegruppe == 'null' ? null : $aufnahmegruppe); $studiensemester = ($studiensemester == 'null' ? null : $studiensemester); - + $returnUsers = null; if ($studiengang != null || $studiensemester != null || $aufnahmegruppe!= null || $reihungstest != null || $stufe != null) { $returnUsers = $this->_getPrestudents($studiengang, $studiensemester, $aufnahmegruppe, $reihungstest, $stufe); } - + $users = null; if (hasData($returnUsers)) { $users = $returnUsers->retval; } - + if ($returnUsers == null || isSuccess($returnUsers)) { $viewData = array( @@ -53,7 +50,7 @@ class PrestudentMultiAssign extends VileSci_Controller 'stufe' => $stufe, 'users' => $users ); - + $this->load->view('system/aufnahme/prestudentMultiAssign', $viewData); } else if (isError($returnUsers)) @@ -61,7 +58,7 @@ class PrestudentMultiAssign extends VileSci_Controller show_error($returnUsers->retval); } } - + /** * To assign a stufe to one or more prestudents */ @@ -69,16 +66,16 @@ class PrestudentMultiAssign extends VileSci_Controller { $prestudentIdArray = $this->input->post('prestudent_id'); $stufe = $this->input->post('stufe'); - + // Converts string 'null' to a null value $stufe = ($stufe == 'null' ? null : $stufe); - + // Load model PrestudentstatusModel $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); - + // Set the HTTP header $this->output->set_header('Content-Type: application/json; charset=utf-8'); - + $result = error("No valid parameters"); if (isset($stufe) && isset($prestudentIdArray) @@ -86,7 +83,7 @@ class PrestudentMultiAssign extends VileSci_Controller && count($prestudentIdArray) > 0) { $result = $this->PrestudentstatusModel->updateStufe($prestudentIdArray, $stufe); - + if (isSuccess($result)) { echo '{"msg": "Data correctly saved"}'; @@ -101,7 +98,7 @@ class PrestudentMultiAssign extends VileSci_Controller echo '{"msg": "'.$result->retval.'"}'; } } - + /** * To assign one or more prestudents to a gruppe */ @@ -109,16 +106,16 @@ class PrestudentMultiAssign extends VileSci_Controller { $prestudentIdArray = $this->input->post('prestudent_id'); $aufnahmegruppe = $this->input->post('aufnahmegruppe'); - + // Converts string 'null' to a null value $aufnahmegruppe = ($aufnahmegruppe == 'null' ? null : $aufnahmegruppe); - + // Load model PrestudentstatusModel $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - + // Set the HTTP header $this->output->set_header('Content-Type: application/json; charset=utf-8'); - + $result = error("No valid parameters"); if (isset($aufnahmegruppe) && isset($prestudentIdArray) @@ -126,7 +123,7 @@ class PrestudentMultiAssign extends VileSci_Controller && count($prestudentIdArray) > 0) { $result = $this->PrestudentModel->updateAufnahmegruppe($prestudentIdArray, $aufnahmegruppe); - + if (isSuccess($result)) { echo '{"msg": "Data correctly saved"}'; @@ -141,7 +138,7 @@ class PrestudentMultiAssign extends VileSci_Controller echo '{"msg": "'.$result->retval.'"}'; } } - + /** * Get the prestudents using search parameters */ @@ -149,32 +146,32 @@ class PrestudentMultiAssign extends VileSci_Controller { // Load model prestudentm_model $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - + if ($studiengang == '' || empty($studiengang)) { $studiengang = null; } - + if ($studiensemester == '' || empty($studiensemester)) { $studiensemester = null; } - + if ($aufnahmegruppe == '' || empty($aufnahmegruppe)) { $aufnahmegruppe = null; } - + if ($reihungstest == '' || empty($reihungstest)) { $reihungstest = null; } - + if ($stufe == '' || empty($stufe)) { $stufe = null; } - + return $this->PrestudentModel->getPrestudentMultiAssign( $studiengang, $studiensemester, @@ -183,4 +180,4 @@ class PrestudentMultiAssign extends VileSci_Controller $stufe ); } -} \ No newline at end of file +} diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 7417a4ca6..0827ac764 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -17,7 +17,11 @@ class FHC_Controller extends CI_Controller $this->_controllerId = null; // set _controllerId as null by default + // Loads helper fhcauth to manage the authentication $this->load->helper('fhcauth'); + + // Loads helper message to manage returning messages + $this->load->helper('message'); } //------------------------------------------------------------------------------------------------------------------ diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php index d880fc5b8..39e1f6245 100644 --- a/application/core/FHC_Model.php +++ b/application/core/FHC_Model.php @@ -17,9 +17,6 @@ class FHC_Model extends CI_Model $this->lang->load('fhc_model'); $this->lang->load('fhcomplete'); - // Load return message helper - $this->load->helper('message'); - // Loads the permission library $this->load->library('PermissionLib'); } diff --git a/application/core/FS_Model.php b/application/core/FS_Model.php index 8b006e91a..3e28e2a82 100644 --- a/application/core/FS_Model.php +++ b/application/core/FS_Model.php @@ -10,16 +10,13 @@ class FS_Model extends FHC_Model public function __construct($filepath = null) { parent::__construct(); - + // Load the filesystem library $this->load->library('FilesystemLib'); - - // Load return message helper - $this->load->helper('message'); - + $this->filepath = $filepath; } - + /** --------------------------------------------------------------- * Read data from file system * @@ -29,13 +26,13 @@ class FS_Model extends FHC_Model { // Check Class-Attributes if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); - + // Check method parameters if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); // Check rights if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent; - + if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename))) { return success(base64_encode($data)); @@ -45,7 +42,7 @@ class FS_Model extends FHC_Model return error(FHC_MODEL_ERROR, FHC_ERROR); } } - + /** --------------------------------------------------------------- * Writing data to file system * @@ -56,7 +53,7 @@ class FS_Model extends FHC_Model { // Check Class-Attributes if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_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); @@ -84,7 +81,7 @@ class FS_Model extends FHC_Model { // Check Class-Attributes if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_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); @@ -112,7 +109,7 @@ class FS_Model extends FHC_Model { // Check Class-Attributes if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR); - + // Check method parameters if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR); @@ -128,7 +125,7 @@ class FS_Model extends FHC_Model return error(FHC_MODEL_ERROR, FHC_ERROR); } } - + /** --------------------------------------------------------------- * Rename a file * @@ -139,11 +136,11 @@ class FS_Model extends FHC_Model { // Check Class-Attributes if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_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); - + // Check rights if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::UPDATE_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent; diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index fb7f81a0a..a7f5b6b5c 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -8,6 +8,7 @@ class MessageToken_model extends CI_Model { /** * Constructor + * NOTE: here are loaded libs, models, helpers, etc. because MessageToken_model extends directly the CI_Model */ public function __construct() { diff --git a/application/widgets/html/HTMLWidget.php b/application/widgets/html/HTMLWidget.php index 9e737a8b7..9639890ea 100644 --- a/application/widgets/html/HTMLWidget.php +++ b/application/widgets/html/HTMLWidget.php @@ -10,12 +10,12 @@ class HTMLWidget extends Widget const HTML_DEFAULT_VALUE = ''; // Default value of the html element const HTML_NAME = 'name'; // HTML name attribute const HTML_ID = 'id'; // HTML id attribute - + // External block definition const EXTERNAL_BLOCK = 'externalBlock'; // External block name const EXTERNAL_START_BLOCK_HTML_TAG = '
'; // External block start tag const EXTERNAL_END_BLOCK_HTML_TAG = '
'; // External block end tag - + // HTML attributes const LABEL = 'title'; const REGEX = 'regex'; @@ -26,21 +26,18 @@ class HTMLWidget extends Widget const MAX_LENGTH = 'max-length'; const MIN_LENGTH = 'min-length'; const PLACEHOLDER = 'placeholder'; - + /** * It gets also the htmlArgs array as parameter, it will be used to set the HTML properties */ public function __construct($name, $args = array(), $htmlArgs = array()) { parent::__construct($name, $args); - + // Initialising HTML properties $this->_setHtmlProperties($htmlArgs); - - // Loads helper message to manage returning messages - $this->load->helper('message'); } - + /** * Initialising html properties, such as the id and name attributes of the HTML element */ @@ -50,19 +47,19 @@ class HTMLWidget extends Widget if (!isset($this->_args[HTMLWidget::HTML_ARG_NAME])) { $this->_args[HTMLWidget::HTML_ARG_NAME] = array(); - + // Avoids that elements in a HTML page have the same name or id $randomIdentifier = uniqid(rand(0, 1000)); $this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_ID] = $randomIdentifier; $this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_NAME] = $randomIdentifier; - + foreach($htmlArgs as $argName => $argValue) { $this->_args[HTMLWidget::HTML_ARG_NAME][$argName] = $argValue; } } } - + /** * Prints an attribute name and eventually also the value extracted from $htmlArgs * Set $isValuePresent to false the value should not be displayed @@ -76,12 +73,12 @@ class HTMLWidget extends Widget if ($isValuePresent === true) { $value = $htmlArgs[$attribute]; - + if (is_bool($value)) { $value = $value ? 'true' : 'false'; } - + echo sprintf('%s="%s"', $attribute, $value); } else @@ -91,7 +88,7 @@ class HTMLWidget extends Widget } } } - + /** * Prints the external block start tag */ @@ -103,7 +100,7 @@ class HTMLWidget extends Widget echo HTMLWidget::EXTERNAL_START_BLOCK_HTML_TAG; } } - + /** * Prints the external block end tag */ @@ -115,4 +112,4 @@ class HTMLWidget extends Widget echo HTMLWidget::EXTERNAL_END_BLOCK_HTML_TAG; } } -} \ No newline at end of file +}