rbrindley: branch rbrindley/astman_revamp r4641 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Fri Mar 20 09:19:46 CDT 2009
Author: rbrindley
Date: Fri Mar 20 09:19:43 2009
New Revision: 4641
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4641
Log:
- copied astgui_manageVMgroups.addVMGroup to pbx.vm_groups.add
- copied astgui_manageVMgroups.parseContext to pbx.vm_groups.parse
- copied astgui_manageVMgroups.deleteVMGroup to pbx.vm_groups.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=4641&r1=4640&r2=4641
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Fri Mar 20 09:19:43 2009
@@ -1418,10 +1418,89 @@
};
/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
/**
* VoiceMail Groups object.
*/
pbx.vm_groups = {};
+
+/**
+ * Add a VM Group.
+ * @param exten VM Group extension.
+ * @param group VM Group.
+ * @return boolean of success.
+ */
+pbx.vm_groups.add = function(exten, group) {
+ var lines = [];
+ lines[0] = exten + ',1,NoOp(' + group.label + ')';
+ lines[1] = exten + ',2,VoiceMail(' + group.mailboxes.join('@default&') + '@default' + ')';
+
+ var actions = new listOfSynActions('extensions.conf');
+ for (var i=0; i<lines.length; i++) {
+ actions.new_action('append', ASTGUI.contexts.VoiceMailGroups, 'exten', line[i]);
+ }
+
+ var resp = actions.callActions();
+ if (!resp.contains('Response: Success')) {
+ top.log.error('pbx.vm_groups.add: Error updating extensions.conf');
+ return false;
+ }
+
+ sessionData.pbxinfo['vmgroups'][exten] = group;
+};
+
+/**
+ * Parse VM Group Context.
+ * @param cxt VM Group Context.
+ * @return boolean of success.
+ */
+pbx.vm_groups.parse = function(cxt) {
+ if (!cxt) {
+ top.log.warn('pbx.vm_groups.parse: cxt is empty.');
+ return false;
+ }
+
+ cxt.each(function(line) {
+ var exten = ASTGUI.parseContextLine.getExten(line);
+ if (!sessionData.pbxinfo.vmgroups.hasOwnProperty(exten)) {
+ sessionData.pbxinfo.vmgroups[exten] = new ASTGUI.customObject;
+ sessionData.pbxinfo.vmgroups[exten].label = '';
+ sessionData.pbxinfo.vmgroups[exten].mailboxes = [];
+ }
+
+ if (line.toLowerCase().contains('noop(')) {
+ var name = line.getNoOp();
+ sessionData.pbxinfo.vmgroups[exten].label = name;
+ } else if (line.toLowerCase().contains('voicemail(')) {
+ var members = ASTGUI.parseContextLine.getArgs(line)[0];
+ members.split('&').each(function(member) {
+ member = member.trim();
+ if (member) {
+ sessionData.pbxinfo.vmgroups[exten].mailboxes.push(member.beforeChar('@').trim());
+ }
+ });
+ }
+ });
+
+ return true;
+};
+
+/**
+ * Remove VM Group.
+ * @param exten VM Group Exten to delete.
+ * @return boolean of success.
+ */
+pbx.vm_groups.remove = function(exten) {
+ ASTGUI.miscFunctions.delete_LinesLike({
+ context_name: ASTGUI.contexts.VoiceMailGroups,
+ beginsWithArr: ['exten=' + exten + ',', 'exten=' + exten + ' ,'],
+ filename: 'extensions.conf',
+ cb: function(){}
+ });
+
+ delete sessionData.pbxinfo.vmgroups[exten];
+};
+/*---------------------------------------------------------------------------*/
/**
* Voicemail object.
More information about the asterisk-gui-commits
mailing list