Merge origin/ci into ci

Conflicts:
	application/config/rest.php
	application/libraries/FHC_Auth.php
	tests/codeception/api/LoginCept.php
This commit is contained in:
paolo
2016-04-20 17:57:55 +02:00
parent 0ffe7fbcc6
commit 78e4c2900b
23 changed files with 914 additions and 445 deletions
+95 -82
View File
@@ -1,93 +1,106 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class FHC_Model extends CI_Model
class FHC_Model extends CI_Model
{
//protected errormsg;
function __construct()
function __construct()
{
parent::__construct();
parent::__construct();
$this->load->helper('language');
$this->lang->load('fhcomplete');
}
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval = '', $message = FHC_SUCCESS)
{
return array(
'err' => 0,
'code' => FHC_SUCCESS,
'msg' => lang('fhc_' . $message),
'retval' => $retval
);
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
{
return array(
'err' => 1,
'code' => FHC_ERR_GENERAL,
'msg' => lang('fhc_'.$message),
'retval' => $retval
);
}
}
class DB_Model extends FHC_Model
{
protected $dbTable=null; // Name of the DB-Table for CI-Insert, -Update, ...
function __construct($uid=null)
{
parent::__construct();
$this->load->database();
$this->load->helper('language');
$this->lang->load('fhc_db');
// UID must be set in Production Mode
if (ENVIRONMENT=='production' && is_null($uid))
log_message('error', 'UID must be set in Production Mode.');
elseif (is_null($uid))
log_message('info', 'UID is not set.');
// Loading Tools for Access Control (Benutzerberechtigungen)
$this->load->library('FHC_DB_ACL',array('uid' => $uid));
}
public function insert($data)
{
if (! is_null($this->dbTable))
{
$this->db->insert($this->dbTable, $data);
return true;
}
else
return false;
$this->lang->load('fhcomplete');
}
/** ---------------------------------------------------------------
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
protected function _invalid_id($error = '')
{
return array(
'err' => 1,
'code' => $error,
'msg' => lang('fhc_'.$error)
);
}
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval = '', $message = FHC_SUCCESS)
{
return array(
'err' => 0,
'code' => FHC_SUCCESS,
'msg' => lang('fhc_' . $message),
'retval' => $retval
);
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
{
return array(
'err' => 1,
'code' => FHC_ERR_GENERAL,
'msg' => lang('fhc_' . $message),
'retval' => $retval
);
}
}
class DB_Model extends FHC_Model
{
protected $dbTable = NULL; // Name of the DB-Table for CI-Insert, -Update, ...
// Addon ID, stored to let to check the permissions
private $_addonID;
function __construct()
{
parent::__construct();
$this->load->database();
$this->lang->load('fhc_db');
}
public function insert($data)
{
if(!is_null($this->dbTable))
{
$this->db->insert($this->dbTable, $data);
return TRUE;
}
else
{
return FALSE;
}
}
/** ---------------------------------------------------------------
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
protected function _invalid_id($error = '')
{
return array(
'err' => 1,
'code' => $error,
'msg' => lang('fhc_' . $error)
);
}
/**
* TODO
*/
protected function _checkPermissions()
{
// If _addonID is NOT set (core) or if _addonID is set (API call) and has permissions
return !isset($this->_addonID) || (isset($this->_addonID) && TRUE);
}
/**
* Method setAddonID
*
* @param $addonID
* @return void
*/
public function setAddonID($addonID)
{
$this->_addonID = $addonID;
}
}