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