@@ -4710,4 +4710,67 @@ public function skipchansipTrunk() {
4710
4710
}
4711
4711
}
4712
4712
}
4713
+
4714
+ public function getAstdbConfigs ($ extension ) {
4715
+ $ results = [];
4716
+ $ astman = $ this ->FreePBX ->astman ;
4717
+ if ($ astman ->connected ()) {
4718
+
4719
+ if ($ this ->FreePBX ->Modules ->checkStatus ("paging " )) {
4720
+ $ answermode =$ astman ->database_get ("AMPUSER " ,$ extension ."/answermode " );
4721
+ $ results ['answermode ' ] = (trim ($ answermode ) == '' ) ? $ this ->freepbx ->Config ->get ("DEFAULT_INTERNAL_AUTO_ANSWER " ) : $ answermode ;
4722
+
4723
+ $ intercom =$ astman ->database_get ("AMPUSER " ,$ extension ."/intercom " );
4724
+ $ results ['intercom ' ] = (trim ($ intercom ) == '' ) ? 'enabled ' : $ intercom ;
4725
+ }
4726
+
4727
+ $ cw = $ astman ->database_get ("CW " ,$ extension );
4728
+ $ results ['callwaiting ' ] = (trim ($ cw ) == 'ENABLED ' ) ? 'enabled ' : 'disabled ' ;
4729
+ $ cid_masquerade =$ astman ->database_get ("AMPUSER " ,$ extension ."/cidnum " );
4730
+ $ results ['cid_masquerade ' ] = (trim ($ cid_masquerade ) != "" )?$ cid_masquerade :$ extension ;
4731
+
4732
+ $ call_screen =$ astman ->database_get ("AMPUSER " ,$ extension ."/screen " );
4733
+ $ results ['call_screen ' ] = (trim ($ call_screen ) != "" )?$ call_screen :'0 ' ;
4734
+
4735
+ $ pinless =$ astman ->database_get ("AMPUSER " ,$ extension ."/pinless " );
4736
+ $ results ['pinless ' ] = (trim ($ pinless ) == 'NOPASSWD ' ) ? 'enabled ' : 'disabled ' ;
4737
+
4738
+ $ results ['ringtimer ' ] = (int ) $ astman ->database_get ("AMPUSER " ,$ extension ."/ringtimer " );
4739
+
4740
+ $ results ['cfringtimer ' ] = (int ) $ astman ->database_get ("AMPUSER " ,$ extension ."/cfringtimer " );
4741
+ $ results ['concurrency_limit ' ] = (int ) $ astman ->database_get ("AMPUSER " ,$ extension ."/concurrency_limit " );
4742
+
4743
+ $ results ['dialopts ' ] = $ astman ->database_get ("AMPUSER " ,$ extension ."/dialopts " );
4744
+
4745
+ $ results ['cwtone ' ] = $ astman ->database_get ("AMPUSER " ,$ extension ."/cwtone " );
4746
+
4747
+ $ results ['recording_in_external ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/recording/in/external " ));
4748
+ $ results ['recording_out_external ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/recording/out/external " ));
4749
+ $ results ['recording_in_internal ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/recording/in/internal " ));
4750
+ $ results ['recording_out_internal ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/recording/out/internal " ));
4751
+ $ results ['recording_ondemand ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/recording/ondemand " ));
4752
+ $ results ['recording_priority ' ] = (int ) $ astman ->database_get ("AMPUSER " ,$ extension ."/recording/priority " );
4753
+ $ results ['rvolume ' ] = strtolower ($ astman ->database_get ("AMPUSER " ,$ extension ."/rvolume " ));
4754
+
4755
+ } else {
4756
+ throw new \Exception ("Cannot connect to Asterisk Manager with using user[ " .$ this ->FreePBX ->Config ->get ("AMPMGRUSER " )."] " );
4757
+ }
4758
+ return $ results ;
4759
+ }
4760
+
4761
+ public function putAstdbConfigs ($ configs ) {
4762
+ $ astman = $ this ->FreePBX ->astman ;
4763
+ //add details to astdb
4764
+ if ($ astman ->connected ()) {
4765
+ $ replace_char = ['recording_in_external ' ,'recording_out_external ' ,'recording_in_internal ' ,'recording_out_internal ' ,'recording_ondemand ' ,'recording_priority ' ];
4766
+ foreach ($ configs as $ ext => $ confs ) {
4767
+ foreach ($ confs as $ key => $ value ) {
4768
+ if (in_array ($ key ,$ replace_char )) {
4769
+ $ key = str_replace ("_ " ,"/ " ,$ key );
4770
+ }
4771
+ $ astman ->database_put ("AMPUSER " ,$ ext ."/ " .$ key ,$ value );
4772
+ }
4773
+ }
4774
+ }
4775
+ }
4713
4776
}
0 commit comments