* @subpackage newmail
*/
+
+/**
+ * Custom formatting for both new mail popup window title
+ * bar and changed main SquirrelMail window title bar
+ *
+ * If you change these, they will ONLY show up in the
+ * language you use here unless you add it to your
+ * SquirrelMail translation files!
+ *
+ * Use ###USERNAME### in these strings if you want to insert
+ * the username in the title.
+ *
+ * Use ###ORG_TITLE### in these strings if you want to insert
+ * the $org_title setting from the main SquirrelMail config
+ * in the title.
+ *
+ * Use %s in these strings if you want to insert the number
+ * of new messages in the title.
+ *
+ * Leave blank to use default title bar strings
+ *
+ * $newmail_title_bar_singular = '###USERNAME### - %s New Message';
+ * $newmail_title_bar_plural = '###USERNAME### - %s New Messages';
+ * $newmail_popup_title_bar_singular = '###ORG_TITLE### - New Mail';
+ * $newmail_popup_title_bar_plural = '###ORG_TITLE### - New Mail';
+ *
+ */
+global $newmail_title_bar_singular, $newmail_title_bar_plural,
+ $newmail_popup_title_bar_singular, $newmail_popup_title_bar_plural;
+$newmail_title_bar_singular = '';
+$newmail_title_bar_plural = '';
+$newmail_popup_title_bar_singular = '';
+$newmail_popup_title_bar_plural = '';
+
+
/**
* Set $newmail_allowsound to false if you don't want sound files available
* @global boolean $newmail_allowsound
global $newmail_allowsound;
$newmail_allowsound = true;
+
/**
* Set $newmail_uploadsounds to false if you don't want to allow uploading
* of custom sound files.
global $newmail_uploadsounds;
$newmail_uploadsounds = true;
+
/**
* controls insertion of embed tags
* @global boolean $newmail_mediacompat_mode
global $newmail_mediacompat_mode;
$newmail_mediacompat_mode=false;
+
/**
* List of available multimedia files.
*
*/
global $newmail_mmedia;
$newmail_mmedia=array();
+
+
* @subpackage newmail
*/
-// Set $newmail_allowsound to false if you don't want sound files available
+
+/**
+ * Custom formatting for both new mail popup window title
+ * bar and changed main SquirrelMail window title bar
+ *
+ * If you change these, they will ONLY show up in the
+ * language you use here unless you add it to your
+ * SquirrelMail translation files!
+ *
+ * Use ###USERNAME### in these strings if you want to insert
+ * the username in the title.
+ *
+ * Use ###ORG_TITLE### in these strings if you want to insert
+ * the $org_title setting from the main SquirrelMail config
+ * in the title.
+ *
+ * Use %s in these strings if you want to insert the number
+ * of new messages in the title.
+ *
+ * Leave blank to use default title bar strings
+ *
+ * $newmail_title_bar_singular = '###USERNAME### - %s New Message';
+ * $newmail_title_bar_plural = '###USERNAME### - %s New Messages';
+ * $newmail_popup_title_bar_singular = '###ORG_TITLE### - New Mail';
+ * $newmail_popup_title_bar_plural = '###ORG_TITLE### - New Mail';
+ *
+ */
+global $newmail_title_bar_singular, $newmail_title_bar_plural,
+ $newmail_popup_title_bar_singular, $newmail_popup_title_bar_plural;
+$newmail_title_bar_singular = '';
+$newmail_title_bar_plural = '';
+$newmail_popup_title_bar_singular = '';
+$newmail_popup_title_bar_plural = '';
+
+
+/**
+ * Set $newmail_allowsound to false if you don't want sound files available
+ * @global boolean $newmail_allowsound
+ */
+global $newmail_allowsound;
$newmail_allowsound = true;
+
/**
- * Don't allow custom sounds
- * prefs are stored in DB and data directory is not shared between
- * web cluster hosts.
+ * Set $newmail_uploadsounds to false if you don't want to allow uploading
+ * of custom sound files.
+ * @global boolean $newmail_uploadsounds
*/
+global $newmail_uploadsounds;
$newmail_uploadsounds = false;
-// controls insertion of embed tags
+
+/**
+ * controls insertion of embed tags
+ * @global boolean $newmail_mediacompat_mode
+ */
+global $newmail_mediacompat_mode;
$newmail_mediacompat_mode=false;
-// List of enabled media files
+
+/**
+ * List of available multimedia files.
+ *
+ * For example.
+ * $newmail_mmedia['notify']['types'] = array(SM_NEWMAIL_FILETYPE_SWF,SM_NEWMAIL_FILETYPE_MP3,SM_NEWMAIL_FILETYPE_WAV);
+ * $newmail_mmedia['notify']['args'] = array('width'=>0,'height'=>0);
+ *
+ * These two entries say that media/ directory contains notify.swf, notify.mp3 and notify.wav files
+ * Object elements for these files should use zero width and height attributes
+ * @global array $newmail_mmedia
+ */
+global $newmail_mmedia;
$newmail_mmedia['notify']['types'] = array(SM_NEWMAIL_FILETYPE_SWF,SM_NEWMAIL_FILETYPE_MP3,SM_NEWMAIL_FILETYPE_WAV);
$newmail_mmedia['notify']['args'] = array('width'=>0,'height'=>0);
$newmail_mmedia['got_a_message']['types'] = array(SM_NEWMAIL_FILETYPE_SWF,SM_NEWMAIL_FILETYPE_MP3,SM_NEWMAIL_FILETYPE_WAV);
$newmail_mmedia['monty_message']['args'] = array('width'=>0,'height'=>0);
$newmail_mmedia['austin_mail']['types'] = array(SM_NEWMAIL_FILETYPE_SWF,SM_NEWMAIL_FILETYPE_MP3,SM_NEWMAIL_FILETYPE_WAV);
$newmail_mmedia['austin_mail']['args'] = array('width'=>0,'height'=>0);
+
+
/* Register Squirrelspell with the $optionpages array. */
$optpage_blocks[] = array(
- 'name' => _("NewMail Options"),
+ 'name' => _("New Mail Options"),
'url' => sqm_baseuri() . 'plugins/newmail/newmail_opt.php',
'desc' => _("This configures settings for playing sounds and/or showing popup windows when new mail arrives."),
'js' => TRUE
function newmail_set_loadinfo_function() {
global $optpage, $optpage_name;
if ($optpage=='newmail') {
- $optpage_name=_("NewMail Options");
+ $optpage_name=_("New Mail Options");
}
}
*/
function newmail_plugin_function() {
global $username, $newmail_media, $newmail_media_enable, $newmail_popup,
- $newmail_recent, $newmail_changetitle, $imapConnection;
- global $newmail_mmedia, $newmail_allowsound;
- global $newmail_userfile_type;
- global $newmail_popup_width, $newmail_popup_height;
- global $totalNewArr;
+ $newmail_recent, $newmail_changetitle, $imapConnection,
+ $newmail_mmedia, $newmail_allowsound, $newmail_userfile_type,
+ $newmail_popup_width, $newmail_popup_height, $totalNewArr,
+ $newmail_title_bar_singular, $newmail_title_bar_plural,
+ $org_title;
if ($newmail_media_enable == 'on' ||
$newmail_popup == 'on' ||
$newmail_changetitle) {
+ $output = '';
+
if (!empty($totalNewArr)) { $totalNew=array_sum($totalNewArr); }
else { $totalNew=0; }
// will play the sound as follows:
if ($newmail_changetitle) {
- echo "<script type=\"text/javascript\">\n" .
- "function ChangeTitleLoad() {\n" .
- "var BeforeChangeTitle;\n";
- echo 'window.parent.document.title = "' .
- sprintf(ngettext("%s New Message","%s New Messages",$totalNew), $totalNew) .
- "\";\n";
- echo "if (BeforeChangeTitle != null)\n".
- "BeforeChangeTitle();\n".
- "}\n".
- "BeforeChangeTitle = window.onload;\n".
- "window.onload = ChangeTitleLoad;\n".
- "</script>\n";
+
+ // make sure default strings are in pot file
+ $ignore = _("%s New Message");
+ $ignore = _("%s New Messages");
+
+ $singular_title = "%s New Message";
+ $plural_title = "%s New Messages";
+ if (!empty($newmail_title_bar_singular))
+ $singular_title = $newmail_title_bar_singular;
+ if (!empty($newmail_title_bar_plural))
+ $plural_title = $newmail_title_bar_plural;
+ list($singular_title, $plural_title) = str_replace(array('###USERNAME###', '###ORG_TITLE###'), array($username, $org_title), array($singular_title, $plural_title));
+ $title = sprintf(ngettext($singular_title, $plural_title, $totalNew), $totalNew);
+
+//FIXME: remove HTML from core - put this into a template file
+ $output .= "<script type=\"text/javascript\">\n"
+ . "function ChangeTitleLoad() {\n"
+ . "var BeforeChangeTitle;\n"
+ . 'window.parent.document.title = "'
+ . $title
+ . "\";\n"
+ . "if (BeforeChangeTitle != null)\n"
+ . "BeforeChangeTitle();\n"
+ . "}\n"
+ . "BeforeChangeTitle = window.onload;\n"
+ . "window.onload = ChangeTitleLoad;\n"
+ . "</script>\n";
}
// create media output if there are new email messages
if ($newmail_allowsound && $totalNew > 0
- && $newmail_media_enable == 'on'
- && $newmail_media != '' ) {
- echo newmail_create_media_tags($newmail_media);
+ && $newmail_media_enable == 'on'
+ && $newmail_media != '' ) {
+//FIXME: remove HTML from core - put this into a template file
+ $output .= newmail_create_media_tags($newmail_media);
}
if ($totalNew > 0 && $newmail_popup == 'on') {
- // Idea by: Nic Wolfe (Nic@TimelapseProductions.com)
- // Web URL: http://fineline.xs.mw
- // More code from Tyler Akins
- echo "<script type=\"text/javascript\">\n".
- "<!--\n".
- "function PopupScriptLoad() {\n".
- 'window.open("'.sqm_baseuri().'plugins/newmail/newmail.php?numnew='.$totalNew.
- '", "SMPopup",'.
- "\"width=$newmail_popup_width,height=$newmail_popup_height,scrollbars=no\");\n".
- "if (BeforePopupScript != null)\n".
- "BeforePopupScript();\n".
- "}\n".
- "BeforePopupScript = window.onload;\n".
- "window.onload = PopupScriptLoad;\n".
- "// End -->\n".
- "</script>\n";
+//FIXME: remove HTML from core - put this into a template file
+ $output .= "<script type=\"text/javascript\">\n"
+ . "<!--\n"
+ . "function PopupScriptLoad() {\n"
+ . 'window.open("'.sqm_baseuri().'plugins/newmail/newmail.php?numnew='.$totalNew
+ . '", "SMPopup",'
+ . "\"width=$newmail_popup_width,height=$newmail_popup_height,scrollbars=no\");\n"
+ . "if (BeforePopupScript != null)\n"
+ . "BeforePopupScript();\n"
+ . "}\n"
+ . "BeforePopupScript = window.onload;\n"
+ . "window.onload = PopupScriptLoad;\n"
+ . "// End -->\n"
+ . "</script>\n";
}
+
+ return array('left_main_after' => $output);
+
}
+
}
// ----- end of hooked functions -----
*/
require('../../include/init.php');
-sqGetGlobalVar('numnew', $numnew, SQ_GET);
-$numnew = (int)$numnew;
+/**
+ * Make sure plugin is activated!
+ */
+global $plugins;
+if (!in_array('newmail', $plugins))
+ exit;
+
+/** load default config */
+if (file_exists(SM_PATH . 'plugins/newmail/config_default.php')) {
+ include_once(SM_PATH . 'plugins/newmail/config_default.php');
+}
+
+/** load config */
+if (file_exists(SM_PATH . 'config/newmail_config.php')) {
+ include_once(SM_PATH . 'config/newmail_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/newmail/config.php')) {
+ include_once(SM_PATH . 'plugins/newmail/config.php');
+}
+
+ sqGetGlobalVar('numnew', $numnew, SQ_GET);
+ $numnew = (int)$numnew;
+
+ global $username, $org_title,
+ $newmail_popup_title_bar_singular, $newmail_popup_title_bar_plural;
+
+ // make sure default strings are in pot file
+ $ignore = _("New Mail");
+
+ $singular_title = "New Mail";
+ $plural_title = "New Mail";
+ if (!empty($newmail_popup_title_bar_singular))
+ $singular_title = $newmail_popup_title_bar_singular;
+ if (!empty($newmail_popup_title_bar_plural))
+ $plural_title = $newmail_popup_title_bar_plural;
+ list($singular_title, $plural_title) = str_replace(array('###USERNAME###', '###ORG_TITLE###'), array($username, $org_title), array($singular_title, $plural_title));
+ $title = sprintf(ngettext($singular_title, $plural_title, $numnew), $numnew);
+
- displayHtmlHeader( _("New Mail"), '', FALSE );
+ displayHtmlHeader( $title, '', FALSE );
echo '<body bgcolor="'.$color[4].'" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">'."\n".
'<div style="text-align: center;">'. "\n" .
"-->\n".
"</script>\n".
"</body></html>\n";
-?>
\ No newline at end of file
*/
require('../../include/init.php');
+/**
+ * Make sure plugin is activated!
+ */
+global $plugins;
+if (!in_array('newmail', $plugins))
+ exit;
+
/** Plugin functions (also loads plugin's config) */
include_once(SM_PATH . 'plugins/newmail/functions.php');
displayPageHeader($color);
+//FIXME: Remove all HTML from core - put this all into a template file
echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
html_tag( 'tr' ) . "\n" .
html_tag( 'td', '', 'center' ) .
html_tag( 'tr' ) . "\n" .
html_tag( 'td', '', 'left', $color[4] ) . "<br />\n";
-echo html_tag( 'p',_("The NewMail plugin will follow the Folder Preferences option "Enable Unread Message Notification"")) . "\n" .
+echo html_tag( 'p',_("Based on the Folder Preferences option "Enable Unread Message Notification", you can be notified when new messages arrive in your account.")) . "\n" .
html_tag( 'p',
- sprintf(_("Selecting the %s option will enable the showing of a popup window when unseen mail is in your folders (requires JavaScript)."), '"'._("Show popup window on new mail").'"')
+ sprintf(_("Selecting the %s option will enable the showing of a popup window when unseen mail is in one of your folders (requires JavaScript)."), '"'._("Show popup window on new mail").'"')
) . "\n" .
html_tag( 'p',
sprintf(_("Use the %s option to only check for messages that are recent. Recent messages are those that have just recently showed up and have not been \"viewed\" or checked yet. This can prevent being continuously annoyed by sounds or popups for unseen mail."), '"'._("Count only messages that are RECENT").'"')
) . "\n" .
html_tag( 'p',
- sprintf(_("Selecting the %s option will change the title in some browsers to let you know when you have new mail (requires JavaScript). This will always tell you if you have new mail, even if you have %s enabled."), '"'._("Change title on supported browsers").'"', '"'._("Count only messages that are RECENT").'"')
+ sprintf(_("Selecting the %s option will change the browser title bar to let you know when you have new mail (requires JavaScript and may only work in some browsers). This will always tell you if you have new mail, even if you have %s enabled."), '"'._("Change title on supported browsers").'"', '"'._("Count only messages that are RECENT").'"')
) . "\n";
if ($newmail_allowsound) {
echo html_tag( 'p',
// Option: media_recent
echo html_tag( 'tr' ) .
- html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
+ html_tag( 'td', '<label for="media_recent">' . _("Count only messages that are RECENT") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
html_tag( 'td', '', 'left' ) .
'<input type="checkbox" ';
if ($newmail_recent == 'on') {
echo 'checked="checked" ';
}
-echo 'name="media_recent" /></td></tr>' . "\n";
+echo 'name="media_recent" id="media_recent" /></td></tr>' . "\n";
// Option: media_changetitle
echo html_tag( 'tr' ) .
- html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
+ html_tag( 'td', '<label for="media_changetitle">' . _("Change title on supported browsers") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
html_tag( 'td', '', 'left' ) .
'<input type="checkbox" ';
if ($newmail_changetitle == 'on') {
echo 'checked="checked" ';
}
-echo 'name="media_changetitle" /> <small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
+echo 'name="media_changetitle" id="media_changetitle" /> <small><label for="media_changetitle">('._("requires JavaScript to work").')</label></small></td></tr>' . "\n";
// Option: media_popup
echo html_tag( 'tr' ) .
- html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
+ html_tag( 'td', '<label for="media_popup">' . _("Show popup window on new mail") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
html_tag( 'td', '', 'left' ) .
'<input type="checkbox" ';
if($newmail_popup == 'on') {
echo 'checked="checked" ';
}
-echo 'name="media_popup" /> <small>('._("requires JavaScript to work").')</small></td></tr>' . "\n";
+echo 'name="media_popup" id="media_popup" /> <small><label for="media_popup">('._("requires JavaScript to work").')</label></small></td></tr>' . "\n";
echo html_tag( 'tr' )
. html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
if ($newmail_allowsound) {
// Option: media_enable
echo html_tag( 'tr' ) .
- html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
+ html_tag( 'td', '<label for="media_enable">' . _("Enable Media Playing") . ':</label>', 'right', '', 'style="white-space: nowrap;"' ) .
html_tag( 'td', '', 'left' ) .
'<input type="checkbox" ';
if ($newmail_media_enable == 'on') {
echo 'checked="checked" ';
}
- echo 'name="media_enable" /></td></tr>' . "\n";
+ echo 'name="media_enable" id="media_enable" /></td></tr>' . "\n";
// Option: media_sel
echo html_tag( 'tr' ) .
* Init newmail plugin
*/
function squirrelmail_plugin_init_newmail() {
+
global $squirrelmail_plugin_hooks;
$totalNewArr=array();
global $totalNewArr;
- $squirrelmail_plugin_hooks['folder_status']['newmail'] = 'newmail_folder_status';
- $squirrelmail_plugin_hooks['left_main_after']['newmail'] = 'newmail_plugin';
- $squirrelmail_plugin_hooks['optpage_register_block']['newmail'] = 'newmail_optpage_register_block';
- $squirrelmail_plugin_hooks['options_save']['newmail'] = 'newmail_sav';
- $squirrelmail_plugin_hooks['loading_prefs']['newmail'] = 'newmail_pref';
- $squirrelmail_plugin_hooks['optpage_set_loadinfo']['newmail'] = 'newmail_set_loadinfo';
+ $squirrelmail_plugin_hooks['folder_status']['newmail']
+ = 'newmail_folder_status';
+ $squirrelmail_plugin_hooks['template_construct_left_main.tpl']['newmail']
+ = 'newmail_plugin';
+ $squirrelmail_plugin_hooks['optpage_register_block']['newmail']
+ = 'newmail_optpage_register_block';
+ $squirrelmail_plugin_hooks['options_save']['newmail']
+ = 'newmail_sav';
+ $squirrelmail_plugin_hooks['loading_prefs']['newmail']
+ = 'newmail_pref';
+ $squirrelmail_plugin_hooks['optpage_set_loadinfo']['newmail']
+ = 'newmail_set_loadinfo';
+
}
+
/**
* Register newmail option block
*/
newmail_optpage_register_block_function();
}
+
/**
* Save newmail plugin settings
*/
newmail_sav_function();
}
+
/**
* Load newmail plugin settings
*/
newmail_pref_function();
}
+
/**
* Set loadinfo data
*
newmail_set_loadinfo_function();
}
+
/**
* Insert needed data in left_main
*/
function newmail_plugin() {
include_once(SM_PATH . 'plugins/newmail/functions.php');
- newmail_plugin_function();
+ return newmail_plugin_function();
+}
+
+
+/**
+ * Returns info about this plugin
+ *
+ */
+function newmail_info() {
+ return array(
+ 'english_name' => 'New Mail',
+ 'authors' => array(
+ 'SquirrelMail Team' => array(),
+ ),
+ 'version' => 'CORE',
+ 'required_sm_version' => 'CORE',
+ 'requires_configuration' => 0,
+ 'summary' => 'This plugin is used to notify the user when a new mail arrives.',
+ 'details' => 'This plugin is used to notify the user when a new mail arrives. This is accomplished by playing a sound through the browser or spawning a popup window whenever the user has unseen messages.',
+ );
}
+
+
+
+/**
+ * Returns version info about this plugin
+ *
+ */
+function newmail_version() {
+ $info = newmail_info();
+ return $info['version'];
+}
+
+