mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Merge branch 'master' into feature-53904/Vertragshistorie_valorisierte_Gehaelter_anzeigen
This commit is contained in:
@@ -74,6 +74,9 @@ require_once('dbupdate_3.4/55968_index_anrechnung.php');
|
||||
require_once('dbupdate_3.4/25999_locale_update.php');
|
||||
require_once('dbupdate_3.4/55289_pep_fine_tuning.php');
|
||||
require_once('dbupdate_3.4/55614_perm_verwaltetoe.php');
|
||||
require_once('dbupdate_3.4/25999_C4_dashboard.php');
|
||||
require_once('dbupdate_3.4/61730_Dashboard_Anpassungen.php');
|
||||
require_once('dbupdate_3.4/40128_search.php');
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 fhcomplete.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Harald Bamberger <harald.bamberger@technikum-wien.at>,
|
||||
*
|
||||
* Beschreibung:
|
||||
* CIS 4.0 Dashboard
|
||||
*/
|
||||
if (! defined('DB_NAME')) exit('No direct script access allowed');
|
||||
|
||||
// Add widget: Hallo Welt
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'hallowelt';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'hallowelt',
|
||||
'Hallo Welt Widget',
|
||||
'{"css": "d-flex justify-content-center align-items-center h-100", "title": "Hallo Welt"}'::jsonb,
|
||||
'{"file": "DashboardWidget/Default.js", "icon": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Farben-Testbild.svg", "name": "Hallo Welt", "width": {"max": 99}, "height": {"max": 99}, "hideFooter": false}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "Hallo Welt"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add widget: News
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'news';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'news',
|
||||
'News Widget',
|
||||
'{}'::jsonb,
|
||||
'{"file": "DashboardWidget/News.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "News", "width": {"max": 4, "min": 1}, "height": {"max": 2, "min": 1}, "cis4link": "/CisVue/Cms/news", "hideFooter": false}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "News"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add widget: Bookmark
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'url';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'url',
|
||||
'Bookmark Widget',
|
||||
'{}'::jsonb,
|
||||
'{"file": "DashboardWidget/Url.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Bookmark", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": true}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "Bookmark"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add widget: Ampel
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'ampel';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'ampel',
|
||||
'Ampel Widget',
|
||||
'{}'::jsonb,
|
||||
'{"file": "DashboardWidget/Ampel.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Ampel", "width": 1, "height": {"max": 2, "min": 1}, "hideFooter": false}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "Ampel"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update stundenplan widget
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'stundenplan';"))
|
||||
{
|
||||
if($db->db_num_rows($result) > 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
UPDATE
|
||||
dashboard.tbl_widget
|
||||
SET
|
||||
widget_kurzbz = 'lvplan',
|
||||
beschreibung = 'LV-Plan Widget',
|
||||
arguments = '{"bodyClass": "p-0"}'::jsonb,
|
||||
setup = '{"file": "DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb
|
||||
WHERE
|
||||
widget_kurzbz = 'stundenplan';
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Renamed Widget "Stundenplan" to "LV-Plan"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add widget: LV-Plan
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'lvplan';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'lvplan',
|
||||
'LV-Plan Widget',
|
||||
'{"bodyClass": "p-0"}'::jsonb,
|
||||
'{"file": "DashboardWidget/LvPlan.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "LV-Plan", "width": {"max": 4, "min": 1}, "height": {"max": 3, "min": 1}, "cis4link": "/Cis/LvPlan", "hideFooter": false}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "LV-Plan"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add widget: Studiengang
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_widget WHERE widget_kurzbz = 'studiengang';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOWHW
|
||||
INSERT INTO
|
||||
dashboard.tbl_widget (
|
||||
widget_kurzbz,
|
||||
beschreibung,
|
||||
arguments,
|
||||
setup
|
||||
)
|
||||
VALUES (
|
||||
'studiengang',
|
||||
'Das Studiengang-Widget enthält Informationen über den Studiengang eines Studenten.',
|
||||
'{}'::jsonb,
|
||||
'{"file": "DashboardWidget/Studiengang.js", "icon": "/skin/images/fh_technikum_wien_illustration_klein.png", "name": "Studiengang", "width": {"max": 2, "min": 1}, "height": {"max": 4, "min": 1}, "hideFooter": true}'::jsonb
|
||||
);
|
||||
EOWHW;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Added Widget "Studiengang"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add dashboard: CIS
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_dashboard WHERE dashboard_kurzbz = 'CIS';"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "INSERT INTO dashboard.tbl_dashboard(dashboard_kurzbz, beschreibung) VALUES('CIS', 'CIS 4.0 Dashboard');";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_dashboard '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_dashboard: Added Dashboard "CIS"<br>';
|
||||
}
|
||||
|
||||
$widgetmappingqry = <<<EOWMQ
|
||||
insert into
|
||||
dashboard.tbl_dashboard_widget (
|
||||
dashboard_id,
|
||||
widget_id
|
||||
)
|
||||
(
|
||||
select
|
||||
td.dashboard_id, tw.widget_id
|
||||
from
|
||||
dashboard.tbl_dashboard td
|
||||
cross join
|
||||
dashboard.tbl_widget tw
|
||||
where
|
||||
td.dashboard_kurzbz = 'CIS'
|
||||
and
|
||||
tw.widget_kurzbz in ('hallowelt', 'news', 'url', 'ampel', 'studiengang')
|
||||
order by td.dashboard_id, tw.widget_id
|
||||
)
|
||||
ON CONFLICT (dashboard_id, widget_id) DO NOTHING
|
||||
EOWMQ;
|
||||
|
||||
if(!$db->db_query($widgetmappingqry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_dashboard_widget '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_dashboard_widget: Added WidgetMapping for Dashboard "CIS"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add general preset for dashboard: CIS
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_dashboard_preset WHERE funktion_kurzbz IS NULL AND dashboard_id = (select dashboard_id from dashboard.tbl_dashboard where dashboard_kurzbz = 'CIS');"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOGP
|
||||
insert into
|
||||
dashboard.tbl_dashboard_preset (
|
||||
dashboard_id,
|
||||
funktion_kurzbz,
|
||||
preset
|
||||
)
|
||||
values (
|
||||
(select dashboard_id from dashboard.tbl_dashboard where dashboard_kurzbz = 'CIS'),
|
||||
NULL,
|
||||
(SELECT '{"general": {"widgets": {"2ad7f459a8218ae39f0b68201a9545a4": {"place": {"4": {"h": 2, "w": 3, "x": 0, "y": 0}}, "config": [], "preset": 1, "widget": ' || (select widget_id from dashboard.tbl_widget where widget_kurzbz = 'news') || ', "widgetid": "2ad7f459a8218ae39f0b68201a9545a4"}, "4590326a80c27e61d861b18b46858084": {"place": {"4": {"h": 1, "w": 1, "x": 3, "y": 2}}, "config": [], "preset": 1, "widget": ' || (select widget_id from dashboard.tbl_widget where widget_kurzbz = 'lvplan') || ', "widgetid": "4590326a80c27e61d861b18b46858084"}, "8ec3f441d4adc9dd2bc5cc14a663eae9": {"place": {"4": {"h": 1, "w": 1, "x": 0, "y": 2}}, "config": [], "preset": 1, "widget": ' || (select widget_id from dashboard.tbl_widget where widget_kurzbz = 'url') || ', "widgetid": "8ec3f441d4adc9dd2bc5cc14a663eae9"}, "e4214d3f2bed8740d4c9cede165ccd07": {"place": {"4": {"h": 2, "w": 1, "x": 3, "y": 0}}, "config": [], "preset": 1, "widget": ' || (select widget_id from dashboard.tbl_widget where widget_kurzbz = 'ampel') || ', "widgetid": "e4214d3f2bed8740d4c9cede165ccd07"}}}}')::jsonb
|
||||
)
|
||||
EOGP;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_dashboard_preset '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_dashboard_preset: Added General Preset for Dashboard "CIS"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add general preset for dashboard: CIS
|
||||
if($result = @$db->db_query("SELECT 1 FROM dashboard.tbl_dashboard_preset WHERE funktion_kurzbz = 'Student' AND dashboard_id = (select dashboard_id from dashboard.tbl_dashboard where dashboard_kurzbz = 'CIS');"))
|
||||
{
|
||||
if($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = <<<EOGP
|
||||
insert into
|
||||
dashboard.tbl_dashboard_preset (
|
||||
dashboard_id,
|
||||
funktion_kurzbz,
|
||||
preset
|
||||
)
|
||||
values (
|
||||
(select dashboard_id from dashboard.tbl_dashboard where dashboard_kurzbz = 'CIS'),
|
||||
'Student',
|
||||
(SELECT '{"Student": {"widgets": {"3c448b2a774ff361bf59516ef0b841ef": {"place": {"4": {"h": 1, "w": 1, "x": 3, "y": 0}}, "config": [], "preset": 1, "widget": 6, "widgetid": "3c448b2a774ff361bf59516ef0b841ef"}, "83808e47ccf95db1afb4fe014d221ca9": {"place": {"4": {"h": 1, "w": 1, "x": 0, "y": 0}}, "config": {}, "preset": 1, "widget": ' || (select widget_id from dashboard.tbl_widget where widget_kurzbz = 'studiengang') || ', "widgetid": "83808e47ccf95db1afb4fe014d221ca9"}}}}')::jsonb
|
||||
)
|
||||
EOGP;
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_dashboard_preset '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_dashboard_preset: Added Student Preset for Dashboard "CIS"<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
if (!defined('DB_NAME')) exit('No direct script access allowed');
|
||||
|
||||
// Activate module pg_trgm
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1
|
||||
FROM pg_extension WHERE extname = 'pg_trgm' LIMIT 1;")))
|
||||
{
|
||||
$qry = "CREATE extension pg_trgm;";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>Module pg_trgm ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'Module pg_trgm: activated<br>';
|
||||
}
|
||||
|
||||
|
||||
// Add additional computed columns
|
||||
// Add column fts_bezeichnung to public.tbl_organisationseinheit
|
||||
if (!@$db->db_query("SELECT fts_bezeichnung FROM public.tbl_organisationseinheit LIMIT 1"))
|
||||
{
|
||||
$qry = "ALTER TABLE public.tbl_organisationseinheit ADD COLUMN fts_bezeichnung tsvector;";
|
||||
$qry .= "COMMENT ON COLUMN public.tbl_organisationseinheit.fts_bezeichnung IS 'used for search - auto generated w triggers';";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong> public.tbl_organisationseinheit ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_organisationseinheit: new column "fts_bezeichnung" added<br>';
|
||||
}
|
||||
|
||||
// Add function tr_update_tbl_organisationseinheit_fts_bezeichnung to public
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1 FROM pg_proc WHERE proname = 'tr_update_tbl_organisationseinheit_fts_bezeichnung' LIMIT 1;")))
|
||||
{
|
||||
$qry = "CREATE FUNCTION tr_update_tbl_organisationseinheit_fts_bezeichnung()
|
||||
RETURNS TRIGGER
|
||||
LANGUAGE PLPGSQL
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
IF TG_TABLE_NAME = 'tbl_organisationseinheit' THEN
|
||||
NEW.fts_bezeichnung := to_tsvector('simple', COALESCE((
|
||||
SELECT bezeichnung
|
||||
FROM public.tbl_organisationseinheittyp
|
||||
WHERE organisationseinheittyp_kurzbz = NEW.organisationseinheittyp_kurzbz
|
||||
), '') || ' ' || COALESCE(NEW.bezeichnung, ''));
|
||||
ELSIF TG_TABLE_NAME = 'tbl_organisationseinheittyp' THEN
|
||||
UPDATE public.tbl_organisationseinheit
|
||||
SET fts_bezeichnung = to_tsvector('simple', COALESCE(NEW.bezeichnung, '') || ' ' || COALESCE(bezeichnung, ''))
|
||||
WHERE organisationseinheittyp_kurzbz = NEW.organisationseinheittyp_kurzbz;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong> public.tr_update_tbl_organisationseinheit_fts_bezeichnung ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tr_update_tbl_organisationseinheit_fts_bezeichnung: function created<br>';
|
||||
}
|
||||
|
||||
$update_column = false;
|
||||
// Add trigger tr_organisationseinheit_update_organisationseinheittyp_kurzbz to public.tbl_organisationseinheit
|
||||
if (!$db->db_num_rows(@$db->db_query("
|
||||
SELECT 1
|
||||
FROM information_schema.triggers
|
||||
WHERE event_object_table ='tbl_organisationseinheit'
|
||||
AND trigger_name = 'tr_organisationseinheit_update_organisationseinheittyp_kurzbz'
|
||||
LIMIT 1;
|
||||
")))
|
||||
{
|
||||
$qry = "CREATE TRIGGER tr_organisationseinheit_update_organisationseinheittyp_kurzbz
|
||||
BEFORE UPDATE OF organisationseinheittyp_kurzbz OR INSERT
|
||||
ON public.tbl_organisationseinheit
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION tr_update_tbl_organisationseinheit_fts_bezeichnung();";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong> public.tbl_organisationseinheit ' . $db->db_last_error() . '</strong><br>';
|
||||
else {
|
||||
echo 'public.tbl_organisationseinheit: trigger "tr_organisationseinheit_update_organisationseinheittyp_kurzbz" created<br>';
|
||||
$update_column = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Add trigger tr_organisationseinheittyp_update_bezeichnung to public.tbl_organisationseinheittyp
|
||||
if (!$db->db_num_rows(@$db->db_query("
|
||||
SELECT 1
|
||||
FROM information_schema.triggers
|
||||
WHERE event_object_table ='tbl_organisationseinheittyp'
|
||||
AND trigger_name = 'tr_organisationseinheittyp_update_bezeichnung'
|
||||
LIMIT 1;
|
||||
")))
|
||||
{
|
||||
$qry = "CREATE TRIGGER tr_organisationseinheittyp_update_bezeichnung
|
||||
BEFORE UPDATE OF bezeichnung
|
||||
ON public.tbl_organisationseinheittyp
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION tr_update_tbl_organisationseinheit_fts_bezeichnung();";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong> public.tbl_organisationseinheittyp ' . $db->db_last_error() . '</strong><br>';
|
||||
else {
|
||||
echo 'public.tbl_organisationseinheittyp: trigger "tr_organisationseinheittyp_update_bezeichnung" created<br>';
|
||||
$update_column = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update fts_bezeichnung on tbl_organisationseinheit with new triggers
|
||||
if ($update_column)
|
||||
{
|
||||
$qry = "UPDATE public.tbl_organisationseinheittyp SET bezeichnung = bezeichnung;";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong> public.tbl_organisationseinheit ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_organisationseinheit: column "fts_bezeichnung" updated<br>';
|
||||
}
|
||||
|
||||
|
||||
// Add Trigram Indexes
|
||||
// Add index for kontakt to public.tbl_kontakt
|
||||
if ($result = @$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_kontakt_kontakt_trgm';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "CREATE INDEX idx_tbl_kontakt_kontakt_trgm ON public.tbl_kontakt USING GIN (COALESCE(kontakt, '') gin_trgm_ops);";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_kontakt ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_kontakt: added index "idx_tbl_kontakt_kontakt_trgm"<br>';
|
||||
}
|
||||
}
|
||||
// Add index for vorname to public.tbl_person
|
||||
if ($result = @$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_person_vorname_trgm';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "CREATE INDEX idx_tbl_person_vorname_trgm ON public.tbl_person USING GIN (COALESCE(vorname, '') gin_trgm_ops);";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_person ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_person: added index "idx_tbl_person_vorname_trgm"<br>';
|
||||
}
|
||||
}
|
||||
// Add index for nachname to public.tbl_person
|
||||
if ($result = @$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_person_nachname_trgm';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "CREATE INDEX idx_tbl_person_nachname_trgm ON public.tbl_person USING GIN (COALESCE(nachname, '') gin_trgm_ops);";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_person ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_person: added index "idx_tbl_person_nachname_trgm"<br>';
|
||||
}
|
||||
}
|
||||
// Add index for vorname || ' ' || nachname to public.tbl_person
|
||||
if ($result = @$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_person_name_trgm';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "CREATE INDEX idx_tbl_person_name_trgm ON public.tbl_person USING GIN (COALESCE((vorname || ' ' || nachname), '') gin_trgm_ops);";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_person ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_person: added index "idx_tbl_person_name_trgm"<br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add Vector Indexes
|
||||
// Add index for fts_bezeichnung to public.tbl_organisationseinheit
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_organisationseinheit_fts_bezeichnung_vector' LIMIT 1;")))
|
||||
{
|
||||
$qry = "CREATE INDEX idx_tbl_organisationseinheit_fts_bezeichnung_vector ON public.tbl_organisationseinheit USING GIN (fts_bezeichnung);";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>public.tbl_organisationseinheit ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'public.tbl_organisationseinheit: added index "idx_tbl_organisationseinheit_fts_bezeichnung_vector"<br>';
|
||||
}
|
||||
// Add index for titel || ' ' || content to campus.tbl_contentsprache
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_contentsprache_fts_titel_content_vector' LIMIT 1;")))
|
||||
{
|
||||
$qry = "
|
||||
CREATE INDEX idx_tbl_contentsprache_fts_titel_content_vector
|
||||
ON campus.tbl_contentsprache
|
||||
USING GIN ((
|
||||
setweight(to_tsvector('simple', COALESCE(titel, '')), 'A')
|
||||
|| setweight(to_tsvector('simple', COALESCE(content, '')::text), 'B')
|
||||
));
|
||||
";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>campus.tbl_contentsprache ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'campus.tbl_contentsprache: added index "idx_tbl_contentsprache_fts_titel_content_vector"<br>';
|
||||
}
|
||||
// Add index for schlagworte to campus.tbl_dms_version
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_dms_version_fts_schlagworte_vector' LIMIT 1;")))
|
||||
{
|
||||
$qry = "
|
||||
CREATE INDEX idx_tbl_dms_version_fts_schlagworte_vector
|
||||
ON campus.tbl_dms_version
|
||||
USING GIN ((to_tsvector('simple', COALESCE(schlagworte, ''))));
|
||||
";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>campus.tbl_dms_version ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'campus.tbl_contentsprache: added index "idx_tbl_dms_version_fts_schlagworte_vector"<br>';
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
$rowcount = 0;
|
||||
$result = @$db->db_query("SELECT preset_id FROM dashboard.tbl_dashboard_preset WHERE preset ? 'widgets'");
|
||||
$result_num_rows = $db->db_num_rows($result);
|
||||
$rowcount += $result_num_rows;
|
||||
$errorList = array();
|
||||
for($i = 0; $i < $result_num_rows; $i++)
|
||||
{
|
||||
$row = $db->db_fetch_object($result, $i);
|
||||
|
||||
$qry = "
|
||||
UPDATE dashboard.tbl_dashboard_preset
|
||||
SET preset =
|
||||
COALESCE(
|
||||
(SELECT jsonb_object_agg(keys,values) FROM (
|
||||
SELECT key AS keys,jsonb_build_object('widgets',to_jsonb(value)) AS values
|
||||
FROM jsonb_each(preset->'widgets')
|
||||
) AS subquery
|
||||
),preset)
|
||||
WHERE preset_id = ".$row->preset_id;
|
||||
|
||||
$db->db_query($qry);
|
||||
if (!$db->db_query($qry))
|
||||
array_push($errorList,'<br><strong>dashboard.tbl_dashboard_preset: ' . $db->db_last_error() . '</strong><br>') ;
|
||||
|
||||
}
|
||||
|
||||
$result = @$db->db_query("SELECT override_id FROM dashboard.tbl_dashboard_benutzer_override WHERE override ? 'widgets'");
|
||||
$result_num_rows = $db->db_num_rows($result);
|
||||
$rowcount += $result_num_rows;
|
||||
for($i = 0; $i < $result_num_rows; $i++)
|
||||
{
|
||||
$row = $db->db_fetch_object($result, $i);
|
||||
|
||||
$qry = "
|
||||
UPDATE dashboard.tbl_dashboard_benutzer_override
|
||||
SET override =
|
||||
COALESCE(
|
||||
(SELECT jsonb_object_agg(keys,values) FROM (
|
||||
SELECT key AS keys,jsonb_build_object('widgets',to_jsonb(value)) AS values
|
||||
FROM jsonb_each(override->'widgets')
|
||||
) AS subquery
|
||||
),override)
|
||||
WHERE override_id = ".$row->override_id;
|
||||
|
||||
$db->db_query($qry);
|
||||
if (!$db->db_query($qry))
|
||||
array_push($errorList,'<br><strong>dashboard.tbl_dashboard_benutzer_override: ' . $db->db_last_error() . '</strong><br>') ;
|
||||
|
||||
}
|
||||
|
||||
if(empty($errorList)){
|
||||
if($rowcount > 0) {
|
||||
echo '<br>successfully updated dashboard.tbl_dashboard_preset and dashboard.tbl_dashboard_benutzer_override';
|
||||
}
|
||||
}
|
||||
else{
|
||||
foreach($errorList as $error){
|
||||
echo $error;
|
||||
}
|
||||
}
|
||||
+5660
-12
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user