diff --git a/application/controllers/system/Test.php b/application/controllers/system/Test.php
new file mode 100644
index 000000000..f22898a34
--- /dev/null
+++ b/application/controllers/system/Test.php
@@ -0,0 +1,38 @@
+load->library('WidgetLib');
+ }
+
+ /**
+ *
+ */
+ public function index()
+ {
+ echo $this->widgetlib->widget(
+ 'FilterWidget',
+ array(
+ 'app' => 'OpenProject',
+ 'datasetName' => 'Arbeitspakete',
+ 'query' => '
+ SELECT p.person_id AS PersonId,
+ p.nachname AS Nachname,
+ p.vorname AS Vorname,
+ k.kontakt AS Email
+ FROM public.tbl_person p INNER JOIN public.tbl_kontakt k USING(person_id)
+ WHERE p.aktiv = TRUE
+ AND p.person_id = k.person_id
+ AND k.kontakttyp = \'email\'
+ AND p.person_id < 1000
+ '
+ )
+ );
+ }
+}
diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php
index ab5ab2768..e6bd31114 100644
--- a/application/core/DB_Model.php
+++ b/application/core/DB_Model.php
@@ -23,6 +23,9 @@ class DB_Model extends FHC_Model
protected $hasSequence; // False if this table has a composite primary key that is not using a sequence
// True if this table has a primary key that uses a sequence
+ private $executedQueryMetaData;
+ private $executedQueryListFields;
+
/**
* Constructor
*/
@@ -670,6 +673,44 @@ class DB_Model extends FHC_Model
return $this->fieldExists(UDFLib::COLUMN_NAME);
}
+ /**
+ * Get the list of the fields after having executed a query
+ */
+ public function getExecutedQueryListFields()
+ {
+ return $this->executedQueryListFields;
+ }
+
+ /**
+ * Get meda data info about the retrived fields after having executed a query
+ */
+ public function getExecutedQueryMetaData()
+ {
+ return $this->executedQueryMetaData;
+ }
+
+ /**
+ * Like execQuery, but it allows only to perform queries to read data
+ */
+ public function execReadOnlyQuery($query, $parametersArray = null)
+ {
+ //
+ if (!stripos($query, 'INSERT')
+ && !stripos($query, 'UPDATE')
+ && !stripos($query, 'DELETE')
+ && !stripos($query, 'CREATE')
+ && !stripos($query, 'ALTER')
+ && !stripos($query, 'GRANT')
+ && !stripos($query, 'DROP'))
+ {
+ return $this->execQuery($query, $parametersArray);
+ }
+ else
+ {
+ return error('You are allowed to run only query for reading data');
+ }
+ }
+
// ------------------------------------------------------------------------------------------
// Protected methods
@@ -809,20 +850,23 @@ class DB_Model extends FHC_Model
if (is_object($result))
{
$toBeConverterdArray = array(); // Fields to be converted
- $metaDataArray = $result->field_data(); // Fields information
- for ($i = 0; $i < count($metaDataArray); $i++) // Looking for booleans and arrays
+
+ $this->executedQueryMetaData = $result->field_data(); // Fields information
+ $this->executedQueryListFields = $result->list_fields(); // List of the retrived fields
+
+ for ($i = 0; $i < count($this->executedQueryMetaData); $i++) // Looking for booleans and arrays
{
// If array type, boolean type OR a UDF
- if (strpos($metaDataArray[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
- || $metaDataArray[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE
- || $this->udflib->isUDFColumn($metaDataArray[$i]->name, $metaDataArray[$i]->type))
+ if (strpos($this->executedQueryMetaData[$i]->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
+ || $this->executedQueryMetaData[$i]->type == DB_Model::PGSQL_BOOLEAN_TYPE
+ || $this->udflib->isUDFColumn($this->executedQueryMetaData[$i]->name, $this->executedQueryMetaData[$i]->type))
{
// Name and type of the field to be converted
$toBeConverted = new stdClass();
// Set the type of the field to be converted
- $toBeConverted->type = $metaDataArray[$i]->type;
+ $toBeConverted->type = $this->executedQueryMetaData[$i]->type;
// Set the name of the field to be converted
- $toBeConverted->name = $metaDataArray[$i]->name;
+ $toBeConverted->name = $this->executedQueryMetaData[$i]->name;
// Add the field to be converted to $toBeConverterdArray
array_push($toBeConverterdArray, $toBeConverted);
}
diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php
index 1e16c11ac..2d453f068 100644
--- a/application/libraries/UDFLib.php
+++ b/application/libraries/UDFLib.php
@@ -625,7 +625,7 @@ class UDFLib
elseif (isset($jsonSchema->{UDFLib::LIST_VALUES}->sql))
{
// UDFModel is loaded in method _loadUDF that is called before the current method
- $queryResult = $this->_ci->UDFModel->execQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
+ $queryResult = $this->_ci->UDFModel->execReadOnlyQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
if (hasData($queryResult))
{
$parameters = $queryResult->retval;
diff --git a/application/models/system/Filters_model.php b/application/models/system/Filters_model.php
new file mode 100644
index 000000000..546e2a5fd
--- /dev/null
+++ b/application/models/system/Filters_model.php
@@ -0,0 +1,14 @@
+dbTable = 'system.tbl_filters';
+ $this->pk = 'filter_id';
+ }
+}
diff --git a/application/models/system/UDF_model.php b/application/models/system/UDF_model.php
index e9bef54f6..ae9a91a69 100644
--- a/application/models/system/UDF_model.php
+++ b/application/models/system/UDF_model.php
@@ -6,10 +6,10 @@ class UDF_model extends DB_Model
const STRING_NULL = 'null';
const STRING_TRUE = 'true';
const STRING_FALSE = 'false';
-
+
const UDF_DROPDOWN_TYPE = 'dropdown';
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
-
+
/**
* Constructor
*/
@@ -20,41 +20,14 @@ class UDF_model extends DB_Model
$this->pk = array('schema', 'table');
$this->hasSequence = false;
}
-
- /**
- * Override DB_Model method execQuery to allow only to perform queries to read data
- */
- public function execQuery($query, $parametersArray = null)
- {
- //
- if (
- (
- substr($query, 0, 6) == 'SELECT'
- || substr($query, 0, 4) == 'WITH'
- )
- &&
- (
- !stripos($query, 'INSERT')
- && !stripos($query, 'UPDATE')
- && !stripos($query, 'DELETE')
- )
- )
- {
- return parent::execQuery($query, $parametersArray);
- }
- else
- {
- return error('You are allowed to run only query for reading data');
- }
- }
-
+
/**
* Returns all the UDF for this table
*/
public function getUDFsDefinitions($schemaAndTable)
{
$st = $this->getSchemaAndTable($schemaAndTable);
-
+
$this->addSelect(UDFLib::COLUMN_JSON_DESCRIPTION);
$udfResults = $this->loadWhere(
array(
@@ -62,13 +35,13 @@ class UDF_model extends DB_Model
'table' => $st->table
)
);
-
+
return $udfResults;
}
// ------------------------------------------------------------------------------------
// These methods work only with the this version of FAS, not with the future versions
-
+
/**
* Methods to save data from FAS
*/
@@ -77,53 +50,53 @@ class UDF_model extends DB_Model
$result = error('No way man!');
$resultPerson = success('person');
$resultPrestudent = success('prestudent');
-
+
$person_id = $udfs['person_id'];
unset($udfs['person_id']);
-
+
$prestudent_id = $udfs['prestudent_id'];
unset($udfs['prestudent_id']);
-
+
$jsons = array();
-
- //
+
+ //
if (isset($person_id))
{
// Load model Person_model
$this->load->model('person/Person_model', 'PersonModel');
-
+
$result = $this->load(array('public', 'tbl_person'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
-
+
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
-
+
$resultPerson = $this->PersonModel->update($person_id, $udfs);
}
-
- //
+
+ //
if (isset($prestudent_id))
{
// Load model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
-
+
$result = $this->load(array('public', 'tbl_prestudent'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
-
+
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
-
+
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
}
-
+
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
{
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
@@ -136,17 +109,17 @@ class UDF_model extends DB_Model
{
$result = $resultPrestudent;
}
-
+
return $result;
}
-
+
/**
- *
+ *
*/
private function _fillMissingChkboxUDF($udfs, $jsons)
{
$_fillMissingChkboxUDF = $udfs;
-
+
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
@@ -168,17 +141,17 @@ class UDF_model extends DB_Model
}
}
}
-
+
return $_fillMissingChkboxUDF;
}
-
+
/**
- *
+ *
*/
private function _fillMissingDropdownUDF($udfs, $jsons)
{
$_fillMissingDropdownUDF = $udfs;
-
+
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
@@ -194,17 +167,17 @@ class UDF_model extends DB_Model
}
}
}
-
+
return $_fillMissingDropdownUDF;
}
-
+
/**
- *
+ *
*/
private function _fillMissingTextUDF($udfs, $jsons)
{
$_fillMissingTextUDF = $udfs;
-
+
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
@@ -220,7 +193,7 @@ class UDF_model extends DB_Model
}
}
}
-
+
return $_fillMissingTextUDF;
}
-}
\ No newline at end of file
+}
diff --git a/application/views/widgets/filter/selectFields.php b/application/views/widgets/filter/selectFields.php
new file mode 100644
index 000000000..a4f11dbfb
--- /dev/null
+++ b/application/views/widgets/filter/selectFields.php
@@ -0,0 +1,20 @@
+
+ $value)
+ {
+ echo '';
+ }
+ ?>
+
+
+ Add:
+
+
diff --git a/application/views/widgets/filter/selectFilters.php b/application/views/widgets/filter/selectFilters.php
new file mode 100644
index 000000000..72f963b57
--- /dev/null
+++ b/application/views/widgets/filter/selectFilters.php
@@ -0,0 +1,20 @@
+
+ $value)
+ {
+ echo $value->name.' - '.$value->type.'
';
+ }
+ ?>
+
+
+ Add filter:
+
+
diff --git a/application/views/widgets/filter/tableDataset.php b/application/views/widgets/filter/tableDataset.php
new file mode 100644
index 000000000..6927a0923
--- /dev/null
+++ b/application/views/widgets/filter/tableDataset.php
@@ -0,0 +1,9 @@
+
+ retval;
+ foreach ($result as $key => $value)
+ {
+ var_dump($value);
+ }
+ ?>
+
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php
new file mode 100644
index 000000000..721fd7c55
--- /dev/null
+++ b/application/widgets/FilterWidget.php
@@ -0,0 +1,61 @@
+load->model('system/Filters_model', 'FiltersModel');
+
+ $this->app = $widgetData['app'];
+ $this->datasetName = $widgetData['datasetName'];
+
+ $dataset = $this->FiltersModel->execReadOnlyQuery($widgetData['query']);
+
+ $this->loadViewSelectFields($this->FiltersModel->getExecutedQueryListFields());
+
+ $this->loadViewSelectFilters($this->FiltersModel->getExecutedQueryMetaData());
+
+ $this->loadViewTableDataset($dataset);
+ }
+
+ /**
+ *
+ */
+ private function loadViewSelectFields($listFields)
+ {
+ $this->view('widgets/filter/selectFields', array('listFields' => $listFields));
+ }
+
+ /**
+ *
+ */
+ private function loadViewSelectFilters($metaData)
+ {
+ $this->view('widgets/filter/selectFilters', array('metaData' => $metaData));
+ }
+
+ /**
+ *
+ */
+ private function loadViewTableDataset($result)
+ {
+ $this->view('widgets/filter/tableDataset', array('dataset' => $result));
+ }
+}
diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php
index 55b272bab..771a3f5e7 100644
--- a/system/dbupdate_3.3.php
+++ b/system/dbupdate_3.3.php
@@ -674,6 +674,225 @@ if ($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berech
//---------------------------------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------------------------------
+// Start filters
+
+// SEQUENCE tbl_filters_id_seq
+if ($result = $db->db_query("SELECT 0 FROM pg_class WHERE relname = 'tbl_filters_id_seq'"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = '
+ CREATE SEQUENCE system.tbl_filters_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+ ';
+ if(!$db->db_query($qry))
+ echo 'system.tbl_filters_id_seq '.$db->db_last_error().'
';
+ else
+ echo '
Created sequence: system.tbl_filters_id_seq';
+
+ // GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO vilesci;
+ $qry = 'GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO vilesci;';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters_id_seq '.$db->db_last_error().'
';
+ else
+ echo '
Granted privileges to vilesci on system.tbl_filters_id_seq';
+
+ // GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO fhcomplete;
+ $qry = 'GRANT SELECT, UPDATE ON SEQUENCE system.tbl_filters_id_seq TO fhcomplete;';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters_id_seq '.$db->db_last_error().'
';
+ else
+ echo '
Granted privileges to vilesci on system.tbl_filters_id_seq';
+ }
+}
+
+// TABLE system.tbl_filters
+if (!@$db->db_query("SELECT 0 FROM system.tbl_filters WHERE 0 = 1"))
+{
+ $qry = '
+ CREATE TABLE system.tbl_filters (
+ filter_id integer NOT NULL DEFAULT nextval(\'system.tbl_filters_id_seq\'::regclass),
+ app character varying(32) NOT NULL,
+ dataset_name character varying(128) NOT NULL,
+ filter_kurzbz character varying(64) NOT NULL,
+ person_id integer,
+ description character varying(128)[] NOT NULL,
+ sort integer,
+ default_filter boolean DEFAULT FALSE,
+ filter jsonb NOT NULL,
+ oe_kurzbz character varying(16)
+ );';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters '.$db->db_last_error().'
';
+ else
+ echo '
Created table system.tbl_filters';
+
+ // GRANT SELECT ON TABLE system.tbl_filters TO web;
+ $qry = 'GRANT SELECT ON TABLE system.tbl_filters TO web;';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters '.$db->db_last_error().'
';
+ else
+ echo '
Granted privileges to web on system.tbl_filters';
+
+ // GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_filters TO vilesci;
+ $qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE system.tbl_filters TO vilesci;';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters '.$db->db_last_error().'
';
+ else
+ echo '
Granted privileges to vilesci on system.tbl_filters';
+
+ // COMMENT ON TABLE system.tbl_filters
+ $qry = 'COMMENT ON TABLE system.tbl_filters IS \'Table to manage filters\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters';
+
+ // COMMENT ON TABLE system.tbl_filters.app
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.app IS \'Application which this filter belongs to\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.app: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.app';
+
+ // COMMENT ON TABLE system.tbl_filters.dataset_name
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.dataset_name IS \'Name that identifies the data set to be filtered\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.dataset_name: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.dataset_name';
+
+ // COMMENT ON TABLE system.tbl_filters.filter_kurzbz
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.filter_kurzbz IS \'Short description of the filter, unique for this application and this data set\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.filter_kurzbz: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.filter_kurzbz';
+
+ // COMMENT ON TABLE system.tbl_filters.person_id
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.person_id IS \'Person identifier which this filter belongs to. If null it is global\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.person_id: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.person_id';
+
+ // COMMENT ON TABLE system.tbl_filters.description
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.description IS \'Long description for this filter\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.description: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.description';
+
+ // COMMENT ON TABLE system.tbl_filters.sort
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.sort IS \'Indicates the order in which the filters appear in a list\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.sort: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.sort';
+
+ // COMMENT ON TABLE system.tbl_filters.default_filter
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.default_filter IS \'If it is the default filter for that data set\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.default_filter: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.default_filter';
+
+ // COMMENT ON TABLE system.tbl_filters.filter
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.filter IS \'Cointains json that define the filter\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.filter: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.filter';
+
+ // COMMENT ON TABLE system.tbl_filters.oe_kurzbz
+ $qry = 'COMMENT ON COLUMN system.tbl_filters.oe_kurzbz IS \'Organisation unit which this filter belongs to. If null it is for all the organisation units\';';
+ if (!$db->db_query($qry))
+ echo 'Adding comment to system.tbl_filters.oe_kurzbz: '.$db->db_last_error().'
';
+ else
+ echo '
Added comment to system.tbl_filters.oe_kurzbz';
+
+ // ALTER SEQUENCE system.tbl_filters_id_seq OWNED BY system.tbl_filters.filter_id;
+ $qry = 'ALTER SEQUENCE system.tbl_filters_id_seq OWNED BY system.tbl_filters.filter_id;';
+ if (!$db->db_query($qry))
+ echo 'system.tbl_filters_id_seq '.$db->db_last_error().'
';
+ else
+ echo '
Altered sequence system.tbl_filters_id_seq';
+}
+
+// UNIQUE INDEX uidx_filters_app_dataset_name_filter_kurzbz
+if ($result = $db->db_query("SELECT 0 FROM pg_class WHERE relname = 'uidx_filters_app_dataset_name_filter_kurzbz'"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = 'CREATE UNIQUE INDEX uidx_filters_app_dataset_name_filter_kurzbz ON system.tbl_filters USING btree (app, dataset_name, filter_kurzbz);';
+ if (!$db->db_query($qry))
+ echo 'uidx_filters_app_dataset_name_filter_kurzbz '.$db->db_last_error().'
';
+ else
+ echo '
Created unique uidx_filters_app_dataset_name_filter_kurzbz';
+ }
+}
+
+// Add permission for filters
+if ($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berechtigung_kurzbz = 'system/filters';"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = "INSERT INTO system.tbl_berechtigung (berechtigung_kurzbz, beschreibung) VALUES('system/filters', 'To manage core filters');";
+ if (!$db->db_query($qry))
+ echo 'system.tbl_berechtigung '.$db->db_last_error().'
';
+ else
+ echo ' system.tbl_berechtigung: Added permission for filters
';
+ }
+}
+
+// FOREIGN KEY tbl_filters_app_fkey
+if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_app_fkey'"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_app_fkey FOREIGN KEY (app) REFERENCES system.tbl_app(app) ON UPDATE CASCADE ON DELETE RESTRICT;';
+ if (!$db->db_query($qry))
+ echo 'tbl_filters_app_fkey '.$db->db_last_error().'
';
+ else
+ echo '
Created foreign key tbl_filters_app_fkey';
+ }
+}
+
+// FOREIGN KEY tbl_filters_person_id_fkey
+if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_person_id_fkey'"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_person_id_fkey FOREIGN KEY (person_id) REFERENCES public.tbl_person(person_id) ON UPDATE CASCADE ON DELETE RESTRICT;';
+ if (!$db->db_query($qry))
+ echo 'tbl_filters_person_id_fkey '.$db->db_last_error().'
';
+ else
+ echo '
Created foreign key tbl_filters_person_id_fkey';
+ }
+}
+
+// FOREIGN KEY tbl_filters_oe_kurzbz_fkey
+if ($result = $db->db_query("SELECT conname FROM pg_constraint WHERE conname = 'tbl_filters_oe_kurzbz_fkey'"))
+{
+ if ($db->db_num_rows($result) == 0)
+ {
+ $qry = 'ALTER TABLE system.tbl_filters ADD CONSTRAINT tbl_filters_oe_kurzbz_fkey FOREIGN KEY (oe_kurzbz) REFERENCES public.tbl_organisationseinheit(oe_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT;';
+ if (!$db->db_query($qry))
+ echo 'tbl_filters_oe_kurzbz_fkey '.$db->db_last_error().'
';
+ else
+ echo '
Created foreign key tbl_filters_oe_kurzbz_fkey';
+ }
+}
+
+// End filters
+//---------------------------------------------------------------------------------------------------------------------
+
+
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
echo 'Pruefe Tabellen und Attribute!
';
@@ -923,6 +1142,7 @@ $tabellen=array(
"system.tbl_benutzerrolle" => array("benutzerberechtigung_id","rolle_kurzbz","berechtigung_kurzbz","uid","funktion_kurzbz","oe_kurzbz","art","studiensemester_kurzbz","start","ende","negativ","updateamum", "updatevon","insertamum","insertvon","kostenstelle_id","anmerkung"),
"system.tbl_berechtigung" => array("berechtigung_kurzbz","beschreibung"),
"system.tbl_extensions" => array("extension_id","name","version","description","license","url","core_version","dependencies","enabled"),
+ "system.tbl_filters" => array("filter_id","app","dataset_name","filter_kurzbz","person_id","description","sort","default_filter","filter","oe_kurzbz"),
"system.tbl_phrase" => array("phrase_id","app","phrase","insertamum","insertvon"),
"system.tbl_phrasentext" => array("phrasentext_id","phrase_id","sprache","orgeinheit_kurzbz","orgform_kurzbz","text","description","insertamum","insertvon"),
"system.tbl_rolle" => array("rolle_kurzbz","beschreibung"),