/usr/share/perl5/Mail/Box/Manage/User.pm is in libmail-box-perl 2.099-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | # Copyrights 2001-2011 by Mark Overmeer.
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.00.
use strict;
use warnings;
package Mail::Box::Manage::User;
use vars '$VERSION';
$VERSION = '2.099';
use base 'Mail::Box::Manager';
use Mail::Box::Collection ();
#-------------------------------------------
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args) or return ();
my $identity = $self->{MBMU_id} = $args->{identity};
defined $identity or die;
my $top = $args->{folder_id_type} || 'Mail::Box::Identity';
my $coltype = $args->{collection_type} || 'Mail::Box::Collection';
unless(ref $top)
{ my $name = $args->{topfolder_name};
$name = '=' unless defined $name; # MailBox's abbrev to top
$top = $top->new
( name => $name
, manager => $self
, location => scalar($self->folderdir)
, folder_type => $self->defaultFolderType
, collection_type => $coltype
);
}
$self->{MBMU_topfolder} = $top;
$self->{MBMU_delim} = $args->{delimiter} || '/';
$self->{MBMU_inbox} = $args->{inbox};
$self;
}
#-------------------------------------------
sub identity() { shift->{MBMU_id} }
#-------------------------------------------
sub inbox(;$)
{ my $self = shift;
@_ ? ($self->{MBMU_inbox} = shift) : $self->{MBMU_inbox};
}
#-------------------------------------------
# A lot of work still has to be done here: all moves etc must inform
# the "existence" administration as well.
#-------------------------------------------
sub topfolder() { shift->{MBMU_topfolder} }
#-------------------------------------------
sub folder($)
{ my ($self, $name) = @_;
my $top = $self->topfolder or return ();
my @path = split $self->{MBMU_delim}, $name;
return () unless shift @path eq $top->name;
$top->folder(@path);
}
#-------------------------------------------
sub folderCollection($)
{ my ($self, $name) = @_;
my $top = $self->topfolder or return ();
my @path = split $self->{MBMU_delim}, $name;
unless(shift @path eq $top->name)
{ $self->log(ERROR => "Folder name $name not under top.");
return ();
}
my $base = pop @path;
($top->folder(@path), $base);
}
#-------------------------------------------
# This feature is thoroughly tested in the Mail::Box::Netzwert distribution
sub create($@)
{ my ($self, $name, %args) = @_;
my ($dir, $base) = $self->folderCollection($name);
unless(defined $dir)
{ unless($args{create_supers})
{ $self->log(ERROR => "Cannot create $name: higher levels missing");
return undef;
}
(my $upper = $name) =~ s!$self->{MBMU_delim}$base!!
or die "$name - $base";
$dir = $self->create($upper, %args, deleted => 1);
}
my $id = $dir->folder($base);
if(!defined $id)
{ my $idopt= $args{id_options} || [];
$id = $dir->addSubfolder($base, @$idopt, deleted => $args{deleted});
}
elsif($args{deleted})
{ $id->deleted(1);
return $id;
}
elsif($id->deleted)
{ # Revive! Raise the death!
$id->deleted(0);
}
else
{ # Bumped into existing folder
$self->log(ERROR => "Folder $name already exists");
return undef;
}
if(!defined $args{create_real} || $args{create_real})
{ $self->defaultFolderType->create($id->location, %args)
or return undef;
}
$id;
}
#-------------------------------------------
sub delete($)
{ my ($self, $name) = @_;
my $id = $self->folder($name) or return ();
$id->remove;
$self->SUPER::delete($name);
}
#-------------------------------------------
sub rename($$@)
{ my ($self, $oldname, $newname, %args) = @_;
my $old = $self->folder($oldname);
unless(defined $old)
{ $self->log(WARNING
=> "Source for rename does not exist: $oldname to $newname");
return ();
}
my ($newdir, $base) = $self->folderCollection($newname);
unless(defined $newdir)
{ unless($args{create_supers})
{ $self->log(ERROR
=> "Cannot rename $oldname to $newname: higher levels missing");
return ();
}
(my $upper = $newname) =~ s!$self->{MBMU_delim}$base!!
or die "$newname - $base";
$newdir = $self->create($upper, %args, deleted => 1);
}
my $oldlocation = $old->location;
my $new = $old->rename($newdir, $base);
my $newlocation = $new->location;
if($oldlocation ne $newlocation)
{ require Carp;
croak("Physical folder relocation not yet implemented");
# this needs a $old->rename(xx,yy) which isn't implemented yet
}
$self->log(PROGRESS => "Renamed folder $oldname to $newname");
$new;
}
#-------------------------------------------
1;
|