Make WarnUser a per user setting

This commit is contained in:
Daniel Berteaud 2016-03-02 09:40:07 +01:00
parent 3ca378f3e0
commit c005e39af3
5 changed files with 17 additions and 17 deletions

View File

@ -45,11 +45,11 @@
</entry>
<entry>
<base>DESC_WARN_USERS</base>
<trans>In addition to notify an administrator, you can notify the user in question by email.</trans>
<trans>Should the user be warned when his account is about to expire</trans>
</entry>
<entry>
<base>LABEL_WARN_USERS</base>
<trans>Notify users</trans>
<base>LABEL_WARN_USER</base>
<trans>Notify user</trans>
</entry>
<entry>
<base>LABEL_USER_ACCOUNT</base>

View File

@ -44,17 +44,17 @@
<trans>Destinataire des notifications</trans>
</entry>
<entry>
<base>DESC_WARN_USERS</base>
<trans>En plus de notifier un administrateur, vous pouvez notifier l'utilisateur concerné par email.</trans>
<base>DESC_WARN_USER</base>
<trans>L'utilisateur doit-il être avertie lorsque son compte est sur le point d'expirer ?</trans>
</entry>
<entry>
<base>LABEL_WARN_USER</base>
<trans>Notifier l'utilisateur</trans>
</entry>
<entry>
<base>LABEL_USER_ACCOUNT</base>
<trans>Compte utilisateur</trans>
</entry>
<entry>
<base>LABEL_WARN_USERS</base>
<trans>Notifier les utilisateurs</trans>
</entry>
<entry>
<base>DESC_LOCK_ON_DATE</base>
<trans>Précisez ici la date à laquelle le compte sera automatiquement verrouillé. La date doit être au format AAAA-MM-JJ, par exemple 2018-07-25 pour le 25 Juillet 2018. Laissez ce champs vide pour désactiver l'expiration du compte.</trans>

View File

@ -57,10 +57,6 @@ __DATA__
<description>DESC_WARNING_RECIPIENT</description>
<label>LABEL_WARNING_RECIPIENT</label>
</field>
<field type="select" id="WarnUsers" value="get_conf_bool('WarnUsers')" options="'enabled' => 'ENABLED', 'disabled' => 'DISABLED'">
<description>DESC_WARN_USERS</description>
<label>LABEL_WARN_USERS</label>
</field>
<subroutine src="print_save_button()" />
</page>
<page name="ModifyLocked" pre-event="turn_off_buttons()" post-event="modify_user()">
@ -84,6 +80,10 @@ __DATA__
<description>DESC_LOCK_ON_DATE</description>
<label>LABEL_LOCK_ON_DATE</label>
</field>
<field type="select" id="WarnUsers" value="get_user_bool('WarnUser')" options="'enabled' => 'ENABLED', 'disabled' => 'DISABLED'">
<description>DESC_WARN_USER</description>
<label>LABEL_WARN_USER</label>
</field>
<field type="text" size="30" id="ExpireForwardAfterLock" validation="is_email_or_empty" value="get_user_prop('ExpireForwardAfterLock')">
<description>DESC_FORWARD_AFTER_LOCK</description>
<label>LABEL_FORWARD_AFTER_LOCK</label>

View File

@ -28,7 +28,6 @@ my $service = $c->get('ExpireAccounts') ||
);
my $warn_delay = $service->prop('WarningDelay') || '30';
my $warn_users = $service->prop('WarnUsers') || 'no';
my $recipient = $service->prop('WarningRecipient') || 'root';
my $days_between_warn = $service->prop('DaysBetweenWarnings') || '5';
my $archive_compress = $service->prop('ArchiveCompression') || '/usr/bin/pbzip2';
@ -148,6 +147,7 @@ my $send_warn_for = {};
foreach my $user (keys %$rem){
my $rec = $a->get($user) || next;
my $last_notif = $rec->prop('ExpireLastNotifiedOn') || 'never';
my $warn_user = $rec->prop('ExpireWarnUser') || 'disabled';
if ($last_notif =~ m/^(\d{4})\-(\d{1,2})\-(\d{1,2})/){
$last_notif = DateTime->new(
year => $1,
@ -164,7 +164,7 @@ foreach my $user (keys %$rem){
# Use templates-custom version by preference if it exists
-f "${templates}-custom${source}" and $templates .= "-custom";
if ($warn_users){
if ($warn_user =~ m/^enabled|yes|on|1$/){
my $t = new Text::Template(TYPE => 'FILE',
SOURCE => "${templates}${source}");

View File

@ -239,7 +239,7 @@ sub modify_config{
my ($self) = @_;
my $rec = $c->get('ExpireAccounts') || $c->new_record('ExpireAccounts', { type => 'service' });
my %new_props = ();
foreach my $prop (qw(WarningDelay DaysBetweenWarnings WarningRecipient WarnUsers)){
foreach my $prop (qw(WarningDelay DaysBetweenWarnings WarningRecipient)){
if (!$self->{cgi}->param($prop) || $self->{cgi}->param($prop) eq ''){
$rec->delete_prop($prop);
}
@ -271,7 +271,7 @@ sub modify_user {
);
}
my %new_props = ();
foreach my $prop (qw(ExpireLockOn ExpireForwardAfterLock ExpireAutoReply ExpireDeleteAfterLock)){
foreach my $prop (qw(ExpireLockOn ExpireForwardAfterLock ExpireAutoReply ExpireDeleteAfterLock WarnUser)){
if (!$self->{cgi}->param($prop) || $self->{cgi}->param($prop) eq ''){
$acct->delete_prop($prop);
}