out(_("ok")); } // Get all the valudes and replace them with announcement_id // outn(_("migrate to recording ids..")); $sql = "SELECT `ivr_id`, `announcement` FROM `ivr`"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getDebugInfo()); } $migrate_arr = array(); $count = 0; foreach ($results as $row) { if (trim($row['announcement']) != '') { $rec_id = recordings_get_or_create_id($row['announcement'], 'ivr'); $migrate_arr[] = array($rec_id, $row['ivr_id']); $count++; } } if ($count) { $compiled = $db->prepare('UPDATE `ivr` SET `announcement_id` = ? WHERE `ivr_id` = ?'); $result = $db->executeMultiple($compiled, $migrate_arr); if (DB::IsError($result)) { out(_("fatal error")); die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); // Now remove the old recording field replaced by new id field //
die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); outn(_("migrate joinannounce to ids..")); $sql = "SELECT `extension`, `joinannounce` FROM `queues_config`"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getDebugInfo()); } $migrate_arr = array(); $count = 0; foreach ($results as $row) { if (trim($row['joinannounce']) != '') { $rec_id = recordings_get_or_create_id($row['joinannounce'], 'queues'); $migrate_arr[] = array($rec_id, $row['extension']); $count++; } } if ($count) { $compiled = $db->prepare('UPDATE `queues_config` SET `joinannounce_id` = ? WHERE `extension` = ?'); $result = $db->executeMultiple($compiled, $migrate_arr); if (DB::IsError($result)) { out(_("fatal error")); die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); // Now remove the old recording field replaced by new id field //
die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); outn(_("migrate toolate to ids..")); $sql = "SELECT `grpnum`, `toolate` FROM `ringgroups`"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getDebugInfo()); } $migrate_arr = array(); $count = 0; foreach ($results as $row) { if (trim($row['toolate']) != '') { $rec_id = recordings_get_or_create_id($row['toolate'], 'ringgroups'); $migrate_arr[] = array($rec_id, $row['grpnum']); $count++; } } if ($count) { $compiled = $db->prepare('UPDATE `ringgroups` SET `toolate_id` = ? WHERE `grpnum` = ?'); $result = $db->executeMultiple($compiled, $migrate_arr); if (DB::IsError($result)) { out(_("fatal error")); die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); // Now remove the old recording field replaced by new id field //
die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); outn(_("migrate toolate to ids..")); $sql = "SELECT `grpnum`, `toolate` FROM `findmefollow`"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getDebugInfo()); } $migrate_arr = array(); $count = 0; foreach ($results as $row) { if (trim($row['toolate']) != '') { $rec_id = recordings_get_or_create_id($row['toolate'], 'findmefollow'); $migrate_arr[] = array($rec_id, $row['grpnum']); $count++; } } if ($count) { $compiled = $db->prepare('UPDATE `findmefollow` SET `toolate_id` = ? WHERE `grpnum` = ?'); $result = $db->executeMultiple($compiled, $migrate_arr); if (DB::IsError($result)) { out(_("fatal error")); die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); // Now remove the old recording field replaced by new id field //
out(_("ok")); } // Get all the valudes and replace them with joinmsg_id // outn(_("migrate to recording ids..")); $sql = "SELECT `exten`, `joinmsg` FROM `meetme`"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getDebugInfo()); } $migrate_arr = array(); $count = 0; foreach ($results as $row) { if (trim($row['joinmsg']) != '') { $rec_id = recordings_get_or_create_id($row['joinmsg'], 'conference'); $migrate_arr[] = array($rec_id, $row['exten']); $count++; } } if ($count) { $compiled = $db->prepare('UPDATE `meetme` SET `joinmsg_id` = ? WHERE `exten` = ?'); $result = $db->executeMultiple($compiled, $migrate_arr); if (DB::IsError($result)) { out(_("fatal error")); die_freepbx($result->getDebugInfo()); } } out(sprintf(_("migrated %s entries"), $count)); // Now remove the old recording field replaced by new id field //
die_freepbx($results->getMessage()); } } } } // Version 2.5 migrate to recording ids // outn(_("Migrating recordings if needed..")); $sql = "SELECT `data` FROM `parkinglot` WHERE `id` = '1' AND `keyword` = 'parkingannmsg'"; $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($results)) { die_freepbx($results->getMessage()); } if (isset($results[0])) { if (trim($results[0]['data']) != '') { $rec_id = recordings_get_or_create_id($results[0]['data'], 'parking'); } else { $rec_id = ''; } // Delete just in case $sql = "DELETE FROM `parkinglot` WHERE `keyword` = 'parkingannmsg_id'"; $results = $db->query($sql); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getMessage()); } $sql = "INSERT INTO `parkinglot` (`id`, `keyword`, `data`) VALUES ('1', 'parkingannmsg_id', '{$rec_id}')"; $results = $db->query($sql); if (DB::IsError($results)) { out(_("fatal error")); die_freepbx($results->getMessage());