getRow($sql, DB_FETCHMODE_ASSOC); if(DB::IsError($check)) { // add new field $sql = 'ALTER TABLE ivr ADD COLUMN dircontext VARCHAR ( 50 ) DEFAULT "default"'; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } } if (version_compare($ivr_modcurrentvers, "2.2", "<")) { //echo "

Start 2.2 upgrade

"; $sql = "ALTER TABLE ivr CHANGE COLUMN announcement announcement VARCHAR ( 255 )"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } else { // Change existing records //echo "

Updating existing records

"; $existing = sql("SELECT DISTINCT announcement FROM ivr WHERE displayname <> '__install_done' AND announcement IS NOT NULL", "getAll"); foreach ($existing as $item) { $recid = $item[0]; //echo "

processing '$recid'

"; $sql = "SELECT filename FROM recordings WHERE id = '$recid' AND displayname <> '__invalid'"; $recordings = sql($sql, "getRow"); if (is_array($recordings)) { $filename = (isset($recordings[0]) ? $recordings[0] : ''); //echo "

filename: $filename"; if ($filename != '') { $sql = "UPDATE ivr SET announcement = '".str_replace("'", "''", $filename)."' WHERE announcement = '$recid'"; $upcheck = $db->query($sql); if(DB::IsError($upcheck)) die_freepbx($upcheck->getDebugInfo()); } } } } } // Version 2.5.7 adds auto-return to IVR $sql = "SELECT ivr_ret FROM ivr_dests"; $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); if(DB::IsError($check)) { // add new field $sql = "ALTER TABLE ivr_dests ADD ivr_ret TINYINT(1) NOT NULL DEFAULT 0;"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } } $results = array(); $sql = "SELECT ivr_id, selection, dest FROM ivr_dests"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (!DB::IsError($results)) { // error - table must not be there foreach ($results as $result) { $old_dest = $result['dest']; $ivr_id = $result['ivr_id']; $selection = $result['selection']; $new_dest = merge_ext_followme(trim($old_dest)); if ($new_dest != $old_dest) { $sql = "UPDATE ivr_dests SET dest = '$new_dest' WHERE ivr_id = $ivr_id AND selection = '$selection' AND dest = '$old_dest'"; $results = $db->query($sql); if(DB::IsError($results)) { die_freepbx($results->getMessage()); } } } } // Version 2.5.17 adds improved i and t destination handling $sql = "SELECT alt_timeout FROM ivr"; $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); if(DB::IsError($check)) { // add new field $sql = "ALTER TABLE ivr ADD alt_timeout VARCHAR(8);"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } } $sql = "SELECT alt_invalid FROM ivr"; $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); if(DB::IsError($check)) { // add new field $sql = "ALTER TABLE ivr ADD alt_invalid VARCHAR(8);"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } } $sql = "SELECT `loops` FROM ivr"; $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); if(DB::IsError($check)) { // add new field $sql = "ALTER TABLE ivr ADD `loops` TINYINT(1) NOT NULL DEFAULT 2;"; $result = $db->query($sql); if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } } ?>