fusionpbx/resources/classes/sounds.php

99 lines
3.3 KiB
PHP
Raw Permalink Normal View History

2018-02-10 02:28:35 +01:00
<?php
/**
* sounds class
*
* @method string get
*/
class sounds {
/**
* Called when the object is created
*/
2018-02-10 16:46:15 +01:00
public $domain_uuid;
public $sound_types;
public $full_path;
2018-02-10 02:28:35 +01:00
/**
* Class constructor
*/
public function __construct() {
2018-02-10 02:28:35 +01:00
}
/**
* Add a specific item in the cache
* @var array $array
* @var string $value string to be cached
*/
public function get() {
//miscellaneous
if (empty($this->sound_types) || (is_array($this->sound_types) && in_array('miscellaneous', $this->sound_types))) {
$x = 0;
if (if_group("superadmin")) {
$array['miscellaneous'][$x]['name'] = "say";
$array['miscellaneous'][$x]['value'] = "say:";
$x++;
$array['miscellaneous'][$x]['name'] = "tone_stream";
$array['miscellaneous'][$x]['value'] = "tone_stream:";
}
2018-02-10 16:46:15 +01:00
}
2018-02-10 02:28:35 +01:00
//recordings
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('recordings', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"]."/app/recordings/app_config.php")) {
2018-02-10 02:28:35 +01:00
$sql = "select recording_name, recording_filename from v_recordings ";
$sql .= "where domain_uuid = :domain_uuid ";
2018-02-10 02:28:35 +01:00
$sql .= "order by recording_name asc ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
$database = new database;
$recordings = $database->select($sql, $parameters, 'all');
if (is_array($recordings) && @sizeof($recordings) != 0) {
foreach ($recordings as $x => $row) {
2018-02-10 02:28:35 +01:00
$recording_name = $row["recording_name"];
$recording_filename = $row["recording_filename"];
$recording_path = !empty($this->full_path) && is_array($this->full_path) && in_array('recordings', $this->full_path) ? $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/' : null;
2018-02-10 02:28:35 +01:00
$array['recordings'][$x]['name'] = $recording_name;
$array['recordings'][$x]['value'] = $recording_path.$recording_filename;
2018-02-10 02:28:35 +01:00
}
}
unset($sql, $parameters, $recordings, $row);
2018-02-10 02:28:35 +01:00
}
//phrases
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('phrases', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"]."/app/phrases/app_config.php")) {
$sql = "select * from v_phrases ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
$database = new database;
$phrases = $database->select($sql, $parameters, 'all');
if (is_array($phrases) && @sizeof($phrases) != 0) {
foreach ($phrases as $row) {
2018-02-10 16:46:15 +01:00
$array['phrases'][$x]['name'] = "phrase:".$row["phrase_name"];
2018-02-10 02:28:35 +01:00
$array['phrases'][$x]['value'] = "phrase:".$row["phrase_uuid"];
$x++;
}
}
unset($sql, $parameters, $phrases, $row);
2018-02-10 02:28:35 +01:00
}
//sounds
if ((empty($this->sound_types) || (is_array($this->sound_types) && in_array('sounds', $this->sound_types))) && file_exists($_SERVER["PROJECT_ROOT"]."/app/phrases/app_config.php")) {
2018-02-10 02:28:35 +01:00
$file = new file;
$sound_files = $file->sounds();
if (is_array($sound_files) && @sizeof($sound_files) != 0) {
2018-02-10 02:28:35 +01:00
foreach ($sound_files as $value) {
if (substr($value, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") {
$value = substr($var, 71);
}
$array['sounds'][$x]['name'] = $value;
$array['sounds'][$x]['value'] = $value;
$x++;
}
}
}
//send the results
return $array;
}
}
?>