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

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


Author: rbrindley
Date: Fri Mar 20 11:14:36 2009
New Revision: 4642

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

- copied astgui_manageCallPlans.addPlan to pbx.call_plans.add
- copied astgui_manageCallPlans.listPlans to pbx.call_plans.list
- copied astgui_manageCallPlans.parseContext to pbx.call_plans.parse
- copied astgui_manageCallPlans.deletePlan to pbx.call_plans.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=4642&r1=4641&r2=4642
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Fri Mar 20 11:14:36 2009
@@ -248,10 +248,118 @@
 };
 /*---------------------------------------------------------------------------*/
 
-/**
- * Dial Plans object.
- */
-pbx.dial_plans = {};
+/*---------------------------------------------------------------------------*/
+/**
+ * Calling Plans object.
+ */
+pbx.call_plans = {};
+
+/**
+ * Add a Calling Plan.
+ * @param name Calling Plan name.
+ * @param callplan The Calling Plan.
+ * @param callback Callback function.
+ * @return boolean of success.
+ */
+pbx.call_plans.add = function(name, callplan, callback) {
+	if (!name) {
+		top.log.warn('pbx.call_plans.add: name is empty.');
+		return false;
+	} else if (!callplan) {
+		top.log.warn('pbx.call_plans.add: callplan is empty.');
+		return false;
+	} else if (!callplan.includes) {
+		top.log.warn('pbx.call_plans.add: callplan.includes is empty.');
+		return false;
+	}
+
+	var actions = new listOfSynActions('extensions.conf');
+	actions.new_action('delcat', name, '', '');
+	actions.new_action('newcat', name, '', '');
+
+	callplan.includes.each(function(cxt) {
+		actions.new_action('append', name, 'include', cxt);
+	});
+
+	var resp = actions.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.error('pbx.call_plans.add: Error updating extensions.conf.');
+		return false;
+	}
+
+	sessionData.pbxinfo.callingPlans[name] = callplan;
+	if (callback) {
+		callback();
+	}
+
+	return true;
+};
+
+/**
+ * List Call Plans.
+ * @return array of Call Plans.
+ */
+pbx.call_plans.list = function() {
+	var list = [];
+
+	for (var x in sessionData.pbxinfo.callingPlans) {
+		if (!sessionData.pbxinfo.callingPlans.hasOwnProperty(x)) {
+			continue;
+		}
+
+		list.push(x);
+	}
+
+	return list;
+};
+
+/**
+ * Parse Call Plans context.
+ * @param cxt Calling Plans context.
+ * @return object of calling plan
+ */
+pbx.call_plans.parse = function(cxt) {
+	if (!cxt) {
+		top.log.warn('pbx.call_plans.parse: cxt is empty.');
+		return null;
+	}
+
+	var dp = {};
+	dp.includes = [];
+
+	cxt.each(function(line) {
+		if (line.beginsWith('include=')) {
+			dp.includes.push(line.afterChar('='));
+		}
+	});
+
+	return dp;
+};
+
+/**
+ * Remove a Calling Plan.
+ * @param name The Calling Plan name.
+ * @return boolean of success.
+ */
+pbx.call_plans.remove = function(name) {
+	if (!name) {
+		top.log.warn('pbx.call_plans.remove: name is empty.');
+		return false;
+	}
+
+	var actions = new listOfSynActions('extensions.conf');
+	actions.new_action('delcat', name, '', '');
+
+	var resp = actions.callActions();
+	if (!resp.contains('Response: Success')) {
+		top.log.error('pbx.call_plans.remove: Error updating extensions.conf');
+		return false;
+	}
+
+	delete sessionData.pbxinfo.callingPlans[name];
+	return true;
+};
+/*---------------------------------------------------------------------------*/
 
 /**
  * Directory object.




More information about the asterisk-gui-commits mailing list