Misc: Implement maximum limits on multiple apps.
This commit is contained in:
@@ -414,4 +414,9 @@
|
||||
$text['button-delete']['pt-pt'] = "Remover";
|
||||
$text['button-delete']['fr-fr'] = "Supprimer";
|
||||
|
||||
?>
|
||||
$text['message-maximum_ring_groups']['en-us'] = "Maximum Ring Groups:";
|
||||
$text['message-maximum_ring_groups']['es-cl'] = "Grupos máximos Anillo Animales:";
|
||||
$text['message-maximum_ring_groups']['pt-pt'] = "Grupos Máximo Anel de Estimação:";
|
||||
$text['message-maximum_ring_groups']['fr-fr'] = "Groupes de Sonneries Maximum Autorisé:";
|
||||
|
||||
?>
|
||||
@@ -67,6 +67,26 @@ else {
|
||||
$action = "add";
|
||||
}
|
||||
|
||||
//get total ring group count from the database, check limit, if defined
|
||||
if ($action == 'add') {
|
||||
if ($_SESSION['limit']['ring_groups']['numeric'] != '') {
|
||||
$sql = "select count(*) as num_rows from v_ring_groups 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_ring_groups = $row['num_rows'];
|
||||
}
|
||||
unset($prep_statement, $row);
|
||||
if ($total_ring_groups >= $_SESSION['limit']['ring_groups']['numeric']) {
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
$_SESSION['message'] = $text['message-maximum_ring_groups'].' '.$_SESSION['limit']['ring_groups']['numeric'];
|
||||
header('Location: ring_groups.php');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get http post variables and set them to php variables
|
||||
if (count($_POST) > 0) {
|
||||
//set variables from http values
|
||||
|
||||
@@ -59,9 +59,17 @@ require_once "resources/paging.php";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) as num_rows from v_ring_groups ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
//get total ring group count from the database
|
||||
$sql = "select count(*) as num_rows from v_ring_groups 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_ring_groups = $row['num_rows'];
|
||||
}
|
||||
unset($prep_statement, $row);
|
||||
|
||||
//prepare to page the results (reuse $sql from above)
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
@@ -114,7 +122,9 @@ require_once "resources/paging.php";
|
||||
echo th_order_by('ring_group_description', $text['header-description'], $order_by, $order);
|
||||
echo "<td class='list_control_icons'>";
|
||||
if (permission_exists('ring_group_add')) {
|
||||
echo "<a href='ring_group_edit.php' alt='add'>$v_link_label_add</a>";
|
||||
if ($_SESSION['limit']['ring_groups']['numeric'] == '' || ($_SESSION['limit']['ring_groups']['numeric'] != '' && $total_ring_groups < $_SESSION['limit']['ring_groups']['numeric'])) {
|
||||
echo "<a href='ring_group_edit.php' alt='add'>".$v_link_label_add."</a>";
|
||||
}
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
@@ -160,7 +170,9 @@ require_once "resources/paging.php";
|
||||
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('ring_group_add')) {
|
||||
echo "<a href='ring_group_edit.php' alt='add'>$v_link_label_add</a>";
|
||||
if ($_SESSION['limit']['ring_groups']['numeric'] == '' || ($_SESSION['limit']['ring_groups']['numeric'] != '' && $total_ring_groups < $_SESSION['limit']['ring_groups']['numeric'])) {
|
||||
echo "<a href='ring_group_edit.php' alt='add'>".$v_link_label_add."</a>";
|
||||
}
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
Reference in New Issue
Block a user