I want to kick off another discussion which I create a wiki page for. Others have discussed this so this would be a good place to concentrate some discussion. The wiki page I posted is here:
http://www.freepbx.org/wiki/AstDBUsage
I’ll repeat it hear to kick off and we can discuss it here, and as appropriate add to the page above:
We should consider moving some more parameters to the AstDB to better facilitate the development of user portals or the addition of features in existing portals like ARI. For example, take the generation of a ringgroup or Follow Me functionality. The guts look something like this today, depending on the options:
[code:1]
exten => 200,n(NEWPREFIX),Set(RGPREFIX=SALES)
exten => 200,n,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})
exten => 200,n,Set(RecordMethod=Group)
exten => 200,n,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
exten => 200,n,Set(RingGroupMethod=ringall)
exten => 200,n(DIALGRP),Macro(dial,27,${DIAL_OPTIONS},200-7737341234#)
exten => 200,n,Set(RingGroupMethod=)
exten => 200,n,Goto(ext-group,1,1)
[/code:1]
By moving several of the settings into the AstDB, the generated dialplan might look something like the following:
[code:1]
exten => 200,n(NEWPREFIX),Set(RGPREFIX=${DB(AMPUSER/200/FOLLOW/PRE)})
exten => 200,n,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})
exten => 200,n,Set(RecordMethod=Group)
exten => 200,n,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
exten => 200,n,Set(RingGroupMethod=${DB(AMPUSER/200/FOLLOW/RGSTRAT)})
exten => 200,n(DIALGRP),Macro(dial,${DB(AMPUSER/200/FOLLOW/RTIME)},${DIAL_OPTIONS},${DB(AMPUSER/200/FOLLOW/NUMS)})
exten => 200,n,Set(RingGroupMethod=)
exten => 200,n,Goto(ext-group,1,1)
[/code:1]
By doing this, we are in a position to do updates from both FreePBX but also dynamically or form a portal. The examples in this case are, PRE (CID prefix), RGSTRAT (ring strategy), RTIME (ring time) and NUMS (numbers to ring in the apporpirate format). Freepbx would generate the initial dialplan and store these values (in this example) in the AstDB instead of in the mysql database. It would of course fetch them from there as well. Now you could easily add the ability from within ARI, for example, to change any of these settings, letting users change their own settings.
The above is just one example, there are several others, some that have been discussed elsewhere (such as DIAL_OPTIONS per user, …)