-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.php
255 lines (220 loc) · 8.31 KB
/
setup.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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/**
* User-friendly interface to SIEVE server-side mail filtering.
* Plugin for Squirrelmail 1.4+
*
* Licensed under the GNU GPL. For full terms see the file COPYING that came
* with the Squirrelmail distribution.
*
* Also view plugins/README.plugins for more information.
*
* @version $Id: setup.php 1055 2009-05-29 07:58:18Z avel $
* @author Alexandros Vellis <[email protected]>
* @copyright 2004-2009 The SquirrelMail Project Team, Alexandros Vellis
* @package plugins
* @subpackage avelsieve
*/
/** Include Configuration */
include_once(SM_PATH . 'plugins/avelsieve/config/config.php');
/**
* Register Plugin
* @return void
*/
function squirrelmail_plugin_init_avelsieve() {
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks['optpage_register_block']['avelsieve'] = 'avelsieve_optpage_register_block';
$squirrelmail_plugin_hooks['menuline']['avelsieve'] = 'avelsieve_menuline';
$squirrelmail_plugin_hooks['read_body_header']['avelsieve'] = 'avelsieve_commands_menu';
$squirrelmail_plugin_hooks['search_after_form']['avelsieve'] = 'avelsieve_search_integration';
$squirrelmail_plugin_hooks['configtest']['avelsieve'] = 'avelsieve_configtest';
$squirrelmail_plugin_hooks['right_main_after_header']['avelsieve'] = 'avelsieve_right_main';
$squirrelmail_plugin_hooks['javascript_libs_register']['avelsieve'] = 'avelsieve_register_jslibs';
$squirrelmail_plugin_hooks['generic_header']['avelsieve'] = 'avelsieve_generic_header';
$squirrelmail_plugin_hooks['special_mailbox']['avelsieve'] = 'junkmail_markspecial';
$squirrelmail_plugin_hooks['folders_bottom']['avelsieve'] = 'junkmail_folders';
$squirrelmail_plugin_hooks['template_construct_page_header.tpl']['avelsieve'] = 'avelsieve_menuline_devel';
}
/**
* Register options block page
* @return void
*/
function avelsieve_optpage_register_block() {
global $optpage_blocks, $avelsieve_enable_rules;
if (defined('SM_PATH')) {
bindtextdomain ('avelsieve', SM_PATH . 'plugins/avelsieve/locale');
} else {
bindtextdomain ('avelsieve', '../plugins/avelsieve/locale');
}
textdomain ('avelsieve');
$optpage_blocks[] = array(
'name' => _("Message Filters"),
'url' => '../plugins/avelsieve/table.php',
'desc' => _("Server-Side mail filtering enables you to add criteria in order to automatically forward, delete or place a given message into a folder."),
'js' => false
);
if(in_array(11, $avelsieve_enable_rules)) {
$optpage_blocks[] = array(
'name' => _("Junk Mail Options"),
'url' => '../plugins/avelsieve/edit.php?type=11',
'desc' => _("The Junk Mail Filter gathers all unwanted SPAM / Junk messages in your Junk folder."),
'js' => false
);
}
if (defined('SM_PATH')) {
bindtextdomain('squirrelmail', SM_PATH . 'locale');
} else {
bindtextdomain ('squirrelmail', '../locale');
}
textdomain('squirrelmail');
}
/**
* Display menuline link (Squirrelmail DEVEL 1.5 version)
* @return void
*/
function avelsieve_menuline_devel() {
global $avelsieveheaderlink;
if($avelsieveheaderlink) {
global $oTemplate, $nbsp;
bindtextdomain('avelsieve', SM_PATH . 'plugins/avelsieve/locale');
textdomain ('avelsieve');
$output = makeInternalLink('plugins/avelsieve/table.php', _("Filters")) . ' ';
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain ('squirrelmail');
return array('menuline' => $output);
}
}
/**
* Display menuline link
* @return void
*/
function avelsieve_menuline() {
global $avelsieveheaderlink;
if($avelsieveheaderlink) {
bindtextdomain('avelsieve', SM_PATH . 'plugins/avelsieve/locale');
textdomain ('avelsieve');
displayInternalLink('plugins/avelsieve/table.php',_("Filters"));
echo " \n";
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain ('squirrelmail');
}
}
/**
* While showing a message, display filter commands.
* @return void
* @see avelsieve_commands_menu_do()
*/
function avelsieve_commands_menu() {
include_once(SM_PATH . 'plugins/avelsieve/include/message_commands.inc.php');
avelsieve_commands_menu_do();
}
/**
* Integration with Advanced Search.
* @return void
* @see avelsieve_search_integration_do()
*/
function avelsieve_search_integration() {
global $squirrelmail_plugin_hooks, $SQM_INTERNAL_VERSION, $version;
if(($SQM_INTERNAL_VERSION[0] == 1 && $SQM_INTERNAL_VERSION[1] >= 5)) {
include_once(SM_PATH . 'plugins/avelsieve/include/search_integration.inc.php');
avelsieve_search_integration_do();
}
}
/**
* Function to insert stuff in HTML head section, mainly javascripts.
*
* Used at the moment in avelsieve's edit.php.
*/
function avelsieve_generic_header() {
global $PHP_SELF, $base_uri, $javascript_on;
if(!$javascript_on) return;
if(stristr(basename($PHP_SELF), 'edit.php')) {
// Edit page (edit.php)
$js = array('prototype.js', 'avelsieve_common.js', 'avelsieve_edit.js', 'prototype-base-extensions.js', 'prototype-date-extensions.js', 'datepicker.js');
echo "\n".'<link rel="stylesheet" type="text/css" href="'.$base_uri.'plugins/avelsieve/styles/datepicker.css"></link>' . "\n";
} elseif(stristr(basename($PHP_SELF), 'table.php')) {
// Table Page (table.php)
$js = array('prototype.js', 'avelsieve_common.js', 'avelsieve_table.js');
echo '<style type="text/css">'.avelsieve_css_styles().'</style>';
}
if(isset($js)) {
foreach($js as $j) {
echo "\n".'<script language="JavaScript" type="text/javascript" src="'.$base_uri.'plugins/avelsieve/javascripts/'.$j.'"></script>';
}
}
}
/**
* Junk Mail functionality: This marks a junk folder as "special" to Squirrelmail.
*
* @param string $box
* @return mixed Return true if this is the special Junk folder.
*/
function junkmail_markspecial($box) {
global $avelsieve_enable_rules, $delimiter;
if(!in_array(11,$avelsieve_enable_rules)) return;
if($box == 'Junk' || $box == 'INBOX.Junk') {
return true;
}
$parts = preg_split('/'.str_replace('.', '\.',$delimiter).'/', $box);
if(sizeof($parts) > 1 && ($parts[0] == 'Junk' || $parts[1] == 'Junk')) {
return true;
}
}
/**
* Call functions that can be called in Message listing (src/right_main.php).
*
* 1) Junk Mail functionality: Link to options from Junk folder.
* 2) Vacation Rule reminder, from INBOX folder.
*
* @see avelsieve_right_main_do()
*/
function avelsieve_right_main() {
include_once(SM_PATH . 'plugins/avelsieve/include/right_main.inc.php');
avelsieve_right_main_do();
}
/**
* Junk Mail functionality: Link to options, from Folders Page (folders.php).
*/
function junkmail_folders() {
global $avelsieve_enable_rules, $mailbox;
if(!in_array(11,$avelsieve_enable_rules)) return;
include_once(SM_PATH . 'plugins/avelsieve/include/junkmail.inc.php');
junkmail_folders_do();
}
/**
* Configuration Test
* @return boolean
*/
function avelsieve_configtest() {
include_once(SM_PATH . 'plugins/avelsieve/include/configtest.inc.php');
return avelsieve_configtest_do();
}
/**
* Register the main avelsieve scripts with the javascript_libs plugin.
*/
function avelsieve_register_jslibs() {
global $plugins;
if(in_array('javascript_libs', $plugins)) {
javascript_libs_register('plugins/avelsieve/table.php', array('prototype-1.6.0.3/prototype.js', 'scriptaculous-1.8.1/effects.js'));
javascript_libs_register('plugins/avelsieve/edit.php', array('prototype-1.6.0.3/prototype.js', 'scriptaculous-1.8.1/effects.js'));
}
}
/**
* Return information about plugin.
* @return array
*/
function avelsieve_info() {
return array(
'english_name' => 'Avelsieve - Sieve Mail Filters',
'version' => '1.9.9',
'summary' => 'An easy user interface for creating Sieve scripts on a Sieve-compliant (RFC 5028) server.',
'details' => 'Avelsieve - Sieve Mail Filters for Squirrelmail - allows editing of Sieve mail filtering scripts on a Sieve-compliant (RFC 5028) server.'
);
}
/**
* Return plugin version.
* @return string
*/
function avelsieve_version() {
$info = avelsieve_info();
return $info['version'];
}