Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion classes/configtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ public function write(): void
*/
public function read(): bool
{
return $this->readConfigData(self::SHORTCUT, $this->config);
try {
return $this->readConfigData(self::SHORTCUT, $this->config);
} catch (Exception $e) {
return false;
}
}

/**
Expand Down
26 changes: 25 additions & 1 deletion classes/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,25 @@
* sendNotification($importData = null) : Sends a notification to all users that have the right to see the item
***********************************************************************************************
*/

// compatibility for Admidio 5.0 ->
if(file_exists(__DIR__ . '/../../../system/bootstrap/constants.php')) {
require_once(__DIR__ . '/../../../system/bootstrap/constants.php');
} else {
require_once(__DIR__ . '/../../../adm_program/system/bootstrap/constants.php');
}
require_once(__DIR__ . '/configtable.php');

// classes for Admidio 5.0
if (!version_compare(ADMIDIO_VERSION, '5.0', '<')) {
class_alias(Admidio\Infrastructure\Database::class, Database::class);
class_alias(Admidio\Infrastructure\Image::class, Image::class);
class_alias(Admidio\Infrastructure\Language::class, Language::class);
class_alias(Admidio\Infrastructure\Utils\StringUtils::class, StringUtils::class);
class_alias(Admidio\Infrastructure\Entity\Entity::class, TableAccess::class);
class_alias(Admidio\Infrastructure\Email::class, Email::class);
}
// <- compatibility for Admidio 5.0
class CItems
{
public array $mItemFields = array(); ///< Array with all item fields objects
Expand Down Expand Up @@ -797,7 +814,14 @@ public function setValue(string $fieldNameIntern, $newValue): bool

$returnCode = $this->mItemData[$imfId]->setValue('imd_value', $newValue);

if ($returnCode && $gSettingsManager->getBool('profile_log_edit_fields')) {
if ($gSettingsManager->has('profile_log_edit_fields')) {
// check if logging of profile field changes is enabled
$loggingEnabled = $gSettingsManager->getBool('profile_log_edit_fields');
} else {
$loggingEnabled = $gSettingsManager->getBool('changelog_module_enabled');
}

if ($returnCode && $loggingEnabled) {
$logEntry = new TableAccess($this->mDb, TBL_INVENTORY_MANAGER_LOG, 'iml');
$logEntry->setValue('iml_imi_id', $this->mItemId);
$logEntry->setValue('iml_imf_id', $imfId);
Expand Down
20 changes: 19 additions & 1 deletion common_function.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,25 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Fill;

require_once(__DIR__ . '/../../adm_program/system/common.php');
// compatibility for Admidio 5.0 ->
if (file_exists(__DIR__ . '/../../system/common.php')) {
require_once(__DIR__ . '/../../system/common.php');
}else {
require_once(__DIR__ . '/../../adm_program/system/common.php');
}
if(file_exists(__DIR__ . '/../../system/bootstrap/constants.php')) {
require_once(__DIR__ . '/../../system/bootstrap/constants.php');
} else {
require_once(__DIR__ . '/../../adm_program/system/bootstrap/constants.php');
}

// classes for Admidio 5.0
if (!version_compare(ADMIDIO_VERSION, '5.0', '<')) {
class_alias(Admidio\Components\Entity\Component::class, Component::class);
class_alias(Admidio\Roles\Entity\RolesRights::class, RolesRights::class);
class_alias(Admidio\Menu\ValueObject\MenuNode::class, MenuNode::class);
}
// <- compatibility for Admidio 5.0

// Define necessary constants if not already defined
defineConstantsPIM();
Expand Down
122 changes: 117 additions & 5 deletions inventory_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,34 @@
use PhpOffice\PhpSpreadsheet\Writer\Ods;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

require_once(__DIR__ . '/../../adm_program/system/common.php');
// compatibility for Admidio 5.0 ->
if (file_exists(__DIR__ . '/../../system/common.php')) {
require_once(__DIR__ . '/../../system/common.php');
}else {
require_once(__DIR__ . '/../../adm_program/system/common.php');
}
if(file_exists(__DIR__ . '/../../system/bootstrap/constants.php')) {
require_once(__DIR__ . '/../../system/bootstrap/constants.php');
} else {
require_once(__DIR__ . '/../../adm_program/system/bootstrap/constants.php');
}
require_once(__DIR__ . '/common_function.php');
require_once(__DIR__ . '/classes/items.php');
require_once(__DIR__ . '/classes/configtable.php');

// Access only with valid login
require_once(__DIR__ . '/../../adm_program/system/login_valid.php');
if (file_exists(__DIR__ . '/../../system/login_valid.php')) {
require_once(__DIR__ . '/../../system/login_valid.php');
} else {
require_once(__DIR__ . '/../../adm_program/system/login_valid.php');
}

// classes for Admidio 5.0
if (!version_compare(ADMIDIO_VERSION, '5.0', '<')) {
class_alias(Admidio\Infrastructure\Utils\SecurityUtils::class, SecurityUtils::class);
class_alias(Admidio\Users\Entity\User::class, User::class);
class_alias(Admidio\Infrastructure\Utils\FileSystemUtils::class, FileSystemUtils::class);
}
// <- compatibility for Admidio 5.0
//$scriptName is the name as it must be entered in the menu, without any preceding folders such as /playground/adm_plugins/InventoryManager...
$scriptName = substr($_SERVER['SCRIPT_NAME'], strpos($_SERVER['SCRIPT_NAME'], FOLDER_PLUGINS));

Expand All @@ -75,7 +95,93 @@

// check if plugin need to be updated
$pPreferences = new CConfigTablePIM();
$pPreferences->checkForUpdate() ? $pPreferences->init() : $pPreferences->read();
// check if installed admidio version is compatible with this plugin version
if (version_compare(ADMIDIO_VERSION, '5.0.0', '<')) {
$pPreferences->checkForUpdate() ? $pPreferences->init() : $pPreferences->read();
} else {
// We are in Version 5.0.0 or higher so the plugin is not compatible anymore
// But we need the preferences to get the export filename
if (!$pPreferences->read()) {
$gMessage->show($gL10n->get('PLG_INVENTORY_MANAGER_V5_NO_DATA', array('<a href="' . ADMIDIO_URL . FOLDER_MODULES . '/inventory.php">' . $gL10n->get('SYS_INVENTORY') . '</a>')));
}

$exportMode = (admFuncVariableIsValid($_GET, 'mode', 'string', array('defaultValue' => 'html', 'validValues' => array('csv-ms', 'csv-oo', 'html', 'print', 'pdf', 'pdfl', 'xlsx', 'ods'))) === 'html') ? false : true;

if (!$exportMode) {
$gNavigation->addStartUrl(CURRENT_URL, $gL10n->get('PLG_INVENTORY_MANAGER_INVENTORY_MANAGER'), 'bi-box-seam');
$page = new HtmlPage('plg-inventory-manager-deprecated');
$page->setTitle($gL10n->get('PLG_INVENTORY_MANAGER_INVENTORY_MANAGER'));
$page->setHeadline($gL10n->get('PLG_INVENTORY_MANAGER_INVENTORY_MANAGER'));

$content = '
<div class="alert alert-warning" role="alert">
<h4 class="alert-heading">' . $gL10n->get('PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE') . '</h4>
<p>' . $gL10n->get('PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT') . '</p>
<hr>
<p' . $gL10n->get('PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT2') . '</p>
';

// add export dropdown menu
$content .= '
<div class="d-flex justify-content-center">
<div class="mb-3 d-flex justify-content-center gap-2">
<a class="btn btn-primary" href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/inventory_manager.php', array(
'filter_string' => '',
'filter_category' => '',
'filter_keeper' => 0,
'show_all' => true,
'mode' => 'xlsx'
)) . '">
<i class="fas fa-file-excel"></i>' . $gL10n->get('SYS_MICROSOFT_EXCEL') . ' (*.xlsx)
</a>
<a class="btn btn-primary" href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/inventory_manager.php', array(
'filter_string' => '',
'filter_category' => '',
'filter_keeper' => 0,
'show_all' => true,
'mode' => 'ods'
)) .'">
<i class="fas fa-file-alt"></i>' . $gL10n->get('SYS_ODF_SPREADSHEET') . '
</a>
<a class="btn btn-primary" href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/inventory_manager.php', array(
'filter_string' => '',
'filter_category' => '',
'filter_keeper' => 0,
'show_all' => true,
'mode' => 'csv-ms'
)) . '">
<i class="fas fa-file-csv"></i>' . $gL10n->get('SYS_COMMA_SEPARATED_FILE') . '
</a>
<a class="btn btn-primary" href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/inventory_manager.php', array(
'filter_string' => '',
'filter_category' => '',
'filter_keeper' => 0,
'show_all' => true,
'mode' => 'csv-oo'
)) . '">
<i class="fas fa-file-csv"></i>' . $gL10n->get('SYS_COMMA_SEPARATED_FILE') . ' (' . $gL10n->get('SYS_UTF8') . ')
</a>
</div>
</div>';
$content .= '
<hr>
<p>' . $gL10n->get('PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT3') . '</p>
<div class="d-flex justify-content-center">';
// add deinstallation button
$formDeinstallation = new HtmlForm('deinstallation_form', SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/preferences/preferences_function.php', array('mode' => 2)), $page);
$formDeinstallation->addSubmitButton('btn_perform_deinstallation', $gL10n->get('PLG_INVENTORY_MANAGER_DEINSTALLATION'), array('icon' => 'bi-trash'));
$content .= $formDeinstallation->show();
$content .= '</div>';

$content .= '<hr>
<p>' . $gL10n->get('PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT4', array('<a href="https://www.admidio.org/forum/index.php">Admidio Forum</a>', '<a href="https://github.com/Admidio/admidio/issues">Issue</a>')) . '</p>';
$content .= '</div>';
$page->addHtml($content);
$page->show();
exit();
}
}

