HTML fix
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me.mod
1 <?php
2 /**
3 * forget_me.mod
4 * --------------
5 * Squirrelspell module
6 *
7 * Copyright (c) 1999-2005 The SquirrelMail Project Team
8 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 *
10 * This module deletes the words from the user dictionary. Called
11 * after EDIT_DIC module.
12 *
13 *
14 *
15 * @author Konstantin Riabitsev <icon@duke.edu>
16 * @version $Id$
17 * @package plugins
18 * @subpackage squirrelspell
19 */
20
21 global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
22
23 if (! sqgetGlobalVar('words_ary',$words_ary,SQ_POST) || ! is_array($words_ary)) {
24 $words_ary = array();
25 }
26
27 if (! sqgetGlobalVar('sqspell_use_app',$sqspell_use_app,SQ_POST)){
28 $sqspell_use_app = $SQSPELL_APP_DEFAULT;
29 }
30
31 /**
32 * If something needs to be deleted, then $words_ary will be
33 * non-zero length.
34 */
35 if (! empty($words_ary)){
36 $lang_words = sqspell_getLang($sqspell_use_app);
37 $msg = '<p>'
38 . sprintf(_("Deleting the following entries from %s dictionary:"), '<strong>'.$sqspell_use_app.'</strong>')
39 . '</p>'
40 . "<ul>\n";
41
42 // print list of deleted words
43 foreach ($words_ary as $deleted_word) {
44 $msg.= '<li>'.htmlspecialchars($deleted_word)."</li>\n";
45 }
46
47 // rebuild dictionary
48 $new_words_ary = array();
49 foreach ($lang_words as $word){
50 if (! in_array($word,$words_ary)) {
51 $new_words_ary[]=$word;
52 }
53 }
54 // save it
55 sqspell_writeWords($new_words_ary,$sqspell_use_app);
56 $msg .= '</ul><p>' . _("All done!") . "</p>\n";
57 sqspell_makePage(_("Personal Dictionary Updated"), null, $msg);
58 } else {
59 /**
60 * Click on some words first, Einstein!
61 */
62 sqspell_makePage(_("Personal Dictionary"), null,
63 '<p>' . _("No changes requested.") . '</p>');
64 }
65
66 /**
67 * For Emacs weenies:
68 * Local variables:
69 * mode: php
70 * End:
71 * vim: syntax=php
72 */
73 ?>