mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Merge branch 'master' into udf
This commit is contained in:
@@ -1,76 +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 Moodle extends APIv1_Controller
|
||||
{
|
||||
/**
|
||||
* Moodle API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model MoodleModel
|
||||
$this->load->model('education/Moodle_model', 'MoodleModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getMoodle()
|
||||
{
|
||||
$moodle_id = $this->get('moodle_id');
|
||||
|
||||
if (isset($moodle_id))
|
||||
{
|
||||
$result = $this->MoodleModel->load($moodle_id);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postMoodle()
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
{
|
||||
if (isset($this->post()['moodle_id']))
|
||||
{
|
||||
$result = $this->MoodleModel->update($this->post()['moodle_id'], $this->post());
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->MoodleModel->insert($this->post());
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
private function _validate($moodle = NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,33 @@
|
||||
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
* Studienjahr controller for listing, editing and removing a Studienjahr
|
||||
*/
|
||||
class Studienjahr extends VileSci_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Studienjahr constructor.
|
||||
* loads model for Studienjahr
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model("organisation/Studienjahr_model", "StudienjahrModel");
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->listStudienjahr();
|
||||
}
|
||||
/**
|
||||
* by default, Studienjahre are listed by calling the listStudienjahr function
|
||||
*/
|
||||
/* public function index()
|
||||
{
|
||||
$this->listStudienjahr();
|
||||
}*/
|
||||
|
||||
/**
|
||||
* lists all Studienjahre
|
||||
*/
|
||||
public function listStudienjahr()
|
||||
{
|
||||
$studienjahr = $this->StudienjahrModel->load();
|
||||
@@ -30,6 +43,13 @@ class Studienjahr extends VileSci_Controller
|
||||
$this->load->view("organisation/studienjahr.php", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows view for editing a Studienjahr with a given Kurzbezeichnung
|
||||
* replaces slash in Kurzbezeichnung with underscore,
|
||||
* otherwise the Kurzbezeichnung is treated as part of url navigation
|
||||
* e.g. organisation/studienjahr/editStudienjahr/2017/18
|
||||
* @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. 2017/18
|
||||
*/
|
||||
public function editStudienjahr($studienjahr_kurzbez)
|
||||
{
|
||||
$studienjahr_kurzbez = str_replace("_", "/", $studienjahr_kurzbez);
|
||||
@@ -44,6 +64,12 @@ class Studienjahr extends VileSci_Controller
|
||||
$this->load->view("organisation/studienjahrEdit.php", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows view for adding a Studienjahr
|
||||
* retrieves all Studienjahre, increases last Studienjahr in database by 1 to get current Studienjahr
|
||||
* sends current Studienjahrkurzbezeichnung to view
|
||||
* So view can prefill fields with current Studienjahr
|
||||
*/
|
||||
public function newStudienjahr()
|
||||
{
|
||||
$this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC");
|
||||
@@ -60,6 +86,11 @@ class Studienjahr extends VileSci_Controller
|
||||
$this->load->view("organisation/studienjahrNew.php", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function for extracting the two years from Studienjahrkurzbezeichnung
|
||||
* @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. 2017/18
|
||||
* @return array contains the two years, e.g. [0] - 2017, [1] - 18
|
||||
*/
|
||||
private function __getYearsFromStudienjahr($studienjahr_kurzbez)
|
||||
{
|
||||
$firstyear = intval(substr($studienjahr_kurzbez, 0, 4));
|
||||
@@ -67,6 +98,12 @@ class Studienjahr extends VileSci_Controller
|
||||
return array($firstyear, $secondyear);
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts a Studienjahr
|
||||
* replaces slash in Kurzbezeichnung with underscore,
|
||||
* redirects to edit page after inserting.
|
||||
* saved=true is a GET parameter passed for showing save message
|
||||
*/
|
||||
public function insStudienjahr()
|
||||
{
|
||||
$data = $this->__retrieveStudienjahrData();
|
||||
@@ -80,13 +117,20 @@ class Studienjahr extends VileSci_Controller
|
||||
redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true"));
|
||||
}
|
||||
|
||||
private function __retrieveStudienjahrData(){
|
||||
/**
|
||||
* gets Studienjahr data from input fields (POST request)
|
||||
* escapes html characters for all texts coming from text input fields
|
||||
* validates the Studienjahr data before returning it or throwing an error
|
||||
* @return array contains all data for a Studienjahr
|
||||
*/
|
||||
private function __retrieveStudienjahrData()
|
||||
{
|
||||
$studienjahr_kurzbz = $this->input->post("studienjahrkurzbz");
|
||||
$bezeichnung = $this->input->post("studienjahrbz");
|
||||
|
||||
$data = array(
|
||||
"studienjahr_kurzbz" => $studienjahr_kurzbz,
|
||||
"bezeichnung" => $bezeichnung,
|
||||
"bezeichnung" => html_escape($bezeichnung)
|
||||
);
|
||||
|
||||
$validation = $this->_validate($data);
|
||||
@@ -99,17 +143,30 @@ class Studienjahr extends VileSci_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* runs checks on Studienjahr data
|
||||
* checks if Studienjahr Kurzbezeichnung has the correct form e.g. 2017/18
|
||||
* checks if second year in Studienjahr is exactly one year after first
|
||||
* @param $data contains all data for a Studienjahr
|
||||
* @return array errorarray with error text if a check failed or success-array if all checks succeeded
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$studienjahr_kurzbz = $data['studienjahr_kurzbz'];
|
||||
$years = $this->__getYearsFromStudienjahr($studienjahr_kurzbz);
|
||||
//if not desired form or second year comes not right after the first
|
||||
//if wrong form or second year comes not right after the first
|
||||
$correctyears = $years[0] % 100 == $years[1] - 1;
|
||||
if (!preg_match("/^\d{4}\/\d{2}$/", $studienjahr_kurzbz) || !$correctyears)
|
||||
return error("Studienjahrbezeichnung muss folgende Form haben: Jahreszahl/letzeZweiZahlenDesNächstenJahres, z.B. 2017/18");
|
||||
return success("Semesterdaten sind valide");
|
||||
return success("Studienjahrdaten sind valide");
|
||||
}
|
||||
|
||||
/**
|
||||
* updates a Studienjahr
|
||||
* redirects to edit page after inserting
|
||||
* replaces slash in Kurzbezeichnung with underscore
|
||||
* saved=true is a GET parameter passed for showing save message
|
||||
*/
|
||||
public function saveStudienjahr()
|
||||
{
|
||||
$data = $this->__retrieveStudienjahrData();
|
||||
@@ -123,6 +180,12 @@ class Studienjahr extends VileSci_Controller
|
||||
redirect("/organisation/studienjahr/editStudienjahr/".str_replace("/", "_", $data['studienjahr_kurzbz']."?saved=true"));
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a Studienjahr
|
||||
* redirects to list Studienjahr view after deleting
|
||||
* replaces slash in Kurzbezeichnung with underscore
|
||||
* @param $studienjahr_kurzbez Studienjahrkurzbezeichnung, e.g. SS2017
|
||||
*/
|
||||
public function deleteStudienjahr($studienjahr_kurzbez)
|
||||
{
|
||||
$studienjahr_kurzbez = str_replace("_", "/", $studienjahr_kurzbez);
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
* Description of Semester
|
||||
*
|
||||
* @author root
|
||||
* Studiensemester controller for listing, editing and removing a Studiensemester
|
||||
*/
|
||||
class Studiensemester extends VileSci_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Studiensemester constructor.
|
||||
* loads model for Studiensemester and Studienjahr (Studienjahr needed for dropdown)
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -17,11 +19,17 @@ class Studiensemester extends VileSci_Controller
|
||||
$this->load->model("organisation/Studienjahr_model", "StudienjahrModel");
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->listStudiensemester();
|
||||
}
|
||||
/**
|
||||
* by default, Studiensemesters are listed by calling the listStudiensemester function
|
||||
*/
|
||||
/* public function index()
|
||||
{
|
||||
$this->listStudiensemester();
|
||||
}*/
|
||||
|
||||
/**
|
||||
* lists all Studiensemesters
|
||||
*/
|
||||
public function listStudiensemester()
|
||||
{
|
||||
$semester = $this->StudiensemesterModel->load();
|
||||
@@ -36,6 +44,11 @@ class Studiensemester extends VileSci_Controller
|
||||
$this->load->view("organisation/studiensemester.php", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows view for editing a Studiensemester with a given Kurzbezeichnung
|
||||
* retrieves Studienjahre for showing in a dropdown in descending order
|
||||
* @param $semester_kurzbez Semesterkurzbezeichnung, e.g. SS2017
|
||||
*/
|
||||
public function editStudiensemester($semester_kurzbez)
|
||||
{
|
||||
$semester = $this->StudiensemesterModel->load($semester_kurzbez);
|
||||
@@ -57,6 +70,10 @@ class Studiensemester extends VileSci_Controller
|
||||
$this->load->view("organisation/studiensemesterEdit.php", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows view for adding a Studiensemester
|
||||
* retrieves Studienjahre for showing in a dropdown in descending order
|
||||
*/
|
||||
public function newStudiensemester()
|
||||
{
|
||||
$this->StudienjahrModel->addOrder('studienjahr_kurzbz', "DESC");
|
||||
@@ -75,7 +92,8 @@ class Studiensemester extends VileSci_Controller
|
||||
|
||||
/**
|
||||
* inserts a Studiensemester
|
||||
* formats dates in english as required by database
|
||||
* redirects to edit page after inserting.
|
||||
* saved=true is a GET parameter passed for showing save message
|
||||
*/
|
||||
public function insStudiensemester()
|
||||
{
|
||||
@@ -91,6 +109,13 @@ class Studiensemester extends VileSci_Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets Studiensemester data from input fields (POST request)
|
||||
* formats Studiensemester begin and end date as required by the database (english format)
|
||||
* escapes html characters for all texts coming from text input fields
|
||||
* validates the Studiensemester data before returning it or throwing an error
|
||||
* @return array contains all data for a Studiensemester
|
||||
*/
|
||||
private function __retrieveStudiensemesterData()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->post("semkurzbz");
|
||||
@@ -104,11 +129,11 @@ class Studiensemester extends VileSci_Controller
|
||||
|
||||
$data = array(
|
||||
"studiensemester_kurzbz" => $studiensemester_kurzbz,
|
||||
"bezeichnung" => $bezeichnung,
|
||||
"bezeichnung" => html_escape($bezeichnung),
|
||||
"start" => $start,
|
||||
"ende" => $ende,
|
||||
"studienjahr_kurzbz" => $studienjahr_kurzbz,
|
||||
"beschreibung" => $beschreibung,
|
||||
"beschreibung" => html_escape($beschreibung),
|
||||
"onlinebewerbung" => $onlinebewerbung
|
||||
);
|
||||
|
||||
@@ -125,6 +150,13 @@ class Studiensemester extends VileSci_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* runs checks on Studiensemester data
|
||||
* checks if Studiensemester Kurzbezeichnung has the correct form e.g. SS2017
|
||||
* checks if date was given in the correct format dd.mm.yyyy (german format)
|
||||
* @param $data contains all data for a Studiensemester
|
||||
* @return array errorarray with error text if a check failed or success-array if all checks succeeded
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$datepattern = "/^\d{2}.\d{2}.\d{4}$/";
|
||||
@@ -138,6 +170,11 @@ class Studiensemester extends VileSci_Controller
|
||||
return success("Semesterdaten sind valide");
|
||||
}
|
||||
|
||||
/**
|
||||
* updates a Studiensemester
|
||||
* redirects to edit page after inserting
|
||||
* saved=true is a GET parameter passed for showing save message
|
||||
*/
|
||||
public function saveStudiensemester()
|
||||
{
|
||||
$data = $this->__retrieveStudiensemesterData();
|
||||
@@ -151,6 +188,11 @@ class Studiensemester extends VileSci_Controller
|
||||
redirect("/organisation/studiensemester/editStudiensemester/".$data['studiensemester_kurzbz']."?saved=true");
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a Studiensemester
|
||||
* redirects to list Studiensemester view after deleting
|
||||
* @param $semester_kurzbez Semesterkurzbezeichnung, e.g. SS2017
|
||||
*/
|
||||
public function deleteStudiensemester($semester_kurzbez)
|
||||
{
|
||||
$semester = $this->StudiensemesterModel->delete($semester_kurzbez);
|
||||
|
||||
Reference in New Issue
Block a user