$disableBorrowing = $pPreferences->config['Optionen']['disable_borrowing'];

// check if user is authorized for preferences panel
Expand Down Expand Up @@ -631,8 +737,14 @@
if ($getMode == 'html') {
$tempValue = '';

if ($gSettingsManager->has('profile_log_edit_fields')) {
// check if logging of profile field changes is enabled
$loggingEnabled = $gSettingsManager->getBool('profile_log_edit_fields');
} else {
$loggingEnabled = $gSettingsManager->getBool('changelog_module_enabled');
}
// show link to view profile field change history
if ($gSettingsManager->getBool('profile_log_edit_fields')) {
if ($loggingEnabled) {
$tempValue .= '
<a class="admidio-icon-link" href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/items/items_history.php', array('item_id' => $item['imi_id'])) . '">
<i class="fas fa-history" title="' . $gL10n->get('SYS_CHANGE_HISTORY') . '"></i>
Expand Down
6 changes: 6 additions & 0 deletions languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
<string name="PLG_INVENTORY_MANAGER_PLUGIN_DATE">Stand</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_INFORMATION">Plugininformationen</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NAME">Name des Plugins</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE">Die Inventarverwaltung ist nicht kompatibel mit dieser Version von Admidio</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT">Vielen Dank, dass Sie das Plugin Inventarverwaltung nutzen!\n\nObwohl es erst kürzlich veröffentlicht wurde, hat sich das Plugin bereits für viele Nutzer als sehr hilfreich erwiesen. Da es schon lange eine Nachfrage nach einem integrierten Inventarverwaltungssystem in Admidio gab, wurde das Plugin nun in ein neues Inventar-Modul innerhalb von Admidio integriert.\n\nBitte beachten Sie, dass das neue Modul möglicherweise noch nicht alle Funktionen des Plugins umfasst, aber im Laufe der Zeit weiter verbessert und erweitert wird.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT2">Unten können Sie Ihre vorhandenen Daten aus der Inventarverwaltung exportieren und anschließend in das neue Inventar-Modul von Admidio importieren.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT3">Nachdem Sie Ihre Daten erfolgreich migriert haben, deinstallieren Sie bitte das Plugin Inventarverwaltung unten, um Konflikte mit dem neuen Inventar-Modul zu vermeiden.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT4">Wenn Sie Fragen oder Probleme haben, kontaktieren Sie uns gerne im #VAR1# oder eröffnen Sie ein #VAR2# auf GitHub.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_VERSION">Version</string>
<string name="PLG_INVENTORY_MANAGER_PROFILE_ADDIN">Einstellungen für die Profilansicht</string>
<string name="PLG_INVENTORY_MANAGER_PROFILE_ADDIN_DESC">In der Profilansicht eines Mitglieds können ausgegebene Gegenstände angezeigt werden. Standardmäßig wird nur der Gegenstandsname angezeigt. Hier können Sie, zusätzlich zum Gegenstandsnamen, weitere Eigenschaftsfelder auswählen und anzeigen lassen.</string>
Expand All @@ -110,6 +115,7 @@
<string name="PLG_INVENTORY_MANAGER_USE_CURRENT_USER">aktueller Benutzer als Standardauswahl</string>
<string name="PLG_INVENTORY_MANAGER_USE_CURRENT_USER_DESC">Soll der aktuelle Benutzer beim Hinzufügen neuer Gegenstände standardmäßig als Verwalter voreingestellt werden, so ist der Haken zu setzen.</string>
<string name="PLG_INVENTORY_MANAGER_USING_CURRENT_VERSION">Sie benutzten eine aktuelle #VAR1#Version von InventoryManager!</string>
<string name="PLG_INVENTORY_MANAGER_V5_NO_DATA">Dieses Plugin ist nicht kompatibel mit Version 5 von Admidio. Es sind keine Daten aus einer vorherigen Version der Inventarverwaltung zum Export verfügbar.\n\nBitte entfernen Sie die Plugin-Dateien aus Ihrer Admidio-Installation und verwenden Sie das neue Inventar-Modul, das in Admidio Version 5 implementiert wurde. (#VAR1#)</string>
<!-- Phrases only in Database -->
<string name="PIM_CATEGORY">Kategorie</string>
<string name="PIM_CATEGORY_DESCRIPTION">Die Kategorie des Gegenstandes</string>
Expand Down
6 changes: 6 additions & 0 deletions languages/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
<string name="PLG_INVENTORY_MANAGER_PLUGIN_DATE">Stand</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_INFORMATION">Plugininformationen</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NAME">Name des Plugins</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE">Die Inventarverwaltung ist nicht kompatibel mit dieser Version von Admidio</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT">Vielen Dank, dass du das Plugin Inventarverwaltung nutzt!\n\nObwohl es erst kürzlich veröffentlicht wurde, hat sich das Plugin bereits für viele Nutzer als sehr hilfreich erwiesen. Da es schon lange eine Nachfrage nach einem integrierten Inventarverwaltungssystem in Admidio gab, wurde das Plugin nun in ein neues Inventar-Modul innerhalb von Admidio integriert.\n\nBitte beachte, dass das neue Modul möglicherweise noch nicht alle Funktionen des Plugins umfasst, aber im Laufe der Zeit weiter verbessert und erweitert wird.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT2">Unten kannst du deine vorhandenen Daten aus der Inventarverwaltung exportieren und anschließend in das neue Inventar-Modul von Admidio importieren.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT3">Nachdem du deine Daten erfolgreich migriert hast, deinstalliere bitte das Plugin Inventarverwaltung unten, um Konflikte mit dem neuen Inventar-Modul zu vermeiden.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_NOT_COMPATIBLE_TEXT4">Wenn du Fragen oder Probleme hast, kontaktiere uns gerne im #VAR1# oder eröffne ein #VAR2# auf GitHub.</string>
<string name="PLG_INVENTORY_MANAGER_PLUGIN_VERSION">Version</string>
<string name="PLG_INVENTORY_MANAGER_PROFILE_ADDIN">Einstellungen für die Profilansicht</string>
<string name="PLG_INVENTORY_MANAGER_PROFILE_ADDIN_DESC">In der Profilansicht eines Mitglieds können ausgegebene Gegenstände angezeigt werden. Standardmäßig wird nur der Gegenstandsname angezeigt. Hier kannst du, zusätzlich zum Gegenstandsnamen, weitere Eigenschaftsfelder auswählen und anzeigen lassen.</string>
Expand All @@ -110,6 +115,7 @@
<string name="PLG_INVENTORY_MANAGER_USE_CURRENT_USER">aktueller Benutzer als Standardauswahl</string>
<string name="PLG_INVENTORY_MANAGER_USE_CURRENT_USER_DESC">Soll der aktuelle Benutzer beim Hinzufügen neuer Gegenstände standardmäßig als Verwalter voreingestellt werden, so ist der Haken zu setzen.</string>
<string name="PLG_INVENTORY_MANAGER_USING_CURRENT_VERSION">Du benutzt eine aktuelle #VAR1#Version von InventoryManager!</string>
<string name="PLG_INVENTORY_MANAGER_V5_NO_DATA">Dieses Plugin ist nicht kompatibel mit Version 5 von Admidio. Es sind keine Daten aus einer vorherigen Version der Inventarverwaltung zum Export verfügbar.\n\nBitte entferne die Plugin-Dateien aus deiner Admidio-Installation und verwenden das neue Inventar-Modul, das in Admidio Version 5 implementiert wurde. (#VAR1#)</string>
<!-- Phrases only in Database -->
<string name="PIM_CATEGORY">Kategorie</string>
<string name="PIM_CATEGORY_DESCRIPTION">Die Kategorie des Gegenstandes</string>
Expand Down
Loading