| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * SETUP.PHP |
| 5 | * --------- |
| 6 | * This is a standard Squirrelmail-1.2 API for plugins. |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * This function checks whether the user's USER_AGENT is known to |
| 11 | * be broken. If so, returns true and the plugin is invisible to the |
| 12 | * offending browser. |
| 13 | */ |
| 14 | function soupNazi(){ |
| 15 | global $HTTP_USER_AGENT; |
| 16 | require ('../plugins/squirrelspell/sqspell_config.php'); |
| 17 | $soup_nazi = false; |
| 18 | |
| 19 | $soup_menu = explode(',', $SQSPELL_SOUP_NAZI); |
| 20 | for ($i = 0; $i < sizeof($soup_menu); $i++) { |
| 21 | if (stristr($HTTP_USER_AGENT, trim($soup_menu[$i]))) { |
| 22 | $soup_nazi=true; |
| 23 | } |
| 24 | } |
| 25 | return $soup_nazi; |
| 26 | } |
| 27 | |
| 28 | function squirrelmail_plugin_init_squirrelspell() { |
| 29 | /* Standard initialization API. */ |
| 30 | global $squirrelmail_plugin_hooks; |
| 31 | |
| 32 | $squirrelmail_plugin_hooks["compose_button_row"]["squirrelspell"] = "squirrelspell_setup"; |
| 33 | $squirrelmail_plugin_hooks["options_register"]["squirrelspell"] = "squirrelspell_options"; |
| 34 | $squirrelmail_plugin_hooks["options_link_and_description"]["squirrelspell"] = "squirrelspell_options"; |
| 35 | } |
| 36 | |
| 37 | function squirrelspell_options() { |
| 38 | // Gets added to the user's OPTIONS page. |
| 39 | global $optionpages; |
| 40 | |
| 41 | if (soupNazi()) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | /* Register Squirrelspell with the $optionpages array. */ |
| 46 | $optionpages[] = array( |
| 47 | 'name' => 'SpellChecker Options', |
| 48 | 'url' => '../plugins/squirrelspell/sqspell_options.php', |
| 49 | 'desc' => 'Here you may set up how your personal dictionary is stored, |
| 50 | edit it, or choose which languages should be available to |
| 51 | you when spell-checking.', |
| 52 | 'js' => true |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | function squirrelspell_setup() { |
| 57 | /* Gets added to the COMPOSE buttons row. */ |
| 58 | if (soupNazi()) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | ?> |
| 63 | <script type="text/javascript"> |
| 64 | <!-- |
| 65 | // using document.write to hide this functionality from people |
| 66 | // with JavaScript turned off. |
| 67 | document.write("<input type=\"button\" value=\"Check Spelling\" onclick=\"window.open('../plugins/squirrelspell/sqspell_interface.php', 'sqspell', 'status=yes,width=550,height=370,resizable=yes')\">"); |
| 68 | //--> |
| 69 | </script> |
| 70 | <?php |
| 71 | } |
| 72 | |
| 73 | ?> |