Added group expiration notifications.
This commit is contained in:
parent
3f2d2c63f9
commit
226ed9abcf
10 changed files with 241 additions and 31 deletions
|
|
@ -34,14 +34,18 @@ This package provides an object-oriented way of managing WebGUI groups and group
|
|||
use WebGUI::Group;
|
||||
$g = WebGUI::Group->new(3); or $g = WebGUI::User->new("new");
|
||||
|
||||
$dateCreated = $g->dateCreated;
|
||||
$description = $g->description("Those really smart dudes.");
|
||||
$expireAfter = $g->expireAfter(360000);
|
||||
$groupId = $g->groupId;
|
||||
$karmaThreshold = $g->karmaThreshold(5000);
|
||||
$ipFilter = $g->ipFilter("10.;192.168.1.");
|
||||
$lastUpdated = $g->lastUpdated;
|
||||
$name = $g->name("Nerds");
|
||||
$epoch = $g->dateCreated;
|
||||
$integer = $g->deleteOffset(14);
|
||||
$text = $g->description("Those really smart dudes.");
|
||||
$integer = $g->expireNotify(1);
|
||||
$integer = $g->expireNotifyMessage("You're outta here!");
|
||||
$integer = $g->expireNotifyOffset(-14);
|
||||
$integer = $g->expireOffset(360000);
|
||||
$integer = $g->groupId;
|
||||
$integer = $g->karmaThreshold(5000);
|
||||
$string = $g->ipFilter("10.;192.168.1.");
|
||||
$epoch = $g->lastUpdated;
|
||||
$string = $g->name("Nerds");
|
||||
|
||||
$g->addGroups(\@arr);
|
||||
$g->deleteGroups(\@arr);
|
||||
|
|
@ -57,7 +61,7 @@ These methods are available from this class:
|
|||
#-------------------------------------------------------------------
|
||||
sub _create {
|
||||
my $groupId = getNextId("groupId");
|
||||
WebGUI::SQL->write("insert into groups (groupId,dateCreated,expireAfter,karmaThreshold) values
|
||||
WebGUI::SQL->write("insert into groups (groupId,dateCreated,expireOffset,karmaThreshold) values
|
||||
($groupId,".time().",314496000,1000000000)");
|
||||
return $groupId;
|
||||
}
|
||||
|
|
@ -130,6 +134,35 @@ sub deleteGroups {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteOffset ( [ value ] )
|
||||
|
||||
Returns the number of days after the expiration to delete the grouping.
|
||||
|
||||
=over
|
||||
|
||||
=item value
|
||||
|
||||
If specified, deleteOffset is set to this value. Defaults to "-14".
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteOffset {
|
||||
my ($class, $value);
|
||||
$class = shift;
|
||||
$value = shift;
|
||||
if (defined $value) {
|
||||
$class->{_group}{"deleteOffset"} = $value;
|
||||
WebGUI::SQL->write("update groups set deleteOffset=$value,
|
||||
lastUpdated=".time()." where groupId=$class->{_groupId}");
|
||||
}
|
||||
return $class->{_group}{"deleteOffset"};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 description ( [ value ] )
|
||||
|
|
@ -161,7 +194,95 @@ sub description {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 expireAfter ( [ value ] )
|
||||
=head2 expireNotify ( [ value ] )
|
||||
|
||||
Returns a boolean value whether or not to notify the user of the group expiry.
|
||||
|
||||
=over
|
||||
|
||||
=item value
|
||||
|
||||
If specified, expireNotify is set to this value.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub expireNotify {
|
||||
my ($class, $value);
|
||||
$class = shift;
|
||||
$value = shift;
|
||||
if (defined $value) {
|
||||
$class->{_group}{"expireNotify"} = $value;
|
||||
WebGUI::SQL->write("update groups set expireNotify=$value,
|
||||
lastUpdated=".time()." where groupId=$class->{_groupId}");
|
||||
}
|
||||
return $class->{_group}{"expireNotify"};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 expireNotifyMessage ( [ value ] )
|
||||
|
||||
Returns the message to send to the user about expiration.
|
||||
|
||||
=over
|
||||
|
||||
=item value
|
||||
|
||||
If specified, expireNotifyMessage is set to this value.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub expireNotifyMessage {
|
||||
my ($class, $value);
|
||||
$class = shift;
|
||||
$value = shift;
|
||||
if (defined $value) {
|
||||
$class->{_group}{"expireNotifyMessage"} = $value;
|
||||
WebGUI::SQL->write("update groups set expireNotifyMessage=".quote($value).",
|
||||
lastUpdated=".time()." where groupId=$class->{_groupId}");
|
||||
}
|
||||
return $class->{_group}{"expireNotifyMessage"};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 expireNotifyOffset ( [ value ] )
|
||||
|
||||
Returns the number of days after the expiration to notify the user.
|
||||
|
||||
=over
|
||||
|
||||
=item value
|
||||
|
||||
If specified, expireNotifyOffset is set to this value.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub expireNotifyOffset {
|
||||
my ($class, $value);
|
||||
$class = shift;
|
||||
$value = shift;
|
||||
if (defined $value) {
|
||||
$class->{_group}{"expireNotifyOffset"} = $value;
|
||||
WebGUI::SQL->write("update groups set expireNotifyOffset=$value,
|
||||
lastUpdated=".time()." where groupId=$class->{_groupId}");
|
||||
}
|
||||
return $class->{_group}{"expireNotifyOffset"};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 expireOffset ( [ value ] )
|
||||
|
||||
Returns the number of seconds any grouping with this group should expire after.
|
||||
|
||||
|
|
@ -169,22 +290,22 @@ Returns the number of seconds any grouping with this group should expire after.
|
|||
|
||||
=item value
|
||||
|
||||
If specified, expireAfter is set to this value.
|
||||
If specified, expireOffset is set to this value.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub expireAfter {
|
||||
sub expireOffset {
|
||||
my ($class, $value);
|
||||
$class = shift;
|
||||
$value = shift;
|
||||
if (defined $value) {
|
||||
$class->{_group}{"expireAfter"} = $value;
|
||||
WebGUI::SQL->write("update groups set expireAfter=".quote($value).",
|
||||
$class->{_group}{"expireOffset"} = $value;
|
||||
WebGUI::SQL->write("update groups set expireOffset=".quote($value).",
|
||||
lastUpdated=".time()." where groupId=$class->{_groupId}");
|
||||
}
|
||||
return $class->{_group}{"expireAfter"};
|
||||
return $class->{_group}{"expireOffset"};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -324,9 +445,12 @@ sub new {
|
|||
$groupId = shift;
|
||||
$groupId = _create() if ($groupId eq "new");
|
||||
if ($groupId eq "") {
|
||||
$group{expireAfter} = 314496000;
|
||||
$group{expireOffset} = 314496000;
|
||||
$group{karmaThreshold} = 1000000000;
|
||||
$group{groupName} = "New Group";
|
||||
$group{expireNotifyOffset} = -14;
|
||||
$group{deleteOffset} = 14;
|
||||
$group{expireNotify} = 0;
|
||||
} else {
|
||||
%group = WebGUI::SQL->quickHash("select * from groups where groupId='$groupId'");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,18 +103,17 @@ An array reference containing a list of groups.
|
|||
|
||||
sub addUsersToGroups {
|
||||
foreach my $gid (@{$_[1]}) {
|
||||
my ($expireAfter) = WebGUI::SQL->quickArray("select expireAfter from groups where groupId=$gid");
|
||||
my ($expireOffset) = WebGUI::SQL->quickArray("select expireOffset from groups where groupId=$gid");
|
||||
foreach my $uid (@{$_[0]}) {
|
||||
my ($isIn) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId=$gid and userId=$uid");
|
||||
unless ($isIn) {
|
||||
WebGUI::SQL->write("insert into groupings (groupId,userId,expireDate)
|
||||
values ($gid, $uid, ".(time()+$expireAfter).")");
|
||||
values ($gid, $uid, ".(time()+$expireOffset).")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteGroupsFromGroups ( groups, fromGroups )
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ sub send {
|
|||
#body
|
||||
$message .= $_[2]."\n";
|
||||
#footer
|
||||
$message .= "\n".$session{setting}{mailFooter}
|
||||
$message .= "\n".$session{setting}{mailFooter};
|
||||
#process macros on message
|
||||
$message = WebGUI::Macro::process($message);
|
||||
if ($session{setting}{smtpServer} =~ /\/sendmail/) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::MessageLog;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Mail;
|
||||
|
|
@ -126,7 +127,8 @@ sub addEntry {
|
|||
foreach $user (@users) {
|
||||
$u = WebGUI::User->new($user);
|
||||
if ($u->userId ne "") {
|
||||
WebGUI::SQL->write("insert into messageLog values ($messageLogId,".$u->userId.",
|
||||
WebGUI::SQL->write("insert into messageLog (messageLogId, userId, message, url, dateOfEntry,
|
||||
subject, status) values ($messageLogId,".$u->userId.",
|
||||
".quote($message).",".quote($url).",".time().",".quote($subject).", ".quote($status).")");
|
||||
if ($url ne "") {
|
||||
$message .= "\n".WebGUI::URL::append('http://'.$session{env}{HTTP_HOST}.$url,'mlog='.$messageLogId);
|
||||
|
|
|
|||
|
|
@ -108,7 +108,27 @@ sub www_editGroup {
|
|||
$f->readOnly($g->groupId,WebGUI::International::get(379));
|
||||
$f->text("groupName",WebGUI::International::get(84),$g->name);
|
||||
$f->textarea("description",WebGUI::International::get(85),$g->description);
|
||||
$f->interval("expireAfter",WebGUI::International::get(367), WebGUI::DateTime::secondsToInterval($g->expireAfter));
|
||||
$f->interval("expireOffset",WebGUI::International::get(367), WebGUI::DateTime::secondsToInterval($g->expireOffset));
|
||||
$f->yesNo(
|
||||
-name=>"expireNotify",
|
||||
-value=>$g->expireNotify,
|
||||
-label=>WebGUI::International::get(865)
|
||||
);
|
||||
$f->integer(
|
||||
-name=>"expireNotifyOffset",
|
||||
-value=>$g->expireNotifyOffset,
|
||||
-label=>WebGUI::International::get(864)
|
||||
);
|
||||
$f->textarea(
|
||||
-name=>"expireNotifyMessage",
|
||||
-value=>$g->expireNotifyMessage,
|
||||
-label=>WebGUI::International::get(866)
|
||||
);
|
||||
$f->integer(
|
||||
-name=>"deleteOffset",
|
||||
-value=>$g->deleteOffset,
|
||||
-label=>WebGUI::International::get(863)
|
||||
);
|
||||
if ($session{setting}{useKarma}) {
|
||||
$f->integer("karmaThreshold",WebGUI::International::get(538),$g->karmaThreshold);
|
||||
}
|
||||
|
|
@ -128,9 +148,13 @@ sub www_editGroupSave {
|
|||
my $g = WebGUI::Group->new($session{form}{gid});
|
||||
$g->description($session{form}{description});
|
||||
$g->name($session{form}{groupName});
|
||||
$g->expireAfter(WebGUI::DateTime::intervalToSeconds($session{form}{expireAfter_interval},$session{form}{expireAfter_units}));
|
||||
$g->expireOffset(WebGUI::DateTime::intervalToSeconds($session{form}{expireOffset_interval},$session{form}{expireOffset_units}));
|
||||
$g->karmaThreshold($session{form}{karmaThreshold});
|
||||
$g->ipFilter($session{form}{ipFilter});
|
||||
$g->expireNotify($session{form}{expireNotify});
|
||||
$g->expireNotifyOffset($session{form}{expireNotifyOffset});
|
||||
$g->expireNotifyMessage($session{form}{expireNotifyMessage});
|
||||
$g->deleteOffset($session{form}{deleteOffset});
|
||||
return www_listGroups();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ sub www_addUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUserSave {
|
||||
my (@groups, $uid, $u, $gid, $encryptedPassword, $expireAfter, $cmd);
|
||||
my (@groups, $uid, $u, $gid, $encryptedPassword, $cmd);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".quote($session{form}{username}));
|
||||
unless ($uid) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue