Commit 6b8a74cd authored by Mike Hibler's avatar Mike Hibler

Add a couple more useful functions.

parent 0bba68e0
......@@ -313,6 +313,32 @@ sub Delete($) {
return 0
}
#
# Return a list of all leases.
#
sub AllLeases($)
{
my ($class) = @_;
my @pleases = ();
my $query_result =
DBQueryWarn("select lease_idx from project_leases");
return ()
if (!$query_result || !$query_result->numrows);
while (my ($lease_idx) = $query_result->fetchrow_array()) {
my $lease = Lookup($class, $lease_idx);
# Something went wrong?
return ()
if (!defined($lease));
push(@pleases, $lease);
}
return @pleases;
}
#
# Return a list of all leases belonging to a particular project.
#
......@@ -461,6 +487,7 @@ sub UpdateState($$) {
"where lease_idx=$idx")
or return -1;
$self->Refresh();
return 0;
}
......@@ -479,6 +506,31 @@ sub BumpLastUsed($) {
return 0;
}
#
# Set last_used to a specific time
#
sub SetLastUsedTime($$) {
my ($self, $ntime) = @_;
return -1
if (!ref($self));
if ($ntime > time()) {
print STDERR "Lease->SetLastUsedTime: Can't set lease last-used time in the future.\n";
return -1
}
if ($ntime < $self->inception()) {
$ntime = 0;
}
my $idx = $self->idx();
DBQueryWarn("update project_leases set last_used=FROM_UNIXTIME($ntime) where lease_idx=$idx")
or return -1;
$self->Refresh();
return 0;
}
#
# Add time to an existing lease
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment