Made function to allow different ways of holding the voicemail files

git-svn-id: http://voip.null.ro/svn/yate@1752 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
monica 2008-03-10 17:11:55 +00:00
parent 5eec57a32c
commit 6f9b570cfc
1 changed files with 20 additions and 11 deletions

View File

@ -26,13 +26,13 @@
require_once("libyate.php");
$vm_base = "/var/spool/voicemail";
$vm_func_for_dir = "vmDefaultGetDir";
function vmGetMessageStats($mailbox,&$total,&$unread,$type = "voicemail")
{
global $vm_base;
$o = 0;
$n = 0;
$dir = "$vm_base/$mailbox";
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && ($d = @opendir($dir))) {
while (($f = readdir($d)) !== false) {
if (substr($f,0,4) == "nvm-") {
@ -52,8 +52,7 @@ function vmGetMessageStats($mailbox,&$total,&$unread,$type = "voicemail")
function vmGetMessageFiles($mailbox,&$files)
{
global $vm_base;
$dir = "$vm_base/$mailbox";
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && ($d = @opendir($dir))) {
$nf = array();
$of = array();
@ -76,8 +75,7 @@ function vmGetMessageFiles($mailbox,&$files)
function vmSetMessageRead($mailbox,&$file)
{
global $vm_base;
$dir = "$vm_base/$mailbox";
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && is_file("$dir/$file")) {
if (substr($file,0,4) != "nvm-")
return false;
@ -92,17 +90,14 @@ function vmSetMessageRead($mailbox,&$file)
function vmInitMessageDir($mailbox)
{
global $vm_base;
$dir = "$vm_base/$mailbox";
$dir = vmGetVoicemailDir($mailbox);
if (!is_dir($dir))
mkdir($dir,0750);
}
function vmHasMessageDir($mailbox)
{
global $vm_base;
$dir = "$vm_base/$mailbox";
return is_dir($dir);
return is_dir(vmGetVoicemailDir($mailbox));
}
function vmBuildNewFilename($caller)
@ -112,4 +107,18 @@ function vmBuildNewFilename($caller)
return $tmp;
}
function vmGetVoicemailDir($called)
{
global $vm_func_for_dir;
return call_user_func($vm_func_for_dir,$called);
}
function vmDefaultGetDir($called)
{
global $vm_base;
return "$vm_base/$called";
}
/* vi: set ts=8 sw=4 sts=4 noet: */