Skip to content

Commit

Permalink
add PostgreSQL compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Nov 26, 2024
1 parent 8e689c0 commit ae9916e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
7 changes: 4 additions & 3 deletions install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
*****************************************************************************/
//Import benötigter Skripts

require_once('../includes.php');
require_once('install_functions.php');
require_once(STATISTICS_PATH . '/statistic_objects/statistic.php');
Expand Down Expand Up @@ -97,7 +98,7 @@ function askInstallationStart($page)
$selectionBox = array(4 => $gL10n->get('PLG_STATISTICS_INSTALL'), 5 => $gL10n->get('PLG_STATISTICS_UNINSTALL'));
$navbarPlugin->addDescription($gL10n->get('PLG_STATISTICS_WELCOME_HEADLINE'));
$navbarPlugin->addSelectBox('install-state', $gL10n->get('PLG_STATISTICS_ACTION'), $selectionBox, array('property' => HtmlForm::FIELD_REQUIRED));
$navbarPlugin->addSubmitButton('btn_send', $gL10n->get('PLG_STATISTICS_PERFORM_ACTION'));
$navbarPlugin->addSubmitButton('adm_button_send', $gL10n->get('PLG_STATISTICS_PERFORM_ACTION'));
$navbarPlugin->closeGroupBox();
$page->addHtml($navbarPlugin->show(false));
}
Expand Down Expand Up @@ -126,7 +127,7 @@ function showActionButton($type = 'home')
break;
}
$navbarPlugin->addInput('install-state', '', $value, array('class' => 'invisible'));
$navbarPlugin->addSubmitButton('btn_send', $text);
$navbarPlugin->addSubmitButton('adm_button_send', $text);
$navbarPlugin->closeGroupBox();
$page->addHtml($navbarPlugin->show(false));

Expand Down Expand Up @@ -158,7 +159,7 @@ function addStatisticTemplates()


//Leere Statistik, die für die temporäre Bearbeitung einer Statistik reserviert ist
$statistic0 = new Statistic(null, $currentOrgID, 'TEMPORARY STATISTIC', null, null, null);
$statistic0 = new Statistic(null, $currentOrgID, 'TEMPORARY STATISTIC', null, null, 0);

//Altersstatistik
$statistic1 = new Statistic(null, $currentOrgID, $gL10n->get('PLG_STATISTICS_AGE_STATISTICS'), $gL10n->get('PLG_STATISTICS_AGE_STATISTICS'), $gL10n->get('PLG_STATISTICS_YEAR') . ' ' . date('Y'), 2);
Expand Down
6 changes: 3 additions & 3 deletions install/install_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
function statCheckPreviousInstallations() {
global $gDb;

$sql = 'SELECT * FROM ' . TBL_STATISTICS;
$sql = 'SELECT 1 FROM ' . TBL_STATISTICS;
$pdoStatement = $gDb->query($sql,false);

if ($pdoStatement !== false && $pdoStatement->rowCount() > 0) {
Expand All @@ -30,8 +30,8 @@ function statAddMenu() {

$sql = 'INSERT INTO '.TBL_MENU.'
(men_com_id, men_men_id_parent, men_uuid, men_node, men_order, men_standard, men_name_intern, men_url, men_icon, men_name, men_description)
VALUES (NULL, 3, \'' . Uuid::uuid4() . '\', 0, 100, false, \'statistics\', \''.FOLDER_PLUGINS.'/'.$pluginFolder.'/gui/overview.php\', \'fa-list\', \'PLG_STATISTICS_STATISTICS\', \'PLG_STATISTICS_STATISTICS_DESC\')
, (NULL, 3, \'' . Uuid::uuid4() . '\', 0, 101, false, \'statistics_editor\', \''.FOLDER_PLUGINS.'/'.$pluginFolder.'/gui/editor.php\', \'fa-cog\', \'PLG_STATISTICS_STATISTICS_EDITOR\', \'PLG_STATISTICS_STATISTICS_EDITOR_DESC\')';
VALUES (NULL, 3, \'' . Uuid::uuid4() . '\', false, 100, false, \'statistics\', \''.FOLDER_PLUGINS.'/'.$pluginFolder.'/gui/overview.php\', \'bi-list\', \'PLG_STATISTICS_STATISTICS\', \'PLG_STATISTICS_STATISTICS_DESC\')
, (NULL, 3, \'' . Uuid::uuid4() . '\', false, 101, false, \'statistics_editor\', \''.FOLDER_PLUGINS.'/'.$pluginFolder.'/gui/editor.php\', \'bi-gear-fill\', \'PLG_STATISTICS_STATISTICS_EDITOR\', \'PLG_STATISTICS_STATISTICS_EDITOR_DESC\')';
$gDb->query($sql);

}
2 changes: 1 addition & 1 deletion statistics.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/******************************************************************************
* Statistiken V 3.4.2 (kompatibel mit Admidio 4.1 and above)
* Statistiken V 3.5.0 (kompatibel mit Admidio 4.1 and above)
*
* Beta-Version
*
Expand Down
27 changes: 12 additions & 15 deletions utils/db_access.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/******************************************************************************
/**
* ****************************************************************************
* Hilsklasse zum Verwalten der Statistiken in der DB
*
* @copyright 2004-2021 The Admidio Team
Expand All @@ -23,25 +24,21 @@ class DBAccess {
public function __construct() {
global $gDb;

if ($this->pluginIsInstalled()) {
$this->tableStatistics = new TableAccess($gDb, TBL_STATISTICS, 'sta');
$this->tableTables = new TableAccess($gDb, TBL_TABLES, 'stt');
$this->tableColumns = new TableAccess($gDb, TBL_COLUMNS, 'stc');
$this->tableRows = new TableAccess($gDb, TBL_ROWS, 'str');
$this->pluginInstalled = true;
} else {
$this->pluginInstalled = false;
}
$this->tableStatistics = new TableAccess($gDb, TBL_STATISTICS, 'sta');
$this->tableTables = new TableAccess($gDb, TBL_TABLES, 'stt');
$this->tableColumns = new TableAccess($gDb, TBL_COLUMNS, 'stc');
$this->tableRows = new TableAccess($gDb, TBL_ROWS, 'str');
$this->pluginInstalled = true;
}

private function pluginIsInstalled(){
global $gDb;

$result = $gDb->query("SHOW TABLES LIKE '" . TBL_STATISTICS . '\'');
if ($result !== false && $result->rowCount() == 1)
return true;
} else {
return false;
$result = $gDb->query('SELECT 1 FROM ' . TBL_STATISTICS);
if ($result !== false && $result->rowCount() > 0) {
return true;
} else {
return false;
}
}

Expand Down

0 comments on commit ae9916e

Please sign in to comment.