- possible to read and write user Variables in Codeigniter

- added Variablenname_model, VariableLib, Variables controller
- Infocenter Übersicht - infocenterData, infocenterFreigegebenData, infocenterReihungstestAbsolviertData: added possibility of toggle of infocenter_studiensemester variable, only prestudents of selected Studiensemester are shown
This commit is contained in:
alex
2019-09-06 17:33:56 +02:00
parent 36ff38b0ee
commit 67415a4707
13 changed files with 485 additions and 26 deletions
@@ -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');
}
}