forked from FreePBX-ContributedModules/routepermissions
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated version of Route Permissions module to support FreePBX 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
// Based on an original Release by Rob Thomas ([email protected]) | ||
// Copyright Rob Thomas (2009) | ||
// Extensive modifications by Michael Newton ([email protected]) | ||
// Copyright 2016 Michael Newton | ||
/* | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
if (!class_exists("RouterpermissionsLegacy")) { | ||
require_once(dirname(__FILE__) . "/functions.inc.php"); | ||
} | ||
|
||
class Routepermissions extends RoutepermissionsLegacy implements FreePBX\BMO | ||
{ | ||
/** Constructor code for version 13+ | ||
* @param Object $freepbx The FreePBX object | ||
* @return void | ||
*/ | ||
public function __construct($freepbx = null) | ||
{ | ||
if ($freepbx === null) { | ||
die("That ain't gonna fly!"); | ||
} | ||
$this->FreePBX = $freepbx; | ||
$this->db = $freepbx->Database; | ||
} | ||
|
||
/** | ||
* Show right navigation for version 13+ | ||
* @param array $request The contents of $_REQUEST | ||
* @return string The right nav HTML | ||
*/ | ||
public function getRightNav($request) | ||
{ | ||
return ""; | ||
} | ||
|
||
/** | ||
* Show floating save buttons for version 13+ | ||
* @param array $request The contents of $_REQUEST | ||
* @return array Associative array including name, id, and value for each button | ||
*/ | ||
public function getActionBar($request) | ||
{ | ||
return array(); | ||
} | ||
|
||
/** | ||
* Ajax request check for version 13+; confirm command is okay and optionally pass some settings | ||
* @param string $command The command name | ||
* @param string $setting Settings to return back | ||
* @return boolean | ||
*/ | ||
public function ajaxRequest($command, &$setting){ | ||
return method_exists(get_called_class(), $command); | ||
} | ||
|
||
/** | ||
* Handle the ajax request for version 13+, passed in $_REQUEST["command"] | ||
* @return mixed The result of the command | ||
*/ | ||
public function ajaxHandler() | ||
{ | ||
$request = $_REQUEST; | ||
$command = isset($_REQUEST["command"]) ? $_REQUEST["command"] : ""; | ||
if (method_exists(get_called_class(), $command)) { | ||
$return = self::$command($request); | ||
if ($return) { | ||
return $return; | ||
} else { | ||
return array("status"=>false, "message"=>sprintf(_("Command %s failed"), $command)); | ||
} | ||
} | ||
return array("status"=>false, "message"=>_("Unknown command")); | ||
} | ||
|
||
/** | ||
* Handle searches for version 13+ | ||
* @param string $query The search itself | ||
* @param array $results The results by reference | ||
* @return boolean | ||
*/ | ||
public function search($query = null, &$results = null) | ||
{ | ||
return false; | ||
} | ||
|
||
public function install() | ||
{ | ||
return; | ||
} | ||
|
||
public function uninstall() | ||
{ | ||
return; | ||
} | ||
|
||
public function backup() | ||
{ | ||
return; | ||
} | ||
|
||
public function restore($backup) | ||
{ | ||
return; | ||
} | ||
|
||
public function genConfig() | ||
{ | ||
return; | ||
} | ||
|
||
public function writeConfig() | ||
{ | ||
return; | ||
} | ||
|
||
public function doConfigPageInit($display) | ||
{ | ||
return; | ||
} | ||
} |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Based on an original Release by Rob Thomas ([email protected]) | ||
// Copyright Rob Thomas (2009) | ||
// Extensive modifications by Michael Newton ([email protected]) | ||
// Copyright 2016 Michael Newton | ||
/* | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
$(function() { | ||
// bulk settings page | ||
$("input[name^='prefix_'], select[name^='goto_']").prop("disabled", true); | ||
$("input[name^='permission_']").change(function(){ | ||
var rname = this.id.replace(/^permission_(.*)_(?:SKIP|YES|NO|REDIRECT)$/, "prefix_$1"); | ||
var dname = this.id.replace(/^permission_(.*)_(?:SKIP|YES|NO|REDIRECT)$/, "goto_$1"); | ||
$("input[name=" + rname + "]") | ||
.val("") | ||
.prop("disabled", (this.value !== "REDIRECT")) | ||
.prop("required", (this.value === "REDIRECT")); | ||
$("select[name=" + dname + "]") | ||
.val("") | ||
.change() | ||
.prop("disabled", (this.value !== "NO")); | ||
}); | ||
// extensions page code is added per element: FUN!!! | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-----BEGIN PGP SIGNED MESSAGE----- | ||
Hash: SHA256 | ||
|
||
;################################################ | ||
;# FreePBX Module Signature File # | ||
;################################################ | ||
;# Do not alter the contents of this file! If # | ||
;# this file is tampered with, the module will # | ||
;# fail validation and be marked as invalid! # | ||
;################################################ | ||
|
||
[config] | ||
version=1 | ||
hash=sha256 | ||
signedwith=B0189C08EE024B99 | ||
signedby=modsign | ||
repo=custom | ||
[hashes] | ||
|
||
agi-bin/checkperms.agi=9867c29d86a19527dfc86d2e0d08de3552fddcaa4a40f4689ae845cf34e316e7 | ||
assets/css/routepermissions.css=98725f8e9a6842c1a3fb1768d135e70bd12c77ba27fa98c6e3639e42bc8d4a6a | ||
assets/js/routepermissions.js=bfa406dd4735f2aba068c6ed39e1d4b7d112214238eb25289606fa521bbb16dc | ||
functions.inc.php=25aa30a240d5d85786f0c4b22c71bd30e4d2718be535232c2e3317d2a62ffce9 | ||
install.php=b1107c489c1d2e8eff6b839937926be6048122d207ec620af8a7e3cde7fb3daf | ||
module.xml=f9d3464d8a69fe2876b0d1397e22ca5725917f668784707fc377764bd00287f6 | ||
page.routepermissions.php=e62382ad2694ec7cb23652c98de160a5cea0e6e43af3e4b986ea54e3ce2ea392 | ||
Routepermissions.class.php=8b9dc61ea96a97dac9720d36f30672f522adec622a1cb36a52df261dc8721936 | ||
uninstall.php=894ca34fb308a3f18a50d18bb773ab8135ca338d588ef1e1d3a411a6d5a39606 | ||
views/settings.php=55f7a3f76ed25a41e0152696c29e95c424d4f2458aec0c67b5183ff0501696c8 | ||
views/settings13.php=00fc4763b6903957988f44a5f8e311dd8da84115aa075542919ad264c3d78b4e | ||
;# End | ||
-----BEGIN PGP SIGNATURE----- | ||
Version: GnuPG v1 | ||
|
||
iF4EAREIAAYFAlbUvK0ACgkQsBicCO4CS5kA1wEAvqQ9YRyOVEtai2alaKWlHXK2 | ||
uhvrdWHZ0DKrPzmPKL8A/1xwBOPs8XxScvFxS4j2GYcFdv5kce1JqFulSqnTmJcn | ||
=T8t6 | ||
-----END PGP SIGNATURE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// Based on an original Release by Rob Thomas ([email protected]) | ||
// Copyright Rob Thomas (2009) | ||
// Extensive modifications by Michael Newton ([email protected]) | ||
// Copyright 2016 Michael Newton | ||
/* | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
outn(_("Removing routepermissions database table… ")); | ||
$result = $db->query("DROP TABLE routepermissions"); | ||
if (DB::IsError($result)) { | ||
out(sprintf(_("Error removing routepermissions table: %s"), $result->getMessage())); | ||
} else { | ||
out(_("complete")); | ||
} | ||
|
||
outn(_("Removing AGI script… ")); | ||
$result = unlink($amp_conf["ASTAGIDIR"] . "/checkperms.agi"); | ||
if (!$result) { | ||
out(_("failed! File must be removed manually")); | ||
} else { | ||
out(_("complete")); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
// Based on an original Release by Rob Thomas ([email protected]) | ||
// Copyright Rob Thomas (2009) | ||
// Extensive modifications by Michael Newton ([email protected]) | ||
// Copyright 2016 Michael Newton | ||
/* | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
$html = "<div class=\"content\" id=\"routepermissions\"><div id=\"content_header\">"; | ||
$html .= heading(_("Route Permissions"), 2); | ||
if (!empty($message)) { | ||
$html .= "<p class=\"routepermissions_infobox\">$message</p>"; | ||
} | ||
if (!empty($errormessage)) { | ||
$html .= "<p class=\"routepermissions_infobox routepermissions_error\">$errormessage</p>"; | ||
} | ||
$html .= "</div>"; | ||
$html .= form_open("$_SERVER[PHP_SELF]?display=$module"); | ||
|
||
$html .= heading(_("Instructions"), 3); | ||
$html .= "<p>"; | ||
$html .= _("This module allows you to allow or deny access to certain routes from specified extensions. You can perform bulk changes on this page, and you can change an individual extension's access to routes on that extension's page."); | ||
$html .= "</p>"; | ||
$html .= "<p>"; | ||
$html .= _("In addition to simple Allow/Deny rules, you can also deny access to a route and then redirect the call, allowing a different outbound route to match the call."); | ||
$html .= "</p>"; | ||
$html .= "<p>"; | ||
$html .= _("For example, if you wanted to stop an extension from using Route A, selecting <b>Deny</b> would preclude the possibility of trying another route. Instead you could select <b>Redirect with prefix</b> and set the <b>Redirect prefix</b> to <code>9999</code>; assuming you've created Route B with a prefix match of <code>9999</code> and not set a deny rule on it, the call can proceed."); | ||
$html .= "</p>"; | ||
$html .= "<p>"; | ||
$html .= _("In addition, if you are denying access to a particular route and wish to use something other than the default destination, you can select <b>Redirect with prefix</b>, and create a <b>Miscellaneous Application</b> that matches the specified <b>Redirect prefix</b>. Using the previous example, a <b>Miscellaneous Application</b> with a feature code of <code>_9999x.</code> could be called if it existed on the system."); | ||
$html .= "</p>"; | ||
|
||
$html .= heading(_("Bulk Changes"), 3); | ||
$html .= "<p>"; | ||
$html .= _("Select a route and select <b>Allow</b> or <b>Deny</b> to set permissions for the entered extensions. If you enter a <b>Redirect prefix</b> and click <b>Redirect with prefix</b>, the route will automatically be set to DENIED."); | ||
$html .= _("You can enter one or more extensions or ranges separated by commas; a range is a start and end extension separated by a hyphen. For example <code>123,125,200-300</code> will select extensions 123 and 125 as well as any extensions between 200 and 300."); | ||
$html .= "</p>"; | ||
$html .= "<p>"; | ||
$html .= _("Note that these changes take effect <em>immediately</em> and do not require a reload."); | ||
$html .= "</p>"; | ||
|
||
$routes = $rp->getRoutes(); | ||
|
||
$table = new CI_Table; | ||
$table->set_heading(array( | ||
_("Route"), | ||
_("Extensions"), | ||
_("Permissions"), | ||
_("Destination"), | ||
_("Redirect Prefix"), | ||
)); | ||
|
||
foreach ($routes as $r) { | ||
$table->add_row(array( | ||
array("data"=>$r, "id"=>"td_$r"), | ||
form_input("range_$r", _("All"), "size=\"10\""), | ||
"<span class=\"radioset\">" . | ||
form_radio("permission_$r", "", true, "id=\"permission_{$r}_SKIP\"") . | ||
form_label(_("No change"), "permission_{$r}_SKIP") . | ||
form_radio("permission_$r", "YES", false, "id=\"permission_{$r}_YES\"") . | ||
form_label(_("Allow"), "permission_{$r}_YES") . | ||
form_radio("permission_$r", "NO", false, "id=\"permission_{$r}_NO\"") . | ||
form_label(_("Deny"), "permission_{$r}_NO") . | ||
form_radio("permission_$r", "REDIRECT", false, "id=\"permission_{$r}_REDIRECT\"") . | ||
form_label(_("Redirect w/prefix"), "permission_{$r}_REDIRECT") . | ||
"</span>", | ||
drawselects("", "_$r", false, false, _("Use default")), | ||
form_input("prefix_$r", "", sprintf("placeholder=\"%s\" size=\"10\"", _("Prefix"))), | ||
)); | ||
} | ||
$table->add_row(array( | ||
form_submit("update_permissions", _("Save Changes")) | ||
)); | ||
$html .= form_open("$_SERVER[PHP_SELF]?display=$module"); | ||
$html .= $table->generate(); | ||
$html .= form_close(); | ||
|
||
$html .= "<p> </p>"; | ||
|
||
$html .= form_open("$_SERVER[PHP_SELF]?display=$module"); | ||
$html .= heading(_("Default Destination if Denied"), 3); | ||
$html .= "<p>"; | ||
$html .= _("Select the destination for calls when they are denied without specifying a destination."); | ||
$html .= "</p>"; | ||
$html .= drawselects($rp->getDefaultDest(), "faildest"); | ||
$html .= "<br/>"; | ||
$html .= form_submit("update_default", "Change Destination"); | ||
$html .= form_close(); | ||
|
||
echo $html; |
Oops, something went wrong.