mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
All the libraries, when it is required, now are using the message helper
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -8,7 +8,7 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
class DmsLib
|
||||
{
|
||||
//
|
||||
const FILE_CONTENT_PROPERTY = "file_content";
|
||||
const FILE_CONTENT_PROPERTY = 'file_content';
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
@@ -17,10 +17,13 @@ class DmsLib
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
|
||||
$this->ci->load->model("crm/Akte_model", "AkteModel");
|
||||
$this->ci->load->model("content/Dms_model", "DmsModel");
|
||||
$this->ci->load->model("content/DmsVersion_model", "DmsVersionModel");
|
||||
$this->ci->load->model("content/DmsFS_model", "DmsFSModel");
|
||||
$this->ci->load->model('crm/Akte_model', 'AkteModel');
|
||||
$this->ci->load->model('content/Dms_model', 'DmsModel');
|
||||
$this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
$this->ci->load->model('content/DmsFS_model', 'DmsFSModel');
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->ci->load->helper('message');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,8 +35,8 @@ class DmsLib
|
||||
|
||||
if (isset($dms_id))
|
||||
{
|
||||
$this->ci->DmsModel->addJoin("campus.tbl_dms_version", "dms_id");
|
||||
$this->ci->DmsModel->addOrder("version", "DESC");
|
||||
$this->ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
$this->ci->DmsModel->addOrder('version', 'DESC');
|
||||
$this->ci->DmsModel->addLimit(1);
|
||||
|
||||
if (!isset($version))
|
||||
@@ -42,7 +45,7 @@ class DmsLib
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->ci->DmsModel->loadWhere(array("dms_id" => $dms_id, "version" => $version));
|
||||
$result = $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,19 +73,19 @@ class DmsLib
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if(isset($dms["new"]) && $dms["new"] == true)
|
||||
if(isset($dms['new']) && $dms['new'] == true)
|
||||
{
|
||||
// Remove new parameter to avoid DB insert errors
|
||||
unset($dms["new"]);
|
||||
unset($dms['new']);
|
||||
|
||||
$result = $this->_saveFileOnInsert($dms);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$filename = $result->retval;
|
||||
if(isset($dms["dms_id"]) && $dms["dms_id"] != "")
|
||||
if(isset($dms['dms_id']) && $dms['dms_id'] != '')
|
||||
{
|
||||
$result = $this->ci->DmsVersionModel->insert(
|
||||
$this->ci->DmsVersionModel->filterFields($dms, $dms["dms_id"], $filename)
|
||||
$this->ci->DmsVersionModel->filterFields($dms, $dms['dms_id'], $filename)
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -102,13 +105,13 @@ class DmsLib
|
||||
$result = $this->_saveFileOnUpdate($dms);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->ci->DmsModel->update($dms["dms_id"], $this->ci->DmsModel->filterFields($dms));
|
||||
$result = $this->ci->DmsModel->update($dms['dms_id'], $this->ci->DmsModel->filterFields($dms));
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->ci->DmsVersionModel->update(
|
||||
array(
|
||||
$dms["dms_id"],
|
||||
$dms["version"]
|
||||
$dms['dms_id'],
|
||||
$dms['version']
|
||||
),
|
||||
$this->ci->DmsVersionModel->filterFields($dms)
|
||||
);
|
||||
@@ -133,7 +136,7 @@ class DmsLib
|
||||
$this->ci->db->trans_start(false);
|
||||
|
||||
// Get akte_id from table tbl_akte
|
||||
$result = $this->ci->AkteModel->loadWhere(array("person_id" => $person_id, "dms_id" => $dms_id));
|
||||
$result = $this->ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id));
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
// Delete all entries in tbl_akte
|
||||
@@ -143,11 +146,11 @@ class DmsLib
|
||||
}
|
||||
|
||||
// Get all filenames related to this dms
|
||||
$resultFileNames = $this->ci->DmsVersionModel->loadWhere(array("dms_id" => $dms_id));
|
||||
$resultFileNames = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id));
|
||||
if (is_object($resultFileNames) && $resultFileNames->error == EXIT_SUCCESS)
|
||||
{
|
||||
// Delete from tbl_dms_version
|
||||
$result = $this->ci->DmsVersionModel->delete(array("dms_id" => $dms_id));
|
||||
$result = $this->ci->DmsVersionModel->delete(array('dms_id' => $dms_id));
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
// Delete from tbl_dms
|
||||
@@ -163,12 +166,12 @@ class DmsLib
|
||||
if ($this->ci->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
|
||||
{
|
||||
$this->ci->db->trans_rollback();
|
||||
$result = $this->_error($result->msg, EXIT_ERROR);
|
||||
$result = error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->ci->db->trans_commit();
|
||||
$result = $this->_success("Dms successfully removed from DB");
|
||||
$result = success('Dms successfully removed from DB');
|
||||
}
|
||||
|
||||
// If everything is ok
|
||||
@@ -183,7 +186,7 @@ class DmsLib
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->_error("Invalid parameters");
|
||||
$result = error('Invalid parameters');
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -194,9 +197,9 @@ class DmsLib
|
||||
*/
|
||||
private function _saveFileOnInsert($dms)
|
||||
{
|
||||
$filename = uniqid() . "." . pathinfo($dms["name"], PATHINFO_EXTENSION);
|
||||
$filename = uniqid() . '.' . pathinfo($dms['name'], PATHINFO_EXTENSION);
|
||||
|
||||
$result = $this->ci->DmsFSModel->write($filename, $dms["file_content"]);
|
||||
$result = $this->ci->DmsFSModel->write($filename, $dms['file_content']);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result->retval = $filename;
|
||||
@@ -212,42 +215,16 @@ class DmsLib
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if(isset($dms["version"]))
|
||||
if(isset($dms['version']))
|
||||
{
|
||||
$result = $this->read($dms["dms_id"], $dms["version"]);
|
||||
$result = $this->read($dms['dms_id'], $dms['version']);
|
||||
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
$result = $this->ci->DmsFSModel->write($result->retval[0]->filename, $dms["file_content"]);
|
||||
$result = $this->ci->DmsFSModel->write($result->retval[0]->filename, $dms['file_content']);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
private function _success($retval, $message = FHC_SUCCESS)
|
||||
{
|
||||
$return = new stdClass();
|
||||
$return->error = EXIT_SUCCESS;
|
||||
$return->Code = $message;
|
||||
$return->msg = lang("message_" . $message);
|
||||
$return->retval = $retval;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error
|
||||
*/
|
||||
private function _error($retval = "", $message = FHC_ERROR)
|
||||
{
|
||||
$return = new stdClass();
|
||||
$return->error = EXIT_ERROR;
|
||||
$return->Code = $message;
|
||||
$return->msg = lang("message_" . $message);
|
||||
$return->retval = $retval;
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user