- DB_Model added new functionalities

- Codeception changed
 - Studiengang_model fixed message error
 - Removed File and File_model, they will be replaced by Dms and Dms_model
 - Added new permissions in fhcomplete config file
This commit is contained in:
paolo
2016-05-09 18:19:58 +02:00
parent 28e1707b4e
commit 6d093dc4ed
11 changed files with 52 additions and 126 deletions
+3
View File
@@ -9,6 +9,9 @@ $config['fhc_acl'] = array
'bis.tbl_nation' => 'basis/nation',
'bis.tbl_lgartcode' => 'basis/lgartcode',
'campus.tbl_dms' => 'basis/tbl_dms',
'campus.tbl_dms_version' => 'basis/tbl_dms_version',
'lehre.tbl_studienplan' => 'basis/studienplan',
'lehre.tbl_studienordnung' => 'basis/studienordnung',
'lehre.vw_studienplan' => 'basis/vw_studienplan',
-45
View File
@@ -1,45 +0,0 @@
<?php
if(!defined('BASEPATH')) exit('No direct script access allowed');
class File extends APIv1_Controller
{
/**
* Person API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model FileModel
$this->load->model('file_model', 'FileModel');
// Load set the uid of the model to let to check the permissions
$this->FileModel->setUID($this->_getUID());
}
/**
* @return void
*/
public function postFile()
{
$result = $this->FileModel->saveFile($this->post());
if($result === TRUE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'File saved.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save file.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
+23
View File
@@ -223,6 +223,29 @@ class DB_Model extends FHC_Model
return $this->_success(TRUE);
}
/** ---------------------------------------------------------------
* Add limit clause
*
* @return void
*/
public function addLimit($start = null, $end = null)
{
// Check Class-Attributes and parameters
if(!is_numeric($start) || (is_numeric($start) && $start <= 0))
return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
if(is_numeric($end) && $end > $start)
{
$this->db->limit($start, $end);
}
else
{
$this->db->limit($start);
}
return $this->_success(TRUE);
}
/** ---------------------------------------------------------------
* Delete data from DB-Table
-42
View File
@@ -1,42 +0,0 @@
<?php
class File_model extends DB_Model
{
/**
*
*/
public function __construct()
{
parent::__construct();
}
/**
*
*/
public function saveFile($file = NULL)
{
$result = FALSE;
// Checks if the operation is permitted by the API caller
// All the code should be put inside this if statement
if(isAllowed($this->getUID(), 'file'))
{
if($this->_validate($file))
{
$result = $this->_write($file);
}
}
return $result;
}
private function _validate($file = NULL)
{
return TRUE;
}
private function _write($file = NULL)
{
return TRUE;
}
}
@@ -34,7 +34,7 @@ class Studiengang_model extends DB_Model
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['lehre.vw_studienplan'], FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->acl['bis.tbl_lgartcode'], 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['lehre.vw_studienplan'], FHC_MODEL_ERROR);
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['bis.tbl_lgartcode'], FHC_MODEL_ERROR);
return $this->db->query($allForBewerbungQuery);
}
@@ -1,12 +0,0 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test API call v1/lehre/studiengang/AllForBewerbung');
$I->amHttpAuthenticated("admin", "1q2w3");
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('v1/lehre/studiengang/AllForBewerbung');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => TRUE,
'message' => 'Courses found']);
+3 -12
View File
@@ -1,19 +1,10 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test API call v1/nation All and FederalState');
$I->wantTo('Test API call v1/codex/nation All and FederalState');
$I->amHttpAuthenticated("admin", "1q2w3");
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('v1/nation/All');
$I->sendGET('v1/codex/nation/All');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => TRUE,
'message' => 'Nation found']);
$I->sendGET('v1/nation/Bundesland');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => TRUE,
'message' => 'Bundesland found']);
$I->seeResponseContainsJson(['error' => 0]);
@@ -25,8 +25,8 @@ $I->sendGET('v1/person/person/Person', array('code' => '12345'));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => false,
'message' => 'Person not found']);
'error' => 0,
'retval' => array()]);
$I->sendGET('v1/person/person/Person', array('code' => '01234567C', 'email' => 'harvey.joshuah@calva.dev'));
$I->seeResponseCodeIs(200);
@@ -1,12 +0,0 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test API call v1/lehre/studienplan/Studienplaene');
$I->amHttpAuthenticated("admin", "1q2w3");
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('v1/lehre/studienplan/Studienplaene', array('studiengang_kz' => 1));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => TRUE,
'message' => 'Plan found']);
@@ -0,0 +1,10 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test API call v1/organisation/studiengang/AllForBewerbung');
$I->amHttpAuthenticated("admin", "1q2w3");
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('v1/organisation/studiengang/AllForBewerbung');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['error' => 0]);
@@ -0,0 +1,10 @@
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test API call v1/organisation/studienplan/Studienplaene');
$I->amHttpAuthenticated("admin", "1q2w3");
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
$I->sendGET('v1/organisation/studienplan/Studienplaene', array('studiengang_kz' => 1));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['error' => 0]);