loads of changes and added things
[spider.git] / cmd / directory.pl
1 #
2 # show the contents of the message directory
3 #
4 # Copyright (c) Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, $line;
11 my @ref;
12 my $ref;
13 my @out;
14
15 $f[0] = uc $f[0];
16 if ($f[0] eq 'ALL') {
17   foreach $ref (DXMsg::get_all()) { 
18     next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
19         push @ref, $ref;
20   }
21 } elsif ($f[0] =~ /^O/o) {   # dir/own
22   foreach $ref (DXMsg::get_all()) { 
23     push @ref, $ref if $ref->private && ($ref->to eq $self->call || $ref->from eq $self->call);
24   }
25 } elsif ($f[0] =~ /^N/o) {   # dir/new
26   foreach $ref (DXMsg::get_all()) { 
27     push @ref, $ref if $ref->private && !$ref->read && $ref->to eq $self->call;
28   }
29 } else {
30   my @all = (DXMsg::get_all());
31   my ($i, $count);
32   for ($i = $#all; $i > 0; $i--) {
33     $ref = $all[$i];
34     next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
35         unshift @ref, $ref;
36         last if ++$count > 10;
37   }
38 }
39
40 foreach $ref (@ref) {
41   push @out, $ref->dir;
42 }
43
44 return (1, @out);