ADD: Возможность запретить ответы
+ смена владельца.
This commit is contained in:
parent
464b13c7e1
commit
2b8bd53793
15 changed files with 109 additions and 45 deletions
|
@ -98,14 +98,15 @@ class EditPostController extends MainController
|
|||
$redirect = getUrlByName('content.edit', ['type' => 'page', 'id' => $post_id]);
|
||||
}
|
||||
|
||||
// Если есть смена post_user_id и это TL5
|
||||
$user_new = Request::getPost('user_id');
|
||||
$post_user_new = json_decode($user_new, true);
|
||||
// If there is a change in post_user_id (owner) and who changes staff
|
||||
// Если есть смена post_user_id (владельца) и кто меняет персонал
|
||||
$post_user_id = $post['post_user_id'];
|
||||
if ($post['post_user_id'] != $post_user_new[0]['id']) {
|
||||
if (UserData::checkAdmin()) {
|
||||
$post_user_id = $post_user_new[0]['id'];
|
||||
}
|
||||
if (UserData::checkAdmin()) {
|
||||
$user_new = Request::getPost('user_id');
|
||||
$post_user_new = json_decode($user_new, true);
|
||||
if ($post['post_user_id'] != $post_user_new[0]['id']) {
|
||||
$post_user_id = $post_user_new[0]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
Validation::Length($post_title, Translate::get('title'), '6', '250', $redirect);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* Settings for the catalog
|
||||
* Настройки для каталога
|
||||
*/
|
||||
$ch = Translate::get('characters');
|
||||
$fe = Translate::get('for example');
|
||||
|
||||
return [
|
||||
// Fields for adding and editing a site in the catalog
|
||||
// Поля для добавления и редактирования сайта в каталоге
|
||||
|
@ -12,12 +11,12 @@ return [
|
|||
[
|
||||
'title' => Translate::get('title'),
|
||||
'tl' => 2,
|
||||
'arr' => ['min' => 14, 'max' => 250, 'required' => true, 'help' => '> 14 ' . $ch . '. ' . $fe . ': «Agouti» — сообщество'],
|
||||
'arr' => ['min' => 14, 'max' => 250, 'required' => true],
|
||||
'name' => 'title'
|
||||
], [
|
||||
'title' => 'URL',
|
||||
'tl' => 2,
|
||||
'arr' => ['required' => true, 'help' => $fe . ': https://google.ru'],
|
||||
'arr' => ['required' => true],
|
||||
'name' => 'url',
|
||||
], [
|
||||
'title' => Translate::get('status'),
|
||||
|
@ -27,8 +26,13 @@ return [
|
|||
], [
|
||||
'title' => Translate::get('description'),
|
||||
'tl' => 2,
|
||||
'arr' => ['type' => 'textarea', 'required' => true, 'help' => '> 25 ' . $ch],
|
||||
'arr' => ['type' => 'textarea', 'required' => true],
|
||||
'name' => 'content',
|
||||
], [
|
||||
'title' => Translate::get('deny.replies'),
|
||||
'tl' => 2,
|
||||
'arr' => ['options' => ['0' => Translate::get('no'), '1' => Translate::get('yes')], 'type' => 'select'],
|
||||
'name' => 'close_replies',
|
||||
], [
|
||||
'title' => Translate::get('posted'),
|
||||
'tl' => UserData::REGISTERED_ADMIN,
|
||||
|
@ -37,7 +41,7 @@ return [
|
|||
], [
|
||||
'title' => Translate::get('there.program'),
|
||||
'tl' => UserData::REGISTERED_ADMIN,
|
||||
'arr' => ['options' => ['0' => Translate::get('no'), '1' => Translate::get('yes')], 'type' => 'select', 'before_html' => '<h3>Soft</h3>'],
|
||||
'arr' => ['options' => ['0' => Translate::get('no'), '1' => Translate::get('yes')], 'type' => 'select', 'before_html' => '<h2>Soft</h2>'],
|
||||
'name' => 'soft',
|
||||
], [
|
||||
'title' => Translate::get('hosted.github'),
|
||||
|
|
3
dev.sql
3
dev.sql
|
@ -1379,4 +1379,5 @@ ALTER TABLE `votes_item`
|
|||
ALTER TABLE `votes_post`
|
||||
MODIFY `votes_post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
ALTER TABLE `items` ADD `item_focus_count` INT(11) NULL DEFAULT '0' AFTER `item_post_related`;
|
||||
ALTER TABLE `items` ADD `item_focus_count` INT(11) NULL DEFAULT '0' AFTER `item_post_related`;
|
||||
ALTER TABLE `items` ADD `item_close_replies` TINYINT(1) NOT NULL DEFAULT '0' AFTER `item_focus_count`;
|
|
@ -80,18 +80,19 @@ class Add
|
|||
|
||||
$item_last = WebModel::add(
|
||||
[
|
||||
'item_url' => $url,
|
||||
'item_domain' => $basic_host,
|
||||
'item_title' => Request::getPost('title'),
|
||||
'item_content' => $content,
|
||||
'item_published' => $published,
|
||||
'item_user_id' => $this->user['id'],
|
||||
'item_type_url' => 0,
|
||||
'item_status_url' => 200,
|
||||
'item_is_soft' => 0,
|
||||
'item_is_github' => 0,
|
||||
'item_votes' => 0,
|
||||
'item_count' => 1,
|
||||
'item_url' => $url,
|
||||
'item_domain' => $basic_host,
|
||||
'item_title' => Request::getPost('title'),
|
||||
'item_content' => $content,
|
||||
'item_published' => $published,
|
||||
'item_user_id' => $this->user['id'],
|
||||
'item_close_replies' => Request::getPostInt('close_replies'),
|
||||
'item_type_url' => 0,
|
||||
'item_status_url' => 200,
|
||||
'item_is_soft' => 0,
|
||||
'item_is_github' => 0,
|
||||
'item_votes' => 0,
|
||||
'item_count' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Modules\Catalog\App;
|
|||
use Hleb\Constructor\Handlers\Request;
|
||||
use Modules\Catalog\App\Models\WebModel;
|
||||
use App\Models\{FacetModel, PostModel, NotificationModel};
|
||||
use App\Models\User\UserModel;
|
||||
use Validation, Translate, UserData, Meta, Html;
|
||||
|
||||
class Edit
|
||||
|
@ -46,6 +47,7 @@ class Edit
|
|||
'domain' => $domain,
|
||||
'sheet' => 'domains',
|
||||
'type' => 'web.edit',
|
||||
'user' => UserModel::getUser($domain['item_user_id'], 'id'),
|
||||
'category_arr' => WebModel::getItemTopic($domain['item_id']),
|
||||
'post_arr' => $item_post_related,
|
||||
]
|
||||
|
@ -106,22 +108,33 @@ class Edit
|
|||
// Если персонал, то сохраняем автора сайта
|
||||
$uid = $this->user['trust_level'] == UserData::REGISTERED_ADMIN ? $item['item_user_id'] : $this->user['id'];
|
||||
|
||||
// If there is a change in item_user_id (owner) and who changes staff
|
||||
// Если есть смена item_user_id (владельца) и кто меняет персонал
|
||||
if (UserData::checkAdmin()) {
|
||||
$user_new = Request::getPost('user_id');
|
||||
$item_user_new = json_decode($user_new, true);
|
||||
if ($item['item_user_id'] != $item_user_new[0]['id']) {
|
||||
$uid = $item_user_new[0]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
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_published' => $published,
|
||||
'item_user_id' => $uid,
|
||||
'item_type_url' => 0,
|
||||
'item_status_url' => $item_status_url,
|
||||
'item_is_soft' => $item_is_soft,
|
||||
'item_is_github' => $item_is_github,
|
||||
'item_post_related' => $post_related ?? '',
|
||||
'item_github_url' => $item_github_url ?? '',
|
||||
'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_published' => $published,
|
||||
'item_close_replies' => Request::getPostInt('close_replies'),
|
||||
'item_user_id' => $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_post_related' => $post_related ?? '',
|
||||
'item_github_url' => $item_github_url ?? '',
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ $data = [
|
|||
'no.bookmarks.sites' => 'Noch keine Lesezeichen',
|
||||
'user.sites.info' => 'Liste der von mir hinzugefügten Websites',
|
||||
'moderation' => 'Mäßigung',
|
||||
|
||||
'deny.replies' => 'Antworten ablehnen?',
|
||||
'discussions.closed' => 'Diskussionen über die Website sind verboten. Der Autor oder Mitarbeiter hat die Diskussion geschlossen.',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">Titelformat:</i><br> «LibArea» — gemeinschaft<br><br><i class="gray-600">Beschreibung (ohne Werbung):</i><br> ...was ist auf der Website?<i>',
|
||||
];
|
||||
|
|
|
@ -55,6 +55,9 @@ $data = [
|
|||
'user.sites.info' => 'Lista site-urilor adăugate de mine',
|
||||
'moderation' => 'Moderation',
|
||||
|
||||
'deny.replies' => 'Deny replies?',
|
||||
'discussions.closed' => 'Discussion of the site is prohibited. The author or staff has closed the discussion.',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">Title Format:</i><br> «LibArea» — community<br><br><i class="gray-600">Description (without advertising):</i><br> ...what is on the site?<i>',
|
||||
];
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ $data = [
|
|||
'user.sites.info' => 'Liste des sites ajoutés par moi',
|
||||
'moderation' => 'Modération',
|
||||
|
||||
'deny.replies' => 'Refuser les réponses?',
|
||||
'discussions.closed' => 'La discussion du site est interdite. L*auteur ou l*équipe a clos la discussion.',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">Format du titre:</i><br> «LibArea» — communauté<br><br><i class="gray-600">Description (sans publicité):</i><br> ...ce quil y a sur le site?<i>',
|
||||
];
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ $data = [
|
|||
'no.bookmarks.sites' => 'Încă nu există marcaje',
|
||||
'user.sites.info' => 'Lista site-urilor adăugate de mine',
|
||||
'moderation' => 'Moderare',
|
||||
|
||||
'deny.replies' => 'Respinge răspunsurile?',
|
||||
'discussions.closed' => 'Discuțiile despre site sunt interzise. Autorul sau personalul a închis discuția.',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">Formatul titlului:</i><br> «LibArea» — comunitate<br><br><i class="gray-600">Descriere (fara publicitate):</i><br> ...ce este pe site?<i>',
|
||||
];
|
||||
|
|
|
@ -57,6 +57,9 @@ $data = [
|
|||
'user.sites.info' => 'Список сайтов добавленных мной',
|
||||
'moderation' => 'Модерация',
|
||||
|
||||
'deny.replies' => 'Запретить ответы?',
|
||||
'discussions.closed' => 'Обсуждение сайта запрещено. Автор или персонал закрыл обсуждение.',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">Формат заголовка:</i><br> «LibArea» — сообщество<br><br><i class="gray-600">Описание (без рекламы):</i><br> ...что есть на сайте?<i>',
|
||||
];
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ $data = [
|
|||
'user.sites.info' => '我添加的網站列表',
|
||||
'moderation' => '適度',
|
||||
|
||||
'deny.replies' => '拒絕回复?',
|
||||
'discussions.closed' => '禁止討論該網站。 作者或工作人員已結束討論。',
|
||||
|
||||
'add.site.help' => '<i class="gray-600">標題格式:</i><br> «LibArea» — 社區<br><br><i class="gray-600">說明(不含廣告):</i><br> ...網站上有什麼?<i>',
|
||||
];
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ class WebModel extends \Hleb\Scheme\App\Models\MainModel
|
|||
item_github_url,
|
||||
item_post_related,
|
||||
item_following_link,
|
||||
item_close_replies,
|
||||
item_is_deleted,
|
||||
votes_item_user_id, votes_item_item_id,
|
||||
rel.*,
|
||||
|
@ -251,6 +252,7 @@ class WebModel extends \Hleb\Scheme\App\Models\MainModel
|
|||
item_status_url,
|
||||
item_is_soft,
|
||||
item_is_github,
|
||||
item_close_replies,
|
||||
item_votes,
|
||||
item_count)
|
||||
|
||||
|
@ -264,6 +266,7 @@ class WebModel extends \Hleb\Scheme\App\Models\MainModel
|
|||
:item_status_url,
|
||||
:item_is_soft,
|
||||
:item_is_github,
|
||||
:item_close_replies,
|
||||
:item_votes,
|
||||
:item_count)";
|
||||
|
||||
|
@ -295,6 +298,7 @@ class WebModel extends \Hleb\Scheme\App\Models\MainModel
|
|||
item_is_soft = :item_is_soft,
|
||||
item_is_github = :item_is_github,
|
||||
item_post_related = :item_post_related,
|
||||
item_close_replies = :item_close_replies,
|
||||
item_github_url = :item_github_url
|
||||
WHERE item_id = :item_id";
|
||||
|
||||
|
@ -323,6 +327,7 @@ class WebModel extends \Hleb\Scheme\App\Models\MainModel
|
|||
item_github_url,
|
||||
item_post_related,
|
||||
item_following_link,
|
||||
item_close_replies,
|
||||
item_is_deleted
|
||||
FROM items
|
||||
WHERE item_id = :item_id AND item_is_deleted = 0";
|
||||
|
|
|
@ -29,6 +29,6 @@ $form->html_form($user['trust_level'], Config::get('form/catalog.site'));
|
|||
</div>
|
||||
|
||||
<?php $url = $user['trust_level'] == UserData::REGISTERED_ADMIN ? 'web' : 'web.user.sites'; ?>
|
||||
<?= includeTemplate('/view/default/_block/ajax', ['url' => 'web.create', 'redirect' => $url, 'id' => 'form#addUrl']); ?>
|
||||
<?= includeTemplate('/view/default/_block/ajax', ['url' => 'create.web', 'redirect' => $url, 'id' => 'form#addUrl']); ?>
|
||||
|
||||
<?= includeTemplate('/view/default/footer', ['user' => $user]); ?>
|
|
@ -14,6 +14,7 @@ $form->adding(['name' => 'github', 'type' => 'selected', 'var' => $domain['item_
|
|||
$form->adding(['name' => 'github_url', 'type' => 'value', 'var' => $domain['item_github_url']]);
|
||||
$form->adding(['name' => 'title_soft', 'type' => 'value', 'var' => $domain['item_title_soft']]);
|
||||
$form->adding(['name' => 'content_soft', 'type' => 'value', 'var' => $domain['item_content_soft']]);
|
||||
$form->adding(['name' => 'close_replies', 'type' => 'selected', 'var' => $domain['item_close_replies']]);
|
||||
|
||||
$form->html_form($user['trust_level'], Config::get('form/catalog.site'));
|
||||
?>
|
||||
|
@ -44,6 +45,17 @@ $form->html_form($user['trust_level'], Config::get('form/catalog.site'));
|
|||
'title' => Translate::get('related posts'),
|
||||
'help' => Translate::get('necessarily'),
|
||||
]); ?>
|
||||
|
||||
<?php if ($user['trust_level'] == UserData::REGISTERED_ADMIN) { ?>
|
||||
<?= Tpl::insert('/_block/form/select/user', [
|
||||
'uid' => $user,
|
||||
'user' => $data['user'],
|
||||
'action' => 'user',
|
||||
'type' => 'user',
|
||||
'title' => Translate::get('author'),
|
||||
'help' => Translate::get('necessarily'),
|
||||
]); ?>
|
||||
<?php } ?>
|
||||
|
||||
<input type="hidden" name="item_id" value="<?= $domain['item_id']; ?>">
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ $item = $data['item'];
|
|||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php if ($item['item_close_replies'] == 0) { ?>
|
||||
<?php if ($user['trust_level'] >= Config::get('trust-levels.tl_add_reply')) { ?>
|
||||
<form class="max-w780" action="<?= getUrlByName('reply.create'); ?>" accept-charset="UTF-8" method="post">
|
||||
<?= csrf_field() ?>
|
||||
|
@ -81,17 +82,25 @@ $item = $data['item'];
|
|||
<?= Html::sumbit(Translate::get('reply')); ?>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($data['tree']) { ?>
|
||||
<h2 class="mt10"><?= Translate::get('answers'); ?></h2>
|
||||
|
||||
<ul class="list-none mt20">
|
||||
<?= includeTemplate('/view/default/replys', ['data' => $data, 'user' => $user]); ?>
|
||||
</ul>
|
||||
<?php } else { ?>
|
||||
<div class="p20 center gray-600">
|
||||
<i class="bi-chat-dots block text-8xl"></i>
|
||||
<?= Translate::get('no.answers'); ?>
|
||||
<?php if ($item['item_close_replies'] == 0) { ?>
|
||||
<div class="p20 center gray-600">
|
||||
<i class="bi-chat-dots block text-8xl"></i>
|
||||
<?= Translate::get('no.answers'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($item['item_close_replies'] == 1) { ?>
|
||||
<div class="mt20">
|
||||
<?= Tpl::insert('/_block/no-content', ['type' => 'small', 'text' => Translate::get('discussions.closed'), 'icon' => 'bi-door-closed']); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</main>
|
||||
|
|
Loading…
Reference in a new issue