-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathleft-ezmlm.php
166 lines (146 loc) · 4.59 KB
/
left-ezmlm.php
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
<?php
// navigation bar - ezmlm mailinglists manager
// $Id: left-ezmlm.php,v 2.42 2007-02-15 12:07:12 turbo Exp $
//
// {{{ Setup session etc
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
require($_SESSION["path"]."/include/pql_ezmlm.inc");
require($_SESSION["path"]."/left-head.html");
// }}}
?>
<!-- EZMLM Mailinglists -->
<div id="el1Parent" class="parent">
<a class="item" href="ezmlm.php">
<font color="black" class="heada"><b>Mailinglists</b></font>
</a>
</div>
<div id="el2Parent" class="parent">
<nobr>
<a href="ezmlm_add.php">Add a mailing list to system</a>
</nobr>
</div>
<?php
// Initialize
$_pql = new pql($_SESSION["USER_HOST"], $_SESSION["USER_DN"], $_SESSION["USER_PASS"], false, 0);
// {{{ Get the domains/branches
if($_SESSION["ALLOW_BRANCH_CREATE"]) {
// This is a 'super-admin'. Should be able to read EVERYTHING!
$domains = pql_get_domains();
} else {
// Get ALL domains we have access to.
// administrator: USER_DN
// in the domain object
foreach($_SESSION["BASE_DN"] as $dn) {
$dom = $_pql->get_attribute($dn, pql_get_define("PQL_ATTR_ADMINISTRATOR_EZMLM"), $_SESSION["USER_DN"]);
if($dom) {
foreach($dom as $d) {
$domains[] = urlencode($d);
}
}
}
}
// }}}
if(!is_array($domains)) {
// {{{ No domain defined - report it
?>
<!-- start domain parent -->
<?php if($_SESSION["opera"]) { ?>
<div id="el0000Parent" class="parent" onclick="showhide(el0000Spn, el0000Img)">
<img name="imEx" src="images/spacer.png" border="0" alt="-" width="9" height="9" id="el0000Img">
<font color="black" class="heada">no domains</font></a>
</div>
<?php } else { ?>
<div id="el0000Parent" class="parent">
<img name="imEx" src="images/plus.png" border="0" alt="+" width="9" height="9" id="el0000Img">
<font color="black" class="heada">no domains</font></a>
</div>
<?php
// }}}
}
?>
<!-- end domain parent -->
</body>
</html>
<?php
die(); // No point in continuing from here!
} else {
// {{{ We got at least one domain - get it's mailing lists
foreach($domains as $key => $domain) {
$number_of_lists = -1; // So that we end up with 0 for first list!
// Get base directory for mails
if(($basemaildir = $_pql->get_attribute($domain, pql_get_define("PQL_ATTR_BASEMAILDIR")))) {
// Get (and remember) lists in this directory
$user = $_pql->get_attribute($domain, pql_get_define("PQL_ATTR_EZMLM_USER"));
if($ezmlm = new ezmlm($user, $basemaildir)) {
if(@$ezmlm->mailing_lists[0]["name"]) {
$lists[$domain] = $ezmlm->mailing_lists;
}
}
}
}
// }}}
if(is_array($lists)) {
// {{{ Load and arrange the list information
foreach($lists as $dom => $entry) {
$index = array();
foreach($entry as $listnumber => $listarray) {
if(is_array($listarray)) {
$listname = $lists[$dom][$listnumber]["name"];
$listhost = $lists[$dom][$listnumber]["host"];
// Remember the listname, so we can sort below.
$index[] = $listname;
foreach($listarray as $key => $value) {
$mailinglists[$listnumber][$key]= $value;
$mailinglists_index[$listname] = $listnumber;
}
$listnumber++;
}
}
// Sort the domainname lists alphabetically.
asort($index);
foreach($index as $number => $name) {
$mailinglists_hostsindex[$listhost][$dom][$name] = $number;
}
}
// }}}
if($mailinglists_hostsindex) {
// {{{ Sort lists by domainname
foreach($mailinglists_hostsindex as $domainname => $listnames) {
foreach($listnames as $branch => $listarray) {
// Get Root DN
$rootdn = pql_get_rootdn($branch, 'left-ezmlm.php');
// URL encode the branch DN so it survives intact
$branch = urlencode($branch);
$links = array(pql_complete_constant($LANG->_('Add a mailinglist to %domainname%'),
array('domainname' => $domainname)) =>
"ezmlm_add.php?rootdn=$rootdn&domain=$branch&domainname=$domainname");
// Go through each list in this branch/domain
foreach($listarray as $listname => $listnumber) {
$new = array($listname => "ezmlm_detail.php?rootdn=$rootdn&domain=$branch&domainname=$domainname&listno=$listnumber");
// Add the link to the main array
$links = $links + $new;
}
pql_format_tree($domainname, "ezmlm_detail.php?rootdn=$rootdn&domain=$branch&domainname=$domainname", $links, 0);
// This an ending for the domain tree
pql_format_tree_end();
}
}
// }}}
}
}
}
require("./left-trailer.html");
?>
</body>
</html>
<?php
pql_flush();
/*
* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>