Sort Voicemail by Date/Time

thx2000

Joined
Mar 28, 2009
Messages
19
Likes
0
Points
0
#1
It always drove me crazy that the voicemail app didn't sort voicemails based on time/date. So here's a fix...

In /var/www/html/aastra/include, create sort.php and fill it with this. (I found this function from: http://us3.php.net/manual/en/function.a ... tisort.php)

Code:
<?php

#       Example: array_sort($my_array,'!group','surname');
#       Using ! reverses sort order



function array_sort_func($a,$b=NULL) {
   static $keys;
   if($b===NULL) return $keys=$a;
   foreach($keys as $k) {
      if(@$k[0]=='!') {
         $k=substr($k,1);
         if(@$a[$k]!==@$b[$k]) {
            return strcmp(@$b[$k],@$a[$k]);
         }
      }
      else if(@$a[$k]!==@$b[$k]) {
         return strcmp(@$a[$k],@$b[$k]);
      }
   }
   return 0;
}

function array_sort(&$array) {
   if(!$array) return $keys;
   $keys=func_get_args();
   array_shift($keys);
   array_sort_func($keys);
   usort($array,"array_sort_func");
}

?>
In the same directory, edit AastraAsterisk.php. First include sort.php in the includes section (Line 143)
Code:
require_once('sort.php');
Then modify the 'Aastra_get_messages_Asterisk' function to sort the messages. This was line 563 for me, but depending on how you added the require_once line, it may be more or less. Regardless, it should be directly after the closing bracket of the while loop.
Code:
array_sort($messages,'!origtime');
Good luck. I'm hoping Aastra will include this, or something like it, in the next round of scripts. Digging through a mess of voicemails always made using the visual voicemail app a pain to use.


-THX2000
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#2
We will, thanks for the input. You are the first user to mention that the VM messages were not sorted by date... It will be implemented ASAP.

aastra1
 

raj

Joined
Apr 19, 2009
Messages
149
Likes
0
Points
0
#3
Hey Aastra,

If those will be added how will we update our existing installations?
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#4
raj said:
Hey Aastra,

If those will be added how will we update our existing installations?
Change has been implemented, the update will come with the next version of the scripts.

aastra1
 

raj

Joined
Apr 19, 2009
Messages
149
Likes
0
Points
0
#5
[/quote]

Change has been implemented, the update will come with the next version of the scripts.

aastra1[/quote]


But we have to re run/reinstall everything or just some update* now etc stuff?
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#6
raj said:
But we have to re run/reinstall everything or just some update* now etc stuff?
Unfortunately yes, we will work on a simple upgrade path. This is being said, the fix is much simpler that what was published as the scriipts already come with an array sort function.

So in /var/www/html/aastra/asterisk/vmail.php around line 292,

After these lines

Code:
# Retrieve messages
$messages=Aastra_get_messages_Asterisk($user,$folder);
add the following lines

Code:
# Sort messages by time starting with the latest one
Aastra_natsort2d($messages,"origtime");
$messages=array_reverse($messages);
This does the trick.

Depending on the other issues/quick enhancements with 2.2.1 we may publish a second patch, we have one ready to go.

Regards

aastra1
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,915
Messages
130,920
Members
17,595
Latest member
feparra121
Top