rbrindley: branch rbrindley/astman_revamp r4604 - /team/rbrindley/astman_reva...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Wed Mar 11 08:48:50 CDT 2009


Author: rbrindley
Date: Wed Mar 11 08:48:47 2009
New Revision: 4604

URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4604
Log:

- implemented pbx.calling_rules.edit, replacing astgui_manageCallingRules.updateCallingRule()
- removed if statements around lChops, as they are redundant, lChop already performs that check


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=4604&r1=4603&r2=4604
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Wed Mar 11 08:48:47 2009
@@ -51,9 +51,7 @@
 		name = ASTGUI.contexts.CallingRulePrefix + name;
 	}
 
-	if (dp.beginsWith('exten=')) {
-		dp = dp.lChop('exten=');
-	}
+	dp = dp.lChop('exten=');
 
 	var ext_conf = new listOfSynActions('extensions.conf');
 
@@ -73,6 +71,40 @@
 	}
 
 	sessionData.pbxinfo.callingRules[name].push('exten=' + dp);
+	return true;
+};
+
+/**
+ * Update a Calling Rule.
+ * Copied from astgui_manageCallingRules.updateCallingRule()
+ * @param name The Calling Rule name.
+ * @param current The existing dialplan to be replaced.
+ * @param edition The dialplan to replace existing.
+ * @return boolean of success.
+ */
+pbx.calling_rules.edit = function(name, current, edition) {
+	if (!name) {
+		top.log.error('pbx.calling_rules.edit: uh oh, name is not defined!');
+		return false;
+	} else if (!current) {
+		top.log.error('pbx.calling_rules.edit: uh oh, current is not defined!');
+		return false;
+	} else if (!edition) {
+		top.log.error('pbx.calling_rules.edit: uh oh, edition is not defined!');
+		return false;
+	}
+
+	var ext_conf = new listOfSynActions('extensions.conf');
+	ext_conf.new_action('update', name, 'exten', edition.lChop('exten='), current.lChop('exten=');
+
+	var resp = ext_conf.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.error('pbx.calling_rules.edit: error updating extensions.conf');
+		top.log.error(resp);
+		return false;
+	}
+
+	sessionData.pbxinfo.callingRules[name] = ASTGUI.cloneObject(sessionData.pbxinfo.callingRules[name]).replaceAB(current, edition);
 	return true;
 };
 
@@ -91,9 +123,7 @@
 		top.log.warn('pbx.calling_rules.remove: ' + name + 'is not a calling rule in cached extensions.conf, likely not in real file as well. Proceeding with caution.');
 	}
 
-	if (dp.beginsWith('exten=')) {
-		dp = dp.lChop('exten=');
-	}
+	dp = dp.lChop('exten=');
 
 	var ext_conf = new listOfSynActions('extensions.conf');
 




More information about the asterisk-gui-commits mailing list