Changeset 6158
- Timestamp:
- 07/23/08 19:12:17 (4 months ago)
- Files:
-
- modules/branches/2.5/findmefollow/functions.inc.php (modified) (6 diffs)
- modules/branches/2.5/findmefollow/install.php (modified) (4 diffs)
- modules/branches/2.5/findmefollow/install.sql (deleted)
- modules/branches/2.5/findmefollow/module.xml (modified) (2 diffs)
- modules/branches/2.5/findmefollow/page.findmefollow.php (modified) (8 diffs)
- modules/branches/2.5/findmefollow/uninstall.php (modified) (1 diff)
- modules/branches/2.5/findmefollow/uninstall.sql (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/findmefollow/functions.inc.php
r6026 r6158 46 46 $postdest = $grp['postdest']; 47 47 $grppre = (isset($grp['grppre'])?$grp['grppre']:''); 48 $annmsg = $grp['annmsg'];48 $annmsg_id = $grp['annmsg_id']; 49 49 $dring = $grp['dring']; 50 50 51 51 $needsconf = $grp['needsconf']; 52 $remotealert = $grp['remotealert'];53 $toolate = $grp['toolate'];52 $remotealert_id = $grp['remotealert_id']; 53 $toolate_id = $grp['toolate_id']; 54 54 $ringing = $grp['ringing']; 55 55 $pre_ring = $grp['pre_ring']; … … 129 129 $ext->add($contextname, $grpnum, '', new ext_setvar('RingGroupMethod',$strategy)); 130 130 $ext->add($contextname, $grpnum, '', new ext_setvar('_FMGRP',$grpnum)); 131 if ((isset($annmsg) ? $annmsg : '') != '') { 131 if ((isset($annmsg_id) ? $annmsg_id : '')) { 132 $annmsg = recordings_get_file($annmsg_id); 132 133 // should always answer before playing anything, shouldn't we ? 133 134 $ext->add($contextname, $grpnum, '', new ext_gotoif('$[$["${DIALSTATUS}" = "ANSWER"] | $["foo${RRNODEST}" != "foo"]]','DIALGRP')); … … 139 140 // Create the confirm target 140 141 $len=strlen($grpnum)+4; 142 $remotealert = recordings_get_file($remotealert_id); 143 $toolate = recordings_get_file($toolate_id); 141 144 $ext->add("fmgrps", "_RG-${grpnum}-.", '', new ext_macro('dial','${DB(AMPUSER/'."$grpnum/followme/grptime)},". 142 145 "M(confirm^${remotealert}^${toolate}^${grpnum})$dialopts".',${EXTEN:'.$len.'}')); … … 184 187 } 185 188 186 function findmefollow_add($grpnum,$strategy,$grptime,$grplist,$postdest,$grppre='',$annmsg ='',$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial) {189 function findmefollow_add($grpnum,$strategy,$grptime,$grplist,$postdest,$grppre='',$annmsg_id='',$dring,$needsconf,$remotealert_id,$toolate_id,$ringing,$pre_ring,$ddial) { 187 190 global $amp_conf; 188 191 global $astman; 189 192 190 $sql = "INSERT INTO findmefollow (grpnum, strategy, grptime, grppre, grplist, annmsg , postdest, dring, needsconf, remotealert, toolate, ringing, pre_ring) VALUES ('".str_replace("'", "''",$grpnum)."', '".str_replace("'", "''", $strategy)."', ".str_replace("'", "''", $grptime).", '".str_replace("'", "''", $grppre)."', '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $annmsg)."', '".str_replace("'", "''", $postdest)."', '".str_replace("'", "''", $dring)."', '$needsconf', '$remotealert', '$toolate', '$ringing', '$pre_ring')";193 $sql = "INSERT INTO findmefollow (grpnum, strategy, grptime, grppre, grplist, annmsg_id, postdest, dring, needsconf, remotealert_id, toolate_id, ringing, pre_ring) VALUES ('".str_replace("'", "''",$grpnum)."', '".str_replace("'", "''", $strategy)."', ".str_replace("'", "''", $grptime).", '".str_replace("'", "''", $grppre)."', '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $annmsg_id)."', '".str_replace("'", "''", $postdest)."', '".str_replace("'", "''", $dring)."', '$needsconf', '$remotealert_id', '$toolate_id', '$ringing', '$pre_ring')"; 191 194 $results = sql($sql); 192 195 … … 293 296 global $astman; 294 297 295 $results = sql("SELECT grpnum, strategy, grptime, grppre, grplist, annmsg , postdest, dring, needsconf, remotealert, toolate, ringing, pre_ring FROM findmefollow WHERE grpnum = '".str_replace("'", "''", $grpnum)."'","getRow",DB_FETCHMODE_ASSOC);298 $results = sql("SELECT grpnum, strategy, grptime, grppre, grplist, annmsg_id, postdest, dring, needsconf, remotealert_id, toolate_id, ringing, pre_ring FROM findmefollow WHERE grpnum = '".str_replace("'", "''", $grpnum)."'","getRow",DB_FETCHMODE_ASSOC); 296 299 297 300 if ($check_astdb) { … … 417 420 } 418 421 422 function findmefollow_recordings_usage($recording_id) { 423 global $active_modules; 424 425 $results = sql("SELECT `grpnum` FROM `findmefollow` WHERE `annmsg_id` = '$recording_id' OR `remotealert_id` = '$recording_id' OR `toolate_id` = '$recording_id'","getAll",DB_FETCHMODE_ASSOC); 426 if (empty($results)) { 427 return array(); 428 } else { 429 //$type = isset($active_modules['ivr']['type'])?$active_modules['ivr']['type']:'setup'; 430 foreach ($results as $result) { 431 $usage_arr[] = array( 432 'url_query' => 'config.php?display=findmefollow&extdisplay=GRP-'.urlencode($result['grpnum']), 433 'description' => "Follow-Me User: ".$result['grpnum'], 434 ); 435 } 436 return $usage_arr; 437 } 438 } 439 419 440 function findmefollow_fmf_toggle($c) { 420 441 global $ext; modules/branches/2.5/findmefollow/install.php
r5864 r6158 2 2 3 3 global $db; 4 global $amp_conf; 5 global $astman; 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 19 $sql = " 20 CREATE TABLE IF NOT EXISTS `findmefollow` 21 ( 22 `grpnum` VARCHAR( 20 ) NOT NULL , 23 `strategy` VARCHAR( 50 ) NOT NULL , 24 `grptime` SMALLINT NOT NULL , 25 `grppre` VARCHAR( 100 ) NULL , 26 `grplist` VARCHAR( 255 ) NOT NULL , 27 `annmsg_id` INTEGER, 28 `postdest` VARCHAR( 255 ) NULL , 29 `dring` VARCHAR ( 255 ) NULL , 30 `remotealert_id` INTEGER, 31 `needsconf` VARCHAR ( 10 ), 32 `toolate_id` INTEGER, 33 `pre_ring` SMALLINT NOT NULL DEFAULT 0, 34 PRIMARY KEY (`grpnum`) 35 ) 36 "; 37 $check = $db->query($sql); 38 if(DB::IsError($check)) { 39 die_freepbx("Can not create annoucment table"); 40 } 4 41 5 42 //TODO: Also need to create all the states if enabled … … 20 57 if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 21 58 } 22 // Version 2.0 upgrade. Yeah. 2.0 baby! 23 $sql = "SELECT remotealert FROM findmefollow"; 59 // If there is no needsconf then this is a really old upgrade. We create the 2 old fields 60 // here and then the migration code below will change them as needed but will work properly 61 // since it now has the fields it is expecting 62 // 63 $sql = "SELECT needsconf FROM findmefollow"; 24 64 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 25 65 if(DB::IsError($check)) { … … 75 115 // is this global...? what if we include this files 76 116 // from a function...? 77 global $astman;78 global $amp_conf;79 117 80 118 $sql = "SELECT * FROM findmefollow"; … … 107 145 } 108 146 147 // Version 2.5 migrate to recording ids 148 // 149 outn(_("Checking if recordings need migration..")); 150 $sql = "SELECT annmsg_id FROM findmefollow"; 151 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 152 if(DB::IsError($check)) { 153 // Add recording_id field 154 // 155 out("migrating"); 156 outn(_("adding annmsg_id field..")); 157 $sql = "ALTER TABLE findmefollow ADD annmsg_id INTEGER"; 158 $result = $db->query($sql); 159 if(DB::IsError($result)) { 160 out(_("fatal error")); 161 die_freepbx($result->getDebugInfo()); 162 } else { 163 out(_("ok")); 164 } 165 outn(_("adding remotealert_id field..")); 166 $sql = "ALTER TABLE findmefollow ADD remotealert_id INTEGER"; 167 $result = $db->query($sql); 168 if(DB::IsError($result)) { 169 out(_("fatal error")); 170 die_freepbx($result->getDebugInfo()); 171 } else { 172 out(_("ok")); 173 } 174 outn(_("adding toolate_id field..")); 175 $sql = "ALTER TABLE findmefollow ADD toolate_id INTEGER"; 176 $result = $db->query($sql); 177 if(DB::IsError($result)) { 178 out(_("fatal error")); 179 die_freepbx($result->getDebugInfo()); 180 } else { 181 out(_("ok")); 182 } 183 184 // Get all the valudes and replace them with recording_id 185 // 186 outn(_("migrate annmsg to ids..")); 187 $sql = "SELECT `grpnum`, `annmsg` FROM `findmefollow`"; 188 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 189 if(DB::IsError($results)) { 190 out(_("fatal error")); 191 die_freepbx($results->getDebugInfo()); 192 } 193 $migrate_arr = array(); 194 $count = 0; 195 foreach ($results as $row) { 196 if (trim($row['annmsg']) != '') { 197 $rec_id = recordings_get_or_create_id($row['annmsg'], 'findmefollow'); 198 $migrate_arr[] = array($rec_id, $row['grpnum']); 199 $count++; 200 } 201 } 202 if ($count) { 203 $compiled = $db->prepare('UPDATE `findmefollow` SET `annmsg_id` = ? WHERE `grpnum` = ?'); 204 $result = $db->executeMultiple($compiled,$migrate_arr); 205 if(DB::IsError($result)) { 206 out(_("fatal error")); 207 die_freepbx($result->getDebugInfo()); 208 } 209 } 210 out(sprintf(_("migrated %s entries"),$count)); 211 212 outn(_("migrate remotealert to ids..")); 213 $sql = "SELECT `grpnum`, `remotealert` FROM `findmefollow`"; 214 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 215 if(DB::IsError($results)) { 216 out(_("fatal error")); 217 die_freepbx($results->getDebugInfo()); 218 } 219 $migrate_arr = array(); 220 $count = 0; 221 foreach ($results as $row) { 222 if (trim($row['remotealert']) != '') { 223 $rec_id = recordings_get_or_create_id($row['remotealert'], 'findmefollow'); 224 $migrate_arr[] = array($rec_id, $row['grpnum']); 225 $count++; 226 } 227 } 228 if ($count) { 229 $compiled = $db->prepare('UPDATE `findmefollow` SET `remotealert_id` = ? WHERE `grpnum` = ?'); 230 $result = $db->executeMultiple($compiled,$migrate_arr); 231 if(DB::IsError($result)) { 232 out(_("fatal error")); 233 die_freepbx($result->getDebugInfo()); 234 } 235 } 236 out(sprintf(_("migrated %s entries"),$count)); 237 238 outn(_("migrate toolate to ids..")); 239 $sql = "SELECT `grpnum`, `toolate` FROM `findmefollow`"; 240 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 241 if(DB::IsError($results)) { 242 out(_("fatal error")); 243 die_freepbx($results->getDebugInfo()); 244 } 245 $migrate_arr = array(); 246 $count = 0; 247 foreach ($results as $row) { 248 if (trim($row['toolate']) != '') { 249 $rec_id = recordings_get_or_create_id($row['toolate'], 'findmefollow'); 250 $migrate_arr[] = array($rec_id, $row['grpnum']); 251 $count++; 252 } 253 } 254 if ($count) { 255 $compiled = $db->prepare('UPDATE `findmefollow` SET `toolate_id` = ? WHERE `grpnum` = ?'); 256 $result = $db->executeMultiple($compiled,$migrate_arr); 257 if(DB::IsError($result)) { 258 out(_("fatal error")); 259 die_freepbx($result->getDebugInfo()); 260 } 261 } 262 out(sprintf(_("migrated %s entries"),$count)); 263 264 // Now remove the old recording field replaced by new id field 265 // 266 outn(_("dropping annmsg field..")); 267 $sql = "ALTER TABLE `findmefollow` DROP `annmsg`"; 268 $result = $db->query($sql); 269 if(DB::IsError($result)) { 270 out(_("no annmsg field???")); 271 } else { 272 out(_("ok")); 273 } 274 outn(_("dropping remotealert field..")); 275 $sql = "ALTER TABLE `findmefollow` DROP `remotealert`"; 276 $result = $db->query($sql); 277 if(DB::IsError($result)) { 278 out(_("no remotealert field???")); 279 } else { 280 out(_("ok")); 281 } 282 outn(_("dropping toolate field..")); 283 $sql = "ALTER TABLE `findmefollow` DROP `toolate`"; 284 $result = $db->query($sql); 285 if(DB::IsError($result)) { 286 out(_("no toolate field???")); 287 } else { 288 out(_("ok")); 289 } 290 291 } else { 292 out("already migrated"); 293 } 294 109 295 ?> modules/branches/2.5/findmefollow/module.xml
r6083 r6158 2 2 <rawname>findmefollow</rawname> 3 3 <name>Follow Me</name> 4 <version>2.5. 0.1</version>4 <version>2.5.1</version> 5 5 <changelog> 6 *2.5.1* #2065 Migrate recordings to recording ids 6 7 *2.5.0.1* #2391, #2908, #2845, #1791, added delete and add icons 7 8 *2.5.0* Add enable/disable featurecode with blf support, new confirmation sound file announces cid availability … … 42 43 <depends> 43 44 <version>2.5.0alpha1</version> 45 <module>recordings ge 3.3.8</module> 44 46 </depends> 45 47 <type>setup</type> modules/branches/2.5/findmefollow/page.findmefollow.php
r5972 r6158 23 23 isset($_REQUEST['grppre'])?$grppre = $_REQUEST['grppre']:$grppre=''; 24 24 isset($_REQUEST['strategy'])?$strategy = $_REQUEST['strategy']:$strategy=''; 25 isset($_REQUEST['annmsg '])?$annmsg = $_REQUEST['annmsg']:$annmsg='';25 isset($_REQUEST['annmsg_id'])?$annmsg_id = $_REQUEST['annmsg_id']:$annmsg_id=''; 26 26 isset($_REQUEST['dring'])?$dring = $_REQUEST['dring']:$dring=''; 27 27 isset($_REQUEST['needsconf'])?$needsconf = $_REQUEST['needsconf']:$needsconf=''; 28 isset($_REQUEST['remotealert '])?$remotealert = $_REQUEST['remotealert']:$remotealert='';29 isset($_REQUEST['toolate '])?$toolate = $_REQUEST['toolate']:$toolate='';28 isset($_REQUEST['remotealert_id'])?$remotealert_id = $_REQUEST['remotealert_id']:$remotealert_id=''; 29 isset($_REQUEST['toolate_id'])?$toolate_id = $_REQUEST['toolate_id']:$toolate_id=''; 30 30 isset($_REQUEST['ringing'])?$ringing = $_REQUEST['ringing']:$ringing=''; 31 31 isset($_REQUEST['pre_ring'])?$pre_ring = $_REQUEST['pre_ring']:$pre_ring='0'; … … 73 73 //add group 74 74 if ($action == 'addGRP') { 75 findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg ,$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial);75 findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg_id,$dring,$needsconf,$remotealert_id,$toolate_id,$ringing,$pre_ring,$ddial); 76 76 77 77 needreload(); … … 89 89 if ($action == 'edtGRP') { 90 90 findmefollow_del($account); 91 findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg ,$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial);91 findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg_id,$dring,$needsconf,$remotealert_id,$toolate_id,$ringing,$pre_ring,$ddial); 92 92 93 93 needreload(); … … 134 134 $grptime = isset($thisgrp['grptime']) ? $thisgrp['grptime'] : ''; 135 135 $goto = isset($thisgrp['postdest']) ? $thisgrp['postdest'] : ''; 136 $annmsg = isset($thisgrp['annmsg']) ? $thisgrp['annmsg'] : '';136 $annmsg_id = isset($thisgrp['annmsg_id']) ? $thisgrp['annmsg_id'] : ''; 137 137 $dring = isset($thisgrp['dring']) ? $thisgrp['dring'] : ''; 138 $remotealert = isset($thisgrp['remotealert']) ? $thisgrp['remotealert'] : '';138 $remotealert_id = isset($thisgrp['remotealert_id']) ? $thisgrp['remotealert_id'] : ''; 139 139 $needsconf = isset($thisgrp['needsconf']) ? $thisgrp['needsconf'] : ''; 140 $toolate = isset($thisgrp['toolate']) ? $thisgrp['toolate'] : '';140 $toolate_id = isset($thisgrp['toolate_id']) ? $thisgrp['toolate_id'] : ''; 141 141 $ringing = isset($thisgrp['ringing']) ? $thisgrp['ringing'] : ''; 142 142 $pre_ring = isset($thisgrp['pre_ring']) ? $thisgrp['pre_ring'] : ''; … … 288 288 <td><a href="#" class="info"><?php echo _("Announcement:")?><span><?php echo _("Message to be played to the caller before dialing this group.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> 289 289 <td> 290 <select name="annmsg " tabindex="<?php echo ++$tabindex;?>">290 <select name="annmsg_id" tabindex="<?php echo ++$tabindex;?>"> 291 291 <?php 292 292 $tresults = recordings_list(); 293 $default = (isset($annmsg ) ? $annmsg: '');293 $default = (isset($annmsg_id) ? $annmsg_id : ''); 294 294 echo '<option value="">'._("None"); 295 295 if (isset($tresults)) { 296 296 foreach ($tresults as $tresult) { 297 echo '<option value="'.$tresult[ 2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1];297 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 298 298 } 299 299 } … … 307 307 <td> 308 308 <?php 309 $default = (isset($annmsg ) ? $annmsg: '');309 $default = (isset($annmsg_id) ? $annmsg_id : ''); 310 310 ?> 311 <input type="hidden" name="annmsg " value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?>311 <input type="hidden" name="annmsg_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> 312 312 </td> 313 313 </tr> … … 354 354 <td><a href="#" class="info"><?php echo _("Remote Announce:")?><span><?php echo _("Message to be played to the person RECEIVING the call, if 'Confirm Calls' is enabled.<br><br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td> 355 355 <td> 356 <select name="remotealert " tabindex="<?php echo ++$tabindex;?>">356 <select name="remotealert_id" tabindex="<?php echo ++$tabindex;?>"> 357 357 <?php 358 358 $tresults = recordings_list(); 359 $default = (isset($remotealert ) ? $remotealert: '');359 $default = (isset($remotealert_id) ? $remotealert_id : ''); 360 360 echo '<option value="">'._("Default")."</option>"; 361 361 if (isset($tresults[0])) { 362 362 foreach ($tresults as $tresult) { 363 echo '<option value="'.$tresult[ 2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";363 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 364 364 } 365 365 } … … 371 371 <td><a href="#" class="info"><?php echo _("Too-Late Announce:")?><span><?php echo _("Message to be played to the person RECEIVING the call, if the call has already been accepted before they push 1.<br><br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td> 372 372 <td> 373 <select name="toolate " tabindex="<?php echo ++$tabindex;?>">373 <select name="toolate_id" tabindex="<?php echo ++$tabindex;?>"> 374 374 <?php 375 375 $tresults = recordings_list(); 376 $default = (isset($toolate ) ? $toolate: '');376 $default = (isset($toolate_id) ? $toolate_id : ''); 377 377 echo '<option value="">'._("Default")."</option>"; 378 378 if (isset($tresults[0])) { 379 379 foreach ($tresults as $tresult) { 380 echo '<option value="'.$tresult[ 2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";380 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 381 381 } 382 382 } modules/branches/2.5/findmefollow/uninstall.php
r5864 r6158 32 32 } 33 33 34 sql('DROP TABLE IF EXISTS findmefollow'); 35 34 36 ?>
