forget_me.mod 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * forget_me.mod
  4. * --------------
  5. * Squirrelspell module
  6. *
  7. * Copyright (c) 1999-2002 The SquirrelMail development 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. * $Id$
  14. *
  15. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  16. * @version $Date$
  17. */
  18. global $words_ary, $sqspell_use_app, $SQSPELL_VERSION;
  19. /**
  20. * If something needs to be deleted, then $words_ary will be
  21. * non-zero length.
  22. */
  23. if (sizeof($words_ary)){
  24. $words=sqspell_getWords();
  25. $lang_words = sqspell_getLang($words, $sqspell_use_app);
  26. $msg = '<p>'
  27. . sprintf(_("Deleting the following entries from <strong>%s</strong> dictionary:"), $sqspell_use_app)
  28. . '</p>'
  29. . "<ul>\n";
  30. for ($i=0; $i<sizeof($words_ary); $i++){
  31. /**
  32. * Remove word by word...
  33. */
  34. $lang_words=str_replace("$words_ary[$i]\n", "", $lang_words);
  35. $msg .= "<li>$words_ary[$i]</li>\n";
  36. }
  37. $new_words_ary=split("\n", $lang_words);
  38. /**
  39. * Wipe this lang, if only 2 members in array (no words left).
  40. * # Language
  41. * # End
  42. */
  43. if (sizeof($new_words_ary)<=2) {
  44. $lang_words='';
  45. }
  46. $new_lang_words = $lang_words;
  47. /**
  48. * Write the dictionary back to the disk.
  49. */
  50. $langs=sqspell_getSettings($words);
  51. $words_dic = "# SquirrelSpell User Dictionary $SQSPELL_VERSION\n# "
  52. . "Last Revision: " . date("Y-m-d") . "\n# LANG: "
  53. . join(", ", $langs) . "\n";
  54. for ($i=0; $i<sizeof($langs); $i++){
  55. /**
  56. * Only rewrite the contents of the selected language.
  57. * Otherwise just write the contents back.
  58. */
  59. if ($langs[$i]==$sqspell_use_app) {
  60. $lang_words = $new_lang_words;
  61. } else {
  62. $lang_words = sqspell_getLang($words, $langs[$i]);
  63. }
  64. if ($lang_words) {
  65. $words_dic .= $lang_words;
  66. }
  67. }
  68. $words_dic .= "# End\n";
  69. sqspell_writeWords($words_dic);
  70. $msg .= '</ul><p>' . _("All done!") . "</p>\n";
  71. sqspell_makePage(_("Personal Dictionary Updated"), null, $msg);
  72. } else {
  73. /**
  74. * Click on some words first, Einstein!
  75. */
  76. sqspell_makePage(_("Personal Dictionary"), null,
  77. '<p>' . _("No changes requested.") . '</p>');
  78. }
  79. /**
  80. * For Emacs weenies:
  81. * Local variables:
  82. * mode: php
  83. * End:
  84. */
  85. ?>