From: <pdo...@us...> - 2021-07-12 22:04:44
|
Revision: 14923 http://sourceforge.net/p/squirrelmail/code/14923 Author: pdontthink Date: 2021-07-12 22:04:37 +0000 (Mon, 12 Jul 2021) Log Message: ----------- Add option to prefix new mail number to the front of the org title (browser title bar) Modified Paths: -------------- branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/newmail_opt.php branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/setup.php Modified: branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/newmail_opt.php =================================================================== --- branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/newmail_opt.php 2021-05-12 05:33:01 UTC (rev 14922) +++ branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/newmail_opt.php 2021-07-12 22:04:37 UTC (rev 14923) @@ -25,14 +25,15 @@ displayPageHeader($color, 'None'); -$media_enable = getPref($data_dir,$username, 'newmail_enable', 'FALSE' ); -$media_popup = getPref($data_dir, $username,'newmail_popup'); -$media_allbox = getPref($data_dir,$username,'newmail_allbox'); -$media_recent = getPref($data_dir,$username,'newmail_recent'); -$media_changetitle = getPref($data_dir,$username,'newmail_changetitle'); +$newmail_enable = getPref($data_dir,$username, 'newmail_enable', 'FALSE' ); +$newmail_popup = getPref($data_dir, $username,'newmail_popup'); +$newmail_allbox = getPref($data_dir,$username,'newmail_allbox'); +$newmail_recent = getPref($data_dir,$username,'newmail_recent'); +$newmail_changetitle = getPref($data_dir,$username,'newmail_changetitle'); +$newmail_changetitle_prefix = getPref($data_dir,$username,'newmail_changetitle_prefix'); $newmail_popup_height = getPref($data_dir, $username, 'newmail_popup_height',130); $newmail_popup_width = getPref($data_dir, $username, 'newmail_popup_width',200); -$media = getPref($data_dir,$username,'newmail_media', '(none)'); +$newmail_media = getPref($data_dir,$username,'newmail_media', '(none)'); // Set $allowsound to false if you don't want sound files available $allowsound = "true"; @@ -56,6 +57,9 @@ ) . "\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").'"') + ) . "\n" . + html_tag( 'p', + sprintf(_("When the browser title change is enabled, you can use %s to have the number of new messages prefixed to the title (suffixed otherwise) (requires JavaScript)."), '"'._("Prefix new message count").'"') ) . "\n"; if ($allowsound == "true") { echo html_tag( 'p', @@ -74,45 +78,55 @@ '<input type="hidden" name="smtoken" value="' . sm_generate_security_token() . '">' . "\n" . html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n"; -// Option: media_allbox +// Option: newmail_allbox echo html_tag( 'tr' ) . html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . '<input type="checkbox" '; -if ($media_allbox == 'on') { +if ($newmail_allbox == 'on') { echo 'checked="checked" '; } -echo 'name="media_allbox" /></td></tr>' . "\n"; +echo 'name="newmail_allbox" /></td></tr>' . "\n"; -// Option: media_recent +// Option: newmail_recent echo html_tag( 'tr' ) . html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . '<input type="checkbox" '; -if ($media_recent == 'on') { +if ($newmail_recent == 'on') { echo 'checked="checked" '; } -echo 'name="media_recent" /></td></tr>' . "\n"; +echo 'name="newmail_recent" /></td></tr>' . "\n"; -// Option: media_changetitle +// Option: newmail_changetitle echo html_tag( 'tr' ) . html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . '<input type="checkbox" '; -if ($media_changetitle == 'on') { +if ($newmail_changetitle == 'on') { echo 'checked="checked" '; } -echo 'name="media_changetitle" /> ('._("requires JavaScript to work").')</td></tr>' . "\n"; +echo 'name="newmail_changetitle" /> ('._("requires JavaScript to work").')</td></tr>' . "\n"; -// Option: media_popup +// Option: newmail_changetitle_prefix echo html_tag( 'tr' ) . + html_tag( 'td', _("Prefix new message count").':', 'right', '', 'nowrap' ) . + html_tag( 'td', '', 'left' ) . + '<input type="checkbox" '; +if ($newmail_changetitle_prefix == 'on') { + echo 'checked="checked" '; +} +echo 'name="newmail_changetitle_prefix" /> ('._("requires JavaScript to work").')</td></tr>' . "\n"; + +// Option: newmail_popup +echo html_tag( 'tr' ) . html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . '<input type="checkbox" '; -if($media_popup == 'on') { +if($newmail_popup == 'on') { echo 'checked="checked" '; } -echo 'name="media_popup" /> ('._("requires JavaScript to work").')</td></tr>' . "\n"; +echo 'name="newmail_popup" /> ('._("requires JavaScript to work").')</td></tr>' . "\n"; echo html_tag( 'tr' ) . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"') @@ -130,23 +144,23 @@ if ($allowsound == "true") { -// Option: media_enable +// Option: newmail_enable echo html_tag( 'tr' ) . html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . '<input type="checkbox" '; - if ($media_enable == 'on') { + if ($newmail_enable == 'on') { echo 'checked="checked" '; } - echo 'name="media_enable" /></td></tr>' . "\n"; + echo 'name="newmail_enable" /></td></tr>' . "\n"; -// Option: media_sel +// Option: newmail_sel echo html_tag( 'tr' ) . html_tag( 'td', _("Select server file").':', 'right', '', 'nowrap' ) . html_tag( 'td', '', 'left' ) . - '<select name="media_sel">' . "\n" . + '<select name="newmail_sel">' . "\n" . '<option value="(none)"'; - if ( $media == '(none)') { + if ( $newmail_media == '(none)') { echo 'selected="selected" '; } echo '>' . _("(none)") . '</option>' . "\n"; @@ -157,7 +171,7 @@ $fname = get_location () . '/sounds/' . $entry; if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') { echo '<option '; - if ($fname == $media) { + if ($fname == $newmail_media) { echo 'selected="selected" '; } echo 'value="' . sm_encode_html_special_chars($fname) . '">' . @@ -166,10 +180,10 @@ } $d->close(); } - $media_output = ($media == '(none)') ? _("(none)") : substr($media, strrpos($media, '/')+1); + $newmail_output = ($newmail_media == '(none)') ? _("(none)") : substr($newmail_media, strrpos($newmail_media, '/')+1); echo '</select>'. '<input type="submit" value="' . _("Try") . '" name="test" onClick="' . - "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," . + "window.open('testsound.php?sound='+newmail_sel.options[newmail_sel.selectedIndex].value, 'TestSound'," . "'width=150,height=30,scrollbars=no');" . 'return false;' . '" /></td></tr>' . @@ -176,8 +190,8 @@ html_tag( 'tr', "\n" . html_tag( 'td', _("Current File:"), 'right', '', 'nowrap' ) . html_tag( 'td', '<input type="hidden" value="' . - sm_encode_html_special_chars($media) . '" name="media_default">' . - sm_encode_html_special_chars($media_output) . '', 'left' ) + sm_encode_html_special_chars($newmail_media) . '" name="newmail_default">' . + sm_encode_html_special_chars($newmail_output) . '', 'left' ) ) . "\n"; } echo html_tag( 'tr', "\n" . Modified: branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/setup.php =================================================================== --- branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/setup.php 2021-05-12 05:33:01 UTC (rev 14922) +++ branches/SM-1_4-STABLE/squirrelmail/plugins/newmail/setup.php 2021-07-12 22:04:37 UTC (rev 14923) @@ -42,7 +42,7 @@ global $folder_prefix, $trash_folder, $sent_folder, $color, $move_to_sent, $move_to_trash, $unseen_notify, $unseen_type, $newmail_allbox, - $newmail_recent, $newmail_changetitle; + $newmail_recent; $mailboxURL = urlencode($real_box); $unseen = $recent = 0; @@ -100,34 +100,37 @@ global $data_dir, $username; if ( sqgetGlobalVar('submit_newmail', $submit, SQ_POST) ) { - $media_enable = ''; - $media_popup = ''; - $media_allbox = ''; - $media_recent = ''; - $media_changetitle = ''; - $media_sel = ''; + $newmail_enable = ''; + $newmail_popup = ''; + $newmail_allbox = ''; + $newmail_recent = ''; + $newmail_changetitle = ''; + $newmail_changetitle_prefix = ''; + $newmail_sel = ''; - sqgetGlobalVar('media_enable', $media_enable, SQ_POST); - sqgetGlobalVar('media_popup', $media_popup, SQ_POST); - sqgetGlobalVar('media_allbox', $media_allbox, SQ_POST); - sqgetGlobalVar('media_recent', $media_recent, SQ_POST); - sqgetGlobalVar('media_changetitle', $media_changetitle, SQ_POST); + sqgetGlobalVar('newmail_enable', $newmail_enable, SQ_POST); + sqgetGlobalVar('newmail_popup', $newmail_popup, SQ_POST); + sqgetGlobalVar('newmail_allbox', $newmail_allbox, SQ_POST); + sqgetGlobalVar('newmail_recent', $newmail_recent, SQ_POST); + sqgetGlobalVar('newmail_changetitle', $newmail_changetitle, SQ_POST); + sqgetGlobalVar('newmail_changetitle_prefix', $newmail_changetitle_prefix, SQ_POST); sqgetGlobalVar('popup_height', $newmail_popup_height, SQ_POST); sqgetGlobalVar('popup_width', $newmail_popup_width, SQ_POST); - setPref($data_dir,$username,'newmail_enable',$media_enable); - setPref($data_dir,$username,'newmail_popup', $media_popup); - setPref($data_dir,$username,'newmail_allbox',$media_allbox); - setPref($data_dir,$username,'newmail_recent',$media_recent); + setPref($data_dir,$username,'newmail_enable',$newmail_enable); + setPref($data_dir,$username,'newmail_popup', $newmail_popup); + setPref($data_dir,$username,'newmail_allbox',$newmail_allbox); + setPref($data_dir,$username,'newmail_recent',$newmail_recent); setPref($data_dir,$username,'newmail_popup_height',$newmail_popup_height); setPref($data_dir,$username,'newmail_popup_width',$newmail_popup_width); - setPref($data_dir,$username,'newmail_changetitle',$media_changetitle); + setPref($data_dir,$username,'newmail_changetitle',$newmail_changetitle); + setPref($data_dir,$username,'newmail_changetitle_prefix',$newmail_changetitle_prefix); - if( sqgetGlobalVar('media_sel', $media_sel, SQ_POST) && - ($media_sel == '(none)' || $media_sel == '(local media)') ) { + if( sqgetGlobalVar('newmail_sel', $newmail_sel, SQ_POST) && + ($newmail_sel == '(none)' || $newmail_sel == '(local media)') ) { removePref($data_dir,$username,'newmail_media'); } else { - setPref($data_dir,$username,'newmail_media',$media_sel); + setPref($data_dir,$username,'newmail_media',$newmail_sel); } } } @@ -134,8 +137,8 @@ function newmail_pref() { global $username, $data_dir, $newmail_media, $newmail_enable, $newmail_popup, - $newmail_allbox, $newmail_recent, $newmail_changetitle, $newmail_popup_height, - $newmail_popup_width; + $newmail_allbox, $newmail_recent, $newmail_changetitle, + $newmail_changetitle_prefix, $newmail_popup_height, $newmail_popup_width; $newmail_recent = getPref($data_dir,$username,'newmail_recent'); @@ -146,6 +149,7 @@ $newmail_popup_height = getPref($data_dir, $username, 'newmail_popup_height',130); $newmail_popup_width = getPref($data_dir, $username, 'newmail_popup_width',200); $newmail_changetitle = getPref($data_dir, $username, 'newmail_changetitle'); + $newmail_changetitle_prefix = getPref($data_dir, $username, 'newmail_changetitle_prefix'); } @@ -165,7 +169,7 @@ global $username, $key, $imapServerAddress, $imapPort, $newmail_media, $newmail_enable, $newmail_popup, $newmail_popup_height, $newmail_popup_width, $newmail_recent, - $newmail_changetitle, $imapConnection; + $newmail_changetitle, $newmail_changetitle_prefix, $imapConnection; include_once(SM_PATH . 'functions/display_messages.php'); @@ -223,14 +227,18 @@ global $org_title; echo "<script language=\"javascript\" type=\"text/javascript\">\n" . "function ChangeTitleLoad() {\n"; - if( $totalNew > 1 || $totalNew == 0 ) { - echo 'window.parent.document.title = "' . $org_title . ' [' . - sprintf(_("%s New Messages"), $totalNew ) . - "]\";\n"; + if ($newmail_changetitle_prefix) { + echo 'window.parent.document.title = "(' . $totalNew .') ' . $org_title . '";'; } else { - echo 'window.parent.document.title = "' . $org_title . ' [' . - sprintf(_("%s New Message"), $totalNew ) . - "]\";\n"; + if( $totalNew > 1 || $totalNew == 0 ) { + echo 'window.parent.document.title = "' . $org_title . ' [' . + sprintf(_("%s New Messages"), $totalNew ) . + "]\";\n"; + } else { + echo 'window.parent.document.title = "' . $org_title . ' [' . + sprintf(_("%s New Message"), $totalNew ) . + "]\";\n"; + } } echo "if (BeforeChangeTitle != null)\n". "BeforeChangeTitle();\n". This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |