rbrindley: branch rbrindley/astman_revamp r4611 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Mar 11 13:12:15 CDT 2009
Author: rbrindley
Date: Wed Mar 11 13:12:12 2009
New Revision: 4611
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4611
Log:
- implemented pbx.time_intervals.add
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=4611&r1=4610&r2=4611
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Wed Mar 11 13:12:12 2009
@@ -334,6 +334,72 @@
* Time Interval object.
*/
pbx.time_intervals = {};
+
+/**
+ * Add a Time Interval.
+ * @param name Name of the Interval.
+ * @param interval contains: time, weekdays, days, months
+ * @return boolean on success.
+ */
+pbx.time_intervals.add = function(name, interval) {
+ /* check the basics */
+ if (!name) {
+ top.log.error('pbx.time_intervals.add: name is empty.');
+ return false;
+ } else if (typeof interval !== 'undefined') {
+ top.log.error('pbx.time_intervals.add: interval is undefined.');
+ return false;
+ }
+
+ /* validate the name */
+ if (name.contains(' ')) {
+ top.log.error('pbx.time_intervals.add: name contains spaces.');
+ return false;
+ }
+ /* we need to check for existing time_intervals with the same name
+ * to do this, we first must make an array holding all the
+ * time_intervals. */
+
+ /* set defaults. can't loop through members, that assumes they exist. */
+ interval.time = interval.time || '*';
+ interval.weekdays = interval.weekdays || '*';
+ interval.days = interval.days || '*';
+ interval.months = interval.months || '*';
+
+ /* validate all the args */
+ if (!this.validate.time(interval.time)) {
+ top.log.error('pbx.time_intervals.add: invalid time.');
+ return false;
+ } else if (!this.validate.weekdays(interval.weekdays)) {
+ top.log.error('pbx.time_intervals.add: invalid days of the week.');
+ return false;
+ } else if (!this.validate.day(interval.days)) {
+ top.log.error('pbx.time_intervals.add: invalid day.');
+ return false;
+ } else if (!this.validate.month(interval.months)) {
+ top.log.error('pbx.time_intervals.add: invalid month.');
+ return false;
+ }
+
+ /* create the time interval string */
+ var value = interval.time.toString() + top.session.delimiter
+ + interval.weekdays.toString() + top.session.delimiter
+ + interval.days.toString() + top.session.delimiter
+ + interval.months.toString();
+
+ /* update extensions.conf */
+ var ext_conf = new listOfActions('extensions.conf');
+
+ var resp = ext_cont.new_action('update', 'globals', name, value);
+ if (!resp.contains('Response: Success')) {
+ top.log.error('pbx.time_intervals.add: error updating extensions.conf');
+ return false;
+ }
+
+ /* TODO: add new time interval to gui cache */
+
+ return true;
+};
/**
* Validater object.
More information about the asterisk-gui-commits
mailing list