mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:35:12 +00:00
move customsql back to admin and turn it into an app
This commit is contained in:
parent
48e1ae73ea
commit
2a6734fa96
4 changed files with 17 additions and 4 deletions
|
@ -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'),
|
||||
|
|
|
@ -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
6
app/customsql.apd
Normal file
|
@ -0,0 +1,6 @@
|
|||
version: 1
|
||||
url: $baseurl/admin/customsql
|
||||
requires: admin
|
||||
name: Custom SQL
|
||||
photo: icon:mysql
|
||||
categories: System,nav_featured_app
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in a new issue