move customsql back to admin and turn it into an app

This commit is contained in:
nobody 2022-05-03 15:36:46 -07:00
parent 48e1ae73ea
commit 2a6734fa96
4 changed files with 17 additions and 4 deletions

View file

@ -362,6 +362,7 @@ class Apps
'Connections' => t('Connections'),
'Content Filter' => t('Content Filter'),
'Content Import' => t('Content Import'),
'Custom SQL' => t('Custom SQL'),
'Directory' => t('Directory'),
'Drafts' => t('Drafts'),
'Events' => t('Events'),

View file

@ -1,9 +1,10 @@
<?php
namespace Code\Module\Dev;
namespace Code\Module\Admin;
use Code\Render\Theme;
use Code\Lib\Apps;
class Customsql
@ -20,6 +21,11 @@ class Customsql
return;
}
if (!Apps::system_app_installed(local_channel(), 'Custom SQL')) {
$text = t('Once installed, this app provides an admin-only interface to execute arbitrary SQL statements.');
return '<div class="section-content-info-wrapper">' . $text . '</div>';
}
$query = [ 'query', 'Enter an SQL query', '', '' ];
$ok = [ 'ok', 'OK to show all results?', '', '' ];
@ -27,13 +33,13 @@ class Customsql
'$title' => t('Custom SQL query'),
'$warn' => t('If you do not know exactly what you are doing, please leave this page now.'),
'$query' => $query,
'$form_security_token' => get_form_security_token('dev_customsql'),
'$form_security_token' => get_form_security_token('admin_customsql'),
'$ok' => $ok,
'$submit' => t('Submit')
]);
if (isset($_REQUEST['query']) && $_REQUEST['query']) {
check_form_security_token_redirectOnErr('/dev/customsql', 'dev_customsql');
check_form_security_token_redirectOnErr('/admin/customsql', 'admin_customsql');
$o .= EOL . EOL;
$r = q($_REQUEST['query']);
if (is_array($r) && count($r) > 500 && !isset($_REQUEST['ok'])) {

6
app/customsql.apd Normal file
View file

@ -0,0 +1,6 @@
version: 1
url: $baseurl/admin/customsql
requires: admin
name: Custom SQL
photo: icon:mysql
categories: System,nav_featured_app

View file

@ -3,7 +3,7 @@
<div class="section-content-wrapper">
<div class="descriptive_text">{{$warn}}</div>
<br><br>
<form action="dev/customsql" method="post">
<form action="admin/customsql" method="post">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
{{include file="field_textarea.tpl" field=$query}}
{{include file="field_checkbox.tpl" field=$ok}}