add date/datetime input fields to relevant formfields
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
namespace Froxlor\Ajax;
|
||||
|
||||
use Exception;
|
||||
use DateTime;
|
||||
use Froxlor\Config\ConfigDisplay;
|
||||
use Froxlor\Config\ConfigParser;
|
||||
use Froxlor\CurrentUser;
|
||||
@@ -233,7 +234,7 @@ class Ajax
|
||||
{
|
||||
$keyid = isset($_POST['id']) ? (int)$_POST['id'] : 0;
|
||||
$allowed_from = isset($_POST['allowed_from']) ? $_POST['allowed_from'] : "";
|
||||
$valid_until = isset($_POST['valid_until']) ? (int)$_POST['valid_until'] : -1;
|
||||
$valid_until = isset($_POST['valid_until']) ? $_POST['valid_until'] : "";
|
||||
|
||||
// validate allowed_from
|
||||
if (!empty($allowed_from)) {
|
||||
@@ -260,8 +261,10 @@ class Ajax
|
||||
$allowed_from = implode(",", array_unique($ip_list));
|
||||
}
|
||||
|
||||
if ($valid_until <= 0 || !is_numeric($valid_until)) {
|
||||
$valid_until = -1;
|
||||
if (!empty($valid_until)) {
|
||||
$valid_until_db = DateTime::createFromFormat('Y-m-d\TH:i', $valid_until)->format('U');
|
||||
} else {
|
||||
$valid_until_db = -1;
|
||||
}
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
@@ -277,7 +280,7 @@ class Ajax
|
||||
Database::pexecute($upd_stmt, [
|
||||
'keyid' => $keyid,
|
||||
'af' => $allowed_from,
|
||||
'vu' => $valid_until,
|
||||
'vu' => $valid_until_db,
|
||||
'aid' => $this->userinfo['adminid'],
|
||||
'cid' => $cid
|
||||
]);
|
||||
|
||||
@@ -403,7 +403,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$documentroot = $_documentroot;
|
||||
}
|
||||
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -412,7 +412,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$registration_date = null;
|
||||
}
|
||||
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -1291,7 +1291,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$adminid = $result['adminid'];
|
||||
}
|
||||
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$registration_date = Validate::validate($registration_date, 'registration_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
@@ -1299,7 +1299,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
if ($registration_date == '0000-00-00' || empty($registration_date)) {
|
||||
$registration_date = null;
|
||||
}
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', '', [
|
||||
$termination_date = Validate::validate($termination_date, 'termination_date', Validate::REGEX_YYYY_MM_DD, '', [
|
||||
'0000-00-00',
|
||||
'0',
|
||||
''
|
||||
|
||||
@@ -43,6 +43,8 @@ class Validate
|
||||
|
||||
const REGEX_DESC_TEXT = '/^[^\0\r\n<>]*$/';
|
||||
|
||||
const REGEX_YYYY_MM_DD = '/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/';
|
||||
|
||||
/**
|
||||
* Validates the given string by matching against the pattern, prints an error on failure and exits
|
||||
*
|
||||
|
||||
@@ -75,19 +75,20 @@ return [
|
||||
'add_date' => [
|
||||
'label' => lng('domains.add_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'label',
|
||||
'type' => 'date',
|
||||
'readonly' => true,
|
||||
'value' => date('Y-m-d')
|
||||
],
|
||||
'registration_date' => [
|
||||
'label' => lng('domains.registration_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'text',
|
||||
'type' => 'date',
|
||||
'size' => 10
|
||||
],
|
||||
'termination_date' => [
|
||||
'label' => lng('domains.termination_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'text',
|
||||
'type' => 'date',
|
||||
'size' => 10
|
||||
]
|
||||
]
|
||||
|
||||
@@ -86,20 +86,21 @@ return [
|
||||
'add_date' => [
|
||||
'label' => lng('domains.add_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'label',
|
||||
'type' => 'date',
|
||||
'readonly' => true,
|
||||
'value' => date('Y-m-d', (int)$result['add_date'])
|
||||
],
|
||||
'registration_date' => [
|
||||
'label' => lng('domains.registration_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'text',
|
||||
'type' => 'date',
|
||||
'value' => $result['registration_date'],
|
||||
'size' => 10
|
||||
],
|
||||
'termination_date' => [
|
||||
'label' => lng('domains.termination_date'),
|
||||
'desc' => lng('panel.dateformat'),
|
||||
'type' => 'text',
|
||||
'type' => 'date',
|
||||
'value' => $result['termination_date'],
|
||||
'size' => 10
|
||||
]
|
||||
|
||||
@@ -58,9 +58,8 @@ return [
|
||||
'title' => lng('apikeys.valid_until'),
|
||||
'description' => lng('apikeys.valid_until_help')
|
||||
],
|
||||
/** @TODO datetime-picker */
|
||||
'type' => 'text',
|
||||
'value' => $result['valid_until'] < 0 ? "" : $result['valid_until']
|
||||
'type' => 'datetime-local',
|
||||
'value' => $result['valid_until'] < 0 ? "" : date('Y-m-d\TH:i', $result['valid_until'])
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -465,7 +465,7 @@ return [
|
||||
'allowed_from' => 'Erlaube Zugriff von',
|
||||
'allowed_from_help' => 'Komma getrennte Liste von IPs oder Netzen.<br>Standard ist leer (von überall erlaubt).',
|
||||
'valid_until' => 'Gültig bis',
|
||||
'valid_until_help' => 'Datum Gültigkeitsende, Format JJJJ-MM-TT',
|
||||
'valid_until_help' => 'Datum Gültigkeitsende, Format YYYY-MM-DDThh:mm',
|
||||
],
|
||||
'changepassword' => [
|
||||
'old_password' => 'Altes Passwort',
|
||||
@@ -1104,7 +1104,7 @@ Vielen Dank, Ihr Administrator',
|
||||
'send' => 'Versenden',
|
||||
'nosslipsavailable' => 'Für diesen Server wurden noch keine SSL IP/Port Kombinationen eingetragen',
|
||||
'backtooverview' => 'Zurück zur Übersicht',
|
||||
'dateformat' => 'JJJJ-MM-TT',
|
||||
'dateformat' => 'TT.MM.JJJJ',
|
||||
'dateformat_function' => 'd.m.Y',
|
||||
'timeformat_function' => 'H:i:s',
|
||||
'default' => 'Standard',
|
||||
|
||||
@@ -506,7 +506,7 @@ return [
|
||||
'allowed_from' => 'Allowed from',
|
||||
'allowed_from_help' => 'Comma separated list of ip addresses / networks.<br>Default is empty (allow from all).',
|
||||
'valid_until' => 'Valid until',
|
||||
'valid_until_help' => 'Date until valid, format YYYY-MM-DD',
|
||||
'valid_until_help' => 'Date until valid, format YYYY-MM-DDThh:mm',
|
||||
],
|
||||
'changepassword' => [
|
||||
'old_password' => 'Old password',
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{% endif %}
|
||||
<div class="col-sm-8">
|
||||
{% endif %}
|
||||
{% if field.type == 'text' or field.type == 'password' or field.type == 'number' or field.type == 'file' or field.type == 'email' or field.type == 'url' or field.type == 'hidden' %}
|
||||
{% if field.type == 'text' or field.type == 'password' or field.type == 'number' or field.type == 'file' or field.type == 'email' or field.type == 'url' or field.type == 'hidden' or field.type == 'date' or field.type == 'datetime-local' %}
|
||||
{{ _self.input(id, field) }}
|
||||
{% elseif field.type == 'textul' %}
|
||||
{{ _self.input_ul(id, field) }}
|
||||
|
||||
Reference in New Issue
Block a user