* Sun Feb 09 2025 Brian Read <brianr@koozali.org> 11.0.0-50.sme

- Move all routines from FormMagic still called by SM2 panels to SM2 [SME:12906]
- delete all references to FormMagic
This commit is contained in:
Brian Read 2025-02-09 15:34:41 +00:00
parent 7ad224998c
commit a4668da720
13 changed files with 108 additions and 23 deletions

View File

@ -17,6 +17,7 @@ use Mojo::Home;
use DBM::Deep;
use Mojo::JWT;
use POSIX qw(strftime);
use Mojolicious::Plugin::Config;
#use Mojolicious::Plugin::I18N;
@ -27,8 +28,10 @@ use SrvMngr::Model::Main;
use SrvMngr::Plugin::WithoutCache;
use esmith::I18N;
#this is overwrittrn with the "release" by the spec file - release can be "99.el8.sme"
our $VERSION = '';
our $VERSION = '50.el8.sme';
#Extract the release value
if ($VERSION =~ /^(\d+)/) {
$VERSION = $1; # $1 contains the matched numeric digits
@ -43,6 +46,7 @@ our @EXPORT_OK = qw(
getNavigation ip_number is_normal_password email_simple
mac_address_or_blank mac_address ip_number_or_blank
lang_space get_routes_list subnet_mask get_reg_mask
gen_locale_date_string get_public_ip_address
);
has home => sub {
@ -784,6 +788,30 @@ sub is_normal_password {
}
}
sub gen_locale_date_string
{
my $self = shift;
my $i18n = esmith::I18N->new();
$i18n->setLocale('formmagick', $i18n->preferredLanguage());
return strftime "%c", localtime;
}
sub get_public_ip_address
{
my $self = shift;
my $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my $sysconfig = $cdb->get('sysconfig');
if ($sysconfig)
{
my $publicIP = $sysconfig->prop('PublicIP');
if ($publicIP)
{
return $publicIP;
}
}
return undef;
}
sub email_simple {
my ($c, $data) = @_;
@ -866,4 +894,4 @@ sub get_reg_mask {
}
1;
1;

View File

@ -14,7 +14,7 @@ use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use Text::Template;
use File::Basename;
use esmith::FormMagick qw( gen_locale_date_string );
use SrvMngr qw( gen_locale_date_string );
our $cdb = esmith::ConfigDB->open or die "Couldn't open ConfigDB\n";
# Get some basic info on the current SME install

View File

@ -12,8 +12,8 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use esmith::FormMagick;
use esmith::util;
use SrvMngr qw( gen_locale_date_string );
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
sub main {
@ -41,7 +41,7 @@ sub main {
# get rid of trailing carriage return on last field
chop($dat_datas{ampm});
$dat_datas{'now_string'} = esmith::FormMagick->gen_locale_date_string();
$dat_datas{'now_string'} = gen_locale_date_string;
$c->stash(title => $title, modul => $modul, dat_datas => \%dat_datas);
$c->render('datetime');
} ## end sub main

View File

@ -14,8 +14,6 @@ use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
#use esmith::util qw(ldapBase);
use esmith::FormMagick::Panel::directory;
our $db = esmith::ConfigDB->open() || die "Couldn't open config db";
sub main {
@ -75,4 +73,21 @@ sub do_update {
$c->stash(title => $title, modul => $result);
$c->render(template => 'module');
} ## end sub do_update
sub get_ldap_base {
return esmith::util::ldapBase(get_value('','DomainName'));
}
sub get_value {
my $fm = shift;
my $item = shift;
my $record = $db->get($item);
if ($record) {
return $record->value();
}
else {
return '';
}
}
1;

View File

@ -18,7 +18,6 @@ use esmith::AccountsDB;
use esmith::ConfigDB;
use esmith::DomainsDB;
#use esmith::FormMagick::Panel::ibays;
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
#our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($adb,$cdb);

View File

@ -14,7 +14,6 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use esmith::FormMagick::Panel::printers;
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my $adb;

View File

@ -10,7 +10,7 @@ package SrvMngr::Controller::Qmailanalog;
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use esmith::FormMagick qw(gen_locale_date_string);
use SrvMngr qw(gen_locale_date_string);
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);

View File

@ -11,9 +11,7 @@ package SrvMngr::Controller::Quota;
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use esmith::FormMagick::Panel::quota;
#use esmith::TestUtils;
use Scalar::Util qw(looks_like_number);
use Locale::gettext;
use SrvMngr::I18N;
@ -55,9 +53,9 @@ sub do_display {
if ($rec and $rec->prop('type') eq 'user') {
$quo_datas{user} = $user;
$quo_datas{userRec} = $rec;
my $max = esmith::FormMagick::Panel::quota->toBestUnit($rec->prop('MaxBlocks'));
my $max = $c->toBestUnit($rec->prop('MaxBlocks'));
$quo_datas{hardlim} = $max;
$max = esmith::FormMagick::Panel::quota->toBestUnit($rec->prop('MaxBlocksSoftLim'));
$max = $c->toBestUnit($rec->prop('MaxBlocksSoftLim'));
$quo_datas{softlim} = $max;
} ## end if ($rec and $rec->prop...)
} ## end if ($trt eq 'UPD')
@ -165,4 +163,48 @@ sub toMB
my ($self,$kb) = @_;
return sprintf("%.2f", $kb / 1024);
}
sub toMBNoDecimalPlaces
{
my ($self,$kb) = @_;
return sprintf("%.0f", $kb / 1024);
}
sub toGBNoDecimalPlaces
{
my ($self,$kb) = @_;
return sprintf("%.0f", $kb / 1024 / 1024);
}
sub toKB
{
my ($self,$mb) = @_;
return sprintf("%.0f", $mb * 1024);
}
sub GBtoKB
{
my ($self,$gb) = @_;
return sprintf("%.0f", $gb * 1024 * 1024);
}
sub MBtoKB
{
my ($self,$mb) = @_;
return sprintf("%.0f", $mb * 1024);
}
sub toBestUnit
{
my ($self,$kb) = @_;
return 0 if($kb == 0);
return $kb."K" if($kb < 1024);
return $kb."K" if($kb > 1024 && $kb < 1048576 && $kb % 1024 != 0);
return $self->toMBNoDecimalPlaces($kb)."M" if($kb < 1048576);
return $self->toMBNoDecimalPlaces($kb)."M" if($kb > 1048576
&& ($kb % 1048576 != 0));
return $self->toGBNoDecimalPlaces($kb)."G";
}
1

View File

@ -17,10 +17,11 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use SrvMngr qw(gen_locale_date_string);
#use SrvMngr::Review_sub qw(print_page);
#use smeserver::Panel::review;
use esmith::FormMagick::Panel::review;
our $db = esmith::ConfigDB->open_ro || die "Couldn't open config db";
our $domains = esmith::DomainsDB->open_ro || die "Couldn't open domains";
our $networks = esmith::NetworksDB->open_ro || die "Couldn't open networks";
@ -33,7 +34,7 @@ sub main {
my %rvw_datas = ();
$rvw_datas{'servermode'} = (get_value('', 'SystemMode') || '');
$rvw_datas{'localip'} = get_value('$c', 'LocalIP') . '/' . get_value('$c', 'LocalNetmask');
$rvw_datas{'publicip'} = esmith::FormMagick::Panel::review->get_public_ip_address($c);
$rvw_datas{'publicip'} = $c->get_public_ip_address($c);
$rvw_datas{'gateway'} = $c->render_to_string(inline => print2_gateway_stanza($c));
$rvw_datas{'serveronly'} = $c->render_to_string(inline => print2_serveronly_stanza($c));
$rvw_datas{'addlocalnetworks'} = get_local_networks($c);

View File

@ -12,15 +12,13 @@ use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
#use esmith::FormMagick qw(gen_locale_date_string);
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use esmith::ConfigDB;
#use Time::TAI64;
use File::Basename;
use HTML::Entities;
use esmith::FormMagick qw(gen_locale_date_string);
use SrvMngr qw(gen_locale_date_string);
use File::Temp qw(tempfile);
use constant TRUE => 1;
use constant FALSE => 0;
@ -295,4 +293,4 @@ sub download_logFile {
);
return undef;
} ## end sub download_logFile
1;
1;

View File

@ -13,7 +13,6 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use esmith::FormMagick::Panel::workgroup;
our $db = esmith::ConfigDB->open || die "Couldn't open config db";
sub main {

View File

@ -64,7 +64,7 @@
% </a>
%};
%my $remove_text = l('REMOVE'); # Localized text
%my $csrf_token = "TOKEN"; # CSRF token for security
%$csrf_token = "TOKEN"; # CSRF token for security
%#my $hostentries_name = $_->{'HostName'}; # hostentries name extracted from the data structure
%$actionRemove = qq{
% <a href="hostentriesd?CsrfDef=$csrf_token&trt=DEL&Hostname=$hostentries_name">

View File

@ -2,7 +2,7 @@ Summary: Sme server navigation module : manager 2
%define name smeserver-manager
Name: %{name}
%define version 11.0.0
%define release 49
%define release 50
Version: %{version}
Release: %{release}%{?dist}
License: GPL
@ -143,6 +143,10 @@ true
%defattr(-,root,root)
%changelog
* Sun Feb 09 2025 Brian Read <brianr@koozali.org> 11.0.0-50.sme
- Move all routines from FormMagic still called by SM2 panels to SM2 [SME:12906]
- delete all references to FormMagic
* Fri Feb 07 2025 Brian Read <brianr@koozali.org> 11.0.0-49.sme
- Fix delete of ibay - typo in link
- Move across toMB() sub from formmagick to quota.pm