2018-03-03
This commit is contained in:
parent
a7694a3046
commit
7ba92c7181
9 changed files with 404 additions and 13 deletions
app
Models
lang
templates
public/style/ForkBB
|
@ -203,6 +203,16 @@ class Groups extends Admin
|
|||
'token' => 'token:' . $marker,
|
||||
'g_title' => 'required|string:trim|max:50|not_in:' . implode(',', $reserve),
|
||||
'g_user_title' => 'string:trim|max:50',
|
||||
])->addAliases([
|
||||
])->addArguments([
|
||||
'token' => $vars,
|
||||
])->addMessages([
|
||||
'g_title.required' => 'You must enter a group title',
|
||||
'g_title.not_in' => 'Title already exists',
|
||||
]);
|
||||
|
||||
if ($group->g_id !== $this->c->GROUP_ADMIN) {
|
||||
$v->addRules([
|
||||
'g_promote_next_group' => 'integer|min:0|not_in:' . $notNext,
|
||||
'g_promote_min_posts' => 'integer|min:0|max:9999999999',
|
||||
'g_moderator' => 'integer|in:0,1',
|
||||
|
@ -228,13 +238,8 @@ class Groups extends Admin
|
|||
'g_search_flood' => 'integer|min:0|max:999999',
|
||||
'g_email_flood' => 'integer|min:0|max:999999',
|
||||
'g_report_flood' => 'integer|min:0|max:999999',
|
||||
])->addAliases([
|
||||
])->addArguments([
|
||||
'token' => $vars,
|
||||
])->addMessages([
|
||||
'g_title.required' => 'You must enter a group title',
|
||||
'g_title.not_in' => 'Title already exists',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($v->validation($_POST)) {
|
||||
return $this->save($group, $baseGroup, $v->getData());
|
||||
|
@ -268,7 +273,7 @@ class Groups extends Admin
|
|||
$data['g_mod_promote_users'] = 0;
|
||||
$data['g_mod_ban_users'] = 0;
|
||||
}
|
||||
if ($data['g_promote_next_group'] * $data['g_promote_min_posts'] == 0) {
|
||||
if (isset($data['g_promote_next_group']) && $data['g_promote_next_group'] * $data['g_promote_min_posts'] == 0) {
|
||||
$data['g_promote_next_group'] = 0;
|
||||
$data['g_promote_min_posts'] = 0;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@ use ForkBB\Models\Page;
|
|||
|
||||
class Rules extends Page
|
||||
{
|
||||
use CrumbTrait;
|
||||
|
||||
/**
|
||||
* Подготавливает данные для шаблона
|
||||
*
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function view()
|
||||
|
@ -17,8 +19,8 @@ class Rules extends Page
|
|||
$this->nameTpl = 'rules';
|
||||
$this->onlinePos = 'rules';
|
||||
$this->canonical = $this->c->Router->link('Rules');
|
||||
$this->titles = \ForkBB\__('Forum rules');
|
||||
$this->title = \ForkBB\__('Forum rules');
|
||||
$this->crumbs = $this->crumbs([$this->c->Router->link('Rules'), \ForkBB\__('Forum rules')]);
|
||||
$this->rules = $this->c->config->o_rules_message;
|
||||
$this->formAction = null;
|
||||
|
||||
|
@ -27,7 +29,7 @@ class Rules extends Page
|
|||
|
||||
/**
|
||||
* Подготавливает данные для шаблона
|
||||
*
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function confirmation()
|
||||
|
@ -38,8 +40,8 @@ class Rules extends Page
|
|||
$this->nameTpl = 'rules';
|
||||
$this->onlinePos = 'rules';
|
||||
$this->robots = 'noindex';
|
||||
$this->titles = \ForkBB\__('Forum rules');
|
||||
$this->title = \ForkBB\__('Forum rules');
|
||||
$this->crumbs = $this->crumbs(\ForkBB\__('Forum rules'), [$this->c->Router->link('Register'), \ForkBB\__('Register')]);
|
||||
$this->rules = $this->c->config->o_rules == '1' ? $this->c->config->o_rules_message : \ForkBB\__('If no rules');
|
||||
$this->formAction = $this->c->Router->link('RegisterForm');
|
||||
$this->formToken = $this->c->Csrf->create('RegisterForm');
|
||||
|
|
59
app/Models/Pages/Userlist.php
Normal file
59
app/Models/Pages/Userlist.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace ForkBB\Models\Pages;
|
||||
|
||||
use ForkBB\Models\Page;
|
||||
use ForkBB\Core\Validator;
|
||||
use ForkBB\Models\Forum\Model as Forum;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Userlist extends Page
|
||||
{
|
||||
use CrumbTrait;
|
||||
|
||||
protected $usersPerPage = 2; // ???? в конфиг!
|
||||
|
||||
/**
|
||||
* Список пользователей
|
||||
*
|
||||
* @param array $args
|
||||
* @param string $method
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function view(array $args, $method)
|
||||
{
|
||||
$this->c->Lang->load('userlist');
|
||||
|
||||
$ids = $this->c->users->filter([], []);
|
||||
$number = \count($ids);
|
||||
$page = isset($args['page']) ? (int) $args['page'] : 1;
|
||||
$pages = $number ? (int) \ceil($number / $this->usersPerPage) : 1;
|
||||
|
||||
if ($page > $pages) {
|
||||
return $this->c->Message->message('Bad request');
|
||||
}
|
||||
|
||||
if ($number) {
|
||||
$this->startNum = ($page - 1) * $this->usersPerPage;
|
||||
$ids = \array_slice($ids, $this->startNum, $this->usersPerPage);
|
||||
$this->userList = $this->c->users->load($ids);
|
||||
} else {
|
||||
$this->startNum = 0;
|
||||
$this->userList = null;
|
||||
// ни чего не найдено
|
||||
}
|
||||
|
||||
$this->fIndex = 'userlist';
|
||||
$this->nameTpl = 'userlist';
|
||||
$this->onlinePos = 'userlist';
|
||||
$this->canonical = $this->c->Router->link('Userlist', ['page' => $page]); // ????
|
||||
$this->robots = 'noindex';
|
||||
// $this->form = $form;
|
||||
$this->crumbs = $this->crumbs([$this->c->Router->link('Userlist'), \ForkBB\__('User_list')]);
|
||||
$this->pagination = $this->c->Func->paginate($pages, $page, 'Userlist');
|
||||
$this->showUserLink = $this->c->config->o_show_user_info == '1';
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
54
app/Models/User/Filter.php
Normal file
54
app/Models/User/Filter.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace ForkBB\Models\User;
|
||||
|
||||
use ForkBB\Models\Action;
|
||||
use InvalidArgumentException;
|
||||
use PDO;
|
||||
|
||||
class Filter extends Action
|
||||
{
|
||||
/**
|
||||
* Получение списка id пользователей по условиям
|
||||
*
|
||||
* @param array $filters
|
||||
* @param array $order
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filter(array $filters, array $order = [])
|
||||
{
|
||||
$fileds = $this->c->dbMap->users;
|
||||
$orderBy = [];
|
||||
$where = ['u.id>1'];
|
||||
|
||||
foreach ($order as $filed => $val) {
|
||||
if (! isset($fileds[$filed])) {
|
||||
throw new InvalidArgumentException('No sorting field found');
|
||||
}
|
||||
if ('ACS' !== $val && 'DESC' !== $val) {
|
||||
throw new InvalidArgumentException('The sorting order is not clear');
|
||||
}
|
||||
$orderBy[] = "u.{$filed} {$val}";
|
||||
}
|
||||
if (empty($orderBy)) {
|
||||
$orderBy = 'u.username ASC';
|
||||
} else {
|
||||
$orderBy = \implode(', ', $orderBy);
|
||||
}
|
||||
|
||||
$where = \implode(' AND ', $where);
|
||||
|
||||
$vars = [];
|
||||
$sql = "SELECT u.id
|
||||
FROM ::users AS u
|
||||
WHERE {$where}
|
||||
ORDER BY {$orderBy}";
|
||||
|
||||
$ids = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
42
app/lang/English/userlist.po
Normal file
42
app/lang/English/userlist.po
Normal file
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Project-Id-Version: ForkBB\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: en\n"
|
||||
|
||||
msgid "User find legend"
|
||||
msgstr "Find and sort users"
|
||||
|
||||
msgid "User search info"
|
||||
msgstr "Enter a username to search for and/or a user group to filter by. The username field can be left blank. Use the wildcard character * for partial matches."
|
||||
|
||||
msgid "User sort info"
|
||||
msgstr "Sort users by name, date registered or number of posts and in ascending/descending order."
|
||||
|
||||
msgid "User group"
|
||||
msgstr "User group"
|
||||
|
||||
msgid "No of posts"
|
||||
msgstr "Number of posts"
|
||||
|
||||
msgid "All users"
|
||||
msgstr "All"
|
||||
|
||||
msgid "User_list"
|
||||
msgstr "User list"
|
||||
|
||||
msgid "%s<span> post,</span>"
|
||||
msgid_plural "%s<span> posts,</span>"
|
||||
msgstr[0] "%s<span> post,</span>"
|
||||
msgstr[1] "%s<span> posts,</span>"
|
||||
|
||||
msgid "<span>registered: </span>%s"
|
||||
msgstr "<span>registered: </span>%s"
|
43
app/lang/Russian/userlist.po
Normal file
43
app/lang/Russian/userlist.po
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"Project-Id-Version: ForkBB\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: ru\n"
|
||||
|
||||
msgid "User find legend"
|
||||
msgstr "Поиск и сортировка пользователей"
|
||||
|
||||
msgid "User search info"
|
||||
msgstr "Введите имя пользователя и/или выберите группу по которой хотите фильтровать список. Имя пользователя может быть пустым. Для поиска по маске разрешено использовать символ звездочки (*)."
|
||||
|
||||
msgid "User sort info"
|
||||
msgstr "Сортируйте пользователей по именам, дате регистрации и количеству сообщений; по возрастанию или убыванию."
|
||||
|
||||
msgid "User group"
|
||||
msgstr "Группа пользователей"
|
||||
|
||||
msgid "No of posts"
|
||||
msgstr "Кол-во сообщений"
|
||||
|
||||
msgid "All users"
|
||||
msgstr "<Все>"
|
||||
|
||||
msgid "User_list"
|
||||
msgstr "Список пользователей"
|
||||
|
||||
msgid "%s<span> post,</span>"
|
||||
msgid_plural "%s<span> posts,</span>"
|
||||
msgstr[0] "%s<span> сообщение,</span>"
|
||||
msgstr[1] "%s<span> сообщения,</span>"
|
||||
msgstr[2] "%s<span> сообщений,</span>"
|
||||
|
||||
msgid "<span>registered: </span>%s"
|
||||
msgstr "<span>дата регистрации: </span>%s"
|
|
@ -1,4 +1,20 @@
|
|||
@section ('crumbs')
|
||||
<ul class="f-crumbs">
|
||||
@foreach ($p->crumbs as $cur)
|
||||
<li class="f-crumb"><!-- inline -->
|
||||
@if ($cur[0])
|
||||
<a href="{!! $cur[0] !!}" @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</a>
|
||||
@else
|
||||
<span @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</span>
|
||||
@endif
|
||||
</li><!-- endinline -->
|
||||
@endforeach
|
||||
</ul>
|
||||
@endsection
|
||||
@extends ('layouts/main')
|
||||
<div class="f-nav-links">
|
||||
@yield ('crumbs')
|
||||
</div>
|
||||
<section class="f-main f-rules">
|
||||
<h2>{!! $p->title !!}</h2>
|
||||
<div id="id-rules">{!! $p->rules !!}</div>
|
||||
|
|
85
app/templates/userlist.tpl
Normal file
85
app/templates/userlist.tpl
Normal file
|
@ -0,0 +1,85 @@
|
|||
@section ('crumbs')
|
||||
<ul class="f-crumbs">
|
||||
@foreach ($p->crumbs as $cur)
|
||||
<li class="f-crumb"><!-- inline -->
|
||||
@if ($cur[0])
|
||||
<a href="{!! $cur[0] !!}" @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</a>
|
||||
@else
|
||||
<span @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</span>
|
||||
@endif
|
||||
</li><!-- endinline -->
|
||||
@endforeach
|
||||
</ul>
|
||||
@endsection
|
||||
@section ('pagination')
|
||||
@if ($p->pagination)
|
||||
<nav class="f-pages">
|
||||
@foreach ($p->pagination as $cur)
|
||||
@if ($cur[2])
|
||||
<a class="f-page active" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
|
||||
@elseif ('info' === $cur[1])
|
||||
<span class="f-pinfo">{!! $cur[0] !!}</span>
|
||||
@elseif ('space' === $cur[1])
|
||||
<span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
|
||||
@elseif ('prev' === $cur[1])
|
||||
<a rel="prev" class="f-page f-pprev" href="{!! $cur[0] !!}">{!! __('Previous') !!}</a>
|
||||
@elseif ('next' === $cur[1])
|
||||
<a rel="next" class="f-page f-pnext" href="{!! $cur[0] !!}">{!! __('Next') !!}</a>
|
||||
@else
|
||||
<a class="f-page" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
|
||||
@endif
|
||||
@endforeach
|
||||
</nav>
|
||||
@endif
|
||||
@endsection
|
||||
@extends ('layouts/main')
|
||||
<div class="f-nav-links">
|
||||
@yield ('crumbs')
|
||||
@if ($p->pagination)
|
||||
<div class="f-links-b clearfix">
|
||||
@yield ('pagination')
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@if ($form = $p->form)
|
||||
<section class="f-main f-userlist-form">
|
||||
<h2>{!! __('Search') !!}</h2>
|
||||
<div class="f-fdiv">
|
||||
@include ('layouts/form')
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
@if ($p->userList)
|
||||
<section class="f-main f-userlist">
|
||||
<h2>{!! __('User list') !!}</h2>
|
||||
<div class="f-ulist">
|
||||
<ol class="f-table">
|
||||
<li class="f-row f-thead" value="{{ $p->startNum }}">
|
||||
<span class="f-hcell f-cusername">{!! __('Username') !!}</span>
|
||||
<span class="f-hcell f-ctitle">{!! __('Title') !!}</span>
|
||||
<span class="f-hcell f-cnumposts">{!! __('Posts') !!}</span>
|
||||
<span class="f-hcell f-cdatereg">{!! __('Registered') !!}</span>
|
||||
</li>
|
||||
@foreach ($p->userList as $user)
|
||||
<li class="f-row">
|
||||
@if ($p->showUserLink && $user->link)
|
||||
<span class="f-cell f-cusername"><a href="{!! $user->link !!}">{{ $user->username }}</a></span>
|
||||
@else
|
||||
<span class="f-cell f-cusername">{{ $user->username }}</span>
|
||||
@endif
|
||||
<span class="f-cell f-ctitle"><span>(</span>{{ $user->title() }}<span>),</span></span>
|
||||
<span class="f-cell f-cnumposts">{!! __('%s<span> post,</span>', $user->num_posts, num($user->num_posts)) !!}</span>
|
||||
<span class="f-cell f-cdatereg">{!! __('<span>registered: </span>%s', dt($user->registered, true)) !!}</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
@if ($p->pagination)
|
||||
<div class="f-nav-links">
|
||||
<div class="f-links clearfix">
|
||||
@yield ('pagination')
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
|
@ -706,6 +706,11 @@ select {
|
|||
padding: 0.625rem 0.625rem 0 0.625rem;
|
||||
}
|
||||
|
||||
.f-links .f-link-post,
|
||||
.f-links .f-pages {
|
||||
padding: 0 0.625rem;
|
||||
}
|
||||
|
||||
.f-nav-links .f-page {
|
||||
/* float: left; */
|
||||
border: 0.0625rem solid #AA7939;
|
||||
|
@ -783,8 +788,9 @@ select {
|
|||
/***********/
|
||||
|
||||
.f-rules > h2 {
|
||||
display: block;
|
||||
padding: 0.625rem;
|
||||
display: none;
|
||||
/* display: block;
|
||||
padding: 0.625rem; */
|
||||
}
|
||||
|
||||
#id-rules {
|
||||
|
@ -1873,6 +1879,10 @@ li + li .f-btn {
|
|||
/* padding-top: 0; */
|
||||
}
|
||||
|
||||
.f-search-form .f-label {
|
||||
padding: 0.5rem 0;
|
||||
}
|
||||
|
||||
.f-field-w3 + .f-field-w3,
|
||||
.f-field-w4 + .f-field-w4 {
|
||||
padding-left: 0.625rem;
|
||||
|
@ -1885,3 +1895,78 @@ li + li .f-btn {
|
|||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
/************************/
|
||||
/* Список пользователей */
|
||||
/************************/
|
||||
|
||||
.f-userlist > h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.f-ulist .f-row {
|
||||
border-bottom: 0.0625rem solid #AA7939;
|
||||
}
|
||||
|
||||
.f-ulist .f-row {
|
||||
padding: 0.625rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.f-ulist .f-thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.f-ulist .f-thead + .f-row {
|
||||
border-top: 0.125rem solid #AA7939;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 50rem) {
|
||||
.f-ulist .f-row {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.f-ulist .f-thead {
|
||||
border-top: 0.125rem solid #AA7939;
|
||||
border-bottom: 0.125rem solid #AA7939;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.f-ulist .f-thead + .f-row {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.f-ulist .f-hcell,
|
||||
.f-ulist .f-cell {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.f-ulist .f-cell > span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.f-ulist .f-cusername {
|
||||
padding: 0.625rem 0 0.625rem 0.625rem;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.f-ulist .f-ctitle {
|
||||
padding: 0.625rem 0 0.625rem 0.625rem;
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.f-ulist .f-cnumposts {
|
||||
padding: 0.625rem 0 0.625rem 0.625rem;
|
||||
width: 8rem;
|
||||
min-width: 8rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.f-ulist .f-cdatereg {
|
||||
padding: 0.625rem;
|
||||
width: 11rem;
|
||||
min-width: 11rem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue