Happy 2015
[squirrelmail.git] / plugins / squirrelspell / modules / forget_me_not.mod
1 <?php
2
3 /**
4 * forget_me_not.mod
5 *
6 * Squirrelspell module
7 *
8 * This module saves the added words into the user dictionary. Called
9 * after CHECK_ME module.
10 *
11 * @author Konstantin Riabitsev <icon at duke.edu>
12 * @copyright 1999-2015 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
19 global $SQSPELL_VERSION, $SQSPELL_APP_DEFAULT;
20
21 if (! sqgetGlobalVar('words',$words,SQ_POST)) {
22 $words='';
23 }
24 if (! sqgetGlobalVar('sqspell_use_app',$sqspell_use_app,SQ_POST)) {
25 $sqspell_use_app = $SQSPELL_APP_DEFAYLT;
26 }
27
28 /**
29 * Because of the nature of Javascript, there is no way to efficiently
30 * pass an array. Hence, the words will arrive as a string separated by
31 * "%". To get the array, we explode the "%"'s.
32 * Dirty: yes. Is there a better solution? Let me know. ;)
33 */
34 $new_words = explode("%",$words);
35 /**
36 * Load the user dictionary and see if there is anything in it.
37 */
38 $old_words=sqspell_getLang($sqspell_use_app);
39 if (empty($old_words)){
40 $word_dic = $new_words;
41 } else {
42 foreach($new_words as $new_word) {
43 $old_words[]=$new_word;
44 }
45 // make sure that dictionary contains only unique values
46 $word_dic = array_unique($old_words);
47 }
48
49 /**
50 * Write out the file
51 */
52 sqspell_writeWords($word_dic,$sqspell_use_app);
53 /**
54 * display the splash screen, then close it automatically after 2 sec.
55 */
56 $onload = "setTimeout('self.close()', 2000)";
57 $msg = '<form onsubmit="return false"><div style="text-align: center;">'
58 . '<input type="submit" value=" '
59 . _("Close") . ' " onclick="self.close()" /></div></form>';
60 sqspell_makeWindow($onload, _("Personal Dictionary Updated"), null, $msg);
61
62 /**
63 * For Emacs weenies:
64 * Local variables:
65 * mode: php
66 * End:
67 * vim: syntax=php
68 */