[vhffs-dev] [497] Add quotacheck function to modobot.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 497
Author: misric
Date: 2007-02-24 21:26:56 +0000 (Sat, 24 Feb 2007)
Log Message:
-----------
Add quotacheck function to modobot.pl
Modified Paths:
--------------
branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
branches/vhffs_4.1/vhffs-irc/modobot.pl
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm 2007-02-24 19:47:10 UTC (rev 496)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm 2007-02-24 21:26:56 UTC (rev 497)
@@ -7,7 +7,7 @@
use constant
{
- VHFFS_VERSION => '4.1-alpha (Revision: 481)',
+ VHFFS_VERSION => '4.1-alpha (Revision: 496)',
VHFFS_RELEASE_NAME => "hippocampus",
WAITING_FOR_VALIDATION => 1,
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm 2007-02-24 19:47:10 UTC (rev 496)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm 2007-02-24 21:26:56 UTC (rev 497)
@@ -769,6 +769,31 @@
}
+sub getall_quotalimit
+{
+ my $vhffs = shift;
+ my $limit = shift;
+ $limit = 10 if(! defined $limit );
+ my $db = $vhffs->get_db_object;
+ my @result;
+ my $query = 'SELECT groupname FROM vhffs_groups g LEFT JOIN vhffs_users u ON g.groupname = u.username WHERE g.quota_used >= 0.9 * g.quota AND u.uid IS NULL LIMIT ?';
+
+ my $request = $db->prepare( $query );
+ my $rows = $request->execute($limit);
+
+ return undef if( $rows <= 0 );
+
+ my $names = $request->fetchall_arrayref;
+
+ my $group;
+ foreach my $name ( @{$names} )
+ {
+ $group = Vhffs::Group::get_by_groupname( $vhffs , $name->[0] );
+ push( @result , $group) if( defined $group );
+ }
+ return \@result;
+}
+
sub get_by_gid {
my ($vhffs, $gid) = @_;
my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.uid_mod, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.gid = ?';
Modified: branches/vhffs_4.1/vhffs-irc/modobot.pl
===================================================================
--- branches/vhffs_4.1/vhffs-irc/modobot.pl 2007-02-24 19:47:10 UTC (rev 496)
+++ branches/vhffs_4.1/vhffs-irc/modobot.pl 2007-02-24 21:26:56 UTC (rev 497)
@@ -548,6 +548,18 @@
}
}
+sub quotacheck
+{
+ my $limit = shift;
+ my $list = Vhffs::Group::getall_quotalimit($vhffs,$limit);
+ my $temp;
+ foreach $temp ( @{$list} )
+ {
+ irc_msg("Group ".$temp->get_groupname.": ".$temp->get_quota_used." / ".$temp->get_quota);
+ }
+}
+
+
sub irc_msg
{
my $text = shift;
@@ -600,7 +612,8 @@
irc_msg("desc <group> - give the description of <group>");
irc_msg("web2group <website> - give the groupe name of <website>");
irc_msg("owner <group> - give owner information of <group>");
- irc_msg("lsgroup <group> - give the list of users of <group>");
+ irc_msg("lsgroup <group> - give the list of users of <group>");
+ irc_msg("quotacheck <limit> - give the list of <limit> users where quota limit nearly reach ");
}
elsif ($texte =~ m/^${mynick}: list$/)
@@ -644,7 +657,14 @@
$groupid =~ s/^${mynick}: lsgroup //;
fetch_usergroup ($groupid);
}
+ elsif ($texte =~ m/^${mynick}: quotacheck$/)
+ {
+ my $limit = $texte;
+ $limit =~ s/^{mynick}: quotacheck //;
+ quotacheck($limit);
+ }
+
} # on_public
sub on_kick {