diff --git a/app/voicemail_greetings/app_languages.php b/app/voicemail_greetings/app_languages.php index 4aa6b8cf86..1dd49e7e98 100644 --- a/app/voicemail_greetings/app_languages.php +++ b/app/voicemail_greetings/app_languages.php @@ -21,145 +21,85 @@ $text['title']['ru-ru'] = ""; $text['title']['sv-se'] = "Röstbrevlåda Hälsningar"; $text['title']['uk-ua'] = "Привітання"; -$text['table-size']['en-us'] = "Size"; -$text['table-size']['ar-eg'] = ""; -$text['table-size']['de-at'] = "Größe"; //copied from de-de -$text['table-size']['de-ch'] = "Größe"; //copied from de-de -$text['table-size']['de-de'] = "Größe"; -$text['table-size']['es-cl'] = "Tamaño"; -$text['table-size']['es-mx'] = "Tamaño"; //copied from es-cl -$text['table-size']['fr-ca'] = "Taille"; //copied from fr-fr -$text['table-size']['fr-fr'] = "Taille"; -$text['table-size']['he-il'] = "גודל"; -$text['table-size']['it-it'] = "Dimensione"; -$text['table-size']['nl-nl'] = "Omvang"; -$text['table-size']['pl-pl'] = "Rozmiar"; -$text['table-size']['pt-br'] = "Tamanho"; //copied from pt-pt -$text['table-size']['pt-pt'] = "Tamanho"; -$text['table-size']['ro-ro'] = ""; -$text['table-size']['ru-ru'] = ""; -$text['table-size']['sv-se'] = "Storlek"; -$text['table-size']['uk-ua'] = "Розмір"; +$text['label-size']['en-us'] = "Size"; +$text['label-size']['ar-eg'] = ""; +$text['label-size']['de-at'] = "Größe"; //copied from de-de +$text['label-size']['de-ch'] = "Größe"; //copied from de-de +$text['label-size']['de-de'] = "Größe"; +$text['label-size']['es-cl'] = "Tamaño"; +$text['label-size']['es-mx'] = "Tamaño"; //copied from es-cl +$text['label-size']['fr-ca'] = "Taille"; //copied from fr-fr +$text['label-size']['fr-fr'] = "Taille"; +$text['label-size']['he-il'] = "גודל"; +$text['label-size']['it-it'] = "Dimensione"; +$text['label-size']['nl-nl'] = "Omvang"; +$text['label-size']['pl-pl'] = "Rozmiar"; +$text['label-size']['pt-br'] = "Tamanho"; //copied from pt-pt +$text['label-size']['pt-pt'] = "Tamanho"; +$text['label-size']['ro-ro'] = ""; +$text['label-size']['ru-ru'] = ""; +$text['label-size']['sv-se'] = "Storlek"; +$text['label-size']['uk-ua'] = "Розмір"; -$text['table-number']['en-us'] = "#"; -$text['table-number']['ar-eg'] = ""; -$text['table-number']['de-at'] = "#"; //copied from de-de -$text['table-number']['de-ch'] = "#"; //copied from de-de -$text['table-number']['de-de'] = "#"; -$text['table-number']['es-cl'] = "Número"; -$text['table-number']['es-mx'] = "Número"; //copied from es-cl -$text['table-number']['fr-ca'] = "Nombre"; //copied from fr-fr -$text['table-number']['fr-fr'] = "Nombre"; -$text['table-number']['he-il'] = "#"; -$text['table-number']['it-it'] = "#"; -$text['table-number']['nl-nl'] = "Nummer"; -$text['table-number']['pl-pl'] = "liczba"; -$text['table-number']['pt-br'] = "Número"; //copied from pt-pt -$text['table-number']['pt-pt'] = "Número"; -$text['table-number']['ro-ro'] = ""; -$text['table-number']['ru-ru'] = ""; -$text['table-number']['sv-se'] = "#"; -$text['table-number']['uk-ua'] = "кількість"; +$text['label-number']['en-us'] = "#"; +$text['label-number']['ar-eg'] = "#"; +$text['label-number']['de-at'] = "#"; //copied from de-de +$text['label-number']['de-ch'] = "#"; //copied from de-de +$text['label-number']['de-de'] = "#"; +$text['label-number']['es-cl'] = "Número"; +$text['label-number']['es-mx'] = "Número"; //copied from es-cl +$text['label-number']['fr-ca'] = "Nombre"; //copied from fr-fr +$text['label-number']['fr-fr'] = "Nombre"; +$text['label-number']['he-il'] = "#"; +$text['label-number']['it-it'] = "#"; +$text['label-number']['nl-nl'] = "Nummer"; +$text['label-number']['pl-pl'] = "liczba"; +$text['label-number']['pt-br'] = "Número"; //copied from pt-pt +$text['label-number']['pt-pt'] = "Número"; +$text['label-number']['ro-ro'] = "#"; +$text['label-number']['ru-ru'] = "#"; +$text['label-number']['sv-se'] = "#"; +$text['label-number']['uk-ua'] = "кількість"; -$text['table-name']['en-us'] = "Name"; -$text['table-name']['ar-eg'] = ""; -$text['table-name']['de-at'] = "Name"; //copied from de-de -$text['table-name']['de-ch'] = "Name"; //copied from de-de -$text['table-name']['de-de'] = "Name"; -$text['table-name']['es-cl'] = "Nombre"; -$text['table-name']['es-mx'] = "Nombre"; //copied from es-cl -$text['table-name']['fr-ca'] = "Nom"; //copied from fr-fr -$text['table-name']['fr-fr'] = "Nom"; -$text['table-name']['he-il'] = "שם"; -$text['table-name']['it-it'] = "Nome"; -$text['table-name']['nl-nl'] = "Naam"; -$text['table-name']['pl-pl'] = "Nazwa"; -$text['table-name']['pt-br'] = "Nome"; //copied from pt-pt -$text['table-name']['pt-pt'] = "Nome"; -$text['table-name']['ro-ro'] = ""; -$text['table-name']['ru-ru'] = ""; -$text['table-name']['sv-se'] = "Namn"; -$text['table-name']['uk-ua'] = "Назва"; +$text['label-name']['en-us'] = "Name"; +$text['label-name']['ar-eg'] = ""; +$text['label-name']['de-at'] = "Name"; //copied from de-de +$text['label-name']['de-ch'] = "Name"; //copied from de-de +$text['label-name']['de-de'] = "Name"; +$text['label-name']['es-cl'] = "Nombre"; +$text['label-name']['es-mx'] = "Nombre"; //copied from es-cl +$text['label-name']['fr-ca'] = "Nom"; //copied from fr-fr +$text['label-name']['fr-fr'] = "Nom"; +$text['label-name']['he-il'] = "שם"; +$text['label-name']['it-it'] = "Nome"; +$text['label-name']['nl-nl'] = "Naam"; +$text['label-name']['pl-pl'] = "Nazwa"; +$text['label-name']['pt-br'] = "Nome"; //copied from pt-pt +$text['label-name']['pt-pt'] = "Nome"; +$text['label-name']['ro-ro'] = ""; +$text['label-name']['ru-ru'] = ""; +$text['label-name']['sv-se'] = "Namn"; +$text['label-name']['uk-ua'] = "Назва"; -$text['table-filename']['en-us'] = "File Name"; -$text['table-filename']['ar-eg'] = ""; -$text['table-filename']['de-at'] = "Dateiname"; //copied from de-de -$text['table-filename']['de-ch'] = "Dateiname"; //copied from de-de -$text['table-filename']['de-de'] = "Dateiname"; -$text['table-filename']['es-cl'] = "Nombre Del Archivo"; -$text['table-filename']['es-mx'] = "Nombre Del Archivo"; //copied from es-cl -$text['table-filename']['fr-ca'] = "Nom de fichier"; //copied from fr-fr -$text['table-filename']['fr-fr'] = "Nom de fichier"; -$text['table-filename']['he-il'] = "שם קובץ"; -$text['table-filename']['it-it'] = "Nome File"; -$text['table-filename']['nl-nl'] = "Bestandsnaam"; -$text['table-filename']['pl-pl'] = "Nazwa Pliku"; -$text['table-filename']['pt-br'] = "Nome Do Arquivo"; //copied from pt-pt -$text['table-filename']['pt-pt'] = "Nome Do Arquivo"; -$text['table-filename']['ro-ro'] = ""; -$text['table-filename']['ru-ru'] = ""; -$text['table-filename']['sv-se'] = "Filnamn"; -$text['table-filename']['uk-ua'] = "ім'я Файлу"; - -$text['table-download']['en-us'] = "Download"; -$text['table-download']['ar-eg'] = ""; -$text['table-download']['de-at'] = "Download"; //copied from de-de -$text['table-download']['de-ch'] = "Download"; //copied from de-de -$text['table-download']['de-de'] = "Download"; -$text['table-download']['es-cl'] = "Descargar"; -$text['table-download']['es-mx'] = "Descargar"; //copied from es-cl -$text['table-download']['fr-ca'] = "Télécharger"; //copied from fr-fr -$text['table-download']['fr-fr'] = "Télécharger"; -$text['table-download']['he-il'] = "הורדה"; -$text['table-download']['it-it'] = "Scaricare"; -$text['table-download']['nl-nl'] = "Ophalen"; -$text['table-download']['pl-pl'] = "Numer"; -$text['table-download']['pt-br'] = "Número"; -$text['table-download']['pt-pt'] = "Descarregar"; -$text['table-download']['ro-ro'] = ""; -$text['table-download']['ru-ru'] = ""; -$text['table-download']['sv-se'] = "Ladda Ned"; -$text['table-download']['uk-ua'] = "Скачати"; - -$text['table-description']['en-us'] = "Description"; -$text['table-description']['ar-eg'] = ""; -$text['table-description']['de-at'] = "Beschreibung"; //copied from de-de -$text['table-description']['de-ch'] = "Beschreibung"; //copied from de-de -$text['table-description']['de-de'] = "Beschreibung"; -$text['table-description']['es-cl'] = "Descripción"; -$text['table-description']['es-mx'] = "Descripción"; //copied from es-cl -$text['table-description']['fr-ca'] = "Description"; //copied from fr-fr -$text['table-description']['fr-fr'] = "Description"; -$text['table-description']['he-il'] = "תיאור"; -$text['table-description']['it-it'] = "Descrizione"; -$text['table-description']['nl-nl'] = "Omschrijving"; -$text['table-description']['pl-pl'] = "Opis"; -$text['table-description']['pt-br'] = "Descrição"; //copied from pt-pt -$text['table-description']['pt-pt'] = "Descrição"; -$text['table-description']['ro-ro'] = ""; -$text['table-description']['ru-ru'] = ""; -$text['table-description']['sv-se'] = "Beskrivning"; -$text['table-description']['uk-ua'] = "Опис"; - -$text['table-choose']['en-us'] = "Choose"; -$text['table-choose']['ar-eg'] = ""; -$text['table-choose']['de-at'] = "Wähle"; //copied from de-de -$text['table-choose']['de-ch'] = "Wähle"; //copied from de-de -$text['table-choose']['de-de'] = "Wähle"; -$text['table-choose']['es-cl'] = "Escoger"; -$text['table-choose']['es-mx'] = "Escoger"; //copied from es-cl -$text['table-choose']['fr-ca'] = "Choisir"; //copied from fr-fr -$text['table-choose']['fr-fr'] = "Choisir"; -$text['table-choose']['he-il'] = "בחר"; -$text['table-choose']['it-it'] = "Scegliere"; -$text['table-choose']['nl-nl'] = "Kiezen"; -$text['table-choose']['pl-pl'] = "Wybierz"; -$text['table-choose']['pt-br'] = "Escolher"; //copied from pt-pt -$text['table-choose']['pt-pt'] = "Escolher"; -$text['table-choose']['ro-ro'] = ""; -$text['table-choose']['ru-ru'] = ""; -$text['table-choose']['sv-se'] = "Välj"; -$text['table-choose']['uk-ua'] = "Вибрати"; +$text['label-description']['en-us'] = "Description"; +$text['label-description']['ar-eg'] = ""; +$text['label-description']['de-at'] = "Beschreibung"; //copied from de-de +$text['label-description']['de-ch'] = "Beschreibung"; //copied from de-de +$text['label-description']['de-de'] = "Beschreibung"; +$text['label-description']['es-cl'] = "Descripción"; +$text['label-description']['es-mx'] = "Descripción"; //copied from es-cl +$text['label-description']['fr-ca'] = "Description"; //copied from fr-fr +$text['label-description']['fr-fr'] = "Description"; +$text['label-description']['he-il'] = "תיאור"; +$text['label-description']['it-it'] = "Descrizione"; +$text['label-description']['nl-nl'] = "Omschrijving"; +$text['label-description']['pl-pl'] = "Opis"; +$text['label-description']['pt-br'] = "Descrição"; //copied from pt-pt +$text['label-description']['pt-pt'] = "Descrição"; +$text['label-description']['ro-ro'] = ""; +$text['label-description']['ru-ru'] = ""; +$text['label-description']['sv-se'] = "Beskrivning"; +$text['label-description']['uk-ua'] = "Опис"; $text['message-uploaded']['en-us'] = "Upload Complete"; $text['message-uploaded']['ar-eg'] = ""; @@ -181,26 +121,6 @@ $text['message-uploaded']['ru-ru'] = ""; $text['message-uploaded']['sv-se'] = "Uppladdning Klar"; $text['message-uploaded']['uk-ua'] = "Завантажено"; -$text['message-unsupported_file_type']['en-us'] = "Unsupported File Type"; -$text['message-unsupported_file_type']['ar-eg'] = ""; -$text['message-unsupported_file_type']['de-at'] = "Nicht unterstütztes Dateiformat"; //copied from de-de -$text['message-unsupported_file_type']['de-ch'] = "Nicht unterstütztes Dateiformat"; //copied from de-de -$text['message-unsupported_file_type']['de-de'] = "Nicht unterstütztes Dateiformat"; -$text['message-unsupported_file_type']['es-cl'] = "Tipo de archivo no compatible"; -$text['message-unsupported_file_type']['es-mx'] = "Tipo de archivo no compatible"; //copied from es-cl -$text['message-unsupported_file_type']['fr-ca'] = "Type de fichier non pris en charge"; //copied from fr-fr -$text['message-unsupported_file_type']['fr-fr'] = "Type de fichier non pris en charge"; -$text['message-unsupported_file_type']['he-il'] = "סוג הקובץ לא נתמך"; -$text['message-unsupported_file_type']['it-it'] = "Tipo File Non Supportato"; -$text['message-unsupported_file_type']['nl-nl'] = "Niet ondersteund bestands type"; -$text['message-unsupported_file_type']['pl-pl'] = "Nieobsługiwany typ pliku"; -$text['message-unsupported_file_type']['pt-br'] = "Não suportado Tipo de Arquivo"; //copied from pt-pt -$text['message-unsupported_file_type']['pt-pt'] = "Não suportado Tipo de Arquivo"; -$text['message-unsupported_file_type']['ro-ro'] = ""; -$text['message-unsupported_file_type']['ru-ru'] = ""; -$text['message-unsupported_file_type']['sv-se'] = "Filtypen Supporteras Inte"; -$text['message-unsupported_file_type']['uk-ua'] = "Тип файлу не підтримується"; - $text['message-greeting_selected']['en-us'] = "Greeting Selected"; $text['message-greeting_selected']['ar-eg'] = ""; $text['message-greeting_selected']['de-at'] = "Begrüßung ausgewählt"; //copied from de-de @@ -401,6 +321,26 @@ $text['label-add']['ru-ru'] = ""; $text['label-add']['sv-se'] = "Lägg Till Hälsning"; $text['label-add']['uk-ua'] = "Додати привітання"; +$text['label-selected']['en-us'] = "Selected"; +$text['label-selected']['ar-eg'] = ""; +$text['label-selected']['de-at'] = "Ausgewählt"; //copied from de-de +$text['label-selected']['de-ch'] = "Ausgewählt"; //copied from de-de +$text['label-selected']['de-de'] = "Ausgewählt"; +$text['label-selected']['es-cl'] = "Seleccionado"; +$text['label-selected']['es-mx'] = "Seleccionado"; //copied from es-cl +$text['label-selected']['fr-ca'] = "Sélectionné"; //copied from fr-fr +$text['label-selected']['fr-fr'] = "Sélectionné"; +$text['label-selected']['he-il'] = ""; +$text['label-selected']['it-it'] = "Selezionato"; +$text['label-selected']['nl-nl'] = ""; +$text['label-selected']['pl-pl'] = "Wybrane"; +$text['label-selected']['pt-br'] = "Selecionado"; //copied from pt-pt +$text['label-selected']['pt-pt'] = "Selecionado"; +$text['label-selected']['ro-ro'] = ""; +$text['label-selected']['ru-ru'] = "Выбор"; +$text['label-selected']['sv-se'] = "Valt"; +$text['label-selected']['uk-ua'] = ""; + $text['description-name']['en-us'] = "A name for the greeting (not parsed)."; $text['description-name']['ar-eg'] = ""; $text['description-name']['de-at'] = "Ein Namen für die Begrüßung."; //copied from de-de diff --git a/app/voicemail_greetings/resources/classes/voicemail_greetings.php b/app/voicemail_greetings/resources/classes/voicemail_greetings.php new file mode 100644 index 0000000000..7b8d94806e --- /dev/null +++ b/app/voicemail_greetings/resources/classes/voicemail_greetings.php @@ -0,0 +1,164 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2019 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//define the voicemail greetings class +if (!class_exists('voicemail_greetings')) { + class voicemail_greetings { + + /** + * declare private variables + */ + private $app_name; + private $app_uuid; + private $permission_prefix; + private $list_page; + private $table; + private $uuid_prefix; + + /** + * declare public variables + */ + public $voicemail_id; + + /** + * called when the object is created + */ + public function __construct() { + + //assign private variables + $this->app_name = 'voicemail_greetings'; + $this->app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2'; + $this->permission_prefix = 'voicemail_greeting_'; + if (is_numeric($this->voicemail_id)) { + $this->list_page = 'voicemail_greetings.php?id='.urlencode($this->voicemail_id).'&back='.urlencode(PROJECT_PATH.'/app/voicemail/voicemails.php'); + } + else { + $this->list_page = PROJECT_PATH.'/app/voicemails/voicemails.php'; + } + $this->table = 'voicemail_greetings'; + $this->uuid_prefix = 'voicemail_greeting_'; + + } + + /** + * called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * delete records + */ + public function delete($records) { + if (permission_exists($this->permission_prefix.'delete')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page); + exit; + } + + //check voicemail id + if (!is_numeric($this->voicemail_id)) { + header('Location: '.$this->list_page); + exit; + } + + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + + //filter out unchecked records + foreach ($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + $uuids[] = "'".$record['uuid']."'"; + } + } + + //get necessary greeting details + if (is_array($uuids) && @sizeof($uuids) != 0) { + $sql = "select ".$this->uuid_prefix."uuid as uuid, greeting_filename from v_".$this->table." "; + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $database = new database; + $rows = $database->select($sql, $parameters, 'all'); + if (is_array($rows) && @sizeof($rows) != 0) { + foreach ($rows as $row) { + $greeting_filenames[$row['uuid']] = $row['greeting_filename']; + } + } + unset($sql, $parameters, $rows, $row); + } + + //set the greeting directory + $greeting_directory = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$this->voicemail_id; + + //loop through greetings + if (is_array($greeting_filenames) && @sizeof($greeting_filenames) != 0) { + $x = 0; + foreach ($greeting_filenames as $voicemail_greeting_uuid => $greeting_filename) { + + //delete the recording file + @unlink($greeting_directory.'/'.$greeting_filename); + + + //build the delete array + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $voicemail_greeting_uuid; + $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $x++; + } + } + + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + + //execute delete + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->delete($array); + unset($array); + + //set message + message::add($text['message-delete']); + } + unset($records); + } + } + } //method + + } //class +} + +?> \ No newline at end of file diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index eaddb343a4..39481b14c1 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2018 + Portions created by the Initial Developer are Copyright (C) 2008-2019 the Initial Developer. All Rights Reserved. Contributor(s): @@ -81,7 +81,6 @@ //download the greeting if ($_GET['a'] == "download" && (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download'))) { - session_cache_limiter('public'); if ($_GET['type'] == "rec") { $voicemail_greeting_uuid = $_GET['uuid']; //get voicemail greeting details from db @@ -138,70 +137,81 @@ } //upload the greeting - if (permission_exists('voicemail_greeting_upload')) { - if ($_POST['submit'] == $text['button-upload'] && $_POST['type'] == 'rec' && is_uploaded_file($_FILES['file']['tmp_name'])) { + if ( + $_POST['a'] == "upload" + && permission_exists('voicemail_greeting_upload') + && $_POST['type'] == 'rec' + && is_uploaded_file($_FILES['file']['tmp_name']) + ) { - //get the file extension - $file_ext = substr($_FILES['file']['name'], -4); - - //check file extension - if ($file_ext == '.wav' || $file_ext != '.mp3') { - - //find the next available - for ($i = 1; $i < 10; $i++) { - - //set the file name - $file_name = 'greeting_'.$i.$file_ext; - - //check the database - if (is_uuid($domain_uuid) && is_numeric($voicemail_id) ) { - $sql = "select count(*) from v_voicemail_greetings "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and voicemail_id = :voicemail_id "; - $sql .= "and greeting_filename = :greeting_filename "; - $parameters['domain_uuid'] = $domain_uuid; - $parameters['voicemail_id'] = $voicemail_id; - $parameters['greeting_filename'] = $file_name; - $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); - - if ($num_rows == 0 && !file_exists($v_greeting_dir.'/'.$file_name)) { - //move the uploaded greeting - event_socket_mkdir($v_greeting_dir); - if ($file_ext == '.wav' || $file_ext == '.mp3') { - move_uploaded_file($_FILES['file']['tmp_name'], $v_greeting_dir.'/'.$file_name); - } - //set newly uploaded greeting as active greeting for voicemail box - $sql = "update v_voicemails "; - $sql .= "set greeting_id = :greeting_id "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and voicemail_id = :voicemail_id "; - $parameters['greeting_id'] = $i; - $parameters['domain_uuid'] = $domain_uuid; - $parameters['voicemail_id'] = $voicemail_id; - $database = new database; - $database->execute($sql, $parameters); - unset($sql, $parameters); - //set message - message::add($text['message-uploaded'].": ".$_FILES['file']['name']); - //found available id, exit; - break; - } - else { - continue; - } - unset($num_rows); - } - - } + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: voicemail_greetings.php?id='.urlencode($voicemail_id)); + exit; } - //set the file name to be inserted as the greeting description - $greeting_description = base64_encode($_FILES['file']['name']); - header("Location: voicemail_greetings.php?id=".$voicemail_id."&order_by=".$order_by."&order=".$order."&gd=".$greeting_description); - exit; + //get the file extension + $file_ext = substr($_FILES['file']['name'], -4); + + //check file extension + if ($file_ext == '.wav' || $file_ext != '.mp3') { + + //find the next available + for ($i = 1; $i < 10; $i++) { + + //set the file name + $file_name = 'greeting_'.$i.$file_ext; + + //check the database + if (is_uuid($domain_uuid) && is_numeric($voicemail_id) ) { + $sql = "select count(*) from v_voicemail_greetings "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and voicemail_id = :voicemail_id "; + $sql .= "and greeting_filename = :greeting_filename "; + $parameters['domain_uuid'] = $domain_uuid; + $parameters['voicemail_id'] = $voicemail_id; + $parameters['greeting_filename'] = $file_name; + $database = new database; + $num_rows = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + + if ($num_rows == 0 && !file_exists($v_greeting_dir.'/'.$file_name)) { + //move the uploaded greeting + event_socket_mkdir($v_greeting_dir); + if ($file_ext == '.wav' || $file_ext == '.mp3') { + move_uploaded_file($_FILES['file']['tmp_name'], $v_greeting_dir.'/'.$file_name); + } + //set newly uploaded greeting as active greeting for voicemail box + $sql = "update v_voicemails "; + $sql .= "set greeting_id = :greeting_id "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and voicemail_id = :voicemail_id "; + $parameters['greeting_id'] = $i; + $parameters['domain_uuid'] = $domain_uuid; + $parameters['voicemail_id'] = $voicemail_id; + $database = new database; + $database->execute($sql, $parameters); + unset($sql, $parameters); + //set message + message::add($text['message-uploaded'].": ".$_FILES['file']['name']); + //found available id, exit; + break; + } + else { + continue; + } + unset($num_rows); + } + + } } + + //set the file name to be inserted as the greeting description + $greeting_description = base64_encode($_FILES['file']['name']); + header("Location: voicemail_greetings.php?id=".urlencode($voicemail_id)."&order_by=".urlencode($order_by)."&order=".urlencode($order)."&gd=".$greeting_description); + exit; } //check the permission @@ -347,6 +357,29 @@ } } +//get the http post data + if (is_array($_POST['voicemail_greetings'])) { + $action = $_POST['action']; + $voicemail_id = $_POST['voicemail_id']; + $voicemail_greetings = $_POST['voicemail_greetings']; + } + +//process the http post data by action + if ($action != '' && is_array($voicemail_greetings) && @sizeof($voicemail_greetings) != 0) { + switch ($action) { + case 'delete': + if (permission_exists('voicemail_greeting_delete')) { + $obj = new voicemail_greetings; + $obj->voicemail_id = $voicemail_id; + $obj->delete($voicemail_greetings); + } + break; + } + + header('Location: voicemail_greetings.php?id='.urlencode($voicemail_id).'&back='.urlencode(PROJECT_PATH.'/app/voicemails/voicemails.php')); + exit; + } + //get the greetings list $sql = "select * from v_voicemail_greetings "; $sql .= "where domain_uuid = :domain_uuid "; @@ -356,98 +389,132 @@ $parameters['voicemail_id'] = $voicemail_id; $database = new database; $greetings = $database->select($sql, $parameters, 'all'); + $num_rows = is_array($greetings) ? @sizeof($greetings) : 0; unset($sql, $parameters); -//set the row styles - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); //include the header $document['title'] = $text['title']; require_once "resources/header.php"; -//begin the content +//file type check script echo ""; - echo "\n"; - echo "
\n"; +//show the content + echo "
\n"; + echo "
".$text['title']." (".$num_rows.")
\n"; + echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>$_SESSION['back'][$_SERVER['PHP_SELF']]]); if (permission_exists('voicemail_greeting_upload')) { - echo "
\n"; - echo " \n"; - echo " \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','onclick'=>"$(this).fadeOut(250, function(){ $('span#form_upload').fadeIn(250); document.getElementById('ulfile').click(); });"]); + echo "\n"; + echo "
"; } - echo "      \n"; - if (permission_exists('voicemail_greeting_upload')) { - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " "; + if (permission_exists('voicemail_greeting_delete') && $greetings) { + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); } - echo "
"; - echo "".$text['title']."\n"; - echo "

