-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_virtdoms.pl
125 lines (110 loc) · 3.34 KB
/
tree_virtdoms.pl
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
#!/usr/bin/perl
# display the mailboxes tree with virtual domains support
sub getInfos
{
my ($name, $parent, $domain)=mbox_info(@_,0);
$name="<I>$name</I>" unless $parent;
if ($parent eq 'user' || !$parent) { $parent = "foldersTree"; }
elsif ($domain) { $parent .= '@'.$domain; }
return ($name, $parent);
}
print "<DIV ALIGN=RIGHT><A TARGET=mainFrame HREF=mbox_info.cgi>$text{create_mbox}</A></DIV>\n";
if (!$q->param('domain'))
{
$nDom=1;
%localDomains=($imapParams{defaultdomain}=>1);
foreach $entry (@list)
{
($name, $parent, $domain)=mbox_info($entry->[0],0);
if ($domain) { $localDomains{$domain}=1; $nDom++; }
}
if ($nDom>1)
{
print "<B>$text{localdomains}:</B>\n<UL>\n";
foreach (sort keys %localDomains)
{ print "<LI><A HREF=tree.cgi?domain=$_>$_</A></LI>\n"; }
}
}
if ($q->param('domain')) { $myDomain = $q->param('domain'); }
if ($nDom == 1) { $myDomain = $imapParams{defaultdomain}; }
if ($myDomain)
{
print <<START;
<A HREF=frames.html TARGET=_parent>$text{localdomains}</A><BR>
<SCRIPT SRC=treeMenu/ua.js></SCRIPT>
<SCRIPT SRC=treeMenu/ftiens4.js></SCRIPT>
<SCRIPT>
USETEXTLINKS = 0;
STARTALLOPEN = 0;
ICONPATH = 'treeMenu/';
WRAPTEXT = 1;
aMbox=new Array(); n=0;
foldersTree = gFld("<b>$myDomain</b>");
START
use Tree::Simple;
$root = Tree::Simple->new("/", Tree::Simple->ROOT);
$mboxes{"foldersTree"}=$root;
foreach $entry (@list)
{
if ($myDomain eq $imapParams{defaultdomain})
{ next if index($entry->[0],'@')>0 && $entry->[0] !~ /\@$myDomain$/; }
else
{ next unless $entry->[0] =~ /\@$myDomain$/; }
($name, $parent)=getInfos($entry->[0]);
($name, $domain)=split /\@/, $name;
$value = "$name#$parent#$entry->[0]";
$mboxes{$entry->[0]} = Tree::Simple->new($value,$mboxes{$parent});
print "aMbox[n++]=\"$entry->[0]\";\n";
}
# traverse the tree and output the result
$root->traverse(
sub {
my $node = shift;
my ($name, $parent, $entry) = split /#/, $node->getNodeValue();
$parent =~ s/\W/_/g; $parent =~ s/^user//;
if ($node->isLeaf())
{
print "insDoc($parent, gLnk('R','$name','mbox_info.cgi?mbox='+escape('$entry')));\n";
}
else
{
$value = $entry; $value =~ s/\W/_/g; $value =~ s/^user//;
print "$value=insFld($parent, gFld('$name','mbox_info.cgi?mbox='+escape('$entry')));\n";
}
}
);
print "domain='$myDomain';\n" unless $myDomain eq $imapParams{defaultdomain};
print <<END;
</SCRIPT>
<DIV STYLE="position:absolute; top:0; left:0;">
<TABLE BORDER=0><TR><TD>
<A HREF="http://www.treemenu.net/" TARGET=_blank></A>
</TD></TR></TABLE></DIV>
<!-- Build the browser objects and display default view of the tree. -->
</BODY>
<SCRIPT>
url="tree.cgi";
initializeDocument();
function setWidth()
{
if (document.width)
{
wLeft=document.width;
wRight=parent.frames[1].document.width;
}
if (document.body.clientWidth)
{
wLeft=document.body.clientWidth;
wRight=parent.frames[1].document.body.clientWidth;
}
if (wLeft && wRight)
{
wLeft=parseInt(wLeft/(wLeft+wRight)*100);
top.frames[0].setCookie("wLeft",wLeft);
}
}
onresize=setWidth;
</SCRIPT>
END
}
1;