~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to src/options_highlight.php

  • Committer: Bazaar Package Importer
  • Author(s): Sam Johnston
  • Date: 2004-02-04 01:42:12 UTC
  • Revision ID: james.westby@ubuntu.com-20040204014212-ek9533qvd2vo1wa1
Tags: upstream-1.5.0
ImportĀ upstreamĀ versionĀ 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * options_highlight.php
 
5
 *
 
6
 * Copyright (c) 1999-2003 The SquirrelMail Project Team
 
7
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 
8
 *
 
9
 * Displays message highlighting options
 
10
 *
 
11
 * $Id: options_highlight.php,v 1.53 2003/12/01 21:56:57 cigamit Exp $
 
12
 * @package squirrelmail
 
13
 */
 
14
 
 
15
/** Path for SquirrelMail required files. */
 
16
define('SM_PATH','../');
 
17
 
 
18
/* SquirrelMail required files. */
 
19
require_once(SM_PATH . 'include/validate.php');
 
20
require_once(SM_PATH . 'functions/display_messages.php');
 
21
require_once(SM_PATH . 'functions/imap.php');
 
22
require_once(SM_PATH . 'functions/plugin.php');
 
23
require_once(SM_PATH . 'functions/strings.php');
 
24
require_once(SM_PATH . 'functions/html.php');
 
25
 
 
26
/* get globals */
 
27
if (isset($_GET['action'])) {
 
28
    $action = $_GET['action'];
 
29
}
 
30
if (isset($_GET['theid'])) {
 
31
    $theid = $_GET['theid'];
 
32
}
 
33
if (isset($_GET['identname'])) {
 
34
    $identname = $_GET['identname'];
 
35
}
 
36
if (isset($_GET['newcolor_choose'])) {
 
37
    $newcolor_choose = $_GET['newcolor_choose'];
 
38
}
 
39
if (isset($_GET['newcolor_input'])) {
 
40
    $newcolor_input = $_GET['newcolor_input'];
 
41
}
 
42
if (isset($_GET['color_type'])) {
 
43
    $color_type = $_GET['color_type'];
 
44
}
 
45
if (isset($_GET['match_type'])) {
 
46
    $match_type = $_GET['match_type'];
 
47
}
 
48
if (isset($_GET['value'])) {
 
49
    $value = $_GET['value'];
 
50
}
 
51
 
 
52
/* end of get globals */
 
53
 
 
54
function oh_opt( $val, $sel, $tit ) {
 
55
    echo "<option value=\"$val\"";
 
56
    if ( $sel )
 
57
        echo ' selected';
 
58
    echo  ">$tit</option>\n";
 
59
}
 
60
 
 
61
if (! isset($action)) {
 
62
    $action = '';
 
63
}
 
64
if (! isset($message_highlight_list)) {
 
65
    $message_highlight_list = array();
 
66
}
 
67
 
 
68
if (isset($theid) && ($action == 'delete') ||
 
69
                     ($action == 'up')     ||
 
70
                     ($action == 'down')) {
 
71
    $new_rules = array();
 
72
    switch($action) {
 
73
        case('delete'):
 
74
            foreach($message_highlight_list as $rid => $rule) {
 
75
                 if($rid != $theid) {
 
76
                     $new_rules[] = $rule;
 
77
                 }
 
78
            }
 
79
            break;
 
80
        case('down'):
 
81
            $theid++;
 
82
        case('up'):
 
83
            foreach($message_highlight_list as $rid => $rule) {
 
84
                if($rid == $theid) {
 
85
                    $temp_rule         = $new_rules[$rid-1];
 
86
                    $new_rules[$rid-1] = $rule;
 
87
                    $new_rules[$rid]   = $temp_rule;
 
88
                } else {
 
89
                    $new_rules[$rid]   = $rule;
 
90
                }
 
91
            }
 
92
            break;
 
93
        default:
 
94
            $new_rules = $message_highlight_list;
 
95
            break;
 
96
    }
 
97
    $message_highlight_list = $new_rules;    
 
98
 
 
99
    setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
 
100
 
 
101
    header( 'Location: ' .get_location(). '/options_highlight.php' );
 
102
    exit;
 
103
} else if ($action == 'save') {
 
104
 
 
105
    if ($color_type == 1) $newcolor = $newcolor_choose;
 
106
    elseif ($color_type == 2) $newcolor = $newcolor_input;
 
107
    else $newcolor = $color_type;
 
108
 
 
109
    $newcolor = str_replace('#', '', $newcolor);
 
110
    $newcolor = str_replace('"', '', $newcolor);
 
111
    $newcolor = str_replace('\'', '', $newcolor);
 
112
    $value = str_replace(',', ' ', $value);
 
113
 
 
114
    if(isset($theid)) {
 
115
        $message_highlight_list[$theid] = 
 
116
            array( 'name' => $identname, 'color' => $newcolor,
 
117
                   'value' => $value, 'match_type' => $match_type );
 
118
    } else {
 
119
        $message_highlight_list[] = 
 
120
            array( 'name' => $identname, 'color' => $newcolor,
 
121
                   'value' => $value, 'match_type' => $match_type );
 
122
    }
 
123
 
 
124
    setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
 
125
}
 
