Add ability to control the display of the "Check Spelling" button. Allows administrat...
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me.mod
CommitLineData
849bdf42 1<?php
4b4abf93 2
d112ed5a 3/**
91e0dccc 4 * forget_me.mod
d112ed5a 5 *
4b4abf93 6 * Squirrelspell module
d112ed5a 7 *
8 * This module deletes the words from the user dictionary. Called
91e0dccc 9 * after EDIT_DIC module.
10 *
d112ed5a 11 *
4b4abf93 12 * @author Konstantin Riabitsev <icon at duke.edu>
22387c8d 13 * @copyright 1999-2017 The SquirrelMail Project Team
4b4abf93 14 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
44d661aa 15 * @version $Id$
16 * @package plugins
17 * @subpackage squirrelspell
d112ed5a 18 */
849bdf42 19
7996c920 20global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
d8aa9efe 21
7996c920 22if (! sqgetGlobalVar('words_ary',$words_ary,SQ_POST) || ! is_array($words_ary)) {
23 $words_ary = array();
24}
25
26if (! sqgetGlobalVar('sqspell_use_app',$sqspell_use_app,SQ_POST)){
27 $sqspell_use_app = $SQSPELL_APP_DEFAULT;
28}
d8aa9efe 29
d112ed5a 30/**
31 * If something needs to be deleted, then $words_ary will be
32 * non-zero length.
33 */
7996c920 34if (! empty($words_ary)){
35 $lang_words = sqspell_getLang($sqspell_use_app);
d112ed5a 36 $msg = '<p>'
74091b64 37 . sprintf(_("Deleting the following entries from %s dictionary:"), '<strong>'.$sqspell_use_app.'</strong>')
d112ed5a 38 . '</p>'
39 . "<ul>\n";
7996c920 40
41 // print list of deleted words
42 foreach ($words_ary as $deleted_word) {
3047e291 43 $msg.= '<li>'.sm_encode_html_special_chars($deleted_word)."</li>\n";
d112ed5a 44 }
7996c920 45
46 // rebuild dictionary
47 $new_words_ary = array();
48 foreach ($lang_words as $word){
49 if (! in_array($word,$words_ary)) {
773d8dcd 50 $new_words_ary[]=$word;
7996c920 51 }
d112ed5a 52 }
7996c920 53 // save it
54 sqspell_writeWords($new_words_ary,$sqspell_use_app);
2a917bbc 55 $msg .= '</ul><p>' . _("All done!") . "</p>\n";
d112ed5a 56 sqspell_makePage(_("Personal Dictionary Updated"), null, $msg);
57} else {
58 /**
59 * Click on some words first, Einstein!
60 */
91e0dccc 61 sqspell_makePage(_("Personal Dictionary"), null,
90ad8cd1 62 '<p>' . _("No changes requested.") . '</p>');
d112ed5a 63}
64
65/**
66 * For Emacs weenies:
67 * Local variables:
68 * mode: php
69 * End:
2b6b400e 70 * vim: syntax=php
91e0dccc 71 */