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

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Mar 20 11:32:34 CDT 2009


Author: rbrindley
Date: Fri Mar 20 11:32:31 2009
New Revision: 4643

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

- added pbx.call_plans.rules object
- copied astgui_manageCallPlans.includeCallingRule to pbx.call_plans.rules.add
- copied astgui_manageCallPlans.dropCallingRule to pbx.call_plans.rules.remove


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=4643&r1=4642&r2=4643
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Fri Mar 20 11:32:31 2009
@@ -357,6 +357,72 @@
 	}
 
 	delete sessionData.pbxinfo.callingPlans[name];
+	return true;
+};
+
+/**
+ * The Calling Rules object.
+ * This object holds all the methods and members to manipulate calling rules
+ * inside a calling plan.
+ */
+pbx.call_plans.rules = {};
+
+/**
+ * Add a Calling Rule.
+ * @param callplan The Calling Plan.
+ * @param rule The Calling Rule to add.
+ * @return boolean of success.
+ */
+pbx.call_plans.rules.add = function(callplan, rule) {
+	if (!callplan) {
+		top.log.warn('pbx.call_plans.rules.remove: Callplan is empty.');
+		return false;
+	} else if (!rule) {
+		top.log.warn('pbx.call_plans.rules.remove: Rule is empty.');
+		return false;
+	}
+
+	var actions = new listOfSynActions('extensions.conf');
+	actions.new_action('append', callplan, 'include', rule);
+
+	var resp = actions.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.eror('pbx.call_plans.rules.add: Error updating extensions.conf');
+		return false;
+	}
+
+	sessionData.pbxinfo.callingPlans[callplan].includes.push(rule);
+	return true;
+};
+
+/**
+ * Delete a Calling Rule.
+ * @param callplan The Calling Plan to delete from.
+ * @param rule The Calling Rule to delete.
+ * @return boolean of success.
+ */
+pbx.call_plans.rules.remove = function(callplan, rule) {
+	if (!callplan) {
+		top.log.warn('pbx.call_plans.rules.remove: Callplan is empty.');
+		return false;
+	} else if (!rule) {
+		top.log.warn('pbx.call_plans.rules.remove: Rule is empty.');
+		return false;
+	}
+
+	var actions = new listOfSynActions('extensions.conf');
+	actions.new_action('delete', callplan, 'include', '', rule);
+
+	var resp = actions.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.error('pbx.call_plans.rules.remove: Error updating extensions.conf.');
+		return false;
+	}
+
+	/* TODO: This is ugly, surely there is a better way */
+	if (sessionData.pbxinfo.callingPlans[callplan].includes) {
+		sessionData.pbxinfo.callingPlans[callplan].includes = sessionData.pbxinfo.callingPlans[callplan].includes.withOut(rule);
+	}
 	return true;
 };
 /*---------------------------------------------------------------------------*/




More information about the asterisk-gui-commits mailing list