Make WarnUser a per user setting

tags/smeserver-expire-accounts-0.1.7-1
Daniel Berteaud 8 years ago
parent 3ca378f3e0
commit c005e39af3
  1. 6
      root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/expireaccounts
  2. 12
      root/etc/e-smith/locale/fr/etc/e-smith/web/functions/expireaccounts
  3. 8
      root/etc/e-smith/web/functions/expireaccounts
  4. 4
      root/sbin/e-smith/expire-accounts
  5. 4
      root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/expireaccounts.pm

@ -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>

@ -44,16 +44,16 @@
<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_USER_ACCOUNT</base>
<trans>Compte utilisateur</trans>
<base>LABEL_WARN_USER</base>
<trans>Notifier l'utilisateur</trans>
</entry>
<entry>
<base>LABEL_WARN_USERS</base>
<trans>Notifier les utilisateurs</trans>
<base>LABEL_USER_ACCOUNT</base>
<trans>Compte utilisateur</trans>
</entry>
<entry>
<base>DESC_LOCK_ON_DATE</base>

@ -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>

@ -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}");

@ -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);
}

Loading…
Cancel
Save