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

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Thu Mar 26 14:28:03 CDT 2009


Author: rbrindley
Date: Thu Mar 26 14:28:01 2009
New Revision: 4670

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

- implemented pbx.trunks.rules.edit


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=4670&r1=4669&r2=4670
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Thu Mar 26 14:28:01 2009
@@ -1609,6 +1609,61 @@
 
 	return true;
 };
+
+/**
+ * Edit a Incoming Calling rule
+ * @param line current calling rule dialplan.
+ * @param dest The destination.
+ * @param cxt The context to edit.
+ * @param pattern The extension pattern.
+ * @param time_interval [optional] The time interval.
+ * @param digits [optional] The 'x' in '${EXTEN:x}', for when dest === 'ByDID'.
+ * @return boolean on success.
+ */
+pbx.trunks.rules.edit = function(params) {
+	/* check to make sure we got everything */
+	if (typeof params !== 'object') {
+		top.log.error('pbx.trunks.rules.add: Expecting params to be an object.');
+		return false;
+	} else if (!params.line) {
+		top.log.error('pbx.trunks.rules.add: params.line not found.');
+		return false;
+	} else if (!params.cxt) {
+		top.log.error('pbx.trunks.rules.add: params.cxt not found.');
+		return false;
+	} else if (!params.dest) {
+		top.log.error('pbx.trunks.rules.add: params.dest not found.');
+		return false;
+	} else if (!params.pattern) {
+		top.log.error('pbx.trunks.rules.add: params.pattern not found.');
+		return false;
+	} else if (params.dest === 'ByDID' && !params.digits) {
+		top.log.error('pbx.trunks.rules.add: Destination is ByDID, but params.digits is not found.');
+		return false;
+	}
+
+	/* just delete time_interval if its empty */
+	if (params.time_interval === '') {
+		delete params.time_interval;
+	}
+
+	/* kk, now lets form the rule */
+	var prior = ASTGUI.parseContextLine.getPriority(params.line);
+	var rule = params.pattern + delim + prior + delim;
+	rule += (params.dest === 'ByDID') ? 'Goto(default,${EXTEN:'+params.digits+'}'+delim+'1)' : params.dest;
+
+	var actions = new listOfSynActions('extensions.conf');
+	actions.new_action('update', cxt, 'exten', rule, line.afterChar('='));
+
+	var resp = actions.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.error('pbx.trunks.rules.edit: Error updating extensions.conf.');
+		top.log.error(resp);
+		return false;
+	}
+
+	return true;
+};
 /*---------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------*/




More information about the asterisk-gui-commits mailing list