mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 17:02:19 +00:00
Merge branch 'feature-4026/TabulatorWidget' into feature-3994/Digitaler_Lehrauftrag
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class CheckUserAuth extends REST_Controller
|
||||
class CheckUserAuth extends RESTFul_Controller
|
||||
{
|
||||
/**
|
||||
* Course API constructor.
|
||||
|
||||
@@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* Testing class for REST calls and authentication
|
||||
*/
|
||||
class Test extends REST_Controller
|
||||
class Test extends RESTFul_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ class Benutzer extends APIv1_Controller
|
||||
|
||||
if (isset($uid))
|
||||
{
|
||||
$result = $this->BenutzerModel->load($uid);
|
||||
$result = $this->BenutzerModel->load(array('uid' => $uid));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
@@ -1,77 +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 CallerLibrary extends APIv1_Controller
|
||||
{
|
||||
/**
|
||||
* API constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array('Call' => 'admin:rw'));
|
||||
|
||||
// Loads the CallerLib
|
||||
$this->load->library('CallerLib');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages a HTTP get call
|
||||
*/
|
||||
public function getCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callLibrary($this->get());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callLibrary($this->post());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function putCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callLibrary($this->put());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callLibrary($this->delete());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +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 CallerModel extends APIv1_Controller
|
||||
{
|
||||
/**
|
||||
* API constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(array('Call' => 'admin:rw'));
|
||||
|
||||
// Loads the CallerLib
|
||||
$this->load->library('CallerLib');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages a HTTP get call
|
||||
*/
|
||||
public function getCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callModel($this->get());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callModel($this->post());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function putCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callModel($this->put());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCall()
|
||||
{
|
||||
// Start me up!
|
||||
$result = $this->callerlib->callModel($this->delete());
|
||||
|
||||
// Print the result
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,8 @@ class Prestudentstatus extends CLI_Controller
|
||||
tbl_prestudent.studiengang_kz,
|
||||
tbl_prestudentstatus.studienplan_id,
|
||||
tbl_studienplan.orgform_kurzbz,
|
||||
tbl_prestudent.person_id');
|
||||
tbl_prestudent.person_id,
|
||||
tbl_studienplan.sprache');
|
||||
$this->PrestudentstatusModel->addJoin('public.tbl_prestudent', 'prestudent_id');
|
||||
$this->PrestudentstatusModel->addJoin('lehre.tbl_studienplan', 'studienplan_id','LEFT');
|
||||
$this->PrestudentstatusModel->addJoin('lehre.tbl_studienordnung', 'studienordnung_id','LEFT');
|
||||
@@ -64,7 +65,8 @@ class Prestudentstatus extends CLI_Controller
|
||||
$row_status->studiengang_kz,
|
||||
$row_status->studiensemester_kurzbz,
|
||||
$row_status->ausbildungssemester,
|
||||
$row_status->orgform_kurzbz);
|
||||
$row_status->orgform_kurzbz,
|
||||
$row_status->sprache);
|
||||
|
||||
if(isSuccess($studienplan) && count($studienplan->retval) == 1)
|
||||
{
|
||||
|
||||
+22
-15
@@ -2,8 +2,10 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class UDF extends Auth_Controller
|
||||
class FAS_UDF extends Auth_Controller
|
||||
{
|
||||
const FAS_UDF_SESSION_NAME = 'fasUdfSessionName';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
@@ -22,31 +24,33 @@ class UDF extends Auth_Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$fasUdfSession = getSession(self::FAS_UDF_SESSION_NAME);
|
||||
|
||||
$person_id = $this->input->get('person_id');
|
||||
if (isset($this->session->person_id))
|
||||
if (isset($fasUdfSession['person_id']))
|
||||
{
|
||||
if (!isset($person_id))
|
||||
{
|
||||
$person_id = $this->session->person_id;
|
||||
$person_id = $fasUdfSession['person_id'];
|
||||
}
|
||||
unset($this->session->person_id);
|
||||
unset($fasUdfSession['person_id']);
|
||||
}
|
||||
|
||||
$prestudent_id = $this->input->get('prestudent_id');
|
||||
if (isset($this->session->prestudent_id))
|
||||
if (isset($fasUdfSession['prestudent_id']))
|
||||
{
|
||||
if (!isset($prestudent_id))
|
||||
{
|
||||
$prestudent_id = $this->session->prestudent_id;
|
||||
$prestudent_id = $fasUdfSession['prestudent_id'];
|
||||
}
|
||||
unset($this->session->prestudent_id);
|
||||
unset($fasUdfSession['prestudent_id']);
|
||||
}
|
||||
|
||||
$result = null;
|
||||
if (isset($this->session->result))
|
||||
if (isset($fasUdfSession['result']))
|
||||
{
|
||||
$result = clone $this->session->result;
|
||||
$this->session->set_userdata('result', null);
|
||||
$result = clone $fasUdfSession['result'];
|
||||
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', null);
|
||||
}
|
||||
|
||||
$data = array('result' => $result);
|
||||
@@ -71,7 +75,7 @@ class UDF extends Auth_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('system/udf', $data);
|
||||
$this->load->view('system/fas_udf', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,9 +94,9 @@ class UDF extends Auth_Controller
|
||||
if (isSuccess($validation))
|
||||
{
|
||||
// Load model UDF_model
|
||||
$this->load->model('system/UDF_model', 'UDFModel');
|
||||
$this->load->model('system/FAS_UDF_model', 'FASUDFModel');
|
||||
|
||||
$result = $this->UDFModel->saveUDFs($udfs);
|
||||
$result = $this->FASUDFModel->saveUDFs($udfs);
|
||||
|
||||
$userdata['result'] = $result;
|
||||
}
|
||||
@@ -101,8 +105,11 @@ class UDF extends Auth_Controller
|
||||
$userdata['result'] = $validation;
|
||||
}
|
||||
|
||||
$this->session->set_userdata($userdata);
|
||||
redirect('system/UDF');
|
||||
setSessionElement(self::FAS_UDF_SESSION_NAME, 'person_id', $userdata['person_id']);
|
||||
setSessionElement(self::FAS_UDF_SESSION_NAME, 'prestudent_id', $userdata['prestudent_id']);
|
||||
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', $userdata['result']);
|
||||
|
||||
redirect('system/FAS_UDF');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Overview on cronjob logs
|
||||
*/
|
||||
class LogsViewer extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'system/developer:r'
|
||||
)
|
||||
);
|
||||
|
||||
// Loads WidgetLib
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
// Loads phrases system
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'filter'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Main page of the InfoCenter tool
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('system/logs/logsViewer.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Class Variables
|
||||
* Provides interface for managing user variables.
|
||||
*/
|
||||
class Variables extends Auth_Controller
|
||||
{
|
||||
private $_uid;
|
||||
|
||||
/**
|
||||
* Variables constructor.
|
||||
* Sets logged in user, loads models and libraries.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'setVar' => 'basis/variable:rw',
|
||||
'getVar' => 'basis/variable:rw',
|
||||
'changeStudiensemesterVar' => 'basis/variable:rw'
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->model('system/variable_model', 'VariableModel');
|
||||
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->load->library('VariableLib', array('uid' => $this->_uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a user variable based on received post parameters, outputs JSON response.
|
||||
*/
|
||||
public function setVar()
|
||||
{
|
||||
$name = $this->input->post('name');
|
||||
$wert = $this->input->post('wert');
|
||||
|
||||
$result = $this->VariableModel->setVariable($this->_uid, $name, $wert);
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a user variable based on received post parameter, outputs JSON response.
|
||||
*/
|
||||
public function getVar()
|
||||
{
|
||||
$name = $this->input->get('name');
|
||||
$this->outputJson($this->VariableModel->getVariables($this->_uid, array($name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes a user variable containing a Studiensemester based on received post parameters, outputs JSON response.
|
||||
*/
|
||||
public function changeStudiensemesterVar()
|
||||
{
|
||||
$name = $this->input->post('name');
|
||||
$change = $this->input->post('change');
|
||||
|
||||
$result = $this->variablelib->changeStudiensemesterVar($this->_uid, $name, $change);
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the UID of the logged user and checks if it is valid
|
||||
*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid) show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ class InfoCenter extends Auth_Controller
|
||||
|
||||
const FILTER_ID = 'filter_id';
|
||||
const PREV_FILTER_ID = 'prev_filter_id';
|
||||
const RELOAD_DATASET = 'reloadDataset';
|
||||
const KEEP_TABLESORTER_FILTER = 'keepTsFilter';
|
||||
|
||||
private $_uid; // contains the UID of the logged user
|
||||
|
||||
@@ -100,9 +102,11 @@ class InfoCenter extends Auth_Controller
|
||||
'reloadNotizen' => 'infocenter:r',
|
||||
'reloadLogs' => 'infocenter:r',
|
||||
'outputAkteContent' => 'infocenter:r',
|
||||
'getParkedDate' => 'infocenter:r',
|
||||
'getPostponeDate' => 'infocenter:r',
|
||||
'park' => 'infocenter:rw',
|
||||
'unpark' => 'infocenter:rw',
|
||||
'setOnHold' => 'infocenter:rw',
|
||||
'removeOnHold' => 'infocenter:rw',
|
||||
'getStudienjahrEnd' => 'infocenter:r',
|
||||
'setNavigationMenuArrayJson' => 'infocenter:r'
|
||||
)
|
||||
@@ -136,6 +140,8 @@ class InfoCenter extends Auth_Controller
|
||||
|
||||
$this->_setAuthUID(); // sets property uid
|
||||
|
||||
$this->load->library('VariableLib', array('uid' => $this->_uid));
|
||||
|
||||
$this->setControllerId(); // sets the controller id
|
||||
}
|
||||
|
||||
@@ -232,7 +238,7 @@ class InfoCenter extends Auth_Controller
|
||||
$redirectLink = '/'.self::INFOCENTER_URI.'?'.self::FHC_CONTROLLER_ID.'='.$this->getControllerId();
|
||||
|
||||
// Force reload of Dataset after Unlock
|
||||
$redirectLink .= '&reloadDataset=true';
|
||||
$redirectLink .= '&'.self::RELOAD_DATASET.'=true&'.self::KEEP_TABLESORTER_FILTER.'=true';
|
||||
|
||||
$currentFilterId = $this->input->get(self::FILTER_ID);
|
||||
if (isset($currentFilterId))
|
||||
@@ -709,11 +715,32 @@ class InfoCenter extends Auth_Controller
|
||||
* Gets the date until which a person is parked
|
||||
* @param $person_id
|
||||
*/
|
||||
public function getParkedDate($person_id)
|
||||
public function getPostponeDate($person_id)
|
||||
{
|
||||
$result = array(
|
||||
'type' => null,
|
||||
'date' => null
|
||||
);
|
||||
|
||||
$parkedDate = $this->personloglib->getParkedDate($person_id);
|
||||
|
||||
$this->outputJsonSuccess(array($parkedDate));
|
||||
if (isset($parkedDate))
|
||||
{
|
||||
$result['type'] = 'parked';
|
||||
$result['date'] = $parkedDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
$onholdDate = $this->personloglib->getOnHoldDate($person_id);
|
||||
|
||||
if (isset($onholdDate))
|
||||
{
|
||||
$result['type'] = 'onhold';
|
||||
$result['date'] = $onholdDate;
|
||||
}
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -741,6 +768,31 @@ class InfoCenter extends Auth_Controller
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a person on hold ("zurückstellen")
|
||||
*/
|
||||
public function setOnHold()
|
||||
{
|
||||
$person_id = $this->input->post('person_id');
|
||||
$date = $this->input->post('onholddate');
|
||||
|
||||
$result = $this->personloglib->setOnHold($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid);
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed on hold status of a person
|
||||
*/
|
||||
public function removeOnHold()
|
||||
{
|
||||
$person_id = $this->input->post('person_id');
|
||||
|
||||
$result = $this->personloglib->removeOnHold($person_id);
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the End date of the current Studienjahr
|
||||
*/
|
||||
@@ -892,10 +944,16 @@ class InfoCenter extends Auth_Controller
|
||||
$freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE);
|
||||
$reihungstestAbsolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE);
|
||||
$currentFilterId = $this->input->get(self::FILTER_ID);
|
||||
$reloadDatasetParam = self::RELOAD_DATASET.'=true';
|
||||
if (isset($currentFilterId))
|
||||
{
|
||||
$freigegebenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId;
|
||||
$reihungstestAbsolviertLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId;
|
||||
$freigegebenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId.'&'.$reloadDatasetParam;
|
||||
$reihungstestAbsolviertLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId.'&'.$reloadDatasetParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
$freigegebenLink .= '?'.$reloadDatasetParam;
|
||||
$reihungstestAbsolviertLink .= '?'.$reloadDatasetParam;
|
||||
}
|
||||
|
||||
$this->navigationlib->setSessionMenu(
|
||||
@@ -948,7 +1006,7 @@ class InfoCenter extends Auth_Controller
|
||||
|
||||
$origin_page = $this->input->get(self::ORIGIN_PAGE);
|
||||
|
||||
$link = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE);
|
||||
$link = site_url(self::INFOCENTER_URI);
|
||||
if ($origin_page == self::FREIGEGEBEN_PAGE)
|
||||
{
|
||||
$link = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE);
|
||||
@@ -961,7 +1019,7 @@ class InfoCenter extends Auth_Controller
|
||||
$prevFilterId = $this->input->get(self::PREV_FILTER_ID);
|
||||
if (isset($prevFilterId))
|
||||
{
|
||||
$link .= '?'.self::FILTER_ID.'='.$prevFilterId;
|
||||
$link .= '?'.self::FILTER_ID.'='.$prevFilterId.'&'.self::RELOAD_DATASET.'=true&'.self::KEEP_TABLESORTER_FILTER.'=true';
|
||||
}
|
||||
|
||||
$this->navigationlib->setSessionMenu(
|
||||
@@ -991,13 +1049,14 @@ class InfoCenter extends Auth_Controller
|
||||
$this->load->library('NavigationLib', array(self::NAVIGATION_PAGE => self::INFOCENTER_URI.'/'.$page));
|
||||
|
||||
// Generate the home link with the eventually loaded filter
|
||||
$homeLink = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE);
|
||||
$freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE);
|
||||
$absolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE);
|
||||
$reloadDatasetParam = '?'.self::RELOAD_DATASET.'=true';
|
||||
$homeLink = site_url(self::INFOCENTER_URI.'/'.self::INDEX_PAGE.$reloadDatasetParam);
|
||||
$freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE.$reloadDatasetParam);
|
||||
$absolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE.$reloadDatasetParam);
|
||||
$prevFilterId = $this->input->get(self::PREV_FILTER_ID);
|
||||
if (isset($prevFilterId))
|
||||
{
|
||||
$homeLink .= '?'.self::FILTER_ID.'='.$prevFilterId;
|
||||
$homeLink .= '&'.self::FILTER_ID.'='.$prevFilterId;
|
||||
}
|
||||
|
||||
$this->navigationlib->setSessionElementMenu(
|
||||
|
||||
@@ -216,6 +216,16 @@ class Filters extends FHC_Controller
|
||||
$this->outputJsonSuccess('Success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the dataset
|
||||
*/
|
||||
public function reloadDataset()
|
||||
{
|
||||
$this->filterslib->reloadDataset();
|
||||
|
||||
$this->outputJsonSuccess('Success');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the tablewidgetlib (back-end)
|
||||
* Provides data to the ajax get calls about the filter
|
||||
* Accepts ajax post calls to change the filter data
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the TableWidget has its
|
||||
* own permissions check
|
||||
*/
|
||||
class Tables extends FHC_Controller
|
||||
{
|
||||
const TABLE_UNIQUE_ID = 'tableUniqueId';
|
||||
|
||||
/**
|
||||
* Calls the parent's constructor and loads the tablewidgetlib
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads authentication library and starts authentication
|
||||
$this->load->library('AuthLib');
|
||||
|
||||
// Loads the tablewidgetlib with HTTP GET/POST parameters
|
||||
$this->_loadTableWidgetLib();
|
||||
|
||||
// Checks if the caller is allow to read this data
|
||||
$this->_isAllowed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves data about the current filter from the session and will be written on the output in JSON format
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
$this->outputJsonSuccess($this->tablewidgetlib->getSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of records present in the current dataset and will be written on the output in JSON format
|
||||
*/
|
||||
public function rowNumber()
|
||||
{
|
||||
$rowNumber = 0;
|
||||
$dataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET);
|
||||
|
||||
if (isset($dataset) && is_array($dataset))
|
||||
{
|
||||
$rowNumber = count($dataset);
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess($rowNumber);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Checks if the user is allowed to use this filter
|
||||
*/
|
||||
private function _isAllowed()
|
||||
{
|
||||
if (!$this->tablewidgetlib->isAllowed())
|
||||
{
|
||||
$this->terminateWithJsonError('You are not allowed to access to this content');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the tablewidgetlib with the TABLE_UNIQUE_ID parameter
|
||||
* If the parameter TABLE_UNIQUE_ID is not given then the execution of the controller is terminated and
|
||||
* an error message is printed
|
||||
*/
|
||||
private function _loadTableWidgetLib()
|
||||
{
|
||||
// If the parameter TABLE_UNIQUE_ID is present in the HTTP GET or POST
|
||||
if (isset($_GET[self::TABLE_UNIQUE_ID]) || isset($_POST[self::TABLE_UNIQUE_ID]))
|
||||
{
|
||||
// If it is present in the HTTP GET
|
||||
if (isset($_GET[self::TABLE_UNIQUE_ID]))
|
||||
{
|
||||
$tableUniqueId = $this->input->get(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP GET
|
||||
}
|
||||
elseif (isset($_POST[self::TABLE_UNIQUE_ID])) // Else if it is present in the HTTP POST
|
||||
{
|
||||
$tableUniqueId = $this->input->post(self::TABLE_UNIQUE_ID); // is retrieved from the HTTP POST
|
||||
}
|
||||
|
||||
// Loads the tablewidgetlib that contains all the used logic
|
||||
$this->load->library('TableWidgetLib');
|
||||
|
||||
$this->tablewidgetlib->setTableUniqueId($tableUniqueId);
|
||||
}
|
||||
else // Otherwise an error will be written in the output
|
||||
{
|
||||
$this->terminateWithJsonError('Parameter "'.self::TABLE_UNIQUE_ID.'" not provided!');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user