String bug fix
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me.mod.php
1 <?php
2 /**
3 FORGET_ME.MOD.PHP
4 ------------------
5 This module deletes the words from the user dictionary. Called
6 after EDIT_DIC module.
7 **/
8 // Make it two packs of Guinness and a bag of pistachios, fidian. :)
9 global $words_ary, $sqspell_use_app, $SQSPELL_VERSION;
10 if (sizeof($words_ary)){
11 // something needs to be deleted.
12 $words=sqspell_getWords();
13 $lang_words = sqspell_getLang($words, $sqspell_use_app);
14 $msg = "<p>Deleting the following entries from <strong>$sqspell_use_app</strong> dictionary:</p>
15 <ul>\n";
16 for ($i=0; $i<sizeof($words_ary); $i++){
17 // remove word by word...
18 $lang_words=str_replace("$words_ary[$i]\n", "", $lang_words);
19 $msg .= "<li>$words_ary[$i]</li>\n";
20 }
21 $new_words_ary=split("\n", $lang_words);
22 // Wipe this lang, if only 2 members in array (no words left).
23 if (sizeof($new_words_ary)<=2) $lang_words="";
24 $new_lang_words = $lang_words;
25 // process the stuff and write the dic back.
26 $langs=sqspell_getSettings($words);
27 $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# Last Revision: " . date("Y-m-d") . "\n# LANG: " . join(", ", $langs) . "\n";
28 for ($i=0; $i<sizeof($langs); $i++){
29 if ($langs[$i]==$sqspell_use_app)
30 $lang_words = $new_lang_words;
31 else $lang_words = sqspell_getLang($words, $langs[$i]);
32 if ($lang_words) $words_dic .= $lang_words;
33 }
34 $words_dic .= "# End\n";
35 sqspell_writeWords($words_dic);
36 $msg .= "</ul>
37 <p>All done!</p>\n";
38 sqspell_makePage("Personal Dictionary Updated", null, $msg);
39 } else {
40 // Click on some words first, Einstein!
41 sqspell_makePage("Personal Dictionary", null, "<p>No changes requested.</p>");
42 }
43 ?>
44