Changeset 6151
- Timestamp:
- 07/23/08 17:07:41 (4 months ago)
- Files:
-
- modules/branches/2.5/ivr/functions.inc.php (modified) (6 diffs)
- modules/branches/2.5/ivr/install.php (modified) (2 diffs)
- modules/branches/2.5/ivr/module.xml (modified) (3 diffs)
- modules/branches/2.5/ivr/page.ivr.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/ivr/functions.inc.php
r5824 r6151 129 129 return array(); 130 130 } else { 131 //$type = isset($active_modules[' announcement']['type'])?$active_modules['announcement']['type']:'setup';131 //$type = isset($active_modules['ivr']['type'])?$active_modules['ivr']['type']:'setup'; 132 132 return array('description' => 'IVR : '.$thisexten['displayname'], 133 133 'edit_url' => 'config.php?display=ivr&action=edit&id='.urlencode($exten), … … 136 136 } else { 137 137 return false; 138 } 139 } 140 141 function ivr_recordings_usage($recording_id) { 142 global $active_modules; 143 144 $results = sql("SELECT `ivr_id`, `displayname` FROM `ivr` WHERE `announcement_id` = '$recording_id'","getAll",DB_FETCHMODE_ASSOC); 145 if (empty($results)) { 146 return array(); 147 } else { 148 //$type = isset($active_modules['ivr']['type'])?$active_modules['ivr']['type']:'setup'; 149 foreach ($results as $result) { 150 $usage_arr[] = array( 151 'url_query' => 'config.php?display=ivr&action=edit&id='.urlencode($result['ivr_id']), 152 'description' => "IVR: ".$result['displayname'], 153 ); 154 } 155 return $usage_arr; 138 156 } 139 157 } … … 151 169 $details = ivr_get_details($item['ivr_id']); 152 170 153 $announcement = (isset($details['announcement']) ? $details['announcement'] : '');171 $announcement_id = (isset($details['announcement_id']) ? $details['announcement_id'] : ''); 154 172 $loops = (isset($details['loops']) ? $details['loops'] : '2'); 155 173 … … 183 201 $ext->add($id, 's', 'begin', new ext_digittimeout(3)); 184 202 $ext->add($id, 's', '', new ext_responsetimeout($details['timeout'])); 185 if ($announcement != '') { 186 $ext->add($id, 's', '', new ext_background($announcement)); 203 if ($announcement_id != '') { 204 $announcement_msg = recordings_get_file($announcement_id); 205 $ext->add($id, 's', '', new ext_background($announcement_msg)); 187 206 } 188 207 $ext->add($id, 's', '', new ext_waitexten()); … … 296 315 $ena_directory = isset($post['ena_directory'])?$post['ena_directory']:''; 297 316 $ena_directdial = isset($post['ena_directdial'])?$post['ena_directdial']:''; 298 $annmsg = isset($post['annmsg'])?$post['annmsg']:'';317 $annmsg_id = isset($post['annmsg_id'])?$post['annmsg_id']:''; 299 318 $dircontext = isset($post['dircontext'])?$post['dircontext']:''; 300 319 … … 316 335 } 317 336 318 sql("UPDATE ivr SET displayname='$displayname', enable_directory='$ena_directory', enable_directdial='$ena_directdial', timeout='$timeout', announcement ='$annmsg', dircontext='$dircontext', alt_timeout='$alt_timeout', alt_invalid='$alt_invalid', `loops`='$loops' WHERE ivr_id='$id'");337 sql("UPDATE ivr SET displayname='$displayname', enable_directory='$ena_directory', enable_directdial='$ena_directdial', timeout='$timeout', announcement_id='$annmsg_id', dircontext='$dircontext', alt_timeout='$alt_timeout', alt_invalid='$alt_invalid', `loops`='$loops' WHERE ivr_id='$id'"); 319 338 320 339 // Delete all the old dests modules/branches/2.5/ivr/install.php
r5824 r6151 1 1 <?php 2 sql('CREATE TABLE IF NOT EXISTS ivr ( ivr_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, displayname VARCHAR(50), deptname VARCHAR(50), enable_directory VARCHAR(8), enable_directdial VARCHAR(8), timeout INT, announcement VARCHAR(255), dircontext VARCHAR ( 50 ) DEFAULT "default", alt_timeout VARCHAR(8), alt_invalid VARCHAR(8), `loops` TINYINT(1) NOT NULL DEFAULT 2 )'); 3 sql('CREATE TABLE IF NOT EXISTS ivr_dests ( ivr_id INT NOT NULL, selection VARCHAR(10), dest VARCHAR(50), ivr_ret TINYINT(1) NOT NULL DEFAULT 0)'); 2 3 if (! function_exists("out")) { 4 function out($text) { 5 echo $text."<br />"; 6 } 7 } 8 9 if (! function_exists("outn")) { 10 function outn($text) { 11 echo $text; 12 } 13 } 4 14 5 15 global $db; 16 global $amp_conf; 17 18 $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT"; 19 $sql = " 20 CREATE TABLE IF NOT EXISTS ivr 21 ( 22 `ivr_id` INT NOT NULL $autoincrement PRIMARY KEY, 23 `displayname` VARCHAR(50), 24 `deptname` VARCHAR(50), 25 `enable_directory` VARCHAR(8), 26 `enable_directdial` VARCHAR(8), 27 `timeout` INT, 28 `announcement` VARCHAR(255), 29 `dircontext` VARCHAR ( 50 ) DEFAULT 'default', 30 `alt_timeout` VARCHAR(8), 31 `alt_invalid` VARCHAR(8), 32 `loops` TINYINT(1) NOT NULL DEFAULT 2 33 ) 34 "; 35 sql($sql); 36 37 $sql = " 38 CREATE TABLE IF NOT EXISTS ivr_dests 39 ( 40 `ivr_id` INT NOT NULL, 41 `selection` VARCHAR(10), 42 `dest` VARCHAR(50), 43 `ivr_ret` TINYINT(1) NOT NULL DEFAULT 0 44 ) 45 "; 46 sql($sql); 6 47 7 48 // Now, we need to check for upgrades. … … 110 151 if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 111 152 } 153 154 155 156 // Version 2.5 migrate to recording ids 157 // 158 outn(_("Checking if announcements need migration..")); 159 $sql = "SELECT announcement_id FROM ivr"; 160 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 161 if(DB::IsError($check)) { 162 // Add announcement_id field 163 // 164 out("migrating"); 165 outn(_("adding announcement_id field..")); 166 $sql = "ALTER TABLE ivr ADD announcement_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 175 // Get all the valudes and replace them with announcement_id 176 // 177 outn(_("migrate to recording ids..")); 178 $sql = "SELECT `ivr_id`, `announcement` FROM `ivr`"; 179 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 180 if(DB::IsError($results)) { 181 out(_("fatal error")); 182 die_freepbx($results->getDebugInfo()); 183 } 184 $migrate_arr = array(); 185 $count = 0; 186 foreach ($results as $row) { 187 if (trim($row['announcement']) != '') { 188 $rec_id = recordings_get_or_create_id($row['announcement'], 'ivr'); 189 $migrate_arr[] = array($rec_id, $row['ivr_id']); 190 $count++; 191 } 192 } 193 if ($count) { 194 $compiled = $db->prepare('UPDATE `ivr` SET `announcement_id` = ? WHERE `ivr_id` = ?'); 195 $result = $db->executeMultiple($compiled,$migrate_arr); 196 if(DB::IsError($result)) { 197 out(_("fatal error")); 198 die_freepbx($result->getDebugInfo()); 199 } 200 } 201 out(sprintf(_("migrated %s entries"),$count)); 202 203 // Now remove the old recording field replaced by new id field 204 // 205 outn(_("dropping announcement field..")); 206 $sql = "ALTER TABLE `ivr` DROP `announcement`"; 207 $result = $db->query($sql); 208 if(DB::IsError($result)) { 209 out(_("no announcement field???")); 210 } else { 211 out(_("ok")); 212 } 213 214 } else { 215 out("already migrated"); 216 } 217 112 218 ?> modules/branches/2.5/ivr/module.xml
r6085 r6151 2 2 <rawname>ivr</rawname> 3 3 <name>IVR</name> 4 <version>2.5.1 7.1</version>4 <version>2.5.18</version> 5 5 <type>setup</type> 6 6 <category>Inbound Call Control</category> … … 9 9 </description> 10 10 <changelog> 11 *2.5.18* #2066 Migrate recordings to recording ids 11 12 *2.5.17.1* #2845 tabindex 12 13 *2.5.17* #2858 Better handing of i and t options, added loop count and ability to loop before going to user defined i, t options … … 37 38 </changelog> 38 39 <depends> 39 <version>2.4.0</version> 40 <version>2.5.0alpha1</version> 41 <module>recordings ge 3.3.8</module> 40 42 </depends> 41 43 <menuitems> modules/branches/2.5/ivr/page.ivr.php
r5970 r6151 190 190 </tr> 191 191 <?php 192 $annmsg = isset($ivr_details['announcement'])?$ivr_details['announcement']:'';192 $annmsg_id = isset($ivr_details['announcement_id'])?$ivr_details['announcement_id']:''; 193 193 if(function_exists('recordings_list')) { //only include if recordings is enabled ?> 194 194 <tr> 195 195 <td><a href="#" class="info"><?php echo _("Announcement")?><span><?php echo _("Message to be played to the caller. To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> 196 196 <td> 197 <select name="annmsg " tabindex="<?php echo ++$tabindex;?>">197 <select name="annmsg_id" tabindex="<?php echo ++$tabindex;?>"> 198 198 <?php 199 199 $tresults = recordings_list(); … … 201 201 if (isset($tresults[0])) { 202 202 foreach ($tresults as $tresult) { 203 echo '<option value="'.$tresult[ 2].'"'.($tresult[2] == $annmsg ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";203 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $annmsg_id ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 204 204 } 205 205 } … … 216 216 <td> 217 217 <?php 218 $default = (isset($annmsg ) ? $annmsg: '');218 $default = (isset($annmsg_id) ? $annmsg_id : ''); 219 219 ?> 220 <input type="hidden" name="annmsg " value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?>220 <input type="hidden" name="annmsg_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> 221 221 </td> 222 222 </tr>
