1
0

Большое обновление

1. Создание личных проектов
2. Управление командой
3. Приглашение участников
4. Уведомления

и многое другое...
This commit is contained in:
2026-01-18 20:17:02 +07:00
parent 250eac70a7
commit 190b4d0a5e
51 changed files with 6179 additions and 426 deletions

View File

@@ -16,27 +16,69 @@ class Account extends BaseEntity {
// Валидация данных при создании аккаунта
protected function validate() {
$this->error_message = [];
static::$error_message = [];
// === ИМЯ ===
if (!$this->name) {
$this->addError('name', 'Имя не может быть пустым');
} elseif (mb_strlen($this->name) < 2) {
$this->addError('name', 'Имя слишком короткое');
} elseif (mb_strlen($this->name) > 50) {
$this->addError('name', 'Имя слишком длинное');
} elseif (!preg_match('/^[\p{L}\s\-]+$/u', $this->name)) {
// Только буквы (любого языка), пробелы и дефис
$this->addError('name', 'Имя может содержать только буквы');
}
// === ЛОГИН ===
if (!$this->username) {
$this->addError('username', 'Логин не может быть пустым');
} elseif (strlen($this->username) < 3) {
$this->addError('username', 'Логин минимум 3 символа');
} elseif (strlen($this->username) > 32) {
$this->addError('username', 'Логин максимум 32 символа');
} elseif (!preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $this->username)) {
// Начинается с буквы, далее a-z, 0-9, _
$this->addError('username', 'Логин: латиница, цифры и _ (начинается с буквы)');
} elseif (Database::get($this->db_name, ['id'], ['username' => $this->username])) {
$this->addError('username', 'Этот логин уже занят');
}
if ($this->username && Database::get($this->db_name, ['id'], ['username' => $this->username])) {
$this->addError('username', 'Пользователь с таким логином уже существует');
}
// === ПАРОЛЬ ===
if (!$this->password) {
$this->addError('password', 'Пароль не может быть пустым');
} elseif (strlen($this->password) < 6) {
$this->addError('password', 'Пароль минимум 6 символов');
} elseif (strlen($this->password) > 100) {
$this->addError('password', 'Пароль слишком длинный');
}
return $this->getErrors();
}
// Очистка данных перед сохранением
protected function sanitize() {
// Имя: убираем лишние пробелы
$this->name = trim(preg_replace('/\s+/', ' ', $this->name));
// Логин: только допустимые символы (регистр сохраняется)
$this->username = preg_replace('/[^a-zA-Z0-9_]/', '', $this->username);
// Telegram: убираем @, только допустимые символы
if ($this->telegram) {
$this->telegram = str_replace('@', '', $this->telegram);
$this->telegram = preg_replace('/[^a-zA-Z0-9_]/', '', $this->telegram);
$this->telegram = strtolower($this->telegram);
$this->telegram = $this->telegram ?: null;
}
}
// Создание нового аккаунта
public function create() {
// Очищаем данные
$this->sanitize();
// Валидация данных
if ($errors = $this->validate()) {
return $errors;
@@ -133,6 +175,7 @@ class Account extends BaseEntity {
// Получаем данные пользователя
$user = Database::get($this->db_name, [
'id',
'id_department',
'name',
'username',