126
displayPageHeader($color, 'None');
 
127
 
 
128
echo
 
129
html_tag( 'table', "\n" .
 
130
    html_tag( 'tr', "\n" .
 
131
        html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left')
 
132
    ),
 
133
    'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" .
 
134
html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"' ) . 
 
135
     html_tag( 'tr' ) . "\n" .
 
136
         html_tag( 'td', '', 'left' );
 
137
 
 
138
echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
 
139
        ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
 
140
$mhl_count = count($message_highlight_list);
 
141
if ($mhl_count > 0) {
 
142
    echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n";
 
143
    for ($i=0; $i < $mhl_count; $i++) {
 
144
        $match_type = '';
 
145
        switch ($message_highlight_list[$i]['match_type'] ) {
 
146
            case 'from' :
 
147
                $match_type = _("From");
 
148
            break;
 
149
            case 'to' :
 
150
                $match_type = _("To");
 
151
            break;
 
152
            case 'cc' :
 
153
                $match_type = _("Cc");
 
154
            break;
 
155
            case 'to_cc' :
 
156
                $match_type = _("To or Cc");
 
157
            break;
 
158
            case 'subject' :
 
159
                $match_type = _("subject");
 
160
            break;
 
161
        }
 
162
 
 
163
        $links = '<small>[<a href="options_highlight.php?action=edit&amp;theid=' . $i . '">' .
 
164
                 _("Edit") .
 
165
                 '</a>]&nbsp;[<a href="options_highlight.php?action=delete&amp;theid='.  $i . '">' .
 
166
                 _("Delete");
 
167
        if($i > 0) {
 
168
            $links .= '</a>]&nbsp;[<a href="options_highlight.php?action=up&amp;theid='.  $i . '">' .  _("Up");
 
169
        }
 
170
        if($i+1 < $mhl_count) {
 
171
            $links .= '</a>]&nbsp;[<a href="options_highlight.php?action=down&amp;theid='.  $i . '">' .  _("Down");
 
172
        }
 
173
        $links .= '</a>]</small>';
 
174
 
 
175
        echo html_tag( 'tr',
 
176
                    html_tag( 'td',
 
177
                        $links,
 
178
                    'left', $color[4], 'width="20%" nowrap' ) .
 
179
                    html_tag( 'td',
 
180
                        htmlspecialchars($message_highlight_list[$i]['name']) ,
 
181
                    'left' ) .
 
182
                    html_tag( 'td',
 
183
                        $match_type . ' = ' .
 
184
                        htmlspecialchars($message_highlight_list[$i]['value']) ,
 
185
                    'left' ) ,
 
186
                '', $message_highlight_list[$i]['color'] ) . "\n";
 
187
    }
 
188
    echo "</table>\n".
 
189
        "<br>\n";
 
190
} else {
 
191
    echo '<center>' . _("No highlighting is defined") . "</center><br>\n".
 
192
        "<br>\n";
 
193
}
 
194
if ($action == 'edit' || $action == 'add') {
 
195
 
 
196
    $color_list[0] = '4444aa';
 
197
    $color_list[1] = '44aa44';
 
198
    $color_list[2] = 'aaaa44';
 
199
    $color_list[3] = '44aaaa';
 
200
    $color_list[4] = 'aa44aa';
 
201
    $color_list[5] = 'aaaaff';
 
202
    $color_list[6] = 'aaffaa';
 
203
    $color_list[7] = 'ffffaa';
 
204
    $color_list[8] = 'aaffff';
 
205
    $color_list[9] = 'ffaaff';
 
206
    $color_list[10] = 'aaaaaa';
 
207
    $color_list[11] = 'bfbfbf';
 
208
    $color_list[12] = 'dfdfdf';
 
209
    $color_list[13] = 'ffffff';
 
210
 
 
211
    # helpful color chart from http://www.visibone.com/colorlab/big.html
 
212
    $new_color_list["0,0"] = 'cccccc';
 
213
    $new_color_list["0,1"] = '999999';
 
214
    $new_color_list["0,2"] = '666666';
 
215
    $new_color_list["0,3"] = '333333';
 
216
    $new_color_list["0,4"] = '000000';
 
217
 
 
218
    # red
 
219
    $new_color_list["1,0"] = 'ff0000';
 
220
    $new_color_list["1,1"] = 'cc0000';
 
221
    $new_color_list["1,2"] = '990000';
 
222
    $new_color_list["1,3"] = '660000';
 
223
    $new_color_list["1,4"] = '330000';
 
224
 
 
225
    $new_color_list["2,0"] = 'ffcccc';
 
226
    $new_color_list["2,1"] = 'cc9999';
 
227
    $new_color_list["2,2"] = '996666';
 
228
    $new_color_list["2,3"] = '663333';
 
229
    $new_color_list["2,4"] = '330000';
 
230
 
 
231
    $new_color_list["3,0"] = 'ffcccc';
 
232
    $new_color_list["3,1"] = 'ff9999';
 
233
    $new_color_list["3,2"] = 'ff6666';
 
234
    $new_color_list["3,3"] = 'ff3333';
 
235
    $new_color_list["3,4"] = 'ff0000';
 
236
 
 
237
    # green
 
238
    $new_color_list["4,0"] = '00ff00';
 
239
    $new_color_list["4,1"] = '00cc00';
 
240
    $new_color_list["4,2"] = '009900';
 
241
    $new_color_list["4,3"] = '006600';
 
242
    $new_color_list["4,4"] = '003300';
 
243
 
 
244
    $new_color_list["5,0"] = 'ccffcc';
 
245
    $new_color_list["5,1"] = '99cc99';
 
246
    $new_color_list["5,2"] = '669966';
 
247
    $new_color_list["5,3"] = '336633';
 
248
    $new_color_list["5,4"] = '003300';
 
249
 
 
250
    $new_color_list["6,0"] = 'ccffcc';
 
251
    $new_color_list["6,1"] = '99ff99';
 
252
    $new_color_list["6,2"] = '66ff66';
 
253
    $new_color_list["6,3"] = '33ff33';
 
254
    $new_color_list["6,4"] = '00ff00';
 
255
 
 
256
    # blue
 
257
    $new_color_list["7,0"] = '0000ff';
 
258
    $new_color_list["7,1"] = '0000cc';
 
259
    $new_color_list["7,2"] = '000099';
 
260
    $new_color_list["7,3"] = '000066';
 
261
    $new_color_list["7,4"] = '000033';
 
262
 
 
263
    $new_color_list["8,0"] = 'ccccff';
 
264
    $new_color_list["8,1"] = '9999cc';
 
265
    $new_color_list["8,2"] = '666699';
 
266
    $new_color_list["8,3"] = '333366';
 
267
    $new_color_list["8,4"] = '000033';
 
268
 
 
269
    $new_color_list["9,0"] = 'ccccff';
 
270
    $new_color_list["9,1"] = '9999ff';
 
271
    $new_color_list["9,2"] = '6666ff';
 
272
    $new_color_list["9,3"] = '3333ff';
 
273
    $new_color_list["9,4"] = '0000ff';
 
274
 
 
275
    # yellow
 
276
    $new_color_list["10,0"] = 'ffff00';
 
277
    $new_color_list["10,1"] = 'cccc00';
 
278
    $new_color_list["10,2"] = '999900';
 
279
    $new_color_list["10,3"] = '666600';
 
280
    $new_color_list["10,4"] = '333300';
 
281
 
 
282
    $new_color_list["11,0"] = 'ffffcc';
 
283
    $new_color_list["11,1"] = 'cccc99';
 
284
    $new_color_list["11,2"] = '999966';
 
285
    $new_color_list["11,3"] = '666633';
 
286
    $new_color_list["11,4"] = '333300';
 
287
 
 
288
    $new_color_list["12,0"] = 'ffffcc';
 
289
    $new_color_list["12,1"] = 'ffff99';
 
290
    $new_color_list["12,2"] = 'ffff66';
 
291
    $new_color_list["12,3"] = 'ffff33';
 
292
    $new_color_list["12,4"] = 'ffff00';
 
293
 
 
294
    # cyan
 
295
    $new_color_list["13,0"] = '00ffff';
 
296
    $new_color_list["13,1"] = '00cccc';
 
297
    $new_color_list["13,2"] = '009999';
 
298
    $new_color_list["13,3"] = '006666';
 
299
    $new_color_list["13,4"] = '003333';
 
300
 
 
301
    $new_color_list["14,0"] = 'ccffff';
 
302
    $new_color_list["14,1"] = '99cccc';
 
303
    $new_color_list["14,2"] = '669999';
 
304
    $new_color_list["14,3"] = '336666';
 
305
    $new_color_list["14,4"] = '003333';
 
306
 
 
307
    $new_color_list["15,0"] = 'ccffff';
 
308
    $new_color_list["15,1"] = '99ffff';
 
309
    $new_color_list["15,2"] = '66ffff';
 
310
    $new_color_list["15,3"] = '33ffff';
 
311
    $new_color_list["15,4"] = '00ffff';
 
312
 
 
313
    # magenta
 
314
    $new_color_list["16,0"] = 'ff00ff';
 
315
    $new_color_list["16,1"] = 'cc00cc';
 
316
    $new_color_list["16,2"] = '990099';
 
317
    $new_color_list["16,3"] = '660066';
 
318
    $new_color_list["16,4"] = '330033';
 
319
 
 
320
    $new_color_list["17,0"] = 'ffccff';
 
321
    $new_color_list["17,1"] = 'cc99cc';
 
322
    $new_color_list["17,2"] = '996699';
 
323
    $new_color_list["17,3"] = '663366';
 
324
    $new_color_list["17,4"] = '330033';
 
325
 
 
326
    $new_color_list["18,0"] = 'ffccff';
 
327
    $new_color_list["18,1"] = 'ff99ff';
 
328
    $new_color_list["18,2"] = 'ff66ff';
 
329
    $new_color_list["18,3"] = 'ff33ff';
 
330
    $new_color_list["18,4"] = 'ff00ff';
 
331
 
 
332
    $selected_input = '';
 
333
    $selected_choose = '';
 
334
 
 
335
    for ($i=0; $i < 14; $i++) {
 
336
        ${"selected".$i} = '';
 
337
    }
 
338
    if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
 
339
        for ($i=0; $i < 14; $i++) {
 
340
            if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
 
341
                $selected_choose = ' checked';
 
342
                ${"selected".$i} = ' selected';
 
343
                continue;
 
344
            }
 
345
        }
 
346
    }
 
