Changeset 5982
- Timestamp:
- 07/10/08 19:16:26 (4 years ago)
- Files:
-
- modules/branches/2.5/recordings/functions.inc.php (modified) (6 diffs)
- modules/branches/2.5/recordings/install.php (modified) (2 diffs)
- modules/branches/2.5/recordings/module.xml (modified) (2 diffs)
- modules/branches/2.5/recordings/page.recordings.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/recordings/functions.inc.php
r5891 r5982 42 42 } 43 43 } 44 45 // Now generate the Feature Codes to edit recordings 46 // 47 $recordings = recordings_list(); 48 foreach ($recordings as $item) { 49 50 // Get the feature code, and do a sanity check if it is not suppose to be active and delete it 51 // 52 if ($item['fcode'] != 0) { 53 $fcc = new featurecode($modulename, 'edit-recording-'.$item['id']); 54 $fcode = $fcc->getCodeActive(); 55 unset($fcc); 56 } else { 57 $fcc = new featurecode('recordings', 'edit-recording-'.$item['id']); 58 $fcc->delete(); 59 unset($fcc); 60 continue; // loop back to foreach 61 } 62 63 if ($fcode != '') { 64 // Do a sanity check, there should be no compound files 65 // 66 if (strpos($item['filename'], '&') === false && trim($item['filename']) != '') { 67 $fcode_pass = (trim($item['fcode_pass']) != '') ? ','.$item['fcode_pass'] : ''; 68 $ext->add($appcontext, $fcode, '', new ext_macro('user-callerid')); 69 $ext->add($appcontext, $fcode, '', new ext_wait('2')); 70 $ext->add($appcontext, $fcode, '', new ext_macro('systemrecording', 'docheck,'.$item['filename'].$fcode_pass)); 71 //$ext->add($appcontext, $fcode, '', new ext_macro('hangup')); 72 } 73 } 74 } 44 75 break; 45 76 } 46 } 77 } 47 78 48 79 function recordings_get_id($fn) { … … 70 101 // somee checking in here for it. 71 102 72 $sql = "SELECT * FROM recordings where displayname <> '__invalid' ORDER BY displayname"; 73 $results = $db->getAll($sql); 74 if(DB::IsError($results)) { 75 $results = null; 76 } 77 return $results; 103 $sql = "SELECT * FROM recordings where displayname <> '__invalid' ORDER BY displayname"; 104 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 105 if(DB::IsError($results)) { 106 return array(); 107 } 108 // Make array backward compatible, put first 4 columns as numeric 109 $count = 0; 110 foreach($results as $item) { 111 $results[$count][0] = $item['id']; 112 $results[$count][1] = $item['displayname']; 113 $results[$count][2] = $item['filename']; 114 $results[$count][3] = $item['description']; 115 $count++; 116 } 117 return $results; 78 118 } 79 119 … … 110 150 } 111 151 112 function recordings_update($id, $rname, $descr, $_REQUEST ) {152 function recordings_update($id, $rname, $descr, $_REQUEST, $fcode=0, $fcode_pass='') { 113 153 114 154 // Update the descriptive fields 115 $results = sql("UPDATE recordings SET displayname = \"$rname\", description = \"$descr\" WHERE id = \"$id\""); 155 $fcode_pass = preg_replace("/[^0-9*]/" ,"", trim($fcode_pass)); 156 $results = sql("UPDATE recordings SET displayname = '".addslashes($rname)."', description = '".addslashes($descr)."', fcode='$fcode', fcode_pass='".$fcode_pass."' WHERE id = '$id'"); 116 157 117 158 // Build the file list from _REQUEST … … 121 162 122 163 // Set the file names from the submitted page, sysrec[N] 123 foreach ($_REQUEST as $key => $val) { 124 $res = strpos($key, 'sysrec'); 125 if ($res !== false) { 126 // strip out any relative paths, since this is coming from a URL 127 str_replace('..','',$val); 128 129 $recordings[substr($key,6)]=$val; 130 } 131 } 132 133 // Stick the filename in the database 134 recordings_set_file($id, implode('&', $recordings)); 164 // We don't set if feature code was selected, we use what was already there 165 // because the fields will have been disabled and won't be accessible in the 166 // $_REQUEST array anyhow 167 // 168 if ($fcode != 1) { 169 // delete the feature code if it existed 170 // 171 $fcc = new featurecode('recordings', 'edit-recording-'.$id); 172 $fcc->delete(); 173 unset($fcc); 174 foreach ($_REQUEST as $key => $val) { 175 $res = strpos($key, 'sysrec'); 176 if ($res !== false) { 177 // strip out any relative paths, since this is coming from a URL 178 str_replace('..','',$val); 179 180 $recordings[substr($key,6)]=$val; 181 } 182 } 183 184 // Stick the filename in the database 185 recordings_set_file($id, implode('&', $recordings)); 186 } else { 187 // Add the feature code if it is needed 188 // 189 $fcc = new featurecode('recordings', 'edit-recording-'.$id); 190 $fcc->setDescription("Edit Recording: $rname"); 191 $fcc->setDefault('*29'.$id); 192 $fcc->update(); 193 unset($fcc); 194 } 135 195 136 196 // In _REQUEST there are also various actions (possibly) … … 193 253 function recordings_del($id) { 194 254 $results = sql("DELETE FROM recordings WHERE id = \"$id\""); 255 256 // delete the feature code if it existed 257 $fcc = new featurecode('recordings', 'edit-recording-'.$id); 258 $fcc->delete(); 259 unset($fcc); 195 260 } 196 261 … … 198 263 // Strip off any dangling &'s on the end: 199 264 $filename = rtrim($filename, '&'); 200 $results = sql("UPDATE recordings SET filename = \"$filename\" WHERE id = \"$id\"");265 $results = sql("UPDATE recordings SET filename = '".addslashes($filename)."' WHERE id = '$id'"); 201 266 } 202 267 modules/branches/2.5/recordings/install.php
r5891 r5982 4 4 global $asterisk_conf; 5 5 global $db; 6 7 if (! function_exists("out")) { 8 function out($text) { 9 echo $text."<br />"; 10 } 11 } 12 13 if (! function_exists("outn")) { 14 function outn($text) { 15 echo $text; 16 } 17 } 18 6 19 $recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; 7 20 $recordings_astsnd_path .= "/sounds/"; … … 78 91 } 79 92 } 93 94 // Version 2.5 upgrade 95 outn(_("checking for fcode field..")); 96 $sql = "SELECT `fcode` FROM recordings"; 97 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 98 if(DB::IsError($check)) { 99 // add new field 100 $sql = "ALTER TABLE recordings ADD `fcode` TINYINT( 1 ) DEFAULT 0 ;"; 101 $result = $db->query($sql); 102 if(DB::IsError($result)) { 103 die_freepbx($result->getDebugInfo()); 104 } 105 out(_("OK")); 106 } else { 107 out(_("already exists")); 108 } 109 outn(_("checking for fcode_pass field..")); 110 $sql = "SELECT `fcode_pass` FROM recordings"; 111 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 112 if(DB::IsError($check)) { 113 // add new field 114 $sql = "ALTER TABLE recordings ADD `fcode_pass` VARCHAR( 20 ) NULL ;"; 115 $result = $db->query($sql); 116 if(DB::IsError($result)) { 117 die_freepbx($result->getDebugInfo()); 118 } 119 out(_("OK")); 120 } else { 121 out(_("already exists")); 122 } 80 123 ?> modules/branches/2.5/recordings/module.xml
r5810 r5982 2 2 <rawname>recordings</rawname> 3 3 <name>Recordings</name> 4 <version>3.3. 6.2</version>4 <version>3.3.7</version> 5 5 <candisable>no</candisable> 6 6 <canuninstall>no</canuninstall> … … 9 9 <description>Creates and manages system recordings, used by many other modules (eg, IVR).</description> 10 10 <changelog> 11 *3.3.7.0* Version 2.5 11 12 *3.3.6.2* #2604, #2843 fix mal-formed html tags, Russian Translation 12 13 *3.3.6.1* #2591, enhance code so bad directory copy errors are reported modules/branches/2.5/recordings/page.recordings.php
r5972 r5982 22 22 $sysrec = isset($_REQUEST['sysrec'])?$_REQUEST['sysrec']:''; 23 23 $suffix = isset($_REQUEST['suffix']) && trim($_REQUEST['suffix'] != "") ? $_REQUEST['suffix'] : 'wav'; 24 25 $fcode = isset($_REQUEST['fcode']) && $_REQUEST['fcode'] != '' ? 1 : 0; 26 $fcode_pass = isset($_REQUEST['fcode_pass'])?$_REQUEST['fcode_pass']:''; 27 28 $fcbase = '*29'; 29 $default_pos = 0; 24 30 25 31 $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; … … 128 134 129 135 case "edited": 130 recordings_update($id, $rname, $notes, $_REQUEST );136 recordings_update($id, $rname, $notes, $_REQUEST, $fcode, $fcode_pass); 131 137 recording_sidebar($id, $usersnum); 132 138 recording_editpage($id, $usersnum); … … 224 230 } 225 231 226 function recording_editpage($id, $num) { ?> 227 232 function recording_editpage($id, $num) { 233 global $fcbase; 234 global $default_pos; 235 global $fcode; 236 global $fcode_pass; 237 ?> 228 238 <div class="content"> 229 239 <h2><?php echo _("System Recordings")?></h2> … … 240 250 $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/sound_delete.png"/> '.$tlabel.'</span>'; 241 251 echo "<a href=".$delURL.">".$label."</a>"; 242 echo "<i style='font-size: x-small'> (";252 echo "<i style='font-size: x-small'> ("; 243 253 echo _("Note, does not delete file from computer"); 244 254 echo ")</i>"; … … 259 269 <td> <textarea name="notes" rows="3" cols="40" tabindex="<?php echo ++$tabindex;?>"><?php echo $this_recording['description'] ?></textarea></td> 260 270 </tr> 261 </table> 262 <hr /> 263 <?php echo _("Files");?>:<br /> 264 <table> 265 <?php 266 $rec = recordings_get($id); 271 272 <?php 273 // This was being called twice: $rec = recordings_get($id); 274 $rec = $this_recording; 267 275 $fn = $rec['filename']; 268 276 $files = explode('&', $fn); 269 277 $counter = 0; 270 278 $arraymax = count($files)-1; 279 $sndfile_html = ""; 280 foreach ($files as $item) { 281 $sndfile_html .= recordings_display_sndfile($item, $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']); 282 $counter++; 283 } 284 $sndfile_html .= recordings_display_sndfile('', $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']); 285 if ($arraymax == 0 && isset($files[0]) && substr($files[0],0,7) == 'custom/') { 286 ?> 287 <tr> 288 <td><a class="info" href="#"><?php echo _("Link to Feature Code")?><span><?php echo _("Check this box to create an options feature code that will allow this recording to be changed directly.")?></span></a>: 289 </td> 290 <td> 291 <input type='checkbox' tabindex="<?php echo ++$tabindex;?>"name='fcode' id="fcode" <?php if ($rec['fcode']=="1") { echo 'CHECKED'; }?> OnClick="resetDefaultSound();"; return true;'><?php echo sprintf(_("Optional Feature Code %s"),$fcbase.$id)?> 292 </td> 293 </tr> 294 <tr> 295 <td><a href="#" class="info"><?php echo _("Feature Code Password");?><span><?php echo _("Optional password to protect access to this feature code which allows a user to re-record it.");?></span></a></td> 296 <td><input type="text" name="fcode_pass" id="fcode_pass" value="<?php echo $rec['fcode_pass'] ?>" tabindex="<?php echo ++$tabindex;?>"></td> 297 </tr> 298 <?php 299 } else { 300 ?> 301 <tr> 302 <td colspan="2"><a class="info" href="#"><?php echo _("Direct Access Feature Code Not Available")?><span><?php echo _("Direct Access Feature Codes for recordings are not available for built in system recordings or compound recordings made of multipe individual ones.")?></span></a>: 303 </td> 304 </tr> 305 <?php 306 } 307 ?> 308 309 <tr><td colspan="2"><hr /></td></tr> 310 </table> 311 <?php echo _("Files");?>:<br /> 312 <table> 313 <?php 271 314 // globals seem to busted in PHP5 define here for now 272 315 $recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; 273 316 $recordings_astsnd_path .= "/sounds/"; 274 317 275 foreach ($files as $item) { 276 recordings_display_sndfile($item, $counter, $arraymax, $recordings_astsnd_path); 277 $counter++; 278 } 279 recordings_display_sndfile('', $counter, $arraymax, $recordings_astsnd_path); 318 // recordings_display_sndfile functions need to be run above so we have $default_pos set 319 // 320 echo $sndfile_html; 280 321 ?> 281 322 </table> … … 283 324 <?php recordings_popup_jscript(); ?> 284 325 <?php recordings_form_jscript(); ?> 326 <script language="javascript"> 327 <!-- Begin 328 var sysrec0_idx; 329 function initPage() { 330 sysrec0_idx = document.getElementById("sysrec0").selectedIndex; 331 alert('Got here with sysrec0_idx as:'.sysrec0_idx); 332 } 333 function resetDefaultSound() { 334 if (document.getElementById('fcode').checked) { 335 document.getElementById('sysrec0').selectedIndex=<?php echo $default_pos ?>; 336 document.getElementById('sysrec1').selectedIndex=0; 337 338 document.getElementById('sysrec0').disabled=true; 339 document.getElementById('sysrec1').disabled=true; 340 document.getElementById('play0').style.visibility='hidden'; 341 document.getElementById('play1').style.visibility='hidden'; 342 document.getElementById('down0').style.visibility='hidden'; 343 document.getElementById('up1').style.visibility='hidden'; 344 document.getElementById('del0').style.visibility='hidden'; 345 document.getElementById('del1').style.visibility='hidden'; 346 } else { 347 document.getElementById('sysrec0').disabled=false; 348 document.getElementById('sysrec1').disabled=false; 349 document.getElementById('play0').style.visibility='visible'; 350 document.getElementById('play1').style.visibility='visible'; 351 document.getElementById('down0').style.visibility='visible'; 352 document.getElementById('up1').style.visibility='visible'; 353 document.getElementById('del0').style.visibility='visible'; 354 document.getElementById('del1').style.visibility='visible'; 355 } 356 } 357 // End --> 358 </script> 285 359 </form> 286 360 </div> … … 386 460 } 387 461 388 function recordings_display_sndfile($item, $count, $max, $astpath) { 462 function recordings_display_sndfile($item, $count, $max, $astpath, $fcode) { 463 global $default_pos; 389 464 global $amp_conf; 465 466 $disabled_state = $fcode == 0 ? "" : "disabled='true' "; 467 $hidden_state = $fcode == 0 ? "" : "style='visibility:hidden' "; 468 469 $html_text = ""; 390 470 // Note that when using this, it needs a <table> definition around it. 391 471 $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; 392 472 $astsnd .= "/sounds/"; 393 473 $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); 394 print "<tr><td><select id='sysrec$count' name='sysrec$count'>\n"; 395 echo '<option value=""'.($item == '' ? ' SELECTED' : '')."></option>\n"; 474 $html_txt .= "<tr><td><select $disabled_state id='sysrec$count' name='sysrec$count'>\n"; 475 $html_txt .= '<option value=""'.($item == '' ? ' SELECTED' : '')."></option>\n"; 476 $index=0; 396 477 foreach ($sysrecs as $sr) { 397 echo '<option value="'.$sr.'"'.($sr == $item ? ' SELECTED' : '').">$sr</option>\n"; 398 } 399 print "</select></td>\n"; 400 401 echo "<td>"; 478 $html_txt .= '<option value="'.$sr.'"'.($sr == $item ? ' SELECTED' : '').">$sr</option>\n"; 479 if ($sr == $item) { 480 $default_pos = $index+1; 481 } 482 $index++; 483 } 484 $html_txt .= "</select></td>\n"; 485 486 $html_txt .= "<td>"; 402 487 $audio=$astpath; 403 488 … … 405 490 $recurl="modules/recordings/popup.php?cryptpass=$REC_CRYPT_PASSWORD&recording=$audio"; 406 491 407 echo "<a href='#' type='submit' onClick=\"javascript:popUp('$recurl',document.prompt.sysrec$count); return false;\" input='foo'>";408 echo"<img border='0' width='20' height='20' src='images/play.png' title='Click here to play this recording' />";409 echo"</img></td>";492 $html_txt .= "<a href='#' $hidden_state type='submit' id='play$count' onClick=\"javascript:popUp('$recurl',document.prompt.sysrec$count); return false;\" input='foo'>"; 493 $html_txt .= "<img border='0' width='20' height='20' src='images/play.png' title='Click here to play this recording' />"; 494 $html_txt .= "</img></td>"; 410 495 411 496 if ($count==0) { 412 print"<td></td>\n";497 $html_txt .= "<td></td>\n"; 413 498 } else { 414 echo"<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />";415 echo '<td><input name="up'.$count.'" width=10 height=20 border=5 title="Move Up" type="image" src="images/scrollup.gif" value="'._("Move Up").'"/>';416 print"</td>\n";499 $html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 500 $html_txt .= "<td><input $hidden_state name='up$count' id='up$count' width=10 height=20 border=5 title='Move Up' type='image' src='images/scrollup.gif' value='"._("Move Up")."'>"; 501 $html_txt .= "</td>\n"; 417 502 } if ($count > $max) { 418 print"<td></td>\n";503 $html_txt .= "<td></td>\n"; 419 504 } else { 420 echo "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 421 echo '<td><input name="down'.$count.'" width=10 height=20 border=0 title="Move Down" type="image" src="images/scrolldown.gif" value="'._("Move Down")."\">\n"; 422 echo "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 423 print "</td>\n"; 424 } 425 echo '<td><input name="del'.$count.'" type="image" border=0 title="Delete" src="images/trash.png" value="'._("Delete")."\">\n"; 426 echo "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 427 echo "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 428 print "</td>\n"; 429 430 print "</tr>\n"; 431 } 432 433 ?> 505 $html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 506 $html_txt .= "<td><input $hidden_state name='down$count' id='down$count' width=10 height=20 border=0 title='Move Down' type='image' src='images/scrolldown.gif' value='"._("Move Down")."'>\n"; 507 $html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 508 $html_txt .= "</td>\n"; 509 } 510 $html_txt .= "<td><input $hidden_state name='del$count' id='del$count' type='image' border=0 title='Delete' src='images/trash.png' value='"._("Delete")."'>\n"; 511 $html_txt .= "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 512 $html_txt .= "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; 513 $html_txt .= "</td>\n"; 514 515 $html_txt .= "</tr>\n"; 516 return $html_txt; 517 } 518 519 ?>
