rbrindley: branch rbrindley/astman_revamp r4602 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Mar 11 08:25:00 CDT 2009
Author: rbrindley
Date: Wed Mar 11 08:24:57 2009
New Revision: 4602
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4602
Log:
- implemented pbx.calling_rules.add, replacing astgui_manageCallingRules.createCallingRule
Modified:
team/rbrindley/astman_revamp/config/js/pbx2.js
Modified: team/rbrindley/astman_revamp/config/js/pbx2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/pbx2.js?view=diff&rev=4602&r1=4601&r2=4602
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Wed Mar 11 08:24:57 2009
@@ -30,6 +30,51 @@
* Calling Rules object.
*/
pbx.calling_rules = {};
+
+/**
+ * Create a Calling Rule.
+ * Copied from astgui_manageCallingRules.createCallingRule()
+ * @param name The Calling Rule name
+ * @param dp The Calling Rule dialplan string
+ * @return boolean of success
+ */
+pbx.calling_rules.add = function(name, dp) {
+ if (!name) {
+ top.log.warn('pbx.calling_rules.add: name is not defined');
+ return false;
+ } else if (!dp) {
+ top.log.warn('pbx.calling_rules.add: dp is not defined');
+ return false;
+ }
+
+ if (!name.beginsWith(ASTGUI.contexts.CallingRulePrefix)) {
+ name = ASTGUI.contexts.CallingRulePrefix + name;
+ }
+
+ if (dp.beginsWith('exten=')) {
+ dp = dp.lChop('exten=');
+ }
+
+ var ext_conf = new listOfSynActions('extensions.conf');
+
+ if (!sessionData.pbxinfo.callingRules.hasOwnProperty(name)) {
+ ext_conf.new_action('delcat', name '', ''); /* for good measure :) */
+ ext_conf.new_action('newcat', name '', '');
+ sessionData.pbxinfo.callingRules[name] = [];
+ }
+
+ ext_conf.new_action('append', name, 'exten', dp);
+ var resp = ext_conf.callActions();
+
+ if (!resp.contains('Response: Success')) {
+ top.log.error('pbx.calling_rules.add: error adding ' + name + ' to extensions.conf');
+ top.log.error(resp);
+ return false;
+ }
+
+ sessionData.pbxinfo.callingRules[name].push('exten=' + dp);
+ return true;
+};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
More information about the asterisk-gui-commits
mailing list