347
 
 
348
    if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
 
349
        $current_color = $message_highlight_list[$theid]['color'];
 
350
    }
 
351
    else {
 
352
        $current_color = '63aa7f';
 
353
    }
 
354
 
 
355
    $pre_defined_color = 0;
 
356
    for($x = 0; $x < 5; $x++) {
 
357
        for($y = 0; $y < 19; $y++) {
 
358
            $gridindex = "$y,$x";
 
359
            $gridcolor = $new_color_list[$gridindex];
 
360
            if ($gridcolor == $current_color) {
 
361
                $pre_defined_color = 1;
 
362
                break;
 
363
            }
 
364
        }
 
365
    }
 
366
 
 
367
    if (!isset($message_highlight_list[$theid]['color']))
 
368
        $selected_choose = ' checked';
 
369
    else if ($pre_defined_color)
 
370
        $selected_predefined = ' checked';
 
371
    else if ($selected_choose == '')
 
372
        $selected_input = ' checked';
 
373
 
 
374
    echo '<form name="f" action="options_highlight.php">' . "\n";
 
375
    echo '<input type="hidden" value="save" name="action">' . "\n";
 
376
    if($action == 'edit')
 
377
        echo '<input type="hidden" value="'.(isset($theid)?$theid:'').'" name="theid">' . "\n";
 
