1. Added a bit more checking to the rcmd thing to make more sure that this
[spider.git] / cmd / set / privilege.pl
1 #
2 # set the privilege of the user
3 #
4 # call as set/priv n <call> ...
5 #
6 # Copyright (c) 1998 Dirk Koopman G1TLH
7 #
8 # $Id$
9 #
10 my ($self, $line) = @_;
11 my @args = split /\s+/, $line;
12 my $call;
13 my $priv = shift @args;
14 my @out;
15 my $user;
16 my $ref;
17
18 return (0) if $self->priv < 9;
19
20 if ($priv < 0 || $priv > 9) {
21   return (0, $self->msg('e5')); 
22 }
23
24 foreach $call (@args) {
25         $call = uc $call;
26         unless ($self->remotecmd) {
27                 if ($ref = DXChannel->get($call)) {
28                         $ref->priv($priv);
29                         $ref->user->priv($priv);
30                         $ref->user->put();
31                 }
32                 if (!$ref && ($user = DXUser->get($call))) {
33                         $user->priv($priv);
34                         $user->put();
35                 }
36                 if ($ref || $user) {
37                         push @out, $self->msg('priv', $call);
38                 } else {
39                         push @out, $self->msg('e3', "Set Privilege", $call);
40                 }
41         } else {
42                 push @out, $self->msg('sorry');
43         }
44 }
45 return (1, @out);