1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 00:06:14 +01:00
openstamanager/modules/utenti/validation.php

34 lines
805 B
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
use Models\User;
$name = filter('name');
$value = filter('value');
switch ($name) {
case 'username':
$disponibile = User::where([
['username', $value],
2019-07-25 17:20:24 +02:00
['id', '<>', $id_record],
])->count() == 0;
2019-10-03 12:09:14 +02:00
$message = $disponibile ? tr("L'username è disponbile") : tr("L'username è già in uso");
$result = $disponibile;
// Lunghezza minima del nome utente (username)
$min_length_username = 4;
if (strlen($value) < $min_length_username) {
$message .= '. '.tr("Lunghezza dell'username non sufficiente").'.';
$result = false;
}
$response = [
'result' => $result,
'message' => $message,
];
break;
}