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