Skip to content

Commit

Permalink
YCom Model Classes optional deaktivieren können
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w committed Feb 10, 2024
1 parent e78b309 commit c4f18a5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
}

rex_ycom::addTable(rex::getTablePrefix() . 'ycom_user');
rex_yform_manager_dataset::setModelClass(rex::getTablePrefix() . 'ycom_user', rex_ycom_user::class);
if(rex_config::get('ycom', 'auto_model_class') === true) {
rex_yform_manager_dataset::setModelClass(rex::getTablePrefix() . 'ycom_user', rex_ycom_user::class);
}

if (rex::isBackend() && ('index.php?page=content/edit' == rex_url::currentBackendPage() || 'mediapool' == rex_be_controller::getCurrentPagePart(1))) {
rex_view::addJsFile($this->getAssetsUrl('ycom_backend.js'));
Expand Down
3 changes: 3 additions & 0 deletions package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ requires:
system_plugins:
- auth
- group

default_config:
auto_model_class: "true"
24 changes: 24 additions & 0 deletions plugins/auth/pages/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$this->setConfig('login_field', stripslashes(str_replace('"', '', rex_request('login_field', 'string'))));
$this->setConfig('session_max_overall_duration', rex_request('session_max_overall_duration', 'int'));
$this->setConfig('session_duration', rex_request('session_duration', 'int'));
$this->setConfig('auto_model_class', rex_request('session_duration', 'bool'));

echo rex_view::success($this->i18n('ycom_auth_settings_updated'));
}
Expand Down Expand Up @@ -71,6 +72,14 @@
$sel_authcookiettl->addOption($this->i18n('ycom_days', 30), '30');
$sel_authcookiettl->addOption($this->i18n('ycom_days', 90), '90');

$sel_auto_model_class = new rex_select();
$sel_auto_model_class->setId('auto_model_class');
$sel_auto_model_class->setName('auto_model_class');
$sel_auto_model_class->setSize(1);
$sel_auto_model_class->addOption('Ja', '1');
$sel_auto_model_class->addOption('Nein', '0');
$sel_auto_model_class->setSelected($this->getConfig('auto_model_class'));

$content .= '
<form action="index.php" method="post" id="ycom_auth_settings">
<input type="hidden" name="page" value="ycom/auth/settings" />
Expand Down Expand Up @@ -200,6 +209,7 @@
</div>
</fieldset>
<fieldset>
<legend>' . $this->i18n('ycom_auth_config_security') . '</legend>
Expand Down Expand Up @@ -258,6 +268,20 @@
</fieldset>
<fieldset>
<legend>' . $this->i18n('ycom_auto_model_class') . '</legend>
<div class="row">
<div class="col-xs-12 col-sm-6">
' . $this->i18n('ycom_auto_model_class') . '
</div>
<div class="col-xs-12 col-sm-6">
<div class="select-style">
' . $sel_auto_model_class->get() . '
</div>
</div>
</div>
</fieldset>
<div class="row">
<div class="col-xs-12 col-sm-6 col-sm-push-6">
Expand Down
4 changes: 3 additions & 1 deletion plugins/group/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* @psalm-scope-this rex_addon
*/

rex_yform_manager_dataset::setModelClass(rex::getTablePrefix() . 'ycom_group', rex_ycom_group::class);
if(rex_config::get('ycom', 'auto_model_class') === true) {
rex_yform_manager_dataset::setModelClass(rex::getTablePrefix() . 'ycom_group', rex_ycom_group::class);
}
rex_ycom::addTable(rex::getTablePrefix() . 'ycom_group');

if (rex::isBackend()) {
Expand Down

0 comments on commit c4f18a5

Please sign in to comment.