forget_me.mod 1.7 KB

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