\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo $text['description']." ".escape($voicemail_id)."\n"; echo "

\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo th_order_by('greeting_id', $text['table-number'], $order_by, $order, '', "width='20'", "id=".escape($voicemail_id)); - echo th_order_by('greeting_name', $text['table-name'], $order_by, $order, '', '', "id=".escape($voicemail_id)); + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
 
\n"; + echo "\n"; + $col_count = 0; + if (permission_exists('voicemail_greeting_delete')) { + echo " \n"; + $col_count++; + } + echo "\n"; + $col_count++; + echo th_order_by('greeting_id', $text['label-number'], $order_by, $order, null, "class='center shrink'", "id=".urlencode($voicemail_id)); + $col_count++; + echo th_order_by('greeting_name', $text['label-name'], $order_by, $order, null, null, "id=".urlencode($voicemail_id)); + $col_count++; if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { - echo th_order_by('greeting_filename', $text['table-filename'], $order_by, $order, '', '', "id=".escape($voicemail_id)); - echo "\n"; + echo th_order_by('greeting_filename', $text['label-filename'], $order_by, $order, null, "class='hide-sm-dn'", "id=".urlencode($voicemail_id)); + $col_count++; } if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) { - echo "\n"; + echo "\n"; + $col_count++; + } + if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { + echo "\n"; + echo "\n"; + $col_count += 2; + } + echo th_order_by('greeting_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn pct-25'", "id=".urlencode($voicemail_id)); + if (permission_exists('voicemail_greeting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; } - echo th_order_by('greeting_description', $text['table-description'], $order_by, $order, '', '', "id=".escape($voicemail_id)); - echo "\n"; echo "\n"; - //calculate colspan for progress bar - $colspan = 7; //max - if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') { $colspan = $colspan - 2; } - if (!(permission_exists('voicemail_greeting_edit') || permission_exists('voicemail_greeting_delete'))) { $colspan = $colspan - 1; } - if (is_array($greetings) && @sizeof($greetings) != 0) { - foreach($greetings as $row) { + $x = 0; + foreach ($greetings as $row) { //playback progress bar - if (permission_exists('voicemail_greeting_play')) { - echo "\n"; + if (permission_exists('voicemail_greeting_play')) { + echo "\n"; + echo "\n"; // dummy row to maintain alternating background color + } + if (permission_exists('voicemail_greeting_edit')) { + $list_row_url = "voicemail_greeting_edit.php?id=".urlencode($row['voicemail_greeting_uuid'])."&voicemail_id=".urlencode($voicemail_id); } - $tr_link = (permission_exists('voicemail_greeting_edit')) ? "href='voicemail_greeting_edit.php?id=".escape($row['voicemail_greeting_uuid'])."&voicemail_id=".escape($voicemail_id)."'" : null; - echo "\n"; - echo " \n"; + if (permission_exists('voicemail_greeting_delete')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; - echo " \n"; - echo " \n"; if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { - echo " \n"; - $tmp_filesize = filesize($v_greeting_dir.'/'.$row['greeting_filename']); - $tmp_filesize = byte_convert($tmp_filesize); - echo " \n"; + echo " \n"; } if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) { - echo " \n"; } - echo " \n"; - echo " \n"; + echo " \n"; } - if (permission_exists('voicemail_greeting_delete')) { - echo "$v_link_label_delete"; + echo " \n"; + if (permission_exists('voicemail_greeting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; } - echo " \n"; echo "\n"; + $x++; - $c = ($c) ? 0 : 1; + /* + echo "$v_link_label_delete"; + */ } + unset($greetings); } - unset($result, $row); + echo "
\n"; + echo " \n"; + echo " ".$text['label-selected']."".$text['table-size']."".$text['label-tools']."".$text['label-tools']."".$text['label-size']."".$text['label-uploaded']." \n"; - echo "
\n"; + echo " \n"; + echo " \n"; + echo " ".escape($row['greeting_id']).""; + if (permission_exists('voicemail_greeting_edit')) { + echo "".escape($row['greeting_name']).""; + } + else { + echo escape($row['greeting_name']); + } echo " ".escape($row['greeting_id'])."".escape($row['greeting_name'])."".escape($row['greeting_filename'])."".$tmp_filesize."".escape($row['greeting_filename'])."".escape($row['greeting_description'])." \n"; - if (permission_exists('voicemail_greeting_edit')) { - echo "$v_link_label_edit"; + if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { + $file_size = byte_convert(filesize($v_greeting_dir.'/'.$row['greeting_filename'])); + $file_date = date("M d, Y H:i:s", filemtime($v_greeting_dir.'/'.$row['greeting_filename'])); + echo " ".$file_size."".$file_date."".escape($row['greeting_description'])." "; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo "
\n"; - echo "


\n"; + echo "
\n"; + echo "\n"; + echo "\n"; //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file