DEV: Незначительные изменения
This commit is contained in:
parent
c4971c711f
commit
4ad067cc3c
6 changed files with 43 additions and 62 deletions
|
@ -51,22 +51,18 @@ class SettingController extends Controller
|
|||
|
||||
function edit()
|
||||
{
|
||||
$name = Request::getPost('name');
|
||||
$about = Request::getPost('about');
|
||||
$public_email = Request::getPost('public_email');
|
||||
$template = Request::getPost('template');
|
||||
$lang = Request::getPost('lang');
|
||||
$data = Request::getPost();
|
||||
|
||||
if (!Validation::length($name, 0, 11)) {
|
||||
if (!Validation::length($data['name'], 0, 11)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('msg.string_length', ['name' => '«' . __('msg.name') . '»'])]);
|
||||
}
|
||||
|
||||
if (!Validation::length($about, 0, 255)) {
|
||||
if (!Validation::length($data['about'], 0, 255)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('msg.string_length', ['name' => '«' . __('msg.about') . '»'])]);
|
||||
}
|
||||
|
||||
if ($public_email) {
|
||||
if (!filter_var($public_email, FILTER_VALIDATE_EMAIL)) {
|
||||
if ($data['public_email']) {
|
||||
if (!filter_var($data['public_email'], FILTER_VALIDATE_EMAIL)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('msg.email_correctness')]);
|
||||
}
|
||||
}
|
||||
|
@ -78,20 +74,20 @@ class SettingController extends Controller
|
|||
'id' => $this->user['id'],
|
||||
'email' => $user['email'],
|
||||
'login' => $user['login'],
|
||||
'name' => $name,
|
||||
'name' => $data['name'],
|
||||
'activated' => $user['activated'],
|
||||
'limiting_mode' => $user['limiting_mode'],
|
||||
'scroll' => Request::getPostInt('scroll'),
|
||||
'trust_level' => $user['trust_level'],
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'color' => Request::getPostString('color', '#339900'),
|
||||
'about' => $about,
|
||||
'template' => $template ?? 'default',
|
||||
'lang' => $lang ?? 'ru',
|
||||
'about' => $data['about'],
|
||||
'template' => $data['template'] ?? 'default',
|
||||
'lang' => $data['lang'] ?? 'ru',
|
||||
'whisper' => $user['whisper'] ?? '',
|
||||
'website' => Request::getPostString('website', null),
|
||||
'location' => Request::getPostString('location', null),
|
||||
'public_email' => $public_email ?? null,
|
||||
'public_email' => $data['public_email'] ?? null,
|
||||
'skype' => Request::getPostString('skype', null),
|
||||
'telegram' => Request::getPostString('telegram', null),
|
||||
'vk' => Request::getPostString('vk', null),
|
||||
|
|
|
@ -109,40 +109,35 @@ class Users extends Controller
|
|||
// Редактировать участника
|
||||
public function change()
|
||||
{
|
||||
$login = Request::getPost('login');
|
||||
$user_id = Request::getInt('id');
|
||||
$email = Request::getPost('email');
|
||||
$user_whisper = Request::getPost('whisper');
|
||||
$user_name = Request::getPost('name');
|
||||
$trust_level = Request::getPostInt('trust_level');
|
||||
$data = Request::getPost();
|
||||
|
||||
if (!$user = UserModel::getUser($user_id, 'id')) {
|
||||
if (!$user = UserModel::getUser($data['user_id'], 'id')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Validation::length($login, 3, 11)) {
|
||||
if (!Validation::length($data['login'], 3, 11)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('msg.string_length', ['name' => '«' . __('msg.login') . '»'])]);
|
||||
}
|
||||
|
||||
if ($email) {
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
if ($data['email']) {
|
||||
if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('msg.email_correctness')]);
|
||||
}
|
||||
}
|
||||
|
||||
SettingModel::edit(
|
||||
[
|
||||
'id' => $user_id,
|
||||
'login' => $login,
|
||||
'email' => $email,
|
||||
'whisper' => $user_whisper ?? '',
|
||||
'name' => $user_name ?? '',
|
||||
'id' => $data['user_id'],
|
||||
'login' => $data['login'],
|
||||
'email' => $data['email'],
|
||||
'whisper' => $data['whisper'],
|
||||
'name' => $data['user_name'],
|
||||
'activated' => Request::getPostInt('activated'),
|
||||
'limiting_mode' => Request::getPostInt('limiting_mode'),
|
||||
'template' => $user['template'] ?? 'default',
|
||||
'lang' => $user['lang'] ?? 'ru',
|
||||
'scroll' => $user['scroll'] ?? 0,
|
||||
'trust_level' => Request::getPostInt('trust_level'),
|
||||
'trust_level' => $data['trust_level'] ?? 1,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'color' => Request::getPostString('color', '#339900'),
|
||||
'about' => Request::getPost('about', null),
|
||||
|
|
|
@ -227,6 +227,7 @@ $setting = [
|
|||
|
||||
<fieldset>
|
||||
<input type="hidden" name="nickname" id="nickname" value="">
|
||||
<input type="hidden" name="user_id" value="<?= $data['user']['id']; ?>">
|
||||
<?= Html::sumbit(__('app.edit')); ?>
|
||||
</fieldset>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Modules\Catalog\App;
|
|||
use Hleb\Constructor\Handlers\Request;
|
||||
use Modules\Catalog\App\Models\WebModel;
|
||||
use App\Models\{SubscriptionModel, ActionModel, FacetModel, NotificationModel};
|
||||
use UserData, Meta;
|
||||
use UserData, Meta, Validation;
|
||||
|
||||
class Add
|
||||
{
|
||||
|
|
|
@ -29,7 +29,6 @@ class Edit
|
|||
redirect(url('web'));
|
||||
}
|
||||
|
||||
|
||||
Request::getResources()->addBottomStyles('/assets/js/tag/tagify.css');
|
||||
Request::getResources()->addBottomScript('/assets/js/tag/tagify.min.js');
|
||||
Request::getResources()->addBottomScript('/assets/js/admin.js');
|
||||
|
@ -63,34 +62,24 @@ class Edit
|
|||
return true;
|
||||
}
|
||||
|
||||
$item_id = Request::getPostInt('item_id');
|
||||
if (!$item = WebModel::getItemId($item_id)) {
|
||||
$data = Request::getPost();
|
||||
|
||||
//$item_id = Request::getPostInt('item_id');
|
||||
if (!$item = WebModel::getItemId($data['item_id'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$item_url = Request::getPost('url');
|
||||
$item_title = Request::getPost('title');
|
||||
$item_content = Request::getPost('content');
|
||||
$item_published = Request::getPostInt('published');
|
||||
$item_status_url = Request::getPostInt('status');
|
||||
// soft
|
||||
$item_is_soft = Request::getPostInt('soft');
|
||||
$item_title_soft = Request::getPost('title_soft');
|
||||
$item_content_soft = Request::getPost('content_soft');
|
||||
$item_is_github = Request::getPostInt('github');
|
||||
$item_github_url = Request::getPost('github_url');
|
||||
|
||||
// Check the length
|
||||
// Проверим длину
|
||||
if (!Validation::length($item_title, 14, 250)) {
|
||||
if (!Validation::length($data['title'], 14, 250)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('web.string_length', ['name' => '«' . __('web.title') . '»'])]);
|
||||
}
|
||||
|
||||
if (!Validation::length($item_content, 24, 1500)) {
|
||||
if (!Validation::length($data['content'], 24, 1500)) {
|
||||
return json_encode(['error' => 'error', 'text' => __('web.string_length', ['name' => '«' . __('web.description') . '»'])]);
|
||||
}
|
||||
|
||||
if (filter_var($item_url, FILTER_VALIDATE_URL) === false) {
|
||||
if (filter_var($data['url'], FILTER_VALIDATE_URL) === false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -107,7 +96,7 @@ class Edit
|
|||
|
||||
// If not staff, then we make the site inactive
|
||||
// Если не персонал, то делаем сайт не активным
|
||||
$published = UserData::checkAdmin() ? $item_published : 0;
|
||||
$published = UserData::checkAdmin() ? $data['published'] : 0;
|
||||
|
||||
// If the staff, then we save the author of the site
|
||||
// Если персонал, то сохраняем автора сайта
|
||||
|
@ -126,20 +115,20 @@ class Edit
|
|||
WebModel::edit(
|
||||
[
|
||||
'item_id' => $item['item_id'],
|
||||
'item_url' => $item_url,
|
||||
'item_title' => $item_title,
|
||||
'item_content' => $item_content,
|
||||
'item_title_soft' => $item_title_soft ?? '',
|
||||
'item_content_soft' => $item_content_soft ?? '',
|
||||
'item_url' => $data['url'],
|
||||
'item_title' => $data['title'],
|
||||
'item_content' => $data['content'],
|
||||
'item_title_soft' => $data['title_soft'] ?? '',
|
||||
'item_content_soft' => $data['content_soft'] ?? '',
|
||||
'item_published' => $published,
|
||||
'item_close_replies' => Request::getPostInt('close_replies'),
|
||||
'item_close_replies' => (int)($data['close_replies'] ?? 0),
|
||||
'item_user_id' => $owner_uid ?? 1,
|
||||
'item_type_url' => 0,
|
||||
'item_status_url' => $item_status_url,
|
||||
'item_is_soft' => $item_is_soft,
|
||||
'item_is_github' => $item_is_github,
|
||||
'item_status_url' => $data['status'] ?? 404,
|
||||
'item_is_soft' => (int)($data['soft'] ?? 0),
|
||||
'item_is_github' => (int)($data['github'] ?? 0),
|
||||
'item_post_related' => $post_related ?? '',
|
||||
'item_github_url' => $item_github_url ?? '',
|
||||
'item_github_url' => $data['item_github_url'] ?? '',
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<?php if (UserData::getRegType(config('trust-levels.tl_add_site'))) : ?>
|
||||
<?php if (config('trust-levels.count_add_site') > $data['user_count_site']) : ?>
|
||||
<?php if (UserData::getRegType(config('trust-levels.tl_add_item'))) : ?>
|
||||
<?php if (config('trust-levels.count_add_item') > $data['user_count_site']) : ?>
|
||||
<li>
|
||||
<a href="<?= url('web.add'); ?>">
|
||||
<i class="bi-plus-lg"></i> <?= __('web.add_website'); ?>
|
||||
|
|
Loading…
Reference in a new issue