Conflicts:
	application/config/fhcomplete.php
	application/core/FHC_Model.php
This commit is contained in:
Paminger
2016-05-10 14:36:01 +02:00
29 changed files with 631 additions and 1316 deletions
-80
View File
@@ -1,80 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Nation extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('nation_model', 'NationModel');
// Load set the addonID of the model to let to check the permissions
$this->NationModel->setAddonID($this->_getAddonID());
}
public function getAll()
{
$result = $this->NationModel->getAll($this->get('ohnesperre'), $this->get('orderEnglish'));
if(is_object($result))
{
$payload = [
'success' => TRUE,
'message' => 'Nation found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
$payload = [
'success' => FALSE,
'message' => 'Nation not found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
public function getBundesland()
{
$result = $this->NationModel->getBundesland();
if(is_object($result))
{
$payload = [
'success' => TRUE,
'message' => 'Bundesland found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
$payload = [
'success' => FALSE,
'message' => 'Bundesland not found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Nation extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('codex/nation_model', 'NationModel');
// Load set the uid of the model to let to check the permissions
$this->NationModel->setUID($this->_getUID());
}
public function getAll()
{
if(!$this->get('orderEnglish'))
{
$result = $this->NationModel->addOrder('kurztext');
}
else
{
$result = $this->NationModel->addOrder('engltext');
}
if($result->error == EXIT_SUCCESS)
{
if($this->get('ohnesperre'))
{
$result = $this->NationModel->loadWhere('sperre IS NULL');
}
else
{
$result = $this->NationModel->loadWhole();
}
}
$this->response($result, REST_Controller::HTTP_OK);
}
}
@@ -1,55 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Studiengang extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('lehre/studiengang_model', 'StudiengangModel');
// Load set the addonID of the model to let to check the permissions
$this->StudiengangModel->setAddonID($this->_getAddonID());
}
public function getAllForBewerbung()
{
$result = $this->StudiengangModel->getAllForBewerbung();
if(is_object($result) && $result->num_rows() > 0)
{
$payload = [
'success' => TRUE,
'message' => 'Courses found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
$payload = [
'success' => FALSE,
'message' => 'No courses found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
@@ -1,55 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Studienplan extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('lehre/studienplan_model', 'StudienplanModel');
// Load set the addonID of the model to let to check the permissions
$this->StudienplanModel->setAddonID($this->_getAddonID());
}
public function getStudienplaene()
{
$result = $this->StudienplanModel->getStudienplaene($this->get('studiengang_kz'));
if(is_object($result) && $result->num_rows() > 0)
{
$payload = [
'success' => TRUE,
'message' => 'Plan found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
$payload = [
'success' => FALSE,
'message' => 'Plan not found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
@@ -0,0 +1,50 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Studienplan extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('organisation/studienplan_model', 'StudienplanModel');
// Load set the uid of the model to let to check the permissions
$this->StudienplanModel->setUID($this->_getUID());
}
public function getStudienplaene()
{
$studiengang_kz = $this->get('studiengang_kz');
if(isset($studiengang_kz))
{
$result = $this->StudienplanModel->addJoin('lehre.tbl_studienordnung', 'studienordnung_id');
if($result->error == EXIT_SUCCESS)
{
$result = $this->StudienplanModel->loadWhere(array('studiengang_kz' => $this->get('studiengang_kz')));
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
}
+264 -90
View File
@@ -24,8 +24,8 @@ class Person extends APIv1_Controller
parent::__construct();
// Load model PersonModel
$this->load->model('person/person_model', 'PersonModel');
// Load set the addonID of the model to let to check the permissions
$this->PersonModel->setAddonID($this->_getAddonID());
// Load set the uid of the model to let to check the permissions
$this->PersonModel->setUID($this->_getUID());
}
/**
@@ -36,28 +36,32 @@ class Person extends APIv1_Controller
$personID = $this->get('person_id');
$code = $this->get('code');
$email = $this->get('email');
$result = $this->PersonModel->getPerson($personID, $code, $email);
if(is_object($result) && $result->num_rows() > 0)
if(isset($code) || isset($email) || isset($personID))
{
$payload = [
'success' => TRUE,
'message' => 'Person found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
if(isset($code) && isset($email))
{
$result = $this->PersonModel->addJoin('public.tbl_kontakt', 'person_id');
if($result->error == EXIT_SUCCESS)
{
$result = $this->PersonModel->loadWhere(array('zugangscode' => $code, 'kontakt' => $email));
}
}
elseif(isset($code))
{
$result = $this->PersonModel->loadWhere(array('zugangscode' => $code));
}
else
{
$result = $this->PersonModel->load($personID);
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$payload = [
'success' => FALSE,
'message' => 'Person not found'
];
$httpstatus = REST_Controller::HTTP_OK;
$this->response();
}
$this->response($payload, $httpstatus);
}
/**
@@ -65,93 +69,263 @@ class Person extends APIv1_Controller
*/
public function postPerson()
{
$result = $this->PersonModel->savePerson($this->post());
if($result === TRUE)
if($this->_validate($this->post()))
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Person saved.'
];
$payload['data'] = $result;
if(isset($this->post()['person_id']))
{
$result = $this->PersonModel->update($this->post()['person_id'], $this->post());
}
else
{
$result = $this->PersonModel->insert($this->post());
}
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save person.'
];
$httpstatus = REST_Controller::HTTP_OK;
$this->response();
}
$this->response($payload, $httpstatus);
}
/**
*
*/
public function postPrestudent()
{
$result = $this->PersonModel->savePrestudent($this->post());
if($result === TRUE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Interested student saved.'
];
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save interested student.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
/**
* @return void
*/
public function getCheckBewerbung()
{
$result = $this->PersonModel->checkBewerbung($this->get("email"), $this->get("studiensemester_kurzbz"));
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Bewerbung exists.'
];
$payload['data'] = $result;
$this->response($payload, $httpstatus);
}
/**
* @return void
*/
public function getCheckZugangscodePerson()
{
$result = $this->PersonModel->checkZugangscodePerson($this->get("code"));
$httpstatus = REST_Controller::HTTP_OK;
if(!empty($result))
$email = $this->get('email');
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
if(isset($email))
{
$payload = [
'success' => true,
'message' => 'Zugangscode exists.'
];
$payload['data'] = $result;
$result = $this->PersonModel->checkBewerbung($email, $studiensemester_kurzbz);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$payload = [
'success' => false,
'message' => 'Zugangscode does not exist.'
];
$httpstatus = REST_Controller::HTTP_OK;
$this->response();
}
}
private function _validate($person = NULL)
{
if(!isset($person))
{
return false;
}
$person['nachname'] = trim($person['nachname']);
$person['vorname'] = trim($person['vorname']);
$person['vornamen'] = trim($person['vornamen']);
$person['anrede'] = trim($person['anrede']);
$person['titelpost'] = trim($person['titelpost']);
$person['titelpre'] = trim($person['titelpre']);
if(mb_strlen($person['sprache']) > 16)
{
//$this->errormsg = 'Sprache darf nicht laenger als 16 Zeichen sein';
return false;
}
if(mb_strlen($person['anrede']) > 16)
{
//$this->errormsg = 'Anrede darf nicht laenger als 16 Zeichen sein';
return false;
}
if(mb_strlen($person['titelpost']) > 32)
{
//$this->errormsg = 'Titelpost darf nicht laenger als 32 Zeichen sein';
return false;
}
if(mb_strlen($person['titelpre']) > 64)
{
//$this->errormsg = 'Titelpre darf nicht laenger als 64 Zeichen sein';
return false;
}
if(mb_strlen($person['nachname']) > 64)
{
//$this->errormsg = 'Nachname darf nicht laenger als 64 Zeichen sein';
return false;
}
if($person['nachname'] == '' || is_null($person['nachname']))
{
//$this->errormsg = 'Nachname muss eingegeben werden';
return false;
}
$this->response($payload, $httpstatus);
if(mb_strlen($person['vorname']) > 32)
{
//$this->errormsg = 'Vorname darf nicht laenger als 32 Zeichen sein';
return false;
}
if(mb_strlen($person['vornamen']) > 128)
{
//$this->errormsg = 'Vornamen darf nicht laenger als 128 Zeichen sein';
return false;
}
//ToDo Gebdatum pruefen -> laut bis muss student aelter als 10 Jahre sein
/* if (strlen($person['gebdatum) == 0 || is_null($person['gebdatum))
{
//$this->errormsg = "Geburtsdatum muss eingegeben werden\n";
return false;
} */
if(mb_strlen($person['gebort']) > 128)
{
//$this->errormsg = 'Geburtsort darf nicht laenger als 128 Zeichen sein';
return false;
}
if(mb_strlen($person['homepage']) > 256)
{
//$this->errormsg = 'Homepage darf nicht laenger als 256 Zeichen sein';
return false;
}
if(mb_strlen($person['svnr']) > 16)
{
//$this->errormsg = 'SVNR darf nicht laenger als 16 Zeichen sein';
return false;
}
if(mb_strlen($person['matr_nr']) > 32)
{
//$this->errormsg = 'Matrikelnummer darf nicht laenger als 32 Zeichen sein';
return false;
}
if($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 && mb_strlen($person['svnr']) != 10)
{
//$this->errormsg = 'SVNR muss 10 oder 16 Zeichen lang sein';
return false;
}
if($person['svnr'] != '' && mb_strlen($person['svnr']) == 10)
{
//SVNR mit Pruefziffer pruefen
//Die 4. Stelle in der SVNR ist die Pruefziffer
//(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer
//Falls nicht, ist die SVNR ungueltig
$gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6);
$erg = 0;
//Quersumme bilden
for($i = 0; $i < 10; $i++)
{
$erg += $gewichtung[$i] * $person['svnr']{$i};
}
if($person['svnr']{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11
{
//$this->errormsg = 'SVNR ist ungueltig';
return false;
}
}
if($person['svnr'] != '')
{
//Pruefen ob bereits ein Eintrag mit dieser SVNR vorhanden ist
$qry = "SELECT person_id FROM public.tbl_person WHERE svnr=" . $person['svnr'];
if(db_query($qry))
{
if($row = db_fetch_object())
{
if($row->person_id != $person['person_id'])
{
//$this->errormsg = 'Es existiert bereits eine Person mit dieser SVNR! Daten wurden NICHT gepeichert.';
return false;
}
}
}
}
if(mb_strlen($person['ersatzkennzeichen']) > 10)
{
//$this->errormsg = 'Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein';
return false;
}
if(mb_strlen($person['familienstand']) > 1)
{
//$this->errormsg = 'Familienstand ist ungueltig';
return false;
}
if($person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
{
//$this->errormsg = 'Anzahl der Kinder ist ungueltig';
return false;
}
if($person['aktiv'] != "t" && $person['aktiv'] != "f")
{
//$this->errormsg = 'Aktiv ist ungueltig';
return false;
}
if(!isset($person['person_id']) && mb_strlen($person['insertvon']) > 32)
{
//$this->errormsg = 'Insertvon darf nicht laenger als 32 Zeichen sein';
return false;
}
if(mb_strlen($person['updatevon']) > 32)
{
//$this->errormsg = 'Updatevon darf nicht laenger als 32 Zeichen sein';
return false;
}
/*if($person['ext_id'] != '' && !is_numeric($person['ext_id']))
{
//$this->errormsg = 'Ext_ID ist keine gueltige Zahl';
return false;
}*/
if(mb_strlen($person['geschlecht']) > 1)
{
//$this->errormsg = 'Geschlecht darf nicht laenger als 1 Zeichen sein';
return false;
}
if(mb_strlen($person['geburtsnation']) > 3)
{
//$this->errormsg = 'Geburtsnation darf nicht laenger als 3 Zeichen sein';
return false;
}
if(mb_strlen($person['staatsbuergerschaft']) > 3)
{
//$this->errormsg = 'Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein';
return false;
}
if($person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
{
//$this->errormsg = 'Geschlecht muss w, m oder u sein!';
return false;
}
//Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt.
if($person['svnr'] != '' && $person['gebdatum'] != '')
{
if(mb_ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})", $person['gebdatum'], $regs))
{
//$day = sprintf('%02s',$regs[1]);
//$month = sprintf('%02s',$regs[2]);
//$year = mb_substr($regs[3],2,2);
}
elseif(mb_ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $person['gebdatum'], $regs))
{
//$day = sprintf('%02s',$regs[3]);
//$month = sprintf('%02s',$regs[2]);
//$year = mb_substr($regs[1],2,2);
}
else
{
//$this->errormsg = 'Format des Geburtsdatums ist ungueltig';
return false;
}
/* das muss nicht immer so sein
$day_svnr = mb_substr($person['svnr, 4, 2);
$month_svnr = mb_substr($person['svnr, 6, 2);
$year_svnr = mb_substr($person['svnr, 8, 2);
if ($day_svnr!=$day || $month_svnr!=$month || $year_svnr!=$year)
{
//$this->errormsg = 'SVNR und Geburtsdatum passen nicht zusammen';
return false;
}
*/
}
return true;
}
}
}