Hide domain from list for user without permission

Use session domain_uuid by default when saving a new stream.
This commit is contained in:
FusionPBX
2022-12-22 00:18:43 -07:00
committed by GitHub
parent ba8adb9df6
commit 8c749a2d02
+37 -29
View File
@@ -98,11 +98,6 @@
return; return;
} }
//set the domain_uuid
if (!permission_exists('stream_all')) {
$domain_uuid = $_SESSION["domain_uuid"];
}
//add the stream_uuid //add the stream_uuid
if (strlen($_POST["stream_uuid"]) == 0) { if (strlen($_POST["stream_uuid"]) == 0) {
$stream_uuid = uuid(); $stream_uuid = uuid();
@@ -110,7 +105,12 @@
//prepare the array //prepare the array
$array['streams'][0]['stream_uuid'] = $stream_uuid; $array['streams'][0]['stream_uuid'] = $stream_uuid;
$array['streams'][0]['domain_uuid'] = $domain_uuid; if (permission_exists('stream_all')) {
$array['streams'][0]['domain_uuid'] = $domain_uuid;
}
elseif ($action == 'add') {
$array['streams'][0]['domain_uuid'] = $_SESSION["domain_uuid"];
}
$array['streams'][0]['stream_name'] = $stream_name; $array['streams'][0]['stream_name'] = $stream_name;
$array['streams'][0]['stream_location'] = $stream_location; $array['streams'][0]['stream_location'] = $stream_location;
$array['streams'][0]['stream_enabled'] = $stream_enabled; $array['streams'][0]['stream_enabled'] = $stream_enabled;
@@ -131,7 +131,7 @@
if ($action == "update") { if ($action == "update") {
$_SESSION["message"] = $text['message-update']; $_SESSION["message"] = $text['message-update'];
} }
header('Location: stream_edit.php?id='.$stream_uuid); header('Location: stream_edit.php?id='.urlencode($stream_uuid));
return; return;
} }
} }
@@ -154,6 +154,12 @@
unset($sql, $parameters, $row); unset($sql, $parameters, $row);
} }
//need stream_all permission to edit a global stream
if (!permission_exists('stream_all') && $domain_uuid == null) {
header('Location: streams.php');
return;
}
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
@@ -222,31 +228,33 @@
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; if (permission_exists('stream_all')) {
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<tr>\n";
echo " ".$text['label-domain_uuid']."\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo "</td>\n"; echo " ".$text['label-domain_uuid']."\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n"; echo "</td>\n";
echo " <select class='formfld' name='domain_uuid'>\n"; echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (strlen($domain_uuid) == 0) { echo " <select class='formfld' name='domain_uuid'>\n";
echo " <option value='' selected='selected'>".$text['label-global']."</option>\n"; if (strlen($domain_uuid) == 0) {
} echo " <option value='' selected='selected'>".$text['label-global']."</option>\n";
else {
echo " <option value=''>".$text['label-global']."</option>\n";
}
foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
} }
else { else {
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n"; echo " <option value=''>".$text['label-global']."</option>\n";
} }
foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
}
else {
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
}
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_uuid']."\n";
echo "</td>\n";
echo "</tr>\n";
} }
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_uuid']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
@@ -270,4 +278,4 @@
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>