ソースを参照

Move the voicemail status that uses mod_voicemail to the optional apps directory.

Mark Crane 12 年 前
コミット
66ce52c40a

+ 48 - 0
voicemail_status/app_config.php

@@ -0,0 +1,48 @@
+<?php
+	//application details
+		$apps[$x]['name'] = "Voicemail Status";
+		$apps[$x]['uuid'] = '9ecd085e-8c0e-92f6-e727-e90f6bb57773';
+		$apps[$x]['category'] = 'Switch';;
+		$apps[$x]['subcategory'] = '';
+		$apps[$x]['version'] = '';
+		$apps[$x]['license'] = 'Mozilla Public License 1.1';
+		$apps[$x]['url'] = 'http://www.fusionpbx.com';
+		$apps[$x]['description']['en-us'] = 'Shows which extensions have voicemails and how many.';
+		$apps[$x]['description']['es-mx'] = '';
+		$apps[$x]['description']['de'] = '';
+		$apps[$x]['description']['de-ch'] = '';
+		$apps[$x]['description']['de-at'] = '';
+		$apps[$x]['description']['fr'] = '';
+		$apps[$x]['description']['fr-ca'] = '';
+		$apps[$x]['description']['fr-ch'] = '';
+		$apps[$x]['description']['pt-pt'] = 'Mostra quais extensões têm mensagens de voz e quantas.';
+		$apps[$x]['description']['pt-br'] = '';
+
+	//menu details
+		$apps[$x]['menu'][0]['title']['en-us'] = 'Voicemail Status';
+		$apps[$x]['menu'][0]['title']['es-mx'] = '';
+		$apps[$x]['menu'][0]['title']['de'] = '';
+		$apps[$x]['menu'][0]['title']['de-ch'] = '';
+		$apps[$x]['menu'][0]['title']['de-at'] = '';
+		$apps[$x]['menu'][0]['title']['fr'] = '';
+		$apps[$x]['menu'][0]['title']['fr-ca'] = '';
+		$apps[$x]['menu'][0]['title']['fr-ch'] = '';
+		$apps[$x]['menu'][0]['title']['pt-pt'] = 'Estado do Correio de Voz';
+		$apps[$x]['menu'][0]['title']['pt-br'] = '';
+		$apps[$x]['menu'][0]['uuid'] = 'ff4ccd3d-e295-7875-04b4-54eb0c74adc5';
+		$apps[$x]['menu'][0]['parent_uuid'] = '0438b504-8613-7887-c420-c837ffb20cb1';
+		$apps[$x]['menu'][0]['category'] = 'internal';
+		$apps[$x]['menu'][0]['path'] = '/app/voicemail_status/voicemail.php';
+		$apps[$x]['menu'][0]['groups'][] = 'admin';
+		$apps[$x]['menu'][0]['groups'][] = 'superadmin';
+
+	//permission details
+		$apps[$x]['permissions'][0]['name'] = 'voicemail_status_view';
+		$apps[$x]['permissions'][0]['groups'][] = 'admin';
+		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][1]['name'] = 'voicemail_status_delete';
+		$apps[$x]['permissions'][1]['groups'][] = 'admin';
+		$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
+
+?>

+ 36 - 0
voicemail_status/app_languages.php

@@ -0,0 +1,36 @@
+<?php
+
+	$text['title-voicemail']['en-us'] = 'Voicemail';
+	$text['title-voicemail']['pt-pt'] = '';
+
+	$text['description-voicemail']['en-us'] = 'Show details about the voicemail settings including the voicemail count, and voicemail to email address.';
+	$text['description-voicemail']['pt-pt'] = '';
+
+	$text['label-extension']['en-us'] = 'Extension';
+	$text['label-extension']['pt-pt'] = '';
+
+	$text['label-voicemail']['en-us'] = 'Voicemail Mail To';
+	$text['label-voicemail']['pt-pt'] = '';
+
+	$text['label-messages']['en-us'] = 'Messages';
+	$text['label-messages']['pt-pt'] = '';
+
+	$text['label-enabled']['en-us'] = 'Enabled';
+	$text['label-enabled']['pt-pt'] = '';
+
+	$text['label-description']['en-us'] = 'Description';
+	$text['label-description']['pt-pt'] = '';
+
+	$text['label-prefs-delete']['en-us'] = 'Voicemail Preferences set to default';
+	$text['label-prefs-delete']['pt-pt'] = '';
+
+	$text['confirm-prefs-delete-alt']['en-us'] = 'restore default preferences';
+	$text['confirm-prefs-delete-alt']['pt-pt'] = '';
+
+	$text['confirm-prefs-delete-title']['en-us'] = 'restore default preferences';
+	$text['confirm-prefs-delete-title']['pt-pt'] = '';
+
+	$text['confirm-prefs-delete']['en-us'] = 'Are you sure you want to remove the voicemail name and greeting?';
+	$text['confirm-prefs-delete']['pt-pt'] = '';
+
+?>

+ 50 - 0
voicemail_status/root.php

@@ -0,0 +1,50 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 200 - 0
voicemail_status/voicemail.php