378
    echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n";
 
379
    echo html_tag( 'tr', '', '', $color[0] ) . "\n";
 
380
    echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "<b>\n";
 
381
    echo _("Identifying name") . ":";
 
382
    echo '      </b></td>' . "\n";
 
383
    echo html_tag( 'td', '', 'left' ) . "\n";
 
384
    if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['name']))
 
385
        $disp = $message_highlight_list[$theid]['name'];
 
386
    else
 
387
        $disp = '';
 
388
    $disp = htmlspecialchars($disp);
 
389
    echo "         <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
 
390
    echo "      </td>\n";
 
391
    echo "   </tr>\n";
 
392
    echo html_tag( 'tr', html_tag( 'td', '<small><small>&nbsp;</small></small>', 'left' ) ) ."\n";
 
393
    echo html_tag( 'tr', '', '', $color[0] ) . "\n";
 
394
    echo html_tag( 'td', '<b>'. _("Color") . ':</b>', 'right' );
 
395
    echo html_tag( 'td', '', 'left' );
 
396
    echo "         <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
 
397
    echo "            <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
 
398
    echo "            <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
 
399
    echo "            <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
 
400
    echo "            <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
 
401
    echo "            <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
 
402
    echo "            <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
 
403
    echo "            <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
 
404
    echo "            <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
 
