Tutorial: Replicate the users from the PBX

In this tutorial you will learn how replicate the users data from the PBX to your app.

Conventions

The used file and class names in this example are based on a newly created App with the name NewApp1 and the company name innovaphone. Your filenames might be different according to your settings. To be able to replicate, the app needs to have access to PbxTableUsers and need the name of the PBX.

Testing and expected behaviour

For testing the app we need to have several users on the PBX. When editing an user, the changes should be relicated to your database. You could check if the users and the changes are been replicated to your app by checking your database using for example Putty. You can connect to your database with Putty setting as Host Name the IP address of your AP Platform, as Port the 22 and as Connection type SSH. Then you have to login using your admin credentials provided by the installer and connecting to your database using PostgreSQL commands.

Connecting to your database

psql -d databasename;

Reading your users table

select * from users;

Step by step

Task 1: Create your replicator object

On the constructor of your app instance, the replicator has to be declared. Here you can check the Replicator functions. After declaring the object, you can add fields to the replicator. There you can link the name of a data field from the PBX to a column from your database.

Task 2: Adding the callback functions for the replicator

Now we need to add the callback functions for the replicator.

Task 3: Add users table to your database

The table to save the replicated data from the PBX needs to be added. Here you can check the Database functions. You can also check this Database Tutorial about how to use the database.

Task 4: Start the replicator

The table to save the replicated data from the PBX needs to be added. Here you can check the Database functions. You can also check this Database Tutorial about how to use the database.

Task 5: Add and configure your App Object on the PBX

You need to configure for App Object on the PBX and give it access to the PbxTableUsers and the Websocket flags.

Task 6: Add groups table to your database and replicate the groups data

The table to save the replicated data from the PBX needs to be added. Here you can check the Database functions. You can also check this Database Tutorial about how to use the database.

Other considerations

The are functions that must be called when your database changes (when a user is added, updated or deleted):

newapp1->replicator->Added(id)This must be called when a user is added on your database, so that the replicator will add it too.
newapp1->replicator->Updated(id)This must be called when a user is updated on your database, so that the replicator will update it too.
newapp1->replicator->Deleted(id)This must be called when you would like to delete a user from your database.

List of data fields that can be replicated

Table users

Table with the user data

ReplicationStringguidGlobally unique identifier
ReplicationStringh323Username
ReplicationStringpwdPassword
ReplicationStringcnCommon name
ReplicationStringdnDisplay name
ReplicationStringapps-myList of the apps displayed on the home screen
ReplicationStringconfigConfig template
ReplicationStringnodeNode
ReplicationStringlocLocation
ReplicationBoolhideHide from LDAP
ReplicationStringe164Phone number
ReplicationTristatecfprCall forward based on Presence
ReplicationTristatet-cfprCall forward based on Presence inherited from the config template
ReplicationStringpseudoPseudo information of the object
ReplicationBoolh323-emailIf true, the email is the username
ReplicationStringappsList of the apps that the user has rights to access
ReplicationBoolfaxIf true, the user has a fax license

Table emails

Table with the emails of the users

ReplicationStringemailEmail

Table allows

Table with the visibility filters defined for the user

ReplicationStringnameFilter name
ReplicationStringgrpIf true, the name is a group name
ReplicationBoolvisibleVisible
ReplicationBoolonlineOnline
ReplicationBoolpresencePresence
ReplicationBoolotfOn the phone
ReplicationBoolnotePresence note
ReplicationBooldialogCalls
ReplicationBoolidsCalls with id

Table t-allows

Table with the visibility filters defined on the config templates

ReplicationStringnameFilter name
ReplicationStringgrpIf true, the name is a group name
ReplicationBoolvisibleVisible
ReplicationBoolonlineOnline
ReplicationBoolpresencePresence
ReplicationBoolotfOn the phone
ReplicationBoolnotePresence note
ReplicationBooldialogCalls
ReplicationBoolidsCalls with id

Table grps

Table with the users groups

ReplicationStringnameGroup name
ReplicationStringmodeMode
ReplicationStringdynDynamic

Table devices

Table with the users devices

ReplicationStringhwHardware ID
ReplicationStringtextName
ReplicationStringappApp
ReplicationBooladminPBX Pwd
ReplicationBoolno-filterNo IP Filter
ReplicationBooltlsTLS only
ReplicationBoolno-mobNo Mobility
ReplicationBooltrustedReverse Proxy
ReplicationBoolsregSingle Reg.
ReplicationBoolmrMedia Relay
ReplicationStringvoipConfig VOIP
ReplicationStringgk-idGatekeeper ID
ReplicationStringprimPrimary gatekeeper

Table cds

Table with the users call diversions

ReplicationStringtypeDiversion type (cfu, cfb or cfnr)
ReplicationStringboolBoolean object
ReplicationBoolbool-notNot flag (boolean object)
ReplicationStringe164Phone number
ReplicationStringh323Username
ReplicationStringsrcFilters data on XML format

Table forks

Table with the users forks

ReplicationStringe164Phone number
ReplicationStringh323Username
ReplicationStringboolBoolean object
ReplicationBoolbool-notNot flag (boolean object)
ReplicationStringmobilityMobility object
ReplicationStringappApp
ReplicationUnsigneddelayDelay
ReplicationStringhwDevice
ReplicationBooloffDisable
ReplicationBoolcwCall-Waiting
ReplicationUnsignedminMin-Alert
ReplicationUnsignedmaxMax-Alert

Useful documentation