Not Logged in - No Account?
Logging in allows you to post to forums, track new posts, subscribe to threads, pm (private message) other members, and receive periodic news letters. Once logged in this message disappears. No account? Create one by registering here. Lost your password, request a new password. We respect your privacy and collect minimal information when you register and we do not resell that information or use it in any objectionable way. You can review our privacy policy for details.
Changes to the "forward_to" button in ARI

I wanted to post this in case the dev team would like to include it (or similar code) in a future release of the Asterisk Recording Interface. As is (in v2.2.1 that I am using) the forward_to button's drop down list was not sorted in any way. It also only showed the extension numbers of whom you could forward voice mail to. I was asked to sort the list, so that it would be more user friendly. I then took it apon myself to display a list of user names instead of their extensions, as I don't typically memorize corporate phone directories. Below is the code fragment I used. This replaces lines 273 - 296 of the recordings/modules/voicemail.module file (which is the "forward options" block. It only displays the first 20 characters of the names, because anything longer was causing the drop down list to wrap to a new line.
DISCLAIMER: This is not only my first free PBX hack, but my first time writting PHP, so I will not be offended if you would like to rewrite this in a more efficient manner.
// forward options
if (is_readable($ASTERISK_VOICEMAIL_CONF)) {
$lines = file($ASTERISK_VOICEMAIL_CONF);
$ext_array = array();
foreach ($lines as $key => $line) {
// get context for forward to mailbox
if (preg_match("/\[.*\]/i",$line)) {
$forwardContext = trim(preg_replace('/\[|\]/', '', $line));
}
// get username and add to options
if (preg_match("/\=\>/i",$line)) {
list($username,$value) = split('=>',$line);
$username = trim($username);
if ($username!=$_SESSION['ari_user']['extension']) {
//$ext_array[] = $username . "|" . $forwardContext;
list(,$real_name,) = split(",",$value,3);
$ext_array[] = $real_name . "|" . $username . "|" . $forwardContext;
}
}
} //foreach
//sort the array
sort($ext_array);
//get the size of the array
$array_size = count($ext_array) - 1;
//loop through the array and build the drop down list
for ($i = 0 ; $i <= $array_size ; $i++)
{
//split the values apart
list($real_name,$username,$context) = explode("|",$ext_array[$i]);
//add it to the drop down
$forward_options .= "" . substr($real_name,0,20);
}
}
else {
$_SESSION['ari_error'] = "File not readable: " . $ASTERISK_VOICEMAIL_CONF;
return;
}

Changes to the "forward_to" button in ARI
pwp - sounds like this may be useful (definately the sorting part). Can you please create a diff for me of this. Do the following:
diff -ubB original_file your_modified_file > forward.diff
then paste what you get in the diff file here, attach it, or somehow get it to me. I can then appy it, review it and most likey add it to the code as it sounds good to me (I never even noticed the forward list - and yes it is not sorted).
If you are a user of ARI, you should be aware that I have added some good stuff in the 2.3 branch (where this would be put) - letting you control followme and VmX Locator, as well as a few other changes.
thanks!
Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here
here is the diff you asked for
here it is ...
--- voicemail.module.old 2007-06-20 14:59:52.000000000 -0300 +++ voicemail.module.new 2007-06-22 15:44:48.000000000 -0300 @@ -273,6 +273,7 @@ // forward options if (is_readable($ASTERISK_VOICEMAIL_CONF)) { $lines = file($ASTERISK_VOICEMAIL_CONF); + $ext_array = array(); foreach ($lines as $key => $line) { // get context for forward to mailbox @@ -285,9 +286,26 @@ list($username,$value) = split('=>',$line); $username = trim($username); if ($username!=$_SESSION['ari_user']['extension']) { - $forward_options .= "" . $username; - } - } + //$ext_array[] = $username . "|" . $forwardContext; + list(,$real_name,) = split(",",$value,3); + $ext_array[] = $real_name . "|" . $username . "|" . $forwardContext; + } + } + } //foreach + //sort the array + sort($ext_array); + + //get the size of the array + $array_size = count($ext_array) - 1; + + //loop through the array and build the drop down list + for ($i = 0 ; $i <= $array_size ; $i++) + { + //split the values apart + list($real_name,$username,$context) = explode("|",$ext_array[$i]); + + //add it to the drop down + $forward_options .= "" . substr($real_name,0,20); } } else {Changes to the "forward_to" button in ARI
pwp,
can you modify it so that you can see both the extension and username? I think it will be problematic with some people if both are not there. (e.g. something like: First Last (extn). With that, I think it looks good and I just as well add it to the release.
thanks,
Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here
name and extension diff file
--- voicemail.module.old 2007-06-20 14:59:52.000000000 -0300 +++ voicemail.module.new 2007-06-28 12:31:02.000000000 -0300 @@ -273,6 +273,7 @@ // forward options if (is_readable($ASTERISK_VOICEMAIL_CONF)) { $lines = file($ASTERISK_VOICEMAIL_CONF); + $ext_array = array(); foreach ($lines as $key => $line) { // get context for forward to mailbox @@ -285,9 +286,26 @@ list($username,$value) = split('=>',$line); $username = trim($username); if ($username!=$_SESSION['ari_user']['extension']) { - $forward_options .= "" . $username; - } - } + //$ext_array[] = $username . "|" . $forwardContext; + list(,$real_name,) = split(",",$value,3); + $ext_array[] = $real_name . "|" . $username . "|" . $forwardContext; + } + } + } //foreach + //sort the array + sort($ext_array); + + //get the size of the array + $array_size = count($ext_array) - 1; + + //loop through the array and build the drop down list + for ($i = 0 ; $i <= $array_size ; $i++) + { + //split the values apart + list($real_name,$username,$context) = explode("|",$ext_array[$i]); + + //add it to the drop down + $forward_options .= "" . substr($real_name,0,15) . " " . $username; } } else {Changes to the "forward_to" button in ARI
minor mod but:
http://www.freepbx.org/trac/changeset/4264
will come out in next framework update.
Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here
Can you remove forward_to altogether?
I do not want the users to have the ability to see other extensions or forward messages to them. How can I disable this feature. I assume it is similar to modifying it the way you did.
I second graybans comment. I
I second graybans comment. I don't want users to see the other users on my Asterisk box.
I commented out lines 273-313 of var/www/html/recordings/modules/voicemail.module and that seems to work.
Would be nice to give the administrator to ability turn the feature on/off and determine who shows up in the list.
Forwarding within VM context
If you don't want users to be able to forward to users outside of their voicemail context (for instance, if you host multiple small businesses and don't want them to be able to see each other), then add the following at line 282 of voicemail.module:
if ($forwardContext!=$_SESSION['ari_user']['context']) { continue; }
This will cause the list of extensions that one can forward to to be limited to the other extensions that are in that user's voicemail context group.
www.bitnetix.com - 877.33.VOICE - sip://bitnetix@bitnetix.com
i've never heard of a
i've never heard of a voicemail context group. what is that?
a voicemail context is a way
a voicemail context is a way to organize a group of extensions into a seperate folder on the system.
By default it should be set to default and that places all extensions and voicemail at /var/spool/voicemail/default/... If you change default to home_system then the path would be /var/spool/voicemail/home_system/...
It can be used in several ways. One of the way mentioned above to organize compaines. The other could be for example if you have a CFO and CEO who NEVER EVER delete voicemails and take a huge amount of disk space. You can add a additional disk drive, create a mount point for that drive and using this context store their voicemail on a separate drive so that when it runs out of space they only effect themselves.
Limiting the selection of if they can or can't transfer to another extension in different context would be implementation dependent.
thanks for the info
thanks for the info fskrotzki.
I would like to integrate the line of code into the voicemail.module. Looks like the relevant part is here:
// get context for forward to mailboxif (preg_match("/\[.*\]/i",$line)) {
$forwardContext = trim(preg_replace('/\[|\]/', '', $line));
}
But not sure where exactly to fit it in. Any help?
Here's a diff
If you want to implement what I suggested, then you would do it as follows. Take the contents of the patch below (starting with --- voicemail.module) and save it to a file. Let's say it's called vm.patch.
Then cd to your FreePBX location (/var/www/html, usually) and cd into recordings/modules.
Now you can run:
patch < /path/to/vm.patch
And it will update your voicemail.module so that only people who are in the same voicemail context can forward things to each other using the ARI web interface. Note that this has nothing to do with what they can do from an actual phone.
Here's the diff:
--- voicemail.module 2008-07-11 11:07:31.000000000 -0400
+++ /var/www/html/recordings/modules/voicemail.module 2008-07-11 11:03:31.000000000 -0400
@@ -280,6 +280,8 @@
$forwardContext = trim(preg_replace('/\[|\]/', '', $line));
}
+if ($forwardContext!=$_SESSION['ari_user']['context']) { continue; }
+
// get username and add to options
if (preg_match("/\=\>/i",$line)) {
list($username,$value) = split('=>',$line);
www.bitnetix.com - 877.33.VOICE - sip://bitnetix@bitnetix.com