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
$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 <embed> objects. Internet Explorer
+can't play them due to broken <object> implementation. OGG and SVG <object>
+elements specific to IE are not implemented.
CREDITS
*/
/**
- * 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
* $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
* @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;
* @version $Id$
* @package plugins
* @subpackage newmail
+ * @todo add midi support
*/
/** @ignore */
* 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 = '';
}
// 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');
$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);
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);
}
* @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='';
.' name="' . $object .'" ' . "\n"
.' type="audio/x-wav">' . "\n";
break;
+ case SM_NEWMAIL_FILETYPE_SVG:
+ if ($addsuffix) $suffix='.svg';
+ $ret_embed='<embed src="' . $path . $object . $suffix . '" '. "\n"
+ .'hidden="true" autostart="true" '. "\n"
+ .$sArgs . "\n"
+ .'name="' . $object .'" ' . "\n"
+ .'type="image/svg-xml" ' . "\n"
+ .'pluginspage="http://www.adobe.com/svg/viewer/install/">' . "\n";
+ break;
case SM_NEWMAIL_FILETYPE_OGG:
+ if ($addsuffix) $suffix='.ogg';
+ $ret_embed='<embed src="' . $path . $object . $suffix . '" '. "\n"
+ .' hidden="true" autostart="true" '. "\n"
+ .' ' .$sArgs . "\n"
+ .' name="' . $object .'" ' . "\n"
+ .' type="application/ogg">' . "\n";
+ break;
case SM_NEWMAIL_FILETYPE_MP3:
- case SM_NEWMAIL_FILETYPE_SVG:
+ if ($addsuffix) $suffix='.mp3';
+ $ret_embed='<embed src="' . $path . $object . $suffix . '" '. "\n"
+ .' hidden="true" autostart="true" '. "\n"
+ .' ' .$sArgs . "\n"
+ .' name="' . $object .'" ' . "\n"
+ .' type="audio/mpeg">' . "\n";
+ break;
default:
$ret_embed='';
}
switch ($type) {
case SM_NEWMAIL_FILETYPE_SWF:
case SM_NEWMAIL_FILETYPE_WAV:
- $ret_end="</embed>\n";
- break;
case SM_NEWMAIL_FILETYPE_OGG:
case SM_NEWMAIL_FILETYPE_MP3:
case SM_NEWMAIL_FILETYPE_SVG:
+ $ret_end="</embed>\n";
+ break;
default:
$ret_end='';
}
$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) {
// 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 '<option ';
- if ($fname == $newmail_media) {
+ if ($entry == $newmail_media) {
echo 'selected="selected" ';
}
- echo 'value="' . htmlspecialchars($fname) . '">' .
+ echo 'value="' . htmlspecialchars($entry) . '">' .
htmlspecialchars($entry) . "</option>\n";
}
}
echo 'value="mmedia_' . $newmail_mm_name . '">'
.htmlspecialchars($newmail_mm_name) . "</option>\n";
}
- // display local file option
- echo '<option ';
- if ($newmail_media=='(userfile)') {
- echo 'selected="selected" ';
+
+ if($newmail_uploadsounds) {
+ // display local file option
+ echo '<option ';
+ if ($newmail_media=='(userfile)') {
+ echo 'selected="selected" ';
+ }
+ echo 'value="(userfile)">'.
+ _("uploaded media file") . "</option>\n";
+ // end of local file option
}
- echo 'value="(userfile)">'.
- _("uploaded media file") . "</option>\n";
- // end of local file option
// Set media file name
if ($newmail_media == '(none)') {
} 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 '</select>'.
"'width=150,height=30,scrollbars=no');" .
'return false;' .
'" /></td></tr>';
- echo html_tag('tr')
- . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
- . html_tag('td','<input type="file" size="40" name="media_file">')
- . "</tr>\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")))
- ."</tr>\n";
-
- if ($newmail_userfile_name!='') {
- echo '<tr>'
- .'<td colspan="2" align="center">'
- .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
- .'</td></tr>';
+ if ($newmail_uploadsounds) {
+ // upload form
+ echo html_tag('tr')
+ . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
+ . html_tag('td','<input type="file" size="40" name="media_file">')
+ . "</tr>\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")))
+ ."</tr>\n";
+
+ if ($newmail_userfile_name!='') {
+ echo '<tr>'
+ .'<td colspan="2" align="center">'
+ .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
+ .'</td></tr>';
+ }
}
echo html_tag( 'tr', "\n" .
html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .