<?php
+
/**
* SquirrelMail NewMail plugin
*
* Functions
+ *
+ * @copyright © 2001-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package plugins
* @subpackage newmail
+ * @todo add midi support
*/
/** @ignore */
// Gets added to the user's OPTIONS page.
global $optpage_blocks;
- if ( checkForJavascript() ) {
- /* Register Squirrelspell with the $optionpages array. */
- $optpage_blocks[] = array(
- 'name' => _("NewMail 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
- );
- }
+ /* Register Squirrelspell with the $optionpages array. */
+ $optpage_blocks[] = array(
+ 'name' => _("NewMail 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
+ );
}
/**
* 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 (isset($newmail_mediacompat_mode) && $newmail_mediacompat_mode)
$ret.= newmail_media_embed($object,$types[0],$path,$args,$addsuffix);
- // add $extra code inside objects
+ // add $extra code inside objects
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='';
/**
* Creates embed tags of multimedia object
- *
+ *
* docs about embed
* Apple: http://www.apple.com/quicktime/authoring/embed.html
*
.' 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='';
+ $ret_embed='';
}
return $ret_embed;
}
/**
* Adds closing tags for ie object
* Warning:
- * * This is internal function, use newmail_media_objects() instead
+ * * This is internal function, use newmail_media_objects() instead
* @param integer $type media object type
* @return string closing tag of media object
*/
case SM_NEWMAIL_FILETYPE_OGG:
case SM_NEWMAIL_FILETYPE_SVG:
default:
- $ret_end='';
+ $ret_end='';
}
return $ret_end;
}
/**
* Adds closing tags for object
* Warning:
- * * This is internal function, use newmail_media_objects() instead
+ * * This is internal function, use newmail_media_objects() instead
* @param integer $type media object type
* @return string closing tag of media object
*/
$ret_end="</object>\n";
break;
default:
- $ret_end='';
+ $ret_end='';
}
return $ret_end;
}
/**
* Adds closing tags for object
* Warning:
- * * This is internal function, use newmail_media_objects() instead
+ * * This is internal function, use newmail_media_objects() instead
* @param integer $type media object type
* @return string closing tag of media object
*/
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='';
+ $ret_end='';
}
return $ret_end;
}
* Converts media attributes to string
* Warning:
* * attribute values are automatically sanitized by htmlspecialchars()
- * * This is internal function, use newmail_media_objects() instead
+ * * This is internal function, use newmail_media_objects() instead
* @param array $args array with object attributes
* @return string string with object attributes
*/
function newmail_media_prepare_args($args) {
$ret_args='';
foreach ($args as $arg => $value) {
- $ret_args.= $arg . '="' . htmlspecialchars($value) . '" ';
+ $ret_args.= $arg . '="' . htmlspecialchars($value) . '" ';
}
return $ret_args;
}