Pause queue members patch for FreePBX versions (>=2.11)

Howto


Sympton

Even if you pause members on FreePBX by dialing feature codes, you do not see those pauses reported on Asternic.

Reason

Some FreePBX versions, for some odd reason, use device states to ‘pause’ queue members, without issuing an actual queue pause state in the queue application.

How to fix this?

If you use FreePBX and builtin feature codes to pause/unpause members, but they do not show on Asternic reports or realtime view, then this might help you.

Here is a patch contributed by a fellow user that solves the problem by adding the missing commands to the .agi responsible of pausing/unpausing members:

The file to modify is /var/lib/asterisk/agi-bin/queue_devstate.agi

And also this one: /var/www/html/admin/modules/queues/agi-bin/queue_devstate.agi

Open those with your favorite text editor, you will find this code:

$new_state = $paused_state ? '0' : '1';
foreach ($agent_queues as $q) {
    $agi->set_variable("QUEUE_MEMBER($q,paused,$user_interface)", $new_state);
    debug("QUEUE_MEMBER($q,paused,$user_interface)=$new_state");
}
$agi->set_variable("TOGGLEPAUSED", $new_state);

After that you must add the following:

if($new_state) {
    $agi->exec('PauseQueueMember',",$user_interface");
} else {
    $agi->exec('UnPauseQueueMember',",$user_interface");
}

So, the final code should look like this:

$new_state = $paused_state ? '0' : '1';
foreach ($agent_queues as $q) {
    $agi->set_variable("QUEUE_MEMBER($q,paused,$user_interface)", $new_state);
    debug("QUEUE_MEMBER($q,paused,$user_interface)=$new_state");
}
$agi->set_variable("TOGGLEPAUSED", $new_state);

if($new_state) {
    $agi->exec('PauseQueueMember',",$user_interface");
} else {
    $agi->exec('UnPauseQueueMember',",$user_interface");
}