mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Misc: Implement maximum limits on multiple apps.
This commit is contained in:
@@ -422,5 +422,9 @@
|
||||
$text['message-cannot_delete_own_account']['pt-pt'] = "Você não pode excluir a sua própria conta de usuário.\\n\\nIdentifique-se como um usuário diferente, em seguida, tente novamente.";
|
||||
$text['message-cannot_delete_own_account']['fr-fr'] = "Vous ne pouvez pas supprimer votre propre compte utilisateur.\\n\\nSe il vous plaît vous identifier en tant qu'utilisateur différent, puis réessayez.";
|
||||
|
||||
$text['message-maximum_users']['en-us'] = "Maximum Users:";
|
||||
$text['message-maximum_users']['es-cl'] = "Usuarios Máximo Permitido:";
|
||||
$text['message-maximum_users']['pt-pt'] = "Usuários Máximo Permitido:";
|
||||
$text['message-maximum_users']['fr-fr'] = "Utilisateurs Maximale Autorisée:";
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -40,6 +40,24 @@ require_once "resources/require.php";
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get total user count from the database, check limit, if defined
|
||||
if ($_SESSION['limit']['users']['numeric'] != '') {
|
||||
$sql = "select count(*) as num_rows from v_users 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_users = $row['num_rows'];
|
||||
}
|
||||
unset($prep_statement, $row);
|
||||
if ($total_users >= $_SESSION['limit']['users']['numeric']) {
|
||||
$_SESSION['message_mood'] = 'negative';
|
||||
$_SESSION['message'] = $text['message-maximum_users'].' '.$_SESSION['limit']['users']['numeric']
|
||||
header('Location: index.php');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//get the values from http and set as variables
|
||||
$username = check_str($_POST["username"]);
|
||||
$password = check_str($_POST["password"]);
|
||||
|
||||
@@ -90,9 +90,17 @@ $field_value = $_REQUEST["field_value"];
|
||||
}
|
||||
unset ($sql, $prep_statement);
|
||||
|
||||
//get the users from the database
|
||||
$sql = "select count(*) as num_rows from v_users ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
//get total user count from the database
|
||||
$sql = "select count(*) as num_rows from v_users 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_users = $row['num_rows'];
|
||||
}
|
||||
unset($prep_statement, $row);
|
||||
|
||||
//get the users from the database (reuse $sql from above)
|
||||
if (strlen($field_name) > 0 && strlen($field_value) > 0) {
|
||||
$sql .= "and $field_name = '$field_value' ";
|
||||
}
|
||||
@@ -148,7 +156,9 @@ $field_value = $_REQUEST["field_value"];
|
||||
echo "<th>".$text['label-enabled']."</th>\n";
|
||||
echo "<td class='list_control_icons'>";
|
||||
if (permission_exists('user_add')) {
|
||||
echo "<a href='signup.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
if ($_SESSION['limit']['users']['numeric'] == '' || ($_SESSION['limit']['users']['numeric'] != '' && $total_users < $_SESSION['limit']['users']['numeric'])) {
|
||||
echo "<a href='signup.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
||||
}
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
@@ -209,7 +219,9 @@ $field_value = $_REQUEST["field_value"];
|
||||
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('user_add')) {
|
||||
echo "<a href='signup.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
if ($_SESSION['limit']['users']['numeric'] == '' || ($_SESSION['limit']['users']['numeric'] != '' && $total_users < $_SESSION['limit']['users']['numeric'])) {
|
||||
echo "<a href='signup.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
||||
}
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
Reference in New Issue
Block a user