Changeset 10571
- Timestamp:
- 11/18/10 17:37:56 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.9/timeconditions/functions.inc.php
r10568 r10571 59 59 $context = 'timeconditions'; 60 60 $fc_context = 'timeconditions-toggles'; 61 $got_code = false;61 $got_code_autoreset = false; 62 62 $need_maint = false; 63 63 $interval = isset($amp_conf['TCINTERVAL']) && ctype_digit($amp_conf['TCINTERVAL']) ? $amp_conf['TCINTERVAL'] : '60'; … … 80 80 } 81 81 } 82 $ext->add($context, $time_id, 'falsestate', new ext_gotoif('$["${DB(TC/'.$time_id.') }" = "true"]','truegoto'));83 $ext->add($context, $time_id, '', new ext_ set("DB(TC/$time_id)",''));82 $ext->add($context, $time_id, 'falsestate', new ext_gotoif('$["${DB(TC/'.$time_id.'):4}" = "true"]','truegoto')); 83 $ext->add($context, $time_id, '', new ext_execif('$["${DB(TC/'.$time_id.')}" = "false"]','Set',"DB(TC/$time_id)=")); 84 84 $skip_dest = 'falsegoto'; 85 85 if ($amp_conf['USEDEVSTATE'] && $generate_hint) { 86 86 $ext->add($context, $time_id, $skip_dest, new ext_set("$DEVSTATE(Custom:TC$time_id)",'INUSE')); 87 $ext->add($context, $time_id, '', new ext_execif('$["${DB(TC/'.$time_id.')}" = "false_sticky" & "${'.$DEVSTATE.'(Custom:TCSTICKY${ARG1})}" != "INUSE"]','Set',$DEVSTATE.'(Custom:TCSTICKY${ARG1})=INUSE')); 87 88 $skip_dest = ''; 88 89 } … … 91 92 $ext->add($context, $time_id, '', new ext_return('')); 92 93 93 $ext->add($context, $time_id, 'truestate', new ext_gotoif('$["${DB(TC/'.$time_id.') }" = "false"]','falsegoto'));94 $ext->add($context, $time_id, '', new ext_ set("DB(TC/$time_id)",''));94 $ext->add($context, $time_id, 'truestate', new ext_gotoif('$["${DB(TC/'.$time_id.'):5}" = "false"]','falsegoto')); 95 $ext->add($context, $time_id, '', new ext_execif('$["${DB(TC/'.$time_id.')}" = "true"]','Set',"DB(TC/$time_id)=")); 95 96 $skip_dest = 'truegoto'; 96 97 if ($amp_conf['USEDEVSTATE'] && $generate_hint) { 97 98 $ext->add($context, $time_id, $skip_dest, new ext_set("$DEVSTATE(Custom:TC$time_id)",'NOT_INUSE')); 99 $ext->add($context, $time_id, '', new ext_execif('$["${DB(TC/'.$time_id.')}" = "true_sticky" & "${'.$DEVSTATE.'(Custom:TCSTICKY${ARG1})}" != "INUSE"]','Set',$DEVSTATE.'(Custom:TCSTICKY${ARG1})=INUSE')); 98 100 $skip_dest = ''; 99 101 } … … 106 108 unset($fcc); 107 109 if ($c != '') { 108 $got_code = true;110 $got_code_autoreset = true; 109 111 if ($amp_conf['USEDEVSTATE'] && $generate_hint) { 110 112 $ext->addHint($fc_context, $c, 'Custom:TC'.$time_id); … … 140 142 } 141 143 142 if ($got_code ) {144 if ($got_code_autoreset) { 143 145 $ext->add($fc_context, 'h', '', new ext_hangup()); 144 146 … … 152 154 $ext->add($m_context, 's', '', new ext_system($amp_conf['ASTVARLIBDIR']."/bin/schedtc.php $interval ".$amp_conf['ASTSPOOLDIR'].'/outgoing 0')); 153 155 } 154 $ext->add($m_context, 's', 'settc', new ext_set('DB(TC/${ARG1})', '${IF($["${TCSTATE }" = "true"]?false:true)}'));156 $ext->add($m_context, 's', 'settc', new ext_set('DB(TC/${ARG1})', '${IF($["${TCSTATE:4}" = "true"]?false:true)}')); 155 157 if ($amp_conf['USEDEVSTATE']) { 156 158 $ext->add($m_context, 's', '', new ext_set($DEVSTATE.'(Custom:TC${ARG1})', '${IF($["${TCSTATE}" = "true"]?INUSE:NOT_INUSE)}')); 159 $ext->add($m_context, 's', '', new ext_execif('$["${'.$DEVSTATE.'(Custom:TCSTICKY${ARG1})}" = "INUSE"]', 'Set',$DEVSTATE.'(Custom:TCSTICKY${ARG1})=NOT_INUSE')); 157 160 } 158 161 if ($amp_conf['FCBEEPONLY']) { … … 249 252 250 253 function timeconditions_get($id){ 254 global $astman; 251 255 //get all the variables for the timecondition 252 256 $results = sql("SELECT * FROM timeconditions WHERE timeconditions_id = '$id'","getRow",DB_FETCHMODE_ASSOC); 257 258 $fcc = new featurecode('timeconditions', 'toggle-mode-'.$id); 259 $c = $fcc->getCodeActive(); 260 unset($fcc); 261 if ($c == '') { 262 $results['tcstate'] = false; 263 $results['tccode'] = false; 264 } else { 265 $results['tccode'] = $c; 266 if ($astman != null) { 267 $results['tcstate'] = $astman->database_get("TC",$id); 268 } else { 269 die_freepbx("No manager connection, can't get Time Condition State"); 270 } 271 } 253 272 return $results; 254 273 } … … 389 408 function timeconditions_edit($id,$post){ 390 409 global $db; 410 global $astman; 411 global $amp_conf; 391 412 392 413 $id = $db->escapeSimple($id); … … 402 423 } 403 424 $results = sql("UPDATE timeconditions SET displayname = \"$displayname\", time = \"$time\", truegoto = \"$truegoto\", falsegoto = \"$falsegoto\", deptname = \"$deptname\", generate_hint = \"$generate_hint\" WHERE timeconditions_id = \"$id\""); 425 426 if (isset($post['tcstate_new']) && $post['tcstate_new'] != 'unchanged') { 427 $tcstate_new = $post['tcstate_new']; 428 429 if ($amp_conf['USEDEVSTATE']) { 430 $engine_info = engine_getinfo(); 431 $version = $engine_info['version']; 432 $DEVSTATE = version_compare($version, "1.6", "ge") ? "DEVICE_STATE" : "DEVSTATE"; 433 } else { 434 $DEVSTATE = false; 435 } 436 if ($astman != null) { 437 switch ($tcstate_new) { 438 case 'auto': 439 $tcstate_new = ""; 440 $blf = 'NOT_INUSE'; 441 $sticky = 'NOT_INUSE'; 442 break; 443 case 'true': 444 $blf = 'NOT_INUSE'; 445 $sticky = 'NOT_INUSE'; 446 break; 447 case 'true_sticky': 448 $blf = 'NOT_INUSE'; 449 $sticky = 'INUSE'; 450 break; 451 case 'false': 452 $blf = 'INUSE'; 453 $sticky = 'NOT_INUSE'; 454 break; 455 case 'false_sticky': 456 $blf = 'INUSE'; 457 $sticky = 'INUSE'; 458 break; 459 default: 460 $tcstate_new = false; 461 break; 462 } 463 if ($tcstate_new !== false) { 464 $astman->database_put("TC",$id,$tcstate_new); 465 if ($DEVSTATE) { 466 $astman->send_request('Command',array('Command'=>"core set global ".$DEVSTATE."(Custom:TC".$id.") $blf")); 467 $astman->send_request('Command',array('Command'=>"core set global ".$DEVSTATE."(Custom:TCSTICKY".$id.") $sticky")); 468 } 469 } 470 } else { 471 die_freepbx("No manager connection, can't update Time Condition State"); 472 } 473 } 404 474 } 405 475 modules/branches/2.9/timeconditions/page.timeconditions.php
r10570 r10571 11 11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 //GNU General Public License for more details. 13 14 13 15 14 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; … … 83 82 } 84 83 $generate_hint = $thisItem['generate_hint'] == '1' ? '1' : '0'; 85 } 84 $tccode = $thisItem['tccode'] === false ? '' : $thisItem['tccode']; 85 } else { 86 $tccode = ''; 87 } 86 88 ?> 87 89 <form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();"> … … 102 104 <?php if ($amp_conf['USEDEVSTATE']) { ?> 103 105 <tr> 104 <td><a href="#" class="info"><?php echo _("Generate BLF Hint")?><span><?php echo _("If set an Asterisk hint will be created for the override feature code associated with this Time Condition that can be used to light BLF buttons on a phone programmed to enable/disable this Time Condition. If not using a BLF it is better to leave this un-checked as additional system resources are required to keep the hint updated. The Feature Code can be found and enabled/disabled on the Feature Codes tab under Time Conditions.")?></span></a></td>106 <td><a href="#" class="info"><?php echo _("Generate BLF Hint")?><span><?php echo sprintf(_("If set an Asterisk hint will be created for the override feature code %s associated with this Time Condition that can be used to light BLF buttons on a phone programmed to enable/disable this Time Condition. If not using a BLF it is better to leave this un-checked as additional system resources are required to keep the hint updated. This Feature Code can be found and enabled/disabled on the Feature Codes tab under Time Conditions."),$tccode)?></span></a></td> 105 107 <td> 106 108 <input name="generate_hint" type="checkbox" value="1" <?php echo ($generate_hint == '1' ? 'checked' : ''); ?> tabindex="<?php echo ++$tabindex;?>"/> 109 </td> 110 </tr> 111 <?php } ?> 112 113 <?php 114 if ($itemid && $thisItem['tcstate'] !== false) { 115 $tcstate = $thisItem['tcstate'] == '' ? 'auto' : $thisItem['tcstate']; 116 switch ($tcstate) { 117 case 'auto': 118 $state_msg = _('No Override'); 119 break; 120 case 'true': 121 $state_msg = _('Temporary Override matching state'); 122 break; 123 case 'true_sticky': 124 $state_msg = _('Permanent Override matching state'); 125 break; 126 case 'false': 127 $state_msg = _('Temporary Override unmatching state'); 128 break; 129 case 'false_sticky': 130 $state_msg = _('Permanent Override unmatching state'); 131 break; 132 default: 133 $state_msg = _('Unknown State'); 134 break; 135 } 136 ?> 137 <tr> 138 <td><a href="#" class="info"><?php echo _("Current Override:")?><span><?php echo _("Indicates the current state of this Time Condition. If it is in a Temporary Override state, it will automatically resume at the next time transition based on the associated Time Group. If in a Permanent Override state, it will stay in that state until changed here or through other means such as external XML applications on your phone. If No Override then it functions normally based on the time schedule.")?></span></a></td> 139 <td><?php echo $state_msg; ?></td> 140 </tr> 141 <tr> 142 <td><a href="#" class="info"><?php echo _("Change Override:")?><span><?php echo sprintf(_("This Time Condition can be set to Temporarily go to the 'matched' or 'unmatched' destination in which case the override will automatcally reset once the current time span has elapsed. If set to Permanent it will stay overriden until manually reset. All overrides can be removed wih the Reset Override option. Temporary Overrides can also be toggled with the %s feature code, which will also remove a Permanent Override if set but can not set a Permanent Override which must be done here or with other applicaions such as an XML based phone options."),$tccode)?></span></a></td> 143 <td> 144 <select name="tcstate_new" tabindex="<?php echo ++$tabindex;?>"> 145 <option value="unchanged" SELECTED><?php echo _("Unchanged");?></option> 146 <option value="auto" ><?php echo _("Reset Override");?></option> 147 <option value="true" ><?php echo _("Temporary matched");?></option> 148 <option value="true_sticky" ><?php echo _("Permanently matched");?></option> 149 <option value="false" ><?php echo _("Temporary unmatched");?></option> 150 <option value="false_sticky" ><?php echo _("Permanently unmatched");?></option> 151 </select> 107 152 </td> 108 153 </tr>
