Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

FOP2 Community Forum

  1. Home
  2. Feedback
  3. Fop2 Realtime PBX support

Fop2 Realtime PBX support

Scheduled Pinned Locked Moved Feedback
1 Posts 1 Posters 181 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F
    F
    Faqterson
    wrote on last edited by
    #1

    I run my own Asterisk PBX software and make use of Realtime databases.
    I have created the engine code to create my buttons from the realtime tables. I hope its useful to other users.
    /var/www/html/fop2/admin/functions.php
    ....
    } else if($config_engine == 'realtime') {
    $return = realtime_check_extension_usage();
    .....

    /var/www/html/fop2/admin/functions-realtime.php
    <?php
    function realtime_populate_contexts_from_tenants() {
    $panelcontexts[0]='GENERAL';
    return $panelcontexts;
    }
    // Same as functions-astdb but querying the asterisk database for sip peers and voicemail tables
    function realtime_check_extension_usage() {
    global $db, $astman, $conf;
    $extenlist = array();

            $dbtablesip       = "asterisk.ps_endpoints AS ps_endpoints";
            $dbtableiax       = "asterisk.iaxfriends AS iaxfriends";
            $dbtablevoicemail = "asterisk.voicemail AS voicemail";
            $dbtablequeues = "asterisk.queues AS queues";
        
            // Extensions
            $fields= "CONCAT('PJSIP/',ps_endpoints.id) as dial,ps_endpoints.id as extension,ps_endpoints.context as context,callerid as name,ps_endpoints.id as mailbox,voicemail.password as vmpin,email";
            $results = $db->select($fields,$dbtablesip,"LEFT JOIN $dbtablevoicemail on ps_endpoints.id=voicemail.mailbox","","","","");
            if(is_array($results)) {
                $trunkcount=0;
                foreach ($results as $result) {
        
                    if(preg_match("/[,&]/",$result['dial'])) {
                        $partes = preg_split("/[,&]/",$result['dial']);
                        $result['dial']=$partes[0];
                    }
        
                    $thisexten = $result['extension'];
                    $vmpin     = $result['vmpin'];
                    $vmemail   = $result['email'];
                    $data = array();
                    $data['name'] = $result['name'];
                    $data['channel'] = $result['dial'];
                    $data['mailbox'] = $result['mailbox'];
        
                    if( $result['name'] != "") {
                       $data['type']='extension';
                       $data['exten']   = $thisexten;
                    } else {
                       $trunkcount++;
                       $data['type']='trunk';
                       $data['exten']=$thisexten;
                    }
        
                    $data['context'] = $result['context'];
                    $data['vmpin']   = $vmpin;
                    $data['email']   = $vmemail;
                    $data['customastdb'] = 'CF/'.$thisexten;
                    $data['context_id'] = 0;
        
                    $extenlist[$data['channel']]  = $data;
        
                }
            }
        
            //IAX2
            $fields= "CONCAT('IAX2/',name) as dial,name,context";
            $results = $db->select($fields,$dbtableiax);
            if(is_array($results)) {
                $trunkcount=0;
                foreach ($results as $result) {
        
                    if(preg_match("/[,&]/",$result['dial'])) {
                        $partes = preg_split("/[,&]/",$result['dial']);
                        $result['dial']=$partes[0];
                    }
        
                    $thisexten = $result['name'];
                    $vmpin     = "";
                    $vmemail   = "";
                    $data = array();
                    $data['name'] = $result['name'];
                    $data['channel'] = $result['dial'];
                    $data['mailbox'] = "";
        
                    $trunkcount++;
                    $data['type']='trunk';
                    $data['exten']=$thisexten;
        
                    $data['context'] = $result['context'];
                    $data['vmpin']   = $vmpin;
                    $data['email']   = $vmemail;
                    $data['customastdb'] = 'CF/'.$thisexten;
                    $data['context_id'] = 0;
        
                    $extenlist[$data['channel']]  = $data;
                }
            }
        
            // Queues
            $fields= "name";
            $results = $db->select($fields,$dbtablequeues,"","","","","");
            if(is_array($results)) {
                foreach ($results as $result) {
                   $thisexten = $result['name'];
                   $data = array();
                   $data['channel'] = "QUEUE/$thisexten";
                   $data['type']    = "queue";
                   $data['context'] = "queue-$thisexten";
                   $data['name']    = $thisexten;
                   $data['exten']   = $thisexten;
                   $data['context_id'] = 0;
                   $extenlist[$data['channel']] = $data;
                }
            }
        
            return $extenlist;
        
        }
    
    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    Powered by NodeBB Contributors
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups