Merge remote-tracking branch 'origin/master'

This commit is contained in:
Manfred Kindl
2020-01-09 14:53:26 +01:00
9 changed files with 247 additions and 121 deletions
@@ -131,7 +131,16 @@ class LehrauftragAkzeptieren extends Auth_Controller
if ($result = getData($this->BenutzerModel->getFromPersonId($result[0]->person_id)))
{
// * finally check uid of contract against the logged in user
if ($result[0]->uid != $this->_uid)
$account_found = false;
foreach($result as $row_accounts)
{
if($row_accounts->uid == $this->_uid)
{
$account_found = true;
}
}
if (!$account_found)
{
show_error('Keine Berechtigung für diesen Vertrag');
}
@@ -148,7 +157,7 @@ class LehrauftragAkzeptieren extends Auth_Controller
// Set status to accepted
$result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $this->_uid, 'akzeptiert');
if ($result->retval)
{
$json []= array(
@@ -165,7 +174,7 @@ class LehrauftragAkzeptieren extends Auth_Controller
}
}
}
/**
* Check if lectors latest active Verwendung has inkludierte Lehre
* - inkludierte_lehre is null OR 0: freelancer lector -> has NO inkludierte Lehre
@@ -175,7 +184,7 @@ class LehrauftragAkzeptieren extends Auth_Controller
public function checkInkludierteLehre()
{
$result = $this->BisverwendungModel->getLast($this->_uid);
if (hasData($result))
{
$this->outputJsonSuccess(!is_null($result->retval[0]->inkludierte_lehre) && $result->retval[0]->inkludierte_lehre != 0);
+2 -1
View File
@@ -378,7 +378,8 @@ class AuthLib
}
else // otherwise
{
$hta = $this->_createAuthObjByPerson(array('uid' => trim($_SERVER['PHP_AUTH_USER'])));
// NOTE: Username needs to be trimmed and lowered because htaccess is allowing login
$hta = $this->_createAuthObjByPerson(array('uid' => mb_strtolower(trim($_SERVER['PHP_AUTH_USER']))));
}
// Invalid credentials
+54 -23
View File
@@ -7,8 +7,10 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class FilterWidgetLib
{
// Session parameters names
const SESSION_NAME = 'FHC_FILTER_WIDGET'; // Filter session name
// FilterWidget session name
const SESSION_NAME = 'FHC_FILTER_WIDGET';
// Session elements
const SESSION_FILTER_NAME = 'filterName';
const SESSION_FIELDS = 'fields';
const SESSION_SELECTED_FIELDS = 'selectedFields';
@@ -17,13 +19,19 @@ class FilterWidgetLib
const SESSION_CHECKBOXES = 'checkboxes';
const SESSION_FILTERS = 'filters';
const SESSION_METADATA = 'datasetMetadata';
const SESSION_DATASET = 'dataset';
const SESSION_ROW_NUMBER = 'rowNumber';
const SESSION_RELOAD_DATASET = 'reloadDataset';
const SESSION_TIMEOUT = 'sessionTimeout';
// Session dataset elements
const SESSION_DATASET = 'dataset';
const SESSION_DATASET_RELOAD = 'reloadDataset';
const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation';
const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions';
const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions';
// Default session timeout
const SESSION_DEFAULT_TIMEOUT = 30;
// Alias for the dynamic table used to retrieve the dataset
const DATASET_TABLE_ALIAS = 'datasetFilterTable';
@@ -33,16 +41,16 @@ class FilterWidgetLib
// ...to identify a single filter widget in the DB
const FILTER_ID = 'filter_id';
const APP_PARAMETER = 'app';
const DATASET_NAME_PARAMETER = 'datasetName';
const FILTER_KURZBZ_PARAMETER = 'filterKurzbz';
const DATASET_RELOAD_PARAMETER = 'reloadDataset';
const APP = 'app';
const DATASET_NAME = 'datasetName';
const FILTER_KURZBZ = 'filterKurzbz';
const DATASET_RELOAD = 'reloadDataset';
// ...to specify permissions that are needed to use this FilterWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
const REQUIRED_PERMISSIONS = 'requiredPermissions';
// ...stament to retrieve the dataset
const QUERY_PARAMETER = 'query';
const QUERY = 'query';
// ...to specify more columns or aliases for them
const ADDITIONAL_COLUMNS = 'additionalColumns';
@@ -131,7 +139,7 @@ class FilterWidgetLib
// Gets the required permissions from the session if they are not provided as parameter
$rq = $requiredPermissions;
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS);
return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_FILTER_METHOD, self::PERMISSION_TYPE);
}
@@ -179,6 +187,29 @@ class FilterWidgetLib
setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value
}
/**
*
*/
public function dropExpiredFilterWidgets()
{
// Loads the session for all the filter widgets
$filterWidgetsSession = getSession(self::SESSION_NAME);
// If something is present in session
if ($filterWidgetsSession != null)
{
// Loops in the session for all the filter widgets
foreach ($filterWidgetsSession as $filterWidget => $filterWidgetData)
{
// If this filter widget is not the currrent used filter widget and the it is expired...
if ($this->_filterUniqueId != $filterWidget && $filterWidgetData[self::SESSION_TIMEOUT] <= time())
{
cleanSessionElement(self::SESSION_NAME, $filterWidget); // ...remove it
}
}
}
}
/**
* Loads the definition data from DB for a filter widget
*/
@@ -471,7 +502,7 @@ class FilterWidgetLib
// Write changes into the session
$this->setSessionElement(self::SESSION_FILTERS, $filters);
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded
$removeAppliedFilter = true;
}
@@ -523,7 +554,7 @@ class FilterWidgetLib
// Write changes into the session
$this->setSessionElement(self::SESSION_FILTERS, $filters);
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true); // the dataset must be reloaded
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true); // the dataset must be reloaded
$applyFilters = true;
}
@@ -537,7 +568,7 @@ class FilterWidgetLib
*/
public function reloadDataset()
{
$this->setSessionElement(self::SESSION_RELOAD_DATASET, true);
$this->setSessionElement(self::SESSION_DATASET_RELOAD, true);
}
/**
@@ -603,8 +634,8 @@ class FilterWidgetLib
// Loads the definition to check if is already present in the DB
$definition = $this->_ci->FiltersModel->loadWhere(array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'description' => $descPGArray,
'person_id' => $authPersonId
));
@@ -632,8 +663,8 @@ class FilterWidgetLib
// update it
$this->_ci->FiltersModel->update(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'description' => $descPGArray,
'person_id' => $authPersonId
),
@@ -648,8 +679,8 @@ class FilterWidgetLib
{
$this->_ci->FiltersModel->insert(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'app' => $this->getSessionElement(self::APP),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME),
'filter_kurzbz' => uniqid($authPersonId, true),
'description' => $descPGArray,
'person_id' => $authPersonId,
@@ -693,7 +724,7 @@ class FilterWidgetLib
public function generateFilterMenu($navigationPage)
{
// Loads the NavigationLib for the current page (given as parameter)
$this->_ci->load->library('NavigationLib', array(FilterWidgetLib::NAVIGATION_PAGE => $navigationPage));
$this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage));
$filterMenu = null;
$currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session
@@ -706,7 +737,7 @@ class FilterWidgetLib
// Loads all the filters related to this page (same dataset_name and same app name)
$filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName(
$session[self::APP_PARAMETER], $session[self::DATASET_NAME_PARAMETER]
$session[self::APP], $session[self::DATASET_NAME]
);
// If filters were loaded
@@ -775,7 +806,7 @@ class FilterWidgetLib
);
// Sets in the session only the element related to the filters menu
$this->_ci->navigationlib->setSessionElementMenu(FilterWidgetLib::NAV_MENU_FILTER_KEY, $filterMenu);
$this->_ci->navigationlib->setSessionElementMenu(self::NAV_MENU_FILTER_KEY, $filterMenu);
}
}
}
+46 -14
View File
@@ -9,33 +9,41 @@ class TableWidgetLib
{
const TABLE_UNIQUE_ID = 'tableUniqueId'; // TableWidget unique id
// Session parameters names
const SESSION_NAME = 'FHC_TABLE_WIDGET'; // Table session name
// TableWidget session name
const SESSION_NAME = 'FHC_TABLE_WIDGET';
// Session elements
const SESSION_FIELDS = 'fields';
const SESSION_COLUMNS_ALIASES = 'columnsAliases';
const SESSION_ADDITIONAL_COLUMNS = 'additionalColumns';
const SESSION_CHECKBOXES = 'checkboxes';
const SESSION_METADATA = 'datasetMetadata';
const SESSION_DATASET = 'dataset';
const SESSION_ROW_NUMBER = 'rowNumber';
const SESSION_RELOAD_DATASET = 'reloadDataset';
const SESSION_TIMEOUT = 'sessionTimeout';
// Session dataset elements
const SESSION_DATASET = 'dataset';
const SESSION_DATASET_RELOAD = 'reloadDataset';
const SESSION_DATASET_REPRESENTATION = 'datasetRepresentation';
const SESSION_DATASET_REP_OPTIONS = 'datasetRepresentationOptions';
const SESSION_DATASET_REP_FIELDS_DEFS = 'datasetRepresentationFieldsDefinitions';
// Default session timeout
const SESSION_DEFAULT_TIMEOUT = 30;
// Alias for the dynamic table used to retrieve the dataset
const DATASET_TABLE_ALIAS = 'datasetTableWidget';
// Parameters names...
// ...to reload the dataset
const DATASET_RELOAD_PARAMETER = 'reloadDataset';
const DATASET_RELOAD = 'reloadDataset';
// ...to specify permissions that are needed to use this TableWidget
const REQUIRED_PERMISSIONS_PARAMETER = 'requiredPermissions';
const REQUIRED_PERMISSIONS = 'requiredPermissions';
// ...stament to retrieve the dataset
const QUERY_PARAMETER = 'query';
const QUERY = 'query';
// ...to specify more columns or aliases for them
const ADDITIONAL_COLUMNS = 'additionalColumns';
@@ -50,6 +58,7 @@ class TableWidgetLib
const DATASET_REPRESENTATION = 'datasetRepresentation';
const DATASET_REP_OPTIONS = 'datasetRepOptions';
const DATASET_REP_FIELDS_DEFS = 'datasetRepFieldsDefs';
const DATASET_TIMEOUT = 'datasetTimeout'; // ...and its expiring time
// Different dataset representations
const DATASET_REP_TABLESORTER = 'tablesorter';
@@ -86,13 +95,13 @@ class TableWidgetLib
// Gets the required permissions from the session if they are not provided as parameter
$rq = $requiredPermissions;
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS_PARAMETER);
if ($rq == null) $rq = $this->getSessionElement(self::REQUIRED_PERMISSIONS);
return $this->_ci->permissionlib->hasAtLeastOne($rq, self::PERMISSION_TABLE_METHOD, self::PERMISSION_TYPE);
}
/**
* Wrapper method to the session helper funtions to retrieve the whole session for this filter
* Wrapper method to the session helper funtions to retrieve the whole session for this table widget
*/
public function getSession()
{
@@ -100,7 +109,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to retrieve one element from the session of this filter
* Wrapper method to the session helper funtions to retrieve one element from the session of this table widget
*/
public function getSessionElement($name)
{
@@ -115,7 +124,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to set the whole session for this filter
* Wrapper method to the session helper funtions to set the whole session for this table widget
*/
public function setSession($data)
{
@@ -123,7 +132,7 @@ class TableWidgetLib
}
/**
* Wrapper method to the session helper funtions to set one element in the session for this filter
* Wrapper method to the session helper funtions to set one element in the session for this table widget
*/
public function setSessionElement($name, $value)
{
@@ -135,7 +144,30 @@ class TableWidgetLib
}
/**
* Generate the query to retrieve the dataset for a filter
*
*/
public function dropExpiredTableWidgets()
{
// Loads the session for all the table widgets
$tableWidgetsSession = getSession(self::SESSION_NAME);
// If something is present in session
if ($tableWidgetsSession != null)
{
// Loops in the session for all the table widgets
foreach ($tableWidgetsSession as $tableWidget => $tableWidgetData)
{
// If this table widget is not the currrent used table widget and the it is expired...
if ($this->_tableUniqueId != $tableWidget && $tableWidgetData[self::SESSION_TIMEOUT] <= time())
{
cleanSessionElement(self::SESSION_NAME, $tableWidget); // ...remove it
}
}
}
}
/**
* Generate the query to retrieve the dataset for a table widget
*/
public function generateDatasetQuery($query)
{
@@ -177,7 +209,7 @@ class TableWidgetLib
}
/**
* Return an unique string that identify this filter widget
* Return an unique string that identify this table widget
* NOTE: The default value is the URI where the FilterWidget is called
* If the fhc_controller_id is present then is also used
*/
+50 -25
View File
@@ -57,6 +57,8 @@ class FilterWidget extends Widget
private $_reloadDataset; // Force Reload of Dataset
private $_sessionTimeout; // session expiring time
private static $_FilterWidgetInstance; // static property that contains the instance of itself
/**
@@ -202,27 +204,28 @@ class FilterWidget extends Widget
$this->_datasetRepresentation = null;
$this->_datasetRepresentationOptions = null;
$this->_datasetRepFieldsDefs = null;
$this->_sessionTimeout = FilterWidgetLib::SESSION_DEFAULT_TIMEOUT;
// Retrieved the required permissions parameter if present
if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER]))
if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS]))
{
$this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER];
$this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS];
}
// Parameters needed to retrieve univocally a filter from DB
if (isset($args[FilterWidgetLib::APP_PARAMETER]))
if (isset($args[FilterWidgetLib::APP]))
{
$this->_app = $args[FilterWidgetLib::APP_PARAMETER];
$this->_app = $args[FilterWidgetLib::APP];
}
if (isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_NAME]))
{
$this->_datasetName = $args[FilterWidgetLib::DATASET_NAME_PARAMETER];
$this->_datasetName = $args[FilterWidgetLib::DATASET_NAME];
}
if (isset($args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER]))
if (isset($args[FilterWidgetLib::FILTER_KURZBZ]))
{
$this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER];
$this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ];
}
if (isset($args[FilterWidgetLib::FILTER_ID]))
@@ -231,14 +234,14 @@ class FilterWidget extends Widget
}
// How to retrieve data for the filter: SQL statement or a result from DB
if (isset($args[FilterWidgetLib::QUERY_PARAMETER]))
if (isset($args[FilterWidgetLib::QUERY]))
{
$this->_query = $args[FilterWidgetLib::QUERY_PARAMETER];
$this->_query = $args[FilterWidgetLib::QUERY];
}
if (isset($args[FilterWidgetLib::DATASET_RELOAD_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_RELOAD]))
{
$this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD_PARAMETER];
$this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD];
}
// Parameter is used to add extra columns to the dataset
@@ -332,6 +335,12 @@ class FilterWidget extends Widget
{
$this->_datasetRepFieldsDefs = $args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS];
}
// To specify the expiring session time
if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT]))
{
$this->_sessionTimeout = $args[FilterWidgetLib::SESSION_TIMEOUT];
}
}
/**
@@ -339,31 +348,36 @@ class FilterWidget extends Widget
*/
private function _checkParameters($args)
{
// If no options are given to this widget...
if (!is_array($args) || (is_array($args) && count($args) == 0))
{
show_error('Second parameter of the widget call must be a NOT empty associative array');
}
else
else // ...otherwise
{
if ((!isset($args[FilterWidgetLib::APP_PARAMETER]) && !isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
// Parameters (app AND dataset name) OR filter id are mandatory
if ((!isset($args[FilterWidgetLib::APP]) && !isset($args[FilterWidgetLib::DATASET_NAME]))
&& !isset($args[FilterWidgetLib::FILTER_ID]))
{
show_error(
'The parameters ("'.FilterWidgetLib::APP_PARAMETER.'" AND "'.FilterWidgetLib::DATASET_NAME_PARAMETER.') OR "'.
'The parameters ("'.FilterWidgetLib::APP.'" AND "'.FilterWidgetLib::DATASET_NAME.') OR "'.
FilterWidgetLib::FILTER_ID.'" must be specified'
);
}
if (!isset($args[FilterWidgetLib::QUERY_PARAMETER]))
// The query parameter is mandatory
if (!isset($args[FilterWidgetLib::QUERY]))
{
show_error('The parameters "'.FilterWidgetLib::QUERY_PARAMETER.'" must be specified');
show_error('The parameter "'.FilterWidgetLib::QUERY.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[FilterWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// Checks if the dataset representation parameter is valid
if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION])
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABLESORTER
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_PIVOTUI
@@ -377,6 +391,12 @@ class FilterWidget extends Widget
.FilterWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// If given the session timeout parameter must be a number
if (isset($args[FilterWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[FilterWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.FilterWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
}
}
@@ -385,6 +405,9 @@ class FilterWidget extends Widget
*/
private function _startFilterWidget()
{
// Looks for expired filter widgets in session and drops them
$this->filterwidgetlib->dropExpiredFilterWidgets();
// Read the all session for this filter widget
$session = $this->filterwidgetlib->getSession();
@@ -402,14 +425,14 @@ class FilterWidget extends Widget
}
else // else if the filter loaded in session is the same that is being requested
{
// Get SESSION_RELOAD_DATASET from the session
$sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET);
// Get SESSION_DATASET_RELOAD from the session
$sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD);
// if Filter changed or reload is forced by parameter then reload the Dataset
if ($this->_reloadDataset === true || $sessionReloadDataset === true)
{
// Set as false to stop changing the dataset
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET, false);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET_RELOAD, false);
// Generate dataset query using filters from the session
$datasetQuery = $this->filterwidgetlib->generateDatasetQuery(
@@ -467,8 +490,8 @@ class FilterWidget extends Widget
$this->filterwidgetlib->setSession(
array(
FilterWidgetLib::FILTER_ID => $this->_filterId, // the current filter id
FilterWidgetLib::APP_PARAMETER => $this->_app, // the current app parameter
FilterWidgetLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name
FilterWidgetLib::APP => $this->_app, // the current app parameter
FilterWidgetLib::DATASET_NAME => $this->_datasetName, // the carrent dataset name
FilterWidgetLib::SESSION_FILTER_NAME => $filterName, // the current filter name
FilterWidgetLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset
FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields
@@ -479,7 +502,7 @@ class FilterWidget extends Widget
FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset
FilterWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter
FilterWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
FilterWidgetLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
FilterWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time
FilterWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
FilterWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
FilterWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
@@ -489,9 +512,11 @@ class FilterWidget extends Widget
}
}
// NOTE: latest operations to be performed in the session to be shure that they are always present
// To be always stored in the session, otherwise is not possible to load data from Filters controller
// NOTE: must the latest operation to be performed in the session to be shure that is always present
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions);
// Renew or set the session expiring time
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time()));
}
/**
+40 -15
View File
@@ -38,6 +38,8 @@ class TableWidget extends Widget
private $_reloadDataset; // Force Reload of Dataset
private $_sessionTimeout; // session expiring time
private static $_TableWidgetInstance; // static property that contains the instance of itself
/**
@@ -124,22 +126,23 @@ class TableWidget extends Widget
$this->_datasetRepresentation = null;
$this->_datasetRepresentationOptions = null;
$this->_datasetRepFieldsDefs = null;
$this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT;
// Retrieved the required permissions parameter if present
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER]))
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS]))
{
$this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER];
$this->_requiredPermissions = $args[TableWidgetLib::REQUIRED_PERMISSIONS];
}
// How to retrieve data for the table: SQL statement or a result from DB
if (isset($args[TableWidgetLib::QUERY_PARAMETER]))
if (isset($args[TableWidgetLib::QUERY]))
{
$this->_query = $args[TableWidgetLib::QUERY_PARAMETER];
$this->_query = $args[TableWidgetLib::QUERY];
}
if (isset($args[TableWidgetLib::DATASET_RELOAD_PARAMETER]))
if (isset($args[TableWidgetLib::DATASET_RELOAD]))
{
$this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD_PARAMETER];
$this->_reloadDataset = $args[TableWidgetLib::DATASET_RELOAD];
}
// Parameter is used to add extra columns to the dataset
@@ -197,6 +200,12 @@ class TableWidget extends Widget
{
$this->_datasetRepFieldsDefs = $args[TableWidgetLib::DATASET_REP_FIELDS_DEFS];
}
// To specify the expiring session time
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
$this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT];
}
}
/**
@@ -204,27 +213,32 @@ class TableWidget extends Widget
*/
private function _checkParameters($args)
{
// If no options are given to this widget...
if (!is_array($args) || (is_array($args) && count($args) == 0))
{
show_error('Second parameter of the widget call must be a NOT empty associative array');
}
else
else // ...otherwise
{
// The unique id parameter is mandatory
if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID]))
{
show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified');
}
if (!isset($args[TableWidgetLib::QUERY_PARAMETER]))
// The query parameter is mandatory
if (!isset($args[TableWidgetLib::QUERY]))
{
show_error('The parameters "'.TableWidgetLib::QUERY_PARAMETER.'" must be specified');
show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// Checks if the dataset representation parameter is valid
if (isset($args[TableWidgetLib::DATASET_REPRESENTATION])
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI
@@ -238,6 +252,12 @@ class TableWidget extends Widget
.TableWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// If given the session timeout parameter must be a number
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
}
}
@@ -246,20 +266,23 @@ class TableWidget extends Widget
*/
private function _startTableWidget($tableUniqueId)
{
// Looks for expired table widgets in session and drops them
$this->tablewidgetlib->dropExpiredTableWidgets();
// Read the all session for this table widget
$session = $this->tablewidgetlib->getSession();
// If session is NOT empty -> a table was already loaded
if ($session != null)
{
// Get SESSION_RELOAD_DATASET from the session
$sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_RELOAD_DATASET);
// Get SESSION_DATASET_RELOAD from the session
$sessionReloadDataset = $this->tablewidgetlib->getSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD);
// if Filter changed or reload is forced by parameter then reload the Dataset
if ($this->_reloadDataset === true || $sessionReloadDataset === true)
{
// Set as false to stop changing the dataset
$this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_RELOAD_DATASET, false);
$this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_DATASET_RELOAD, false);
// Generate dataset query using tables from the session
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
@@ -305,7 +328,7 @@ class TableWidget extends Widget
TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset
TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table
TableWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
TableWidgetLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
TableWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time
TableWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
@@ -314,9 +337,11 @@ class TableWidget extends Widget
}
}
// To be always stored in the session, otherwise is not possible to load data from Filters controller
// NOTE: must the latest operation to be performed in the session to be shure that is always present
$this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
// To be always stored in the session, otherwise is not possible to load data from Filters controller
$this->tablewidgetlib->setSessionElement(TableWidgetLib::REQUIRED_PERMISSIONS, $this->_requiredPermissions);
// Renew or set the session expiring time
$this->tablewidgetlib->setSessionElement(TableWidgetLib::SESSION_TIMEOUT, strtotime('+'.$this->_sessionTimeout.' minutes', time()));
}
/**
@@ -170,7 +170,9 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') )
if($pr->getPruefungen($student_uid, "Termin1", $lvid, $stsem))
{
if ($pr->result)
{
$termin1 = 1;
}
else
{
$lvnote = new lvgesamtnote();
@@ -183,6 +185,7 @@ if (isset($_REQUEST["submit"]) && ($_REQUEST["student_uid"] != '') )
else
{
$pr_note = 9;
$pr_punkte = '';
$benotungsdatum = $jetzt;
}
+26 -23
View File
@@ -575,8 +575,8 @@ function saveAnmeldung(lehrveranstaltung_id, termin_id)
studienverpflichtung_id = $("#studienverpflichtung option:selected").val();
var studiengang_kz = null;
if($('#select_studiengang').length)
studiengang_kz = $('#select_studiengang option:selected').val();
if($('#prestudent_studiengang').length)
studiengang_kz = $('#prestudent_studiengang option:selected').val();
$.ajax({
dataType: 'json',
@@ -892,28 +892,31 @@ function saveReihung(terminId, lehrveranstaltung_id)
anmeldung.uid = v.id;
reihung.push(anmeldung);
});
$.ajax({
dataType: 'json',
url: "./pruefungsanmeldung.json.php",
type: "POST",
data: {
method: "saveReihung",
reihung: reihung
},
error: loadError,
success: function(data){
if(data.error === 'false' && data.result === true)
{
messageBox("message", "<?php echo $p->t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000);
}
else
{
messageBox("message", data.errormsg, "red", "highlight", 1000);
}
showAnmeldungen(terminId, lehrveranstaltung_id);
}
});
if (reihung.length > 0) {
$.ajax({
dataType: 'json',
url: "./pruefungsanmeldung.json.php",
type: "POST",
data: {
method: "saveReihung",
reihung: reihung
},
error: loadError,
success: function(data){
if(data.error === 'false' && data.result === true)
{
messageBox("message", "<?php echo $p->t('pruefung/reihunghErfolgreichGeaendert'); ?>", "green", "highlight", 1000);
}
else
{
messageBox("message", data.errormsg, "red", "highlight", 1000);
}
showAnmeldungen(terminId, lehrveranstaltung_id);
}
});
}
}
/**
@@ -632,24 +632,11 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null)
{
foreach ($prestudenten as $ps)
{
if($ps->studiengang_kz === $studiengang_kz)
if ($ps->getLaststatus($ps->prestudent_id, $stdsem))
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem))
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
else
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
}
}
$prestudent_id = $ps->prestudent_id;
}
else
{
@@ -662,6 +649,16 @@ function saveAnmeldung($aktStudiensemester = null, $uid = null)
}
}
}
else
{
if ($ps->getLaststatus($ps->prestudent_id, $stdsem_lv_besuch))
{
if (($ps->status_kurzbz == "Student") || ($ps->status_kurzbz == "Unterbrecher"))
{
$prestudent_id = $ps->prestudent_id;
}
}
}
}
}
else