1 |
michel |
1.1 |
diff -urN smeserver-manager-0.1.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Datetime.pm smeserver-manager-0.1.0/root/usr/share/smanager/lib/SrvMngr/Controller/Datetime.pm |
2 |
|
|
--- smeserver-manager-0.1.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Datetime.pm 2020-07-01 16:03:45.268785684 +0200 |
3 |
|
|
+++ smeserver-manager-0.1.0/root/usr/share/smanager/lib/SrvMngr/Controller/Datetime.pm 2020-07-05 19:59:27.000000000 +0200 |
4 |
|
|
@@ -17,7 +17,7 @@ |
5 |
|
|
use SrvMngr qw(theme_list init_session); |
6 |
|
|
|
7 |
|
|
use esmith::FormMagick; |
8 |
|
|
-#use esmith::FormMagick::Panel::datetime; |
9 |
|
|
+use esmith::util; |
10 |
|
|
|
11 |
|
|
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; |
12 |
|
|
|
13 |
|
|
@@ -29,9 +29,27 @@ |
14 |
|
|
my $title = $c->l('dat_FORM_TITLE'); |
15 |
|
|
my $modul = $c->l('dat_INITIAL_DESC'); |
16 |
|
|
|
17 |
|
|
-# more complicated for ntpstatus |
18 |
|
|
- $dat_datas{'ntpstatus'} = ($cdb->get_prop('ntpd','status')) || ''; |
19 |
|
|
- $dat_datas{'ntpserver'} = ($cdb->get_prop('ntpd','NTPServer')) || ''; |
20 |
|
|
+ |
21 |
|
|
+ $dat_datas{ntpstatus} = 'disabled'; |
22 |
|
|
+ |
23 |
|
|
+ my $rec = $cdb->get('ntpd'); |
24 |
|
|
+ if ($rec) { |
25 |
|
|
+ $dat_datas{'ntpserver'} = $rec->prop('NTPServer') || ''; |
26 |
|
|
+ if ( $rec->prop('status') eq 'enabled' ) { |
27 |
|
|
+ $dat_datas{ntpstatus} = 'enabled' |
28 |
|
|
+ unless ($rec->prop('SyncToHWClockSupported') || 'yes') eq 'yes' and $dat_datas{ntpserver} =~ m#^\s*$#; |
29 |
|
|
+ } |
30 |
|
|
+ } |
31 |
|
|
+ |
32 |
|
|
+ ($dat_datas{weekday}, $dat_datas{monthname}, |
33 |
|
|
+ $dat_datas{month}, $dat_datas{day}, $dat_datas{year}, |
34 |
|
|
+ $dat_datas{hour}, $dat_datas{minute}, $dat_datas{second}, |
35 |
|
|
+ $dat_datas{ampm}) = split /\|/, |
36 |
|
|
+ `/bin/date '+%A|%B|%-m|%-d|%Y|%-I|%M|%S|%p'`; |
37 |
|
|
+ |
38 |
|
|
+ # get rid of trailing carriage return on last field |
39 |
|
|
+ chop ($dat_datas{ampm}); |
40 |
|
|
+ |
41 |
|
|
$dat_datas{'now_string'} = esmith::FormMagick->gen_locale_date_string(); |
42 |
|
|
|
43 |
|
|
$c->stash( title => $title, modul => $modul, dat_datas => \%dat_datas ); |
44 |
|
|
@@ -40,53 +58,342 @@ |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
sub do_update { |
48 |
|
|
+ |
49 |
|
|
my $c = shift; |
50 |
|
|
- $c->app->log->info($c->log_req); |
51 |
|
|
|
52 |
|
|
my %dat_datas = (); |
53 |
|
|
my $title = $c->l('dat_FORM_TITLE'); |
54 |
|
|
- my $result = ''; |
55 |
|
|
+ my $modul = $c->l('dat_INITIAL_DESC'); |
56 |
|
|
+ my $result; |
57 |
|
|
+ my $success; |
58 |
|
|
+ |
59 |
|
|
+ my $old_ntpstatus = $c->param('Old_ntpstatus'); |
60 |
|
|
+ $dat_datas{ntpstatus} = $c->param('Ntpstatus'); |
61 |
|
|
+ |
62 |
|
|
+ |
63 |
|
|
+ if ( $dat_datas{ntpstatus} ne $old_ntpstatus) { |
64 |
|
|
+ |
65 |
|
|
+ if ( $dat_datas{ntpstatus} eq 'disabled' ) { |
66 |
|
|
+ ($dat_datas{weekday}, |
67 |
|
|
+ $dat_datas{monthname}, |
68 |
|
|
+ $dat_datas{month}, |
69 |
|
|
+ $dat_datas{day}, |
70 |
|
|
+ $dat_datas{year}, |
71 |
|
|
+ $dat_datas{hour}, |
72 |
|
|
+ $dat_datas{minute}, |
73 |
|
|
+ $dat_datas{second}, |
74 |
|
|
+ $dat_datas{ampm}) = split /\|/, |
75 |
|
|
+ `/bin/date '+%A|%B|%-m|%-d|%Y|%-I|%M|%S|%p'`; |
76 |
|
|
|
77 |
|
|
- my $old_ntpstatus = $c->param('old_ntpstatus'); |
78 |
|
|
- $dat_datas{ntpstatus} = $c->param('ntpstatus'); |
79 |
|
|
+ # get rid of trailing carriage return on last field |
80 |
|
|
+ chop ($dat_datas{ampm}); |
81 |
|
|
+ |
82 |
|
|
+ } else { |
83 |
|
|
+ |
84 |
|
|
+ $dat_datas{ntpserver} = ($cdb->get_prop('ntpd','NTPServer')) || ''; |
85 |
|
|
+ } |
86 |
|
|
|
87 |
|
|
- if ($dat_datas{ntpstatus} ne $old_ntpstatus) { |
88 |
|
|
- my $modul = $c->l('dat_INITIAL_DESC'); |
89 |
|
|
- $dat_datas{ntpserver} = ($cdb->get_prop('ntpd','NTPServer')) || ''; |
90 |
|
|
$dat_datas{now_string} = esmith::FormMagick->gen_locale_date_string(); |
91 |
|
|
+ |
92 |
|
|
$c->stash( title => $title, modul => $modul, dat_datas => \%dat_datas ); |
93 |
|
|
return $c->render('datetime'); |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
- if ($dat_datas{ntpstatus} eq 'enabled') { |
97 |
|
|
- $dat_datas{ntpserver} = $c->param('ntpserver'); |
98 |
|
|
- $cdb->get('ntpd')->set_prop('NTPServer', $dat_datas{'ntpserver'}); |
99 |
|
|
+ if ( $dat_datas{ntpstatus} eq 'enabled' ) { |
100 |
|
|
+ |
101 |
|
|
+ # update ntpserver |
102 |
|
|
+ |
103 |
|
|
+ $dat_datas{ntpserver} = $c->param('Ntpserver') || ''; |
104 |
|
|
+ |
105 |
|
|
+ if ( $dat_datas{ntpserver} eq "pool.ntp.org" ) { |
106 |
|
|
+ $result .= $c->l('dat_INVALID_NTP_ADDR'); |
107 |
|
|
+ } elsif ( $dat_datas{ntpserver} =~ /^([a-zA-Z0-9\.\-]+)$/ ) { |
108 |
|
|
+ $dat_datas{ntpserver} = $1; |
109 |
|
|
+# } elsif ( $dat_datas{ntpserver} =~ /^\s*$/ ) { |
110 |
|
|
+# $dat_datas{ntpserver} = ""; |
111 |
|
|
+ } else { |
112 |
|
|
+ $result .= $c->l('dat_INVALID_NTP_ADDR'); |
113 |
|
|
+ } |
114 |
|
|
+ |
115 |
|
|
+ if ( ! $result ) { |
116 |
|
|
+ $success = update_ntpserver( $c, $dat_datas{ntpserver} ); |
117 |
|
|
+ } |
118 |
|
|
+ |
119 |
|
|
} else { |
120 |
|
|
+ |
121 |
|
|
+ # set Locale time & clean ntpserver |
122 |
|
|
+ |
123 |
|
|
#my $servername = ($c->param('ServerName') || 'WS'); |
124 |
|
|
+ if ( ! $result ) { |
125 |
|
|
+ $result = validate_change_datetime( $c ); |
126 |
|
|
+ if ( $result eq 'OK' ) { |
127 |
|
|
+ $success = $c->l('dat_UPDATING_CLOCK'); |
128 |
|
|
+ $result = ''; |
129 |
|
|
+ disable_ntp(); |
130 |
|
|
+ $success .= '<br>'. $c->l('dat_SERVER_DISABLED_DESC'); |
131 |
|
|
+ } |
132 |
|
|
+ } |
133 |
|
|
} |
134 |
|
|
- # controls |
135 |
|
|
|
136 |
|
|
- # |
137 |
|
|
- # Update the system |
138 |
|
|
- # |
139 |
|
|
- system ("/sbin/e-smith/signal-event", "datetime-update") == 0 |
140 |
|
|
- or $result = $c->l('ERROR_UPDATING_CONFIGURATION'); |
141 |
|
|
|
142 |
|
|
if ( $result ) { |
143 |
|
|
$c->stash( error => $result ); |
144 |
|
|
- $c->stash( title => $title, dat_datas => \%dat_datas ); |
145 |
|
|
+ $c->stash( title => $title, modul => $modul, dat_datas => \%dat_datas ); |
146 |
|
|
return $c->render('datetime'); |
147 |
|
|
- #$c->flash( error => $result . '- f l a s h' ); |
148 |
|
|
- #$c->redirect_to('/datetime'); |
149 |
|
|
} |
150 |
|
|
- $result = $c->l('dat_SUCCESS'); |
151 |
|
|
+ #$result = $c->l('dat_SUCCESS'); |
152 |
|
|
|
153 |
|
|
my $message = "'Datetime' update DONE"; |
154 |
|
|
$c->app->log->info($message); |
155 |
|
|
- $c->flash( success => $result ); |
156 |
|
|
+ $c->flash( success => $success ); |
157 |
|
|
|
158 |
|
|
$c->redirect_to('/datetime'); |
159 |
|
|
}; |
160 |
|
|
|
161 |
|
|
|
162 |
|
|
+sub validate_change_datetime { |
163 |
|
|
+ |
164 |
|
|
+ my $c = shift; |
165 |
|
|
+ |
166 |
|
|
+ #-------------------------------------------------- |
167 |
|
|
+ # Untaint parameters and check for validity |
168 |
|
|
+ #-------------------------------------------------- |
169 |
|
|
+ |
170 |
|
|
+ my $timezone = $c->param ('Timezone'); |
171 |
|
|
+ if ($timezone =~ /^(.*)$/) { |
172 |
|
|
+ $timezone = $1; |
173 |
|
|
+ } else { |
174 |
|
|
+ $timezone = "US/Eastern"; |
175 |
|
|
+ } |
176 |
|
|
+ |
177 |
|
|
+ my $month = $c->param ('Month'); |
178 |
|
|
+ if ($month =~ /^(.*)$/) { |
179 |
|
|
+ $month = $1; |
180 |
|
|
+ } else { |
181 |
|
|
+ $month = "1"; |
182 |
|
|
+ } |
183 |
|
|
+ |
184 |
|
|
+ my $day = $c->param ('Day'); |
185 |
|
|
+ if ($day =~ /^(.*)$/) { |
186 |
|
|
+ $day = $1; |
187 |
|
|
+ } else { |
188 |
|
|
+ $day = "1"; |
189 |
|
|
+ } |
190 |
|
|
+ if (($day < 1) || ($day > 31)) { |
191 |
|
|
+ return $c->l('dat_INVALID_DAY')." $day. ". $c->l('dat_BETWEEN_1_AND_31'); |
192 |
|
|
+ } |
193 |
|
|
+ |
194 |
|
|
+ my $year = $c->param ('Year'); |
195 |
|
|
+ if ($year =~ /^(.*)$/) { |
196 |
|
|
+ $year = $1; |
197 |
|
|
+ } else { |
198 |
|
|
+ $year = "2000"; |
199 |
|
|
+ } |
200 |
|
|
+ |
201 |
|
|
+ if (($year < 1900) || ($year > 2200)) { |
202 |
|
|
+ return $c->l('dat_INVALID_YEAR')." $year. ". $c->l('dat_FOUR_DIGIT_YEAR'); |
203 |
|
|
+ } |
204 |
|
|
+ |
205 |
|
|
+ my $hour = $c->param ('Hour'); |
206 |
|
|
+ if ($hour =~ /^(.*)$/) { |
207 |
|
|
+ $hour = $1; |
208 |
|
|
+ } else { |
209 |
|
|
+ $hour = "12"; |
210 |
|
|
+ } |
211 |
|
|
+ if (($hour < 1) || ($hour > 12)) { |
212 |
|
|
+ return $c->l('dat_INVALID_HOUR')." $hour. ". $c->l('dat_BETWEEN_1_AND_12'); |
213 |
|
|
+ } |
214 |
|
|
+ |
215 |
|
|
+ my $minute = $c->param ('Minute'); |
216 |
|
|
+ if ($minute =~ /^(.*)$/) { |
217 |
|
|
+ $minute = $1; |
218 |
|
|
+ } else { |
219 |
|
|
+ $minute = "0"; |
220 |
|
|
+ } |
221 |
|
|
+ |
222 |
|
|
+ if (($minute < 0) || ($minute > 59)) { |
223 |
|
|
+ return $c->l('datINVALID_MINUTE')." $minute. ".$c->l('dat_BETWEEN_0_AND_59'); |
224 |
|
|
+ } |
225 |
|
|
+ |
226 |
|
|
+ my $second = $c->param ('Second'); |
227 |
|
|
+ if ($second =~ /^(.*)$/) { |
228 |
|
|
+ $second = $1; |
229 |
|
|
+ } else { |
230 |
|
|
+ $second = "0"; |
231 |
|
|
+ } |
232 |
|
|
+ |
233 |
|
|
+ if (($second < 0) || ($second > 59)) { |
234 |
|
|
+ return $c->l('dat_INVALID_SECOND')." $second. ". $c->l('dat_BETWEEN_0_AND_59'); |
235 |
|
|
+ } |
236 |
|
|
+ |
237 |
|
|
+ my $ampm = $c->param ('Ampm'); |
238 |
|
|
+ if ($ampm =~ /^(.*)$/) { |
239 |
|
|
+ $ampm = $1; |
240 |
|
|
+ } else { |
241 |
|
|
+ $ampm = "AM"; |
242 |
|
|
+ } |
243 |
|
|
+ |
244 |
|
|
+ # convert to 24 hour time |
245 |
|
|
+ |
246 |
|
|
+ $hour = $hour % 12; |
247 |
|
|
+ if ($ampm eq "PM") { |
248 |
|
|
+ $hour = $hour + 12; |
249 |
|
|
+ } |
250 |
|
|
+ |
251 |
|
|
+ #-------------------------------------------------- |
252 |
|
|
+ # Store time zone in configuration database |
253 |
|
|
+ #-------------------------------------------------- |
254 |
|
|
+ |
255 |
|
|
+ my $conf = esmith::ConfigDB->open(); |
256 |
|
|
+ my $old = $conf->get('UnsavedChanges')->value; |
257 |
|
|
+ my $rec = $conf->get('TimeZone'); |
258 |
|
|
+ unless ($rec) { |
259 |
|
|
+ $rec = $conf->new_record('TimeZone',undef); |
260 |
|
|
+ } |
261 |
|
|
+ $rec->set_value($timezone); |
262 |
|
|
+ $conf->get('UnsavedChanges')->set_value($old); |
263 |
|
|
+ |
264 |
|
|
+ #-------------------------------------------------- |
265 |
|
|
+ # Signal event to change time zone, system time |
266 |
|
|
+ # and hardware clock |
267 |
|
|
+ #-------------------------------------------------- |
268 |
|
|
+ |
269 |
|
|
+ my $newdate = sprintf "%02d%02d%02d%02d%04d.%02d", |
270 |
|
|
+ $month, $day, $hour, $minute, $year, $second; |
271 |
|
|
+ |
272 |
|
|
+ esmith::util::backgroundCommand(2, |
273 |
|
|
+ "/sbin/e-smith/signal-event","timezone-update",$newdate); |
274 |
|
|
+ |
275 |
|
|
+ return 'OK'; |
276 |
|
|
+} |
277 |
|
|
+ |
278 |
|
|
+ |
279 |
|
|
+sub update_ntpserver { |
280 |
|
|
+ |
281 |
|
|
+ my $c = shift; |
282 |
|
|
+ my $ntpserver = shift; |
283 |
|
|
+ |
284 |
|
|
+ my $msg; |
285 |
|
|
+ #------------------------------------------------------------ |
286 |
|
|
+ # Looks good; go ahead and change the parameters. |
287 |
|
|
+ #------------------------------------------------------------ |
288 |
|
|
+ |
289 |
|
|
+ my $old = $cdb->get('UnsavedChanges')->value; |
290 |
|
|
+ my $rec = $cdb->get('ntpd'); |
291 |
|
|
+ if ($rec) { |
292 |
|
|
+ $rec->set_prop('status','enabled'); |
293 |
|
|
+ $rec->set_prop('NTPServer',$ntpserver); |
294 |
|
|
+ } else { |
295 |
|
|
+ $rec = $cdb->new_record( 'ntpd', |
296 |
|
|
+ { type=>'service', status=>'enabled', SyncToHWClockSupported => 'yes', NTPServer=>$ntpserver } ); |
297 |
|
|
+ } |
298 |
|
|
+ $cdb->get('UnsavedChanges')->set_value($old); |
299 |
|
|
+ |
300 |
|
|
+ $msg = $c->l('dat_SETTINGS_CHANGED'); |
301 |
|
|
+ |
302 |
|
|
+ if ( $ntpserver =~ /^\s*$/ ) { |
303 |
|
|
+ $rec->set_prop('status', ($rec->prop('SyncToHWClockSupported') || 'yes') eq 'yes' ? 'enabled' : 'disabled'); |
304 |
|
|
+ $rec->set_prop('NTPServer', ''); |
305 |
|
|
+ $msg = $c->l('dat_INVALID_NTP_SERVER') if ($rec->prop('SyncToHWClockSupported') || 'yes') ne 'yes'; |
306 |
|
|
+ } |
307 |
|
|
+ |
308 |
|
|
+ esmith::util::backgroundCommand( 2, "/sbin/e-smith/signal-event", "timeserver-update" ); |
309 |
|
|
+ |
310 |
|
|
+ return $msg; |
311 |
|
|
+} |
312 |
|
|
+ |
313 |
|
|
+ |
314 |
|
|
+sub disable_ntp { |
315 |
|
|
+ |
316 |
|
|
+ # make sure that the parameters are set for disabled |
317 |
|
|
+ |
318 |
|
|
+ my $old = $cdb->get('UnsavedChanges')->value; |
319 |
|
|
+ my $rec = $cdb->get('ntpd'); |
320 |
|
|
+ |
321 |
|
|
+ if ($rec) { |
322 |
|
|
+ $rec->set_prop('status', ($rec->prop('SyncToHWClockSupported') || 'yes') eq 'yes' ? 'enabled' : 'disabled'); |
323 |
|
|
+ $rec->set_prop('NTPServer',''); |
324 |
|
|
+ } else { |
325 |
|
|
+ $rec = $cdb->new_record('ntpd', |
326 |
|
|
+ {type=>'service', status=>'enabled', SyncToHWClockSupported => 'yes', NTPServer=>''}); |
327 |
|
|
+ } |
328 |
|
|
+ |
329 |
|
|
+ $cdb->get('UnsavedChanges')->set_value($old); |
330 |
|
|
+ |
331 |
|
|
+} |
332 |
|
|
+ |
333 |
|
|
+ |
334 |
|
|
+sub getTimezone { |
335 |
|
|
+ |
336 |
|
|
+ #-------------------------------------------------- |
337 |
|
|
+ # Figure out time zone by looking first looking at |
338 |
|
|
+ # the configuration database value of TimeZone. |
339 |
|
|
+ # If that is not defined, try and get it from /etc/localtime. |
340 |
|
|
+ # If that doesn't work, default to US/Eastern. |
341 |
|
|
+ #-------------------------------------------------- |
342 |
|
|
+ |
343 |
|
|
+ my $localtime; |
344 |
|
|
+ my $timezonedefault = "US/Eastern"; |
345 |
|
|
+ |
346 |
|
|
+ if (defined $cdb->get('TimeZone')) { |
347 |
|
|
+ $timezonedefault = $cdb->get('TimeZone')->value; |
348 |
|
|
+ } else { |
349 |
|
|
+ if (defined ($localtime = readlink '/etc/localtime')) { |
350 |
|
|
+ my $pos = index $localtime, 'zoneinfo/'; |
351 |
|
|
+ if ( $pos > -1 ) { |
352 |
|
|
+ $timezonedefault = substr $localtime, ($pos + 9); |
353 |
|
|
+ } |
354 |
|
|
+ } |
355 |
|
|
+ } |
356 |
|
|
+ return $timezonedefault; |
357 |
|
|
+} |
358 |
|
|
+ |
359 |
|
|
+ |
360 |
|
|
+sub getZone_list { |
361 |
|
|
+ |
362 |
|
|
+ my $c = shift; |
363 |
|
|
+ |
364 |
|
|
+ #-------------------------------------------------- |
365 |
|
|
+ # Get a sorted list of time zones |
366 |
|
|
+ #-------------------------------------------------- |
367 |
|
|
+ |
368 |
|
|
+ $ENV{BASH_ENV} = ''; |
369 |
|
|
+ if (! open (ZONES, "cd /usr/share/zoneinfo; /usr/bin/find . -type f -or -type l | /bin/grep '^./[A-Z]' |")) |
370 |
|
|
+ { |
371 |
|
|
+ warn ( $c->l('COULD_NOT_OPEN_TZ_FILE').$!.'.' ); |
372 |
|
|
+ return undef; |
373 |
|
|
+ } |
374 |
|
|
+ my $zone; |
375 |
|
|
+ my @zones = (); |
376 |
|
|
+ |
377 |
|
|
+ while (defined ($zone = <ZONES>)) |
378 |
|
|
+ { |
379 |
|
|
+ chop ($zone); |
380 |
|
|
+ $zone =~ s/^.\///; |
381 |
|
|
+ push @zones, $zone; |
382 |
|
|
+ } |
383 |
|
|
+ close ZONES; |
384 |
|
|
+ my @zt = sort @zones; |
385 |
|
|
+ return \@zt; |
386 |
|
|
+} |
387 |
|
|
+ |
388 |
|
|
+ |
389 |
|
|
+sub getMonth_list { |
390 |
|
|
+ |
391 |
|
|
+ my $c = shift; |
392 |
|
|
+ return [[ $c->l('dat_JANUARY') => '1'], |
393 |
|
|
+ [ $c->l('dat_FEBRUARY') => '2'], |
394 |
|
|
+ [ $c->l('dat_MARCH') => '3'], |
395 |
|
|
+ [ $c->l('dat_APRIL') => '4'], |
396 |
|
|
+ [ $c->l('dat_MAY') => '5'], |
397 |
|
|
+ [ $c->l('dat_JUNE') => '6'], |
398 |
|
|
+ [ $c->l('dat_JULY') => '7'], |
399 |
|
|
+ [ $c->l('dat_AUGUST') => '8'], |
400 |
|
|
+ [ $c->l('dat_SEPTEMBER') => '9'], |
401 |
|
|
+ [ $c->l('dat_OCTOBER') => '10'], |
402 |
|
|
+ [ $c->l('dat_NOVEMBER') => '11'], |
403 |
|
|
+ [ $c->l('dat_DECEMBER') => '12']]; |
404 |
|
|
+} |
405 |
|
|
+ |
406 |
|
|
+ |
407 |
|
|
1; |
408 |
|
|
diff -urN smeserver-manager-0.1.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Quota.pm smeserver-manager-0.1.0/root/usr/share/smanager/lib/SrvMngr/Controller/Quota.pm |
409 |
|
|
--- smeserver-manager-0.1.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Quota.pm 2020-06-28 16:50:36.433935049 +0200 |
410 |
|
|
+++ smeserver-manager-0.1.0/root/usr/share/smanager/lib/SrvMngr/Controller/Quota.pm 2020-07-05 21:02:49.000000000 +0200 |
411 |
|
|
@@ -33,17 +33,15 @@ |
412 |
|
|
|
413 |
|
|
my %quo_datas = (); |
414 |
|
|
my $title = $c->l('quo_FORM_TITLE'); |
415 |
|
|
- my $modul = ''; |
416 |
|
|
|
417 |
|
|
$quo_datas{'trt'} = 'LIST'; |
418 |
|
|
|
419 |
|
|
my @userAccounts; |
420 |
|
|
- if ($adb) |
421 |
|
|
- { |
422 |
|
|
+ if ($adb) { |
423 |
|
|
@userAccounts = $adb->users(); |
424 |
|
|
} |
425 |
|
|
|
426 |
|
|
- $c->stash( title => $title, modul => $modul, quo_datas => \%quo_datas, userAccounts => \@userAccounts ); |
427 |
|
|
+ $c->stash( title => $title, quo_datas => \%quo_datas, userAccounts => \@userAccounts ); |
428 |
|
|
$c->render(template => 'quota'); |
429 |
|
|
|
430 |
|
|
}; |
431 |
|
|
@@ -61,7 +59,6 @@ |
432 |
|
|
|
433 |
|
|
my %quo_datas = (); |
434 |
|
|
my $title = $c->l('quo_FORM_TITLE'); |
435 |
|
|
- my $modul = ''; |
436 |
|
|
|
437 |
|
|
$quo_datas{'trt'} = $trt; |
438 |
|
|
|
439 |
|
|
@@ -79,7 +76,7 @@ |
440 |
|
|
|
441 |
|
|
} |
442 |
|
|
|
443 |
|
|
- $c->stash( title => $title, modul => $modul, quo_datas => \%quo_datas ); |
444 |
|
|
+ $c->stash( title => $title, quo_datas => \%quo_datas ); |
445 |
|
|
$c->render( template => 'quota' ); |
446 |
|
|
|
447 |
|
|
}; |
448 |
|
|
@@ -90,30 +87,46 @@ |
449 |
|
|
my $c = shift; |
450 |
|
|
$c->app->log->info($c->log_req); |
451 |
|
|
|
452 |
|
|
+ my $title = $c->l('quo_FORM_TITLE'); |
453 |
|
|
+ my %quo_datas = (); |
454 |
|
|
+ |
455 |
|
|
my $rt = $c->current_route; |
456 |
|
|
my $trt = ($c->param('trt') || 'LIST'); |
457 |
|
|
|
458 |
|
|
+ $quo_datas{trt} = $trt; |
459 |
|
|
my $result = ''; |
460 |
|
|
+ my $res; |
461 |
|
|
|
462 |
|
|
if ( $trt eq 'UPD' ) { |
463 |
|
|
|
464 |
|
|
- my $acct = ($c->param('user') || ''); |
465 |
|
|
- my $soft = ($c->param('Soft') || ''); |
466 |
|
|
- my $hard = ($c->param('Hard') || ''); |
467 |
|
|
+ $quo_datas{user} = ($c->param('user') || ''); |
468 |
|
|
+ $quo_datas{softlim} = ($c->param('Soft') || ''); |
469 |
|
|
+ $quo_datas{hardlim} = ($c->param('Hard') || ''); |
470 |
|
|
|
471 |
|
|
# controls |
472 |
|
|
- my $res = validate_quota( $c, $acct, $soft, $hard ); |
473 |
|
|
+ $res = validate_quota( $c, $quo_datas{user}, $quo_datas{softlim}, $quo_datas{hardlim} ); |
474 |
|
|
$result .= $res unless $res eq 'OK'; |
475 |
|
|
|
476 |
|
|
if ( ! $result ) { |
477 |
|
|
- $result = $c->l('quo_SUCCESSFULLY_MODIFIED') . ' ' . $acct; |
478 |
|
|
+ $result = $c->l('quo_SUCCESSFULLY_MODIFIED') . ' ' . $quo_datas{user}; |
479 |
|
|
+ } else { |
480 |
|
|
+ $quo_datas{userRec} = $adb->get($quo_datas{user}) || undef; |
481 |
|
|
} |
482 |
|
|
} |
483 |
|
|
|
484 |
|
|
- my $title = $c->l('quo_FORM_TITLE'); |
485 |
|
|
+ # common parts |
486 |
|
|
+ |
487 |
|
|
+ if ($res ne 'OK') { |
488 |
|
|
+ $c->stash( error => $result ); |
489 |
|
|
+ $c->stash( title => $title, quo_datas => \%quo_datas ); |
490 |
|
|
+ return $c->render('quota'); |
491 |
|
|
+ } |
492 |
|
|
+ |
493 |
|
|
+ my $message = "'Quota' updates ($trt) DONE"; |
494 |
|
|
+ $c->app->log->info($message); |
495 |
|
|
+ $c->flash( success => $result ); |
496 |
|
|
|
497 |
|
|
- $c->stash( title => $title, modul => $result ); |
498 |
|
|
- $c->render(template => 'module'); |
499 |
|
|
+ $c->redirect_to('/quota'); |
500 |
|
|
|
501 |
|
|
}; |
502 |
|
|
|
503 |
|
|
diff -urN smeserver-manager-0.1.0.old/root/usr/share/smanager/themes/default/templates/datetime.html.ep smeserver-manager-0.1.0/root/usr/share/smanager/themes/default/templates/datetime.html.ep |
504 |
|
|
--- smeserver-manager-0.1.0.old/root/usr/share/smanager/themes/default/templates/datetime.html.ep 2020-07-05 22:56:57.000000000 +0200 |
505 |
|
|
+++ smeserver-manager-0.1.0/root/usr/share/smanager/themes/default/templates/datetime.html.ep 2020-07-05 19:21:53.000000000 +0200 |
506 |
|
|
@@ -22,10 +22,10 @@ |
507 |
|
|
|
508 |
|
|
%= form_for '/datetime' => (method => 'POST') => begin |
509 |
|
|
<p> |
510 |
|
|
- %= hidden_field 'old_ntpstatus' => $dat_datas->{ntpstatus}; |
511 |
|
|
+ %= hidden_field 'Old_ntpstatus' => $dat_datas->{ntpstatus}; |
512 |
|
|
|
513 |
|
|
- % param 'ntpstatus' => $dat_datas->{ntpstatus} unless param 'ntpstatus'; |
514 |
|
|
- %= radio_button ntpstatus => 'enabled' |
515 |
|
|
+ % param 'Ntpstatus' => $dat_datas->{ntpstatus} unless param 'Ntpstatus'; |
516 |
|
|
+ %= radio_button Ntpstatus => 'enabled' |
517 |
|
|
<span class=label> |
518 |
|
|
%=l 'dat_NTP_CONFIGURE_TITLE' |
519 |
|
|
</span> |
520 |
|
|
@@ -46,12 +46,12 @@ |
521 |
|
|
<span class=label> |
522 |
|
|
%=l 'dat_NTP_SERVER' |
523 |
|
|
</span><span class=data2> |
524 |
|
|
- %= text_field 'ntpServer' => $dat_datas->{ntpserver}, class => 'input' |
525 |
|
|
+ %= text_field 'Ntpserver' => $dat_datas->{ntpserver}, class => 'input' |
526 |
|
|
</span> |
527 |
|
|
</p> |
528 |
|
|
% } |
529 |
|
|
<p> |
530 |
|
|
- %= radio_button ntpstatus => 'disabled' |
531 |
|
|
+ %= radio_button Ntpstatus => 'disabled' |
532 |
|
|
<span class=label> |
533 |
|
|
%=l 'dat_NTP_DISABLE_TITLE' |
534 |
|
|
</span> |
535 |
|
|
@@ -66,36 +66,44 @@ |
536 |
|
|
</p> |
537 |
|
|
<p> |
538 |
|
|
%=l 'dat_CURRENT_SETTING' |
539 |
|
|
- <span class=data2> |
540 |
|
|
+ <span class=label> |
541 |
|
|
%= $dat_datas->{now_string} |
542 |
|
|
</span> |
543 |
|
|
<br> |
544 |
|
|
<span class=label> |
545 |
|
|
%=l 'dat_NEW_M/D/Y' |
546 |
|
|
</span><span class=data2> |
547 |
|
|
- %= text_field 'month' => $dat_datas->{month}, size => '2', class => 'input' |
548 |
|
|
+ % param 'Month' => $dat_datas->{month} unless param 'Month'; |
549 |
|
|
+ %= select_field 'Month' => $c->getMonth_list(), class => 'input' |
550 |
|
|
</span><span class=data2> |
551 |
|
|
- %= text_field 'day' => $dat_datas->{day}, size => '2', class => 'input' |
552 |
|
|
+ % param 'Day' => $dat_datas->{day} unless param 'Day'; |
553 |
|
|
+ %= text_field 'Day', size => '2', class => 'input' |
554 |
|
|
</span><span class=data2> |
555 |
|
|
- %= text_field 'year' => $dat_datas->{year}, size => '2', class => 'input' |
556 |
|
|
+ % param 'Year' => $dat_datas->{year} unless param 'Year'; |
557 |
|
|
+ %= text_field 'Year', size => '4', class => 'input' |
558 |
|
|
</span> |
559 |
|
|
<br> |
560 |
|
|
<span class=label> |
561 |
|
|
%=l 'dat_NEW_H/M/S' |
562 |
|
|
</span><span class=data2> |
563 |
|
|
- %= text_field 'hour' => $dat_datas->{hour}, size => '2', class => 'input' |
564 |
|
|
+ % param 'Hour' => $dat_datas->{hour} unless param 'Hour'; |
565 |
|
|
+ %= text_field 'Hour', size => '2', class => 'input' |
566 |
|
|
</span><span class=data2> |
567 |
|
|
- %= text_field 'minute' => $dat_datas->{minute}, size => '2', class => 'input' |
568 |
|
|
+ % param 'Minute' => $dat_datas->{minute} unless param 'Minute'; |
569 |
|
|
+ %= text_field 'Minute', size => '2', class => 'input' |
570 |
|
|
</span><span class=data2> |
571 |
|
|
- %= text_field 'second' => $dat_datas->{second}, size => '2', class => 'input' |
572 |
|
|
+ % param 'Second' => $dat_datas->{second} unless param 'Second'; |
573 |
|
|
+ %= text_field 'Second', size => '2', class => 'input' |
574 |
|
|
</span> |
575 |
|
|
<br> |
576 |
|
|
<span class=label> |
577 |
|
|
%=l 'dat_AM/PM_AND_TZ' |
578 |
|
|
</span><span class=data2> |
579 |
|
|
- %= select_field 'ampm' => [[AM => 'am'],[PM => 'pm']], class => 'input' |
580 |
|
|
+ % param 'Ampm' => $dat_datas->{ampm} unless param 'Ampm'; |
581 |
|
|
+ %= select_field 'Ampm' => ['AM', 'PM'], class => 'input' |
582 |
|
|
</span><span class=data2> |
583 |
|
|
- %= text_field 'timezone' => $dat_datas->{timezone}, class => 'input' |
584 |
|
|
+ % param 'Timezone' => $c->getTimezone() unless param 'Timezone'; |
585 |
|
|
+ %= select_field 'Timezone' => $c->getZone_list(), class => 'input' |
586 |
|
|
</span> |
587 |
|
|
</p> |
588 |
|
|
% } |
589 |
|
|
diff -urN smeserver-manager-0.1.0.old/root/usr/share/smanager/themes/default/templates/quota.html.ep smeserver-manager-0.1.0/root/usr/share/smanager/themes/default/templates/quota.html.ep |
590 |
|
|
--- smeserver-manager-0.1.0.old/root/usr/share/smanager/themes/default/templates/quota.html.ep 2020-04-26 11:00:06.000000000 +0200 |
591 |
|
|
+++ smeserver-manager-0.1.0/root/usr/share/smanager/themes/default/templates/quota.html.ep 2020-07-05 21:03:24.000000000 +0200 |
592 |
|
|
@@ -5,18 +5,18 @@ |
593 |
|
|
|
594 |
|
|
% if ($config->{debug} == 1) { |
595 |
|
|
<p> |
596 |
|
|
- (DBG)route: |
597 |
|
|
%= dumper $c->current_route |
598 |
|
|
- <br> |
599 |
|
|
- (DBG)datas: |
600 |
|
|
%= dumper $quo_datas |
601 |
|
|
- --> |
602 |
|
|
</p> |
603 |
|
|
% } |
604 |
|
|
|
605 |
|
|
- <h1><%= $title%></h1> |
606 |
|
|
+ % if ( stash 'error' ) { |
607 |
|
|
+ <br><div class=sme-error> |
608 |
|
|
+ %= $c->render_to_string(inline => stash 'error') |
609 |
|
|
+ </div> |
610 |
|
|
+ %} |
611 |
|
|
|
612 |
|
|
- %= $modul |
613 |
|
|
+ <h1><%= $title%></h1> |
614 |
|
|
|
615 |
|
|
% if ($quo_datas->{trt} eq 'UPD') { |
616 |
|
|
%= include 'partials/_quo_upd' |