Problem where unless all the correct settings are applied for each extension then camp-on does not work.
Old code would add all defaults into ASTDB if you added new extension but not on edit and thus on upgrade.
Ive modified the code here to work with defaults on each extension, its nearly finished but will allow all extens to be set to default and then as callflow is processed it will detect this and setup accordingly, ive also put a double check in there incase no entries exist for the extn, this is then considered a default unless otherwise specified.
This now works fairly well.
Finalized version will allow user to disable system defaults and decide on a per exten basis if they want to use system defaults or extn specific.
29c29
< $ext->splice('macro-user-callerid', 's', $priority,new ext_gosubif('$[${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)})} & "${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)}" != "never"]', 'sub-ccss,s,1',false,'${MACRO_CONTEXT},${CALLERID(dnid)}'));
---
> $ext->splice('macro-user-callerid', 's', $priority,new ext_gosubif('$["${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)}" != "never" || ${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)})}==0]','sub-ccss,s,1',false,'${MACRO_CONTEXT},${CALLERID(dnid)}'));
76a77,78
>
> $ext->add($mcontext,$exten,'', new ext_noop('AMPUSER: ${AMPUSER} Calling ${ARG2}:${ARG1}'));
78,79c80,81
< $ext->add($mcontext,$exten,'monitor', new ext_gosubif('$[${LEN(${DB(AMPUSER/${ARG2}/ccss/cc_monitor_policy)})}]','monitor_config,1','monitor_default,1','${ARG1},${ARG2}','${ARG1},${ARG2}'));
< $ext->add($mcontext,$exten,'agent', new ext_gosubif('$[${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)})}]','agent_config,1','agent_default,1'));
---
> $ext->add($mcontext,$exten,'monitor', new ext_gosubif('$[${LEN(DB(AMPUSER/${ARG2}/ccss/cc_monitor_policy))}==0 || "${DB(AMPUSER/${ARG2}/ccss/cc_monitor_policy)}" == "default"]','monitor_default,1','monitor_config,1','${ARG1},${ARG2}','${ARG1},${ARG2}'));
> $ext->add($mcontext,$exten,'agent', new ext_gosubif('$[${LEN(DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy))}==0 || "${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)}" == "default"]','agent_default,1','agent_config,1'));
335a338
> $currentcomponent->addoptlistitem('cc_agent_policy', 'default', _('Use System Defaults'));
396a400
> $currentcomponent->addoptlistitem('cc_monitor_policy', 'default', _('Use System Defaults'));
538a543
> $ccss['cc_monitor_policy'] = isset($_REQUEST['cc_monitor_policy']) ? $_REQUEST['cc_monitor_policy'] : $amp_conf['CC_MONITOR_POLICY_DEFAULT'];
541c546
< if ($action == 'add' || $action == 'edit' && !$amp_conf['CC_FORCE_DEFAULTS']) {
---
> if (($action == 'add' || $action == 'edit') && !$amp_conf['CC_FORCE_DEFAULTS']) {
547d551
< $ccss['cc_monitor_policy'] = isset($_REQUEST['cc_monitor_policy']) ? $_REQUEST['cc_monitor_policy'] : $amp_conf['CC_MONITOR_POLICY_DEFAULT'];
576c580
< $ccss['cc_agent_policy'] = $cc_agent_policy ? $cc_agent_policy : $amp_conf['CC_AGENT_POLICY_DEFAULT'];
---
> $ccss['cc_agent_policy'] = $cc_agent_policy ? $cc_agent_policy : 'default';
578c582
< $ccss['cc_monitor_policy'] = $cc_monitor_policy ? $cc_monitor_policy : $amp_conf['CC_MONITOR_POLICY_DEFAULT'];
---
> $ccss['cc_monitor_policy'] = $cc_monitor_policy ? $cc_monitor_policy : 'default';