Changeset 8173

Show
Ignore:
Timestamp:
08/25/09 23:11:15 (4 years ago)
Author:
p_lindheimer
Message:

closes #3585 add ability to choose the on/off recordings played when day/night is toggled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.6/daynight/functions.inc.php

    r7623 r8173  
    192192  $passwords = daynight_passwords(); 
    193193  $got_code = false; 
     194 
     195  $day_recording = daynight_recording('day'); 
     196  $night_recording = daynight_recording('night'); 
    194197   
    195198  $id = "app-daynight-toggle"; // The context to be included 
     
    212215    } 
    213216    $ext->add($id, $c, '', new ext_setvar('INDEX', $index));   
     217    $day_file = "beep&silence/1&day&reception&digits/${index}&activated"; 
     218    $night_file = "beep&silence/1&day&reception&digits/${index}&de-activated"; 
     219    if (function_exists('recordings_get_file')) { 
     220      if ($day_recording[$index] != 0 ) { $day_file = recordings_get_file ($day_recording[$index]); } 
     221      if ($night_recording[$index] != 0 ) { $night_file = recordings_get_file ($night_recording[$index]); } 
     222      } 
     223    $ext->add($id, $c, '', new ext_setvar('DAYREC', $day_file));   
     224    $ext->add($id, $c, '', new ext_setvar('NIGHTREC', $night_file));   
    214225    $ext->add($id, $c, '', new ext_goto($id.',s,1')); 
    215226  } 
     
    229240      $ext->add($id, $c, 'hook_day', new ext_playback('beep')); // $cmd,n,Playback(...) 
    230241    } else { 
    231      $ext->add($id, $c, 'hook_day', new ext_playback('beep&silence/1&day&reception&digits/${INDEX}&enabled')); 
     242      $ext->add($id, $c, 'hook_day', new ext_playback('${DAYREC}')); 
    232243    } 
    233244    $ext->add($id, $c, '', new ext_hangup('')); 
     
    240251      $ext->add($id, $c, 'hook_night', new ext_playback('beep')); // $cmd,n,Playback(...) 
    241252    } else { 
    242      $ext->add($id, $c, 'hook_night', new ext_playback('beep&silence/1&beep&silence/1&day&reception&digits/${INDEX}&disabled')); 
     253       $ext->add($id, $c, 'hook_night', new ext_playback('${NIGHTREC}')); 
    243254    } 
    244255    $ext->add($id, $c, '', new ext_hangup('')); 
     
    293304} 
    294305 
     306//get the existing daynight recordings 
     307//$mode is either 'day' or 'night' 
     308function daynight_recording($mode) { 
     309  $results = sql("SELECT ext, dest FROM daynight WHERE dmode = '".$mode."_recording_id'","getAll",DB_FETCHMODE_ASSOC); 
     310  if(is_array($results)){ 
     311    foreach($results as $result){ 
     312      $list[$result['ext']] = $result['dest']; 
     313    } 
     314  } 
     315  if (isset($list)) { 
     316    return $list; 
     317  } else {  
     318    return array(); 
     319  } 
     320} 
     321 
    295322function daynight_edit($post, $id=0) { 
    296323  global $db; 
     
    300327 
    301328  // Delete all the old dests 
    302   sql("DELETE FROM daynight WHERE dmode IN ('day', 'night', 'password', 'fc_description') AND ext = '$id'"); 
     329  sql("DELETE FROM daynight WHERE dmode IN ('day', 'night', 'password', 'fc_description','day_recording_id','night_recording_id') AND ext = '$id'"); 
    303330 
    304331  $day   = isset($post[$post['goto0'].'0'])?$post[$post['goto0'].'0']:''; 
     
    314341  $fc_description = isset($post['fc_description']) ? trim($post['fc_description']) : ""; 
    315342  sql("INSERT INTO daynight (ext, dmode, dest) VALUES ('$id', 'fc_description', '".$db->escapeSimple($fc_description)."')"); 
     343 
     344  $day_recording_id = isset($post['day_recording_id']) ? trim($post['day_recording_id']) : ""; 
     345  sql("INSERT INTO daynight (ext, dmode, dest) VALUES ('$id', 'day_recording_id', '$day_recording_id')"); 
     346  $night_recording_id = isset($post['night_recording_id']) ? trim($post['night_recording_id']) : ""; 
     347  sql("INSERT INTO daynight (ext, dmode, dest) VALUES ('$id', 'night_recording_id', '$night_recording_id')"); 
    316348 
    317349  $dn = new dayNightObject($id); 
     
    350382  global $db; 
    351383 
    352   $sql = "SELECT dmode, dest FROM daynight WHERE dmode IN ('day', 'night', 'password', 'fc_description') AND ext = '$id' ORDER BY dmode"; 
     384  $sql = "SELECT dmode, dest FROM daynight WHERE dmode IN ('day', 'night', 'password', 'fc_description','day_recording_id','night_recording_id') AND ext = '$id' ORDER BY dmode"; 
    353385  $res = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    354386  if(DB::IsError($res)) { 
  • modules/branches/2.6/daynight/module.xml

    r7928 r8173  
    22  <rawname>daynight</rawname> 
    33  <name>Day Night Mode</name> 
    4   <version>2.6.0.1</version> 
     4  <version>2.6.0.2</version> 
    55  <publisher>FreePBX</publisher> 
    66  <license>GPLv2+</license> 
     
    1212  </description> 
    1313  <changelog> 
     14    *2.6.0.2* #3585 custom recordings 
    1415    *2.6.0.1* init tabindex 
    1516    *2.6.0.0* #3650, #3651 
  • modules/branches/2.6/daynight/page.daynight.php

    r7792 r8173  
    1919$password = isset($_REQUEST['password'])?$_REQUEST['password']:''; 
    2020$fc_description = isset($_REQUEST['fc_description'])?$_REQUEST['fc_description']:''; 
     21$day_recording_id = isset($_POST['day_recording_id']) ? $_POST['day_recording_id'] :  ''; 
     22$night_recording_id = isset($_POST['night_recording_id']) ? $_POST['night_recording_id'] :  ''; 
    2123 
    2224isset($_REQUEST['itemid'])?$itemid=mysql_real_escape_string($_REQUEST['itemid']):$itemid=''; 
     
    7880  $fc_description = isset($dests['fc_description'])?$dests['fc_description']:''; 
    7981  $state = isset($dests['state'])?$dests['state']:'DAY'; 
     82  $day_recording_id = isset($dests['day_recording_id'])?$dests['day_recording_id']:''; 
     83  $night_recording_id = isset($dests['night_recording_id'])?$dests['night_recording_id']:''; 
    8084?> 
    8185  <div class="content"> 
     
    173177    </td> 
    174178  </tr> 
     179 
     180<?php if(function_exists('recordings_list')) { //only include if recordings are enabled ?> 
     181  <tr> 
     182    <td><a href="#" class="info"><?php echo _("Recording for Day Mode")?><span><?php echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td> 
     183    <td> 
     184      <select name="day_recording_id"  tabindex="<?php echo ++$tabindex;?>"> 
     185      <?php 
     186        $tresults = recordings_list(); 
     187        $default = (isset($day_recording_id) ? $day_recording_id : ''); 
     188        echo '<option value="0">' ._("Default") ."</option>\n"; 
     189        if (isset($tresults[0])) { 
     190          foreach ($tresults as $tresult) { 
     191            echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 
     192          } 
     193        } 
     194      ?> 
     195      </select> 
     196    </td> 
     197  </tr> 
     198  <tr> 
     199    <td><a href="#" class="info"><?php echo _("Recording for Night Mode")?><span><?php echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td> 
     200    <td> 
     201      <select name="night_recording_id"  tabindex="<?php echo ++$tabindex;?>"> 
     202      <?php 
     203        $default = (isset($night_recording_id) ? $night_recording_id : ''); 
     204        echo '<option value="0">' ._("Default") ."</option>\n"; 
     205        if (isset($tresults[0])) { 
     206          foreach ($tresults as $tresult) { 
     207            echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 
     208          } 
     209        } 
     210      ?> 
     211      </select> 
     212    </td> 
     213  </tr> 
     214 
     215<?php } ?> 
     216 
    175217  <tr> 
    176218    <td><a href="#" class="info"><?php echo _("Optional Password")?>:<span><?php echo _('You can optionally include a password to authenticate before toggling the day/night mode. If left blank anyone can use the feature code and it will be un-protected')?></span></a></td>