Misc: Implement maximum limits on multiple apps.

This commit is contained in:
Nate Jones
2015-03-22 08:17:04 +00:00
parent 0e67783602
commit fcb53fd7f9
24 changed files with 1173 additions and 865 deletions
+6 -1
View File
@@ -429,4 +429,9 @@
$text['message-required']['pt-pt'] = "Por favor indique: ";
$text['message-required']['fr-fr'] = "Merci d'indiquer: ";
?>
$text['message-maximum_gateways']['en-us'] = "Maximum Gateways:";
$text['message-maximum_gateways']['es-cl'] = "Gateways Máximo Permitido:";
$text['message-maximum_gateways']['pt-pt'] = "Gateways Máximo Permitido:";
$text['message-maximum_gateways']['fr-fr'] = "Passerelles Maximum Autorisé:";
?>
+20
View File
@@ -47,6 +47,26 @@ else {
$action = "add";
}
//get total gateway count from the database, check limit, if defined
if ($action == 'add') {
if ($_SESSION['limit']['gateways']['numeric'] != '') {
$sql = "select count(*) as num_rows from v_gateways where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$total_gateways = $row['num_rows'];
}
unset($prep_statement, $row);
if ($total_gateways >= $_SESSION['limit']['gateways']['numeric']) {
$_SESSION['message_mood'] = 'negative';
$_SESSION['message'] = $text['message-maximum_gateways'].' '.$_SESSION['limit']['gateways']['numeric'];
header('Location: gateways.php');
return;
}
}
}
//get http post variables and set them to php variables
if (count($_POST) > 0) {
$domain_uuid = check_str($_POST["domain_uuid"]);
+16 -2
View File
@@ -100,6 +100,16 @@ else {
echo "</table>\n";
echo "<br />\n";
//get total gateway count from the database
$sql = "select count(*) as num_rows from v_gateways where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$total_gateways = $row['num_rows'];
}
unset($sql, $prep_statement, $row);
//prepare to page the results
$sql = "select count(*) as num_rows from v_gateways ";
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
@@ -153,7 +163,9 @@ else {
echo th_order_by('description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('gateway_add')) {
echo "<a href='gateway_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
if ($_SESSION['limit']['gateways']['numeric'] == '' || ($_SESSION['limit']['gateways']['numeric'] != '' && $total_gateways < $_SESSION['limit']['gateways']['numeric'])) {
echo "<a href='gateway_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo "</td>\n";
echo "</tr>\n";
@@ -229,7 +241,9 @@ else {
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('gateway_add')) {
echo "<a href='gateway_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
if ($_SESSION['limit']['gateways']['numeric'] == '' || ($_SESSION['limit']['gateways']['numeric'] != '' && $total_gateways < $_SESSION['limit']['gateways']['numeric'])) {
echo "<a href='gateway_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
else {
echo "&nbsp;";