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.
[code:1]
// 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 .= "<option VALUE='" . $context . "/" . $username . "'>" . substr($real_name,0,20);
}
}
else {
$_SESSION['ari_error'] = "File not readable: " . $ASTERISK_VOICEMAIL_CONF;
return;
}
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.
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.
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.
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.
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.
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.
+if ($forwardContext!=$_SESSION[‘ari_user’][‘context’]) { continue; }
+
// get username and add to options
if (preg_match("/=>/i",$line)) {
list($username,$value) = split(’=>’,$line);
as i mentioned in an earlier post in this thread, I commented out lines 273-313 of var/www/html/recordings/modules/voicemail.module and that seems to work.
To do that, i used the /* to start the commnets and / to end the comments. Looked like this:
///forward options
At the end it looked like this:
$_SESSION['ari_error'] = "File not readable: " . $ASTERISK_VOICEMAIL_CONF;
return;
}*/