@@ -0,0 +1,200 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('voicemail_status_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+//add multi-lingual support
+	echo "<!--\n";
+	require_once "app_languages.php";
+	echo "-->\n";
+	foreach($text as $key => $value) {
+		$text[$key] = $value[$_SESSION['domain']['language']['code']];
+	}
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+//show the content
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+	echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
+	echo "	<tr>\n";
+	echo "	<td align='left'><b>".$text['title-voicemail']."</b><br>\n";
+	echo "		".$text['description-voicemail']."\n";
+	echo "	</td>\n";
+	echo "	</tr>\n";
+	echo "</table>\n";
+	echo "<br />";
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('extension', $text['label-extension'], $order_by, $order);
+	echo th_order_by('vm_mailto', $text['label-voicemail'], $order_by, $order);
+	echo "<th>".$text['label-messages']."</th>\n";
+	echo th_order_by('enabled', $text['label-enabled'], $order_by, $order);
+	echo th_order_by('description', $text['label-description'], $order_by, $order);
+	echo "<tr>\n";
+
+	$sql = "select * from v_extensions ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	if (!(if_group("admin") || if_group("superadmin"))) {
+		if (count($_SESSION['user']['extension']) > 0) {
+			$sql .= "and (";
+			$x = 0;
+			foreach($_SESSION['user']['extension'] as $row) {
+				if ($x > 0) { $sql .= "or "; }
+				$sql .= "extension = '".$row['user']."' ";
+				$x++;
+			}
+			$sql .= ")";
+		}
+		else {
+			//hide any results when a user has not been assigned an extension
+			$sql .= "and extension = 'disabled' ";
+		}
+	}
+	if (strlen($order_by)> 0) { 
+		$sql .= "order by $order_by $order ";
+	}
+	else {
+		$sql .= "order by extension asc ";
+	}
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+
+	$rows_per_page = 100;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "select * from v_extensions ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	if (!(if_group("admin") || if_group("superadmin"))) {
+		if (count($_SESSION['user']['extension']) > 0) {
+			$sql .= "and (";
+			$x = 0;
+			foreach($_SESSION['user']['extension'] as $row) {
+				if ($x > 0) { $sql .= "or "; }
+				$sql .= "extension = '".$row['user']."' ";
+				$x++;
+			}
+			$sql .= ")";
+		}
+		else {
+			//hide any results when a user has not been assigned an extension
+			$sql .= "and extension = 'disabled' ";
+		}
+	}
+	if (strlen($order_by)> 0) {
+		$sql .= "order by $order_by $order ";
+	}
+	else {
+		$sql .= "order by extension asc ";
+	}
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+	//pdo voicemail database connection
+//		include "includes/lib_pdo_vm.php";
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+
+			$sql = "select count(*) as count from voicemail_msgs ";
+			$sql .= "where domain = '".$_SESSION['domains'][$domain_uuid]['domain_name']."' ";
+			$sql .= "and username = '".$row['extension']."' ";
+//			$prep_statement = $db->prepare(check_sql($sql));
+//			$prep_statement->execute();
+//			$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+//			foreach ($result as &$row2) {
+//				$count = $row2["count"];
+//				break; //limit to 1 row
+//			}
+//			unset ($prep_statement);
+
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['extension']."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['vm_mailto']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$count."&nbsp;</td>\n";
+			echo "  <td valign='top' class='".$row_style[$c]."'>".($row['vm_enabled']?"true":"false")."</td>\n";
+			echo "	<td valign='top' class='row_stylebg' width='30%'>".$row['description']."&nbsp;</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			if (permission_exists('voicemail_status_delete')) {
+				echo "		<a href='voicemail_prefs_delete.php?id=".$row['extension_uuid']."' alt='".$text['confirm-prefs-delete-alt']."' title='".$text['confirm-prefs-delete-title']."' onclick=\"return confirm('".$text['confirm-prefs-delete']."')\">$v_link_label_delete</a>\n";
+			}
+			echo "	</td>\n";
+			echo "</tr>\n";
+
+			unset($count);
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+echo "</table>";
+echo "</div>";
+echo "<br><br>";
+echo "<br><br>";
+
+echo "</td>";
+echo "</tr>";
+echo "</table>";
+echo "</div>";
+echo "<br><br>";
+
+//show the footer
+	require "includes/require.php";
+	require_once "includes/footer.php";
+?>

+ 71 - 0
voicemail_status/voicemail_prefs_delete.php

@@ -0,0 +1,71 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('voicemail_status_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = $_GET["id"];
+}
+
+//pdo voicemail database connection
+	include "includes/lib_pdo_vm.php";
+
+//delete the data
+	if (strlen($id)>0) {
+		$sql = "delete from voicemail_prefs ";
+		$sql .= "where domain = '".$_SESSION['domains'][$domain_uuid]['domain_name']."' ";
+		$sql .= "and username = '$domain_uuid' ";
+		$count = $db->exec(check_sql($sql));
+		unset($sql);
+	}
+
+//add multi-lingual support
+	echo "<!--\n";
+	require_once "app_languages.php";
+	echo "-->\n";
+	foreach($text as $key => $value) {
+		$text[$key] = $value[$_SESSION['domain']['language']['code']];
+	}
+
+//redirect the user
+	require "includes/require.php";
+	require_once "includes/header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"2;url=voicemail.php\">\n";
+	echo "<div align='center'>\n";
+	echo $text['label-prefs-delete']."\n";
+	echo "</div>\n";
+	require_once "includes/footer.php";
+	return;
+
+?>