update README to reflect inclusion in squirrelmail-core-plugins
[squirrelmail.git] / plugins / fortune / functions.php
CommitLineData
28e62e6d 1<?php
2/**
3 * Fortune plugin functions
4 *
6c84ba1e 5 * @copyright (c) 2004-2005 The SquirrelMail Project Team
28e62e6d 6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
7 * @version $Id$
8 * @package plugins
9 * @subpackage fortune
10 */
11
12/**
13 * Declare configuration globals
14 */
15global $fortune_location, $fortune_options;
16
17/**
18 * Load default config
19 */
20include_once(SM_PATH . 'plugins/fortune/config_default.php');
21
22/**
23 * Load site config
24 */
25if (file_exists(SM_PATH . 'config/fortune_config.php')) {
26 include_once(SM_PATH . 'config/fortune_config.php');
27} elseif (file_exists(SM_PATH . 'plugins/fortune/config.php')) {
28 include_once(SM_PATH . 'plugins/fortune/config.php');
29}
30
31/**
32 * Show fortune
33 * @access private
34 * @since 1.5.1
35 */
36function fortune_function() {
37 global $fortune_visible, $color, $fortune_location, $fortune_options;
38
39 if (!$fortune_visible) {
40 return;
41 }
42
43 $exist = file_exists($fortune_location);
44
45 if ($fortune_options!='') {
46 $fortune_command=$fortune_location . ' ' . $fortune_options;
47 } else {
48 $fortune_command=$fortune_location;
49 }
50
51 echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
52 "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
53 "<tr><td align=\"center\">\n";
54 echo '<table><tr><td>';
55 if (!$exist) {
554f6946 56 printf(_("%s is not found."),$fortune_location);
28e62e6d 57 } else {
58 echo "<center><em>" . _("Today's Fortune") . "</em></center><pre>\n";
59 htmlspecialchars(system($fortune_command));
60 echo "</pre>\n";
61 }
62
63 echo '</td></tr></table></td></tr></table></td></tr></table></center>';
64}
65
66/**
67 * Add fortune options
68 * @access private
69 * @since 1.5.1
70 */
71function fortune_function_options() {
72 global $optpage_data;
73
74 $optpage_data['grps']['fortune'] = _("Fortunes:");
75 $optionValues = array();
76 $optionValues[] = array('name' => 'fortune_visible',
77 'caption' => _("Show fortunes at top of mailbox"),
78 'type' => SMOPT_TYPE_BOOLEAN,
79 'initial_value' => false );
80 $optpage_data['vals']['fortune'] = $optionValues;
81}
82
83/**
84 * Get fortune prefs
85 * @access private
86 * @since 1.5.1
87 */
88function fortune_function_load() {
89 global $username, $data_dir, $fortune_visible;
90
91 $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
92}
554f6946 93?>