From 6f9b570cfc1f3e4b8490199fecfcf642b07fa6c7 Mon Sep 17 00:00:00 2001 From: monica Date: Mon, 10 Mar 2008 17:11:55 +0000 Subject: [PATCH] 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 --- share/scripts/libvoicemail.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/share/scripts/libvoicemail.php b/share/scripts/libvoicemail.php index d6a03c71..5d2fbbf2 100644 --- a/share/scripts/libvoicemail.php +++ b/share/scripts/libvoicemail.php @@ -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: */