Sort Voicemail by Date/Time

Discussion in 'IP Phones' started by thx2000, May 8, 2009.

  1. thx2000

    Joined:
    Mar 28, 2009
    Messages:
    19
    Likes Received:
    0
    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
     
  2. aastra1

    Joined:
    Mar 5, 2009
    Messages:
    46
    Likes Received:
    0
    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
     
  3. raj

    raj

    Joined:
    Apr 19, 2009
    Messages:
    149
    Likes Received:
    0
    Hey Aastra,

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

    Joined:
    Mar 5, 2009
    Messages:
    46
    Likes Received:
    0
    Change has been implemented, the update will come with the next version of the scripts.

    aastra1
     
  5. raj

    raj

    Joined:
    Apr 19, 2009
    Messages:
    149
    Likes Received:
    0
    [/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?
     
  6. aastra1

    Joined:
    Mar 5, 2009
    Messages:
    46
    Likes Received:
    0
    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
     

Share This Page