Phrases: Database class integration.
This commit is contained in:
@@ -68,11 +68,10 @@ if ($domains_processed == 1) {
|
||||
if ($_SESSION['recordings']['storage_type']['text'] == 'base64') {
|
||||
$sql = "select phrase_detail_uuid, phrase_detail_data ";
|
||||
$sql .= "from v_phrase_details where phrase_detail_function = 'play-file' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $index => &$row) {
|
||||
$phrase_detail_uuid = $row['phrase_detail_uuid'];
|
||||
$phrase_detail_data = $row['phrase_detail_data'];
|
||||
if (substr_count($phrase_detail_data, $_SESSION['switch']['recordings']['dir'].'/'.$domain_name) > 0) {
|
||||
@@ -80,15 +79,24 @@ if ($domains_processed == 1) {
|
||||
}
|
||||
//update function and data to be base64 compatible
|
||||
$phrase_detail_data = "lua(streamfile.lua ".$phrase_detail_data.")";
|
||||
$sql = "update v_phrase_details set ";
|
||||
$sql .= "phrase_detail_function = 'execute', ";
|
||||
$sql .= "phrase_detail_data = '".$phrase_detail_data."' ";
|
||||
$sql .= "where phrase_detail_uuid = '".$phrase_detail_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['phrase_details'][$index]['phrase_detail_uuid'] = $phrase_detail_uuid;
|
||||
$array['phrase_details'][$index]['phrase_detail_function'] = 'execute';
|
||||
$array['phrase_details'][$index]['phrase_detail_data'] = $phrase_detail_data;
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
$p = new permissions;
|
||||
$p->add('phrase_detail_edit', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'phrases';
|
||||
$database->app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('phrase_detail_edit', 'temp');
|
||||
}
|
||||
}
|
||||
unset($sql, $prep_statement, $result, $row);
|
||||
unset($sql, $result, $row);
|
||||
}
|
||||
|
||||
//if not base64, revert base64 phrases to standard method
|
||||
@@ -97,11 +105,10 @@ if ($domains_processed == 1) {
|
||||
$sql .= "from v_phrase_details where ";
|
||||
$sql .= "phrase_detail_function = 'execute' ";
|
||||
$sql .= "and phrase_detail_data like 'lua(streamfile.lua %)' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $index => &$row) {
|
||||
$phrase_detail_uuid = $row['phrase_detail_uuid'];
|
||||
$phrase_detail_data = $row['phrase_detail_data'];
|
||||
//update function and data to use standard method
|
||||
@@ -110,15 +117,24 @@ if ($domains_processed == 1) {
|
||||
if (substr_count($phrase_detail_data, '/') === 0) {
|
||||
$phrase_detail_data = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/'.$phrase_detail_data;
|
||||
}
|
||||
$sql = "update v_phrase_details set ";
|
||||
$sql .= "phrase_detail_function = 'play-file', ";
|
||||
$sql .= "phrase_detail_data = '".$phrase_detail_data."' ";
|
||||
$sql .= "where phrase_detail_uuid = '".$phrase_detail_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['phrase_details'][$index]['phrase_detail_uuid'] = $phrase_detail_uuid;
|
||||
$array['phrase_details'][$index]['phrase_detail_function'] = 'play-file';
|
||||
$array['phrase_details'][$index]['phrase_detail_data'] = $phrase_detail_data;
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
$p = new permissions;
|
||||
$p->add('phrase_detail_edit', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'phrases';
|
||||
$database->app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('phrase_detail_edit', 'temp');
|
||||
}
|
||||
}
|
||||
unset($sql, $prep_statement, $result, $row);
|
||||
unset($sql, $result, $row);
|
||||
}
|
||||
|
||||
//save the xml to the file system if the phrase directory is set
|
||||
@@ -130,16 +146,17 @@ if ($domains_processed == 1) {
|
||||
if ($fp) {
|
||||
//get phrase languages
|
||||
$sql = "select distinct phrase_language from v_phrases order by phrase_language asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
//delete memcache var
|
||||
foreach ($result as $row) {
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("languages:".$row['phrase_language']);
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("languages:".$row['phrase_language']);
|
||||
}
|
||||
}
|
||||
unset($sql, $prep_statement, $result, $row);
|
||||
unset($sql, $result, $row);
|
||||
}
|
||||
unset($fp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user