405
    echo "            <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
 
406
    echo "            <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
 
407
    echo "            <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
 
408
    echo "            <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
 
409
    echo "            <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
 
410
    echo "            <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
 
411
    echo "         </select><br>\n";
 
412
    echo "         <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
 
413
    if ($selected_input && isset($theid)) echo $message_highlight_list[$theid]["color"];
 
414
    echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n";
 
415
    echo "      </td>\n";
 
416
    echo "   </tr>\n";
 
417
 
 
418
    # Show grid of color choices
 
419
    echo html_tag( 'tr', '', '', $color[0] ) . "\n";
 
420
    echo html_tag( 'td', '', 'left', '', 'colspan="2"' );
 
421
    echo html_tag( 'table', '', 'center', '', 'border=0 cellpadding="2" cellspacing="1"' ) . "\n";
 
422
 
 
423
    for($x = 0; $x < 5; $x++) {
 
424
        echo html_tag( 'tr' ) . "\n";
 
425
        for($y = 0; $y < 19; $y++) {
 
426
        $gridindex = "$y,$x";
 
427
        $gridcolor = $new_color_list[$gridindex];
 
428
        $selected = ($gridcolor == $current_color) ? ' checked' : '' ;
 
429
        echo html_tag( 'td', '<input type="radio" name="color_type" value="#' . $gridcolor .'"' . $selected . '>', 'left', $gridcolor, 'colspan="2"' );
 
430
        }
 
431
        echo "</tr>\n";
 
432
    }
 
433
    echo "</table>\n";
 
434
    echo "</td></tr>\n";
 
435
 
 
436
    echo html_tag( 'tr', html_tag( 'td', '<small><small>&nbsp;</small></small>', 'left' ) ) . "\n";
 
437
    echo html_tag( 'tr', '', '', $color[0] ) . "\n";
 
438
    echo html_tag( 'td', '', 'center', '', 'colspan="2"' ) . "\n";
 
439
    echo "         <select name=match_type>\n";
 
440
    oh_opt( 'from',
 
441
            (isset($theid)?$message_highlight_list[$theid]['match_type'] == 'from':1),
 
442
            _("From") );
 
443
    oh_opt( 'to',
 
444
            (isset($theid)?$message_highlight_list[$theid]['match_type'] == 'to':0),
 
445
            _("To") );
 
446
    oh_opt( 'cc',
 
447
            (isset($theid)?$message_highlight_list[$theid]['match_type'] == 'cc':0),
 
448
            _("Cc") );
 
449
    oh_opt( 'to_cc',
 
450
            (isset($theid)?$message_highlight_list[$theid]['match_type'] == 'to_cc':0),
 
451
            _("To or Cc") );
 
452
    oh_opt( 'subject',
 
453
            (isset($theid)?$message_highlight_list[$theid]['match_type'] == 'subject':0),
 
454
            _("Subject") );
 
455
    echo "         </select>\n";
 
456
    echo '<b>' . _("Matches") . ':</b> ';
 
457
    if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['value']))
 
458
        $disp = $message_highlight_list[$theid]['value'];
 
459
    else
 
460
        $disp = '';
 
461
    $disp = htmlspecialchars($disp);
 
462
    echo '         <input type="text" value="' . $disp .
 
463
        '" name="value" size=40>';
 
464
    echo "        </td>\n";
 
465
    echo "   </tr>\n";
 
466
    echo "</table>\n";
 
467
    echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
 
468
    echo "</form>\n";
 
469
}
 
470
do_hook('options_highlight_bottom');
 
471
?>
 
472
</table></body></html>