Skip to content

Commit

Permalink
Merge pull request #21 from FriendsOfREDAXO/live-mode
Browse files Browse the repository at this point in the history
Berücksichtigt den "live-mode"
  • Loading branch information
christophboecker authored Mar 11, 2024
2 parents 29786b8 + dba76c2 commit a7975eb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Das Kommendo wird nicht ausgeführt, nur angezeigt
- `YFormAdminer::dbEdit($table_name,$data_id)`
Ruft die edit-Maske für den angegebenen Datensatz der Tabelle im Adminer auf.
- im Live-Mode deaktiviert

## **09.03.2023 1.3.0**

Expand Down
7 changes: 6 additions & 1 deletion boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
use rex_addon;
use rex_perm;

// nicht im live-Mode ausführen
if (true === rex::getProperty('live_mode', false)) {
return;
}

rex_perm::register('yform_adminer[]');

if( rex::isBackend()) {
if (rex::isBackend()) {
$user = rex::getUser();
if (null !== $user && $user->hasPerm('yform_adminer[]') && rex_addon::get('yform')->isAvailable() && rex_addon::get('adminer')->isAvailable()) {
YFormAdminer::init();
Expand Down
30 changes: 29 additions & 1 deletion lib/YFormAdminer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class YFormAdminer
*/
public static function init(): void
{
if (true === rex::getProperty('live_mode', false)) {
return;
}

// Vorbereitung: Query ermitteln
rex_extension::register('YFORM_DATA_LIST_QUERY', self::YFORM_DATA_LIST_QUERY(...), rex_extension::LATE);

Expand Down Expand Up @@ -71,6 +75,9 @@ public static function init(): void
*/
public static function YFORM_DATA_LIST_QUERY(rex_extension_point $ep): void
{
if (true === rex::getProperty('live_mode', false)) {
return;
}
$query = $ep->getSubject();
$label = md5(__CLASS__ . $query->getTableName());
self::$query[$label] = $query;
Expand All @@ -83,7 +90,7 @@ public static function YFORM_DATA_LIST_QUERY(rex_extension_point $ep): void
*/
public static function YFORM_DATA_LIST_LINKS(rex_extension_point $ep): void
{
if (true === $ep->getParam('popup')) {
if (true === $ep->getParam('popup') || true === rex::getProperty('live_mode', false)) {
return;
}
$links = $ep->getSubject();
Expand Down Expand Up @@ -155,6 +162,10 @@ public static function YFORM_DATA_LIST_LINKS(rex_extension_point $ep): void
*/
public static function YFORM_DATA_LIST_ACTION_BUTTONS(rex_extension_point $ep): void
{
if (true === rex::getProperty('live_mode', false)) {
return;
}

/** @var rex_yform_manager_table $table */
$table = $ep->getParam('table');
$buttons = $ep->getSubject();
Expand Down Expand Up @@ -222,6 +233,10 @@ public static function YFORM_DATA_LIST_ACTION_BUTTONS(rex_extension_point $ep):
*/
public static function TF_REX_LIST_GET(rex_extension_point $ep): void
{
if (true === rex::getProperty('live_mode', false)) {
return;
}

/** @var rex_yform_list $list */
$list = $ep->getSubject();
$page = $list->getParams()['page'] ?? '';
Expand Down Expand Up @@ -251,6 +266,10 @@ public static function TF_REX_LIST_GET(rex_extension_point $ep): void
*/
public static function TE_REX_LIST_GET(rex_extension_point $ep): void
{
if (true === rex::getProperty('live_mode', false)) {
return;
}

/** @var rex_yform_list $list */
$list = $ep->getSubject();
$page = $list->getParams()['page'] ?? '';
Expand Down Expand Up @@ -314,6 +333,9 @@ protected static function baseUrl(array $params = []): string
*/
public static function dbTable(string $tablename, array $where = []): string
{
if (true === rex::getProperty('live_mode', false)) {
return '';
}
$params = [
'select' => $tablename,
];
Expand All @@ -331,6 +353,9 @@ public static function dbTable(string $tablename, array $where = []): string
*/
public static function dbSql(string $query): string
{
if (true === rex::getProperty('live_mode', false)) {
return '';
}
return self::baseUrl(
[
'sql' => $query,
Expand All @@ -353,6 +378,9 @@ protected static function YformField(): string
*/
public static function dbEdit(string $tablename, int|string $id): string
{
if (true === rex::getProperty('live_mode', false)) {
return '';
}
return self::baseUrl(
[
'edit' => $tablename,
Expand Down

0 comments on commit a7975eb

Please sign in to comment.