From: tokul Date: Mon, 1 Aug 2005 08:12:07 +0000 (+0000) Subject: don't use full URL in sounds media preferences. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=f9710f76ba50f74474a88a315905a0ebc50d59c9 don't use full URL in sounds media preferences. adding configuration option to disable upload of sound files. adding svg and ogg support in embed tags. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9862 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/plugins/newmail/README b/plugins/newmail/README index 2e5535a0..a4561e95 100644 --- a/plugins/newmail/README +++ b/plugins/newmail/README @@ -1,13 +1,12 @@ This plugin is used to notify the user when a new mail arrives. There are -several ways to do this. One is to play a sound (currently a WAV, SWF or MP3 -file) through the browser whenever the user has unseen messages flagged in the -left window pane. There are options available (on the options page of course) to -disable this feature for each user, and to select different media files from the -users local computer. The default is that this is NOT enabled, so you'll need to -go to the options menu to turn it on first! There are also options to show a -popup window via JavaScript. +several ways to do this. One is to play a sound through the browser whenever +the user has unseen messages flagged in the left window pane. There are options +available (on the options page of course) to disable this feature for each user, +and to select different media files from the users local computer. The default +is that this is NOT enabled, so you'll need to go to the options menu to turn +it on first! There are also options to show a popup window via JavaScript. -Plugin options are visible only when Javascript is enabled or detected by +Plugin options are visible only when JavaScript is enabled or detected by SquirrelMail JavaScript detection functions. From SquirrelMail 1.5.1 newmail plugin's site configuration can be stored in @@ -16,6 +15,11 @@ config/newmail_config.php or plugins/newmail/config.php. $allowsound setting is replaced with $newmail_allowsound and should be stored inside plugin's site configuration file. +Plugin supports playback of WAV, SWF, MP3, OGG and SVG media files. Currently +OGG and SVG files are played only by browsers that implement w3.org nested +objects correctly and browsers that can play objects. Internet Explorer +can't play them due to broken implementation. OGG and SVG +elements specific to IE are not implemented. CREDITS diff --git a/plugins/newmail/config_default.php b/plugins/newmail/config_default.php index c6c07e95..a00cf756 100644 --- a/plugins/newmail/config_default.php +++ b/plugins/newmail/config_default.php @@ -9,12 +9,20 @@ */ /** - * Set $allowsound to false if you don't want sound files available + * 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 boolean $newmail_uploadsounds + */ +global $newmail_uploadsounds; +$newmail_uploadsounds = true; + /** * controls insertion of embed tags * @global boolean $newmail_mediacompat_mode @@ -30,9 +38,9 @@ $newmail_mediacompat_mode=false; * $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 entities for these files should be use zero width and height attributes + * Object elements for these files should use zero width and height attributes * @global array $newmail_mmedia */ - global $newmail_mmedia; +global $newmail_mmedia; $newmail_mmedia=array(); ?> \ No newline at end of file diff --git a/plugins/newmail/config_sample.php b/plugins/newmail/config_sample.php index 7c00e9a9..4ab8e8a3 100644 --- a/plugins/newmail/config_sample.php +++ b/plugins/newmail/config_sample.php @@ -8,9 +8,16 @@ * @subpackage newmail */ -// Set $allowsound to false if you don't want sound files available +// Set $newmail_allowsound to false if you don't want sound files available $newmail_allowsound = true; +/** + * Don't allow custom sounds + * prefs are stored in DB and data directory is not shared between + * web cluster hosts. + */ +$newmail_uploadsounds = false; + // controls insertion of embed tags $newmail_mediacompat_mode=false; diff --git a/plugins/newmail/functions.php b/plugins/newmail/functions.php index 39d37170..0a276788 100644 --- a/plugins/newmail/functions.php +++ b/plugins/newmail/functions.php @@ -6,6 +6,7 @@ * @version $Id$ * @package plugins * @subpackage newmail + * @todo add midi support */ /** @ignore */ @@ -57,7 +58,7 @@ function newmail_optpage_register_block_function() { * Save newmail plugin settings */ function newmail_sav_function() { - global $data_dir, $username, $_FILES; + global $data_dir, $username, $_FILES, $newmail_uploadsounds; if ( sqgetGlobalVar('submit_newmail', $submit, SQ_POST) ) { $media_enable = ''; @@ -99,7 +100,7 @@ function newmail_sav_function() { } // process uploaded file - if (isset($_FILES['media_file']['tmp_name']) && $_FILES['media_file']['tmp_name']!='') { + if ($newmail_uploadsounds && isset($_FILES['media_file']['tmp_name']) && $_FILES['media_file']['tmp_name']!='') { // set temp file and get media file name $newmail_tempmedia=getHashedDir($username, $data_dir) . "/$username.tempsound"; $newmail_mediafile=getHashedFile($username, $data_dir, $username . '.sound'); @@ -142,6 +143,10 @@ function newmail_pref_function() { $newmail_recent = getPref($data_dir,$username,'newmail_recent'); $newmail_enable = getPref($data_dir,$username,'newmail_enable'); $newmail_media = getPref($data_dir, $username, 'newmail_media', '(none)'); + // remove full location from setting (since SM 1.5.1 plugin uses only filename). + if ($newmail_media!='(none)') + $newmail_media = basename($newmail_media); + $newmail_popup = getPref($data_dir, $username, 'newmail_popup'); $newmail_popup_width = getPref($data_dir, $username, 'newmail_popup_width',200); $newmail_popup_height = getPref($data_dir, $username, 'newmail_popup_height',130); @@ -423,9 +428,11 @@ function newmail_media_objects($object,$types,$path,$args=array(),$extra='',$add if ($extra!='') $ret.=$extra . "\n"; + // close embed tags if (isset($newmail_mediacompat_mode) && $newmail_mediacompat_mode) $ret.= newmail_media_embed_close($types[0]); + // close w3.org nested objects foreach (array_reverse($types) as $type) { $ret.= newmail_media_object_close($type); } @@ -509,6 +516,7 @@ function newmail_media_object($object,$type,$path,$args=array(),$addsuffix=true) * @param array $args media object attributes * @param bool $addsuffix controls addition of suffix to media object url * @return string object html tags and attributes required by selected media type. + * @todo add ogg and svg support */ function newmail_media_object_ie($object,$type,$path,$args=array(),$addsuffix) { $ret_ie=''; @@ -591,9 +599,31 @@ function newmail_media_embed($object,$type,$path,$args=array(),$addsuffix=true) .' name="' . $object .'" ' . "\n" .' type="audio/x-wav">' . "\n"; break; + case SM_NEWMAIL_FILETYPE_SVG: + if ($addsuffix) $suffix='.svg'; + $ret_embed='' . "\n"; + break; case SM_NEWMAIL_FILETYPE_OGG: + if ($addsuffix) $suffix='.ogg'; + $ret_embed='' . "\n"; + break; case SM_NEWMAIL_FILETYPE_MP3: - case SM_NEWMAIL_FILETYPE_SVG: + if ($addsuffix) $suffix='.mp3'; + $ret_embed='' . "\n"; + break; default: $ret_embed=''; } @@ -658,11 +688,11 @@ function newmail_media_embed_close($type) { switch ($type) { case SM_NEWMAIL_FILETYPE_SWF: case SM_NEWMAIL_FILETYPE_WAV: - $ret_end="\n"; - break; case SM_NEWMAIL_FILETYPE_OGG: case SM_NEWMAIL_FILETYPE_MP3: case SM_NEWMAIL_FILETYPE_SVG: + $ret_end="\n"; + break; default: $ret_end=''; } diff --git a/plugins/newmail/loadfile.php b/plugins/newmail/loadfile.php index 16538c26..6d373fb9 100644 --- a/plugins/newmail/loadfile.php +++ b/plugins/newmail/loadfile.php @@ -28,7 +28,7 @@ $newmail_userfile_type=getPref($data_dir,$username,'newmail_userfile_type',false $newmail_userfile_location=getHashedFile($username, $data_dir, $username . '.sound'); -if ($newmail_userfile_type!=false && file_exists($newmail_userfile_location)) { +if ($newmail_uploadsounds && $newmail_userfile_type!=false && file_exists($newmail_userfile_location)) { // open media file $newmail_userfile_handle = fopen($newmail_userfile_location,'rb'); if ($newmail_userfile_handle) { diff --git a/plugins/newmail/newmail_opt.php b/plugins/newmail/newmail_opt.php index d45a4a1e..4ef135aa 100644 --- a/plugins/newmail/newmail_opt.php +++ b/plugins/newmail/newmail_opt.php @@ -141,13 +141,13 @@ if ($newmail_allowsound) { // Iterate sound files for options $d = dir(SM_PATH . 'plugins/newmail/sounds'); while($entry=$d->read()) { - $fname = get_location () . '/sounds/' . $entry; + // $fname = get_location () . '/sounds/' . $entry; if ($entry != '..' && $entry != '.' && $entry != 'CVS') { echo '\n"; } } @@ -161,14 +161,17 @@ if ($newmail_allowsound) { echo 'value="mmedia_' . $newmail_mm_name . '">' .htmlspecialchars($newmail_mm_name) . "\n"; } - // display local file option - echo '\n"; + // end of local file option } - echo 'value="(userfile)">'. - _("uploaded media file") . "\n"; - // end of local file option // Set media file name if ($newmail_media == '(none)') { @@ -178,7 +181,7 @@ if ($newmail_allowsound) { } elseif (preg_match("/^mmedia_+/",$newmail_media)) { $media_output = preg_replace("/^mmedia_/",'',$newmail_media); } else { - $media_output = substr($newmail_media, strrpos($newmail_media, '/')+1); + $media_output = basename($newmail_media); } echo ''. @@ -187,21 +190,24 @@ if ($newmail_allowsound) { "'width=150,height=30,scrollbars=no');" . 'return false;' . '" />'; - echo html_tag('tr') - . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"') - . html_tag('td','') - . "\n"; - - echo html_tag('tr') - . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"') - . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable"))) - ."\n"; - - if ($newmail_userfile_name!='') { - echo '' - .'' - .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name)) - .''; + if ($newmail_uploadsounds) { + // upload form + echo html_tag('tr') + . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"') + . html_tag('td','') + . "\n"; + // display currently uploaded file information + echo html_tag('tr') + . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"') + . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable"))) + ."\n"; + + if ($newmail_userfile_name!='') { + echo '' + .'' + .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name)) + .''; + } } echo html_tag( 'tr', "\n" . html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .