2018-04-13

This commit is contained in:
Visman 2018-04-13 14:35:07 +07:00
parent 1d9ca9814d
commit 99a5ab6dd1
15 changed files with 452 additions and 67 deletions

View file

@ -296,6 +296,12 @@ class Validator
$rules = $this->rules[$field];
if (isset($this->raw[$field])) {
$value = $this->c->Secury->replInvalidChars($this->raw[$field]);
// пустое поле в соответствии с правилом 'required' должно быть равно null
if ((\is_string($value) && 0 === \strlen(\preg_replace('%^\s+|\s+$%u', '', $value)))
|| (\is_array($value) && empty($value))
) {
$value = null;
}
}
}

View file

@ -99,10 +99,7 @@ class Page extends Model
$nav['register'] = [$r->link('Register'), 'Register'];
$nav['login'] = [$r->link('Login'), 'Login'];
} else {
$nav['profile'] = [$r->link('User', [
'id' => $this->user->id,
'name' => $this->user->username,
]), 'Profile'];
$nav['profile'] = [$this->user->link, 'Profile'];
// New PMS
if ($this->c->config->o_pms_enabled == '1' && ($this->user->isAdmin || $this->user->messages_new > 0)) { //????
$nav['pmsnew'] = ['pmsnew.php', 'PM']; //'<li id="nav"'.((PUN_ACTIVE_PAGE == 'pms_new' || $user['messages_new'] > 0) ? ' class="isactive"' : '').'><a href="pmsnew.php">'.\ForkBB\__('PM').(($user['messages_new'] > 0) ? ' (<span'.((empty($this->c->config->o_pms_flasher) || PUN_ACTIVE_PAGE == 'pms_new') ? '' : ' class="remflasher"' ).'>'.$user['messages_new'].'</span>)' : '').'</a></li>';

View file

@ -12,6 +12,284 @@ class Profile extends Page
{
use CrumbTrait;
/**
* Подготавливает данные для шаблона настройки форума
*
* @param array $args
* @param string $method
*
* @return Page
*/
public function config(array $args, $method)
{
$this->curUser = $this->c->users->load((int) $args['id']);
if (! $this->curUser instanceof User || ($this->curUser->isUnverified && ! $this->user->isAdmMod)) {
return $this->c->Message->message('Bad request');
}
$this->rules = $this->c->ProfileRules->setUser($this->curUser);
if (! $this->rules->editConfig) {
return $this->c->Message->message('Bad request');
}
$this->c->Lang->load('profile');
$this->c->Lang->load('profile_other');
if ('POST' === $method) {
$v = $this->c->Validator->reset()
->addValidators([
])->addRules([
'token' => 'token:EditBoardConfig',
'language' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getLangs()),
'style' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getStyles()),
'timezone' => 'required|string:trim|in:-12,-11,-10,-9.5,-9,-8.5,-8,-7,-6,-5,-4,-3.5,-3,-2,-1,0,1,2,3,3.5,4,4.5,5,5.5,5.75,6,6.5,7,8,8.75,9,9.5,10,10.5,11,11.5,12,12.75,13,14',
'dst' => 'required|integer|in:0,1',
'time_format' => 'required|integer|in:' . \implode(',', \array_keys($this->c->TIME_FORMATS)),
'date_format' => 'required|integer|in:' . \implode(',', \array_keys($this->c->DATE_FORMATS)),
'show_smilies' => 'required|integer|in:0,1',
'show_sig' => 'required|integer|in:0,1',
'show_avatars' => 'required|integer|in:0,1',
'show_img' => 'required|integer|in:0,1',
'show_img_sig' => 'required|integer|in:0,1',
'disp_topics' => 'integer|min:10|max:50',
'disp_posts' => 'integer|min:10|max:50',
])->addAliases([
'language' => 'Language',
'style' => 'Style',
'timezone' => 'Time zone',
'dst' => 'DST label',
'time_format' => 'Time format',
'date_format' => 'Date format',
'show_smilies' => 'Smilies label',
'show_sig' => 'Sigs label',
'show_avatars' => 'Avatars label',
'show_img' => 'Images label',
'show_img_sig' => 'Images sigs label',
'disp_topics' => 'Topics per page label',
'disp_posts' => 'Posts per page label',
])->addArguments([
'token' => ['id' => $this->curUser->id],
])->addMessages([
]);
if ($v->validation($_POST)) {
}
$this->fIswev = $v->getErrors();
}
$form = [
'action' => $this->c->Router->link('EditBoardConfig', ['id' => $this->curUser->id]),
'hidden' => [
'token' => $this->c->Csrf->create('EditBoardConfig', ['id' => $this->curUser->id]),
],
'sets' => [],
'btns' => [
'save' => [
'type' => 'submit',
'value' => \ForkBB\__('Save changes'),
'accesskey' => 's',
],
],
];
$yn = [1 => \ForkBB\__('Yes'), 0 => \ForkBB\__('No')];
$langs = $this->c->Func->getLangs();
$langs = \array_combine($langs, $langs);
$styles = $this->c->Func->getStyles();
$styles = \array_combine($styles, $styles);
$timeFormat = [];
foreach ($this->c->TIME_FORMATS as $key => $value) {
$timeFormat[$key] = \ForkBB\dt(\time(), false, null, $value, true, true) . ($key ? '' : ' (' . \ForkBB\__('Default') . ')');
}
$dateFormat = [];
foreach ($this->c->DATE_FORMATS as $key => $value) {
$dateFormat[$key] = \ForkBB\dt(\time(), true, $value, null, false, true) . ($key ? '' : ' (' . \ForkBB\__('Default') . ')');
}
$form['sets'][] = [
'id' => 'essentials',
'legend' => \ForkBB\__('Essentials'),
'class' => 'data-edit',
'fields' => [
'language' => [
'id' => 'language',
'type' => 'select',
'options' => $langs,
'value' => $this->curUser->language,
'caption' => \ForkBB\__('Language'),
],
'style' => [
'id' => 'style',
'type' => 'select',
'options' => $styles,
'value' => $this->curUser->style,
'caption' => \ForkBB\__('Style'),
],
'timezone' => [
'id' => 'timezone',
'type' => 'select',
'options' => [
'-12' => \ForkBB\__('UTC-12:00'),
'-11' => \ForkBB\__('UTC-11:00'),
'-10' => \ForkBB\__('UTC-10:00'),
'-9.5' => \ForkBB\__('UTC-09:30'),
'-9' => \ForkBB\__('UTC-09:00'),
'-8.5' => \ForkBB\__('UTC-08:30'),
'-8' => \ForkBB\__('UTC-08:00'),
'-7' => \ForkBB\__('UTC-07:00'),
'-6' => \ForkBB\__('UTC-06:00'),
'-5' => \ForkBB\__('UTC-05:00'),
'-4' => \ForkBB\__('UTC-04:00'),
'-3.5' => \ForkBB\__('UTC-03:30'),
'-3' => \ForkBB\__('UTC-03:00'),
'-2' => \ForkBB\__('UTC-02:00'),
'-1' => \ForkBB\__('UTC-01:00'),
'0' => \ForkBB\__('UTC'),
'1' => \ForkBB\__('UTC+01:00'),
'2' => \ForkBB\__('UTC+02:00'),
'3' => \ForkBB\__('UTC+03:00'),
'3.5' => \ForkBB\__('UTC+03:30'),
'4' => \ForkBB\__('UTC+04:00'),
'4.5' => \ForkBB\__('UTC+04:30'),
'5' => \ForkBB\__('UTC+05:00'),
'5.5' => \ForkBB\__('UTC+05:30'),
'5.75' => \ForkBB\__('UTC+05:45'),
'6' => \ForkBB\__('UTC+06:00'),
'6.5' => \ForkBB\__('UTC+06:30'),
'7' => \ForkBB\__('UTC+07:00'),
'8' => \ForkBB\__('UTC+08:00'),
'8.75' => \ForkBB\__('UTC+08:45'),
'9' => \ForkBB\__('UTC+09:00'),
'9.5' => \ForkBB\__('UTC+09:30'),
'10' => \ForkBB\__('UTC+10:00'),
'10.5' => \ForkBB\__('UTC+10:30'),
'11' => \ForkBB\__('UTC+11:00'),
'11.5' => \ForkBB\__('UTC+11:30'),
'12' => \ForkBB\__('UTC+12:00'),
'12.75' => \ForkBB\__('UTC+12:45'),
'13' => \ForkBB\__('UTC+13:00'),
'14' => \ForkBB\__('UTC+14:00'),
],
'value' => $this->curUser->timezone,
'caption' => \ForkBB\__('Time zone'),
],
'dst' => [
'id' => 'dst',
'type' => 'radio',
'value' => $this->curUser->dst,
'values' => $yn,
'caption' => \ForkBB\__('DST label'),
'info' => \ForkBB\__('DST help'),
],
'time_format' => [
'id' => 'time_format',
'type' => 'select',
'options' => $timeFormat,
'value' => $this->curUser->time_format,
'caption' => \ForkBB\__('Time format'),
],
'date_format' => [
'id' => 'date_format',
'type' => 'select',
'options' => $dateFormat,
'value' => $this->curUser->date_format,
'caption' => \ForkBB\__('Date format'),
],
],
];
$form['sets'][] = [
'id' => 'viewing-posts',
'legend' => \ForkBB\__('Viewing posts'),
'class' => 'data-edit',
'fields' => [
'show_smilies' => [
'id' => 'show_smilies',
'type' => 'radio',
'value' => $this->curUser->show_smilies,
'values' => $yn,
'caption' => \ForkBB\__('Smilies label'),
'info' => \ForkBB\__('Smilies info'),
],
'show_sig' => [
'id' => 'show_sig',
'type' => 'radio',
'value' => $this->curUser->show_sig,
'values' => $yn,
'caption' => \ForkBB\__('Sigs label'),
'info' => \ForkBB\__('Sigs info'),
],
'show_avatars' => [
'id' => 'show_avatars',
'type' => 'radio',
'value' => $this->curUser->show_avatars,
'values' => $yn,
'caption' => \ForkBB\__('Avatars label'),
'info' => \ForkBB\__('Avatars info'),
],
'show_img' => [
'id' => 'show_img',
'type' => 'radio',
'value' => $this->curUser->show_img,
'values' => $yn,
'caption' => \ForkBB\__('Images label'),
'info' => \ForkBB\__('Images info'),
],
'show_img_sig' => [
'id' => 'show_img_sig',
'type' => 'radio',
'value' => $this->curUser->show_img_sig,
'values' => $yn,
'caption' => \ForkBB\__('Images sigs label'),
'info' => \ForkBB\__('Images sigs info'),
],
],
];
$form['sets'][] = [
'id' => 'pagination',
'legend' => \ForkBB\__('Pagination'),
'class' => 'data-edit',
'fields' => [
'disp_topics' => [
'id' => 'disp_topics',
'type' => 'number',
'min' => 10,
'max' => 50,
'value' => $this->curUser->disp_topics,
'caption' => \ForkBB\__('Topics per page label'),
'info' => \ForkBB\__('For default'),
],
'disp_posts' => [
'id' => 'disp_posts',
'type' => 'number',
'min' => 10,
'max' => 50,
'value' => $this->curUser->disp_posts,
'caption' => \ForkBB\__('Posts per page label'),
'info' => \ForkBB\__('For default'),
],
],
];
$crumbs = [];
$crumbs[] = [$this->c->Router->link('EditBoardConfig', ['id' => $this->curUser->id]), \ForkBB\__('Board configuration')];
$this->robots = 'noindex';
$this->crumbs = $this->extCrumbs(...$crumbs);
$this->fIndex = $this->rules->my ? 'profile' : 'userlist';
$this->nameTpl = 'profile';
$this->onlinePos = 'profile-' . $this->curUser->id; // ????
$this->title = \ForkBB\__('%s\'s profile', $this->curUser->username);
$this->form = $form;
$this->actionBtns = $this->btns('config');
return $this;
}
/**
* Подготавливает данные для шаблона редактирования профиля
*

View file

@ -33,8 +33,8 @@ class Current extends Action
if ($user->isGuest) {
$user->__isBot = $this->isBot();
$user->__disp_topics = $this->c->config->o_disp_topics_default;
$user->__disp_posts = $this->c->config->o_disp_posts_default;
# $user->__disp_topics = $this->c->config->o_disp_topics_default;
# $user->__disp_posts = $this->c->config->o_disp_posts_default;
$user->__timezone = $this->c->config->o_default_timezone;
$user->__dst = $this->c->config->o_default_dst;
# $user->language = $this->c->config->o_default_lang;
@ -51,12 +51,12 @@ class Current extends Action
} */
} else {
$user->__isBot = false;
if (! $user->disp_topics) {
$user->__disp_topics = $this->c->config->o_disp_topics_default;
}
if (! $user->disp_posts) {
$user->__disp_posts = $this->c->config->o_disp_posts_default;
}
# if (! $user->disp_topics) {
# $user->__disp_topics = $this->c->config->o_disp_topics_default;
# }
# if (! $user->disp_posts) {
# $user->__disp_posts = $this->c->config->o_disp_posts_default;
# }
// Special case: We've timed out, but no other user has browsed the forums since we timed out
if ($user->isLogged && $user->logged < time() - $this->c->config->o_timeout_visit) {
$this->manager->updateLastVisit($user); //????

View file

@ -289,4 +289,24 @@ class Model extends DataModel
{
return '1' == $this->c->config->o_show_post_count || $this->isAdmMod;
}
/**
* Число тем на одну страницу
*
* @return int
*/
protected function getdisp_topics()
{
return (int) (empty($this->a['disp_topics']) ? $this->c->config->o_disp_topics_default : $this->a['disp_topics']);
}
/**
* Число сообщений на одну страницу
*
* @return int
*/
protected function getdisp_posts()
{
return (int) (empty($this->a['disp_posts']) ? $this->c->config->o_disp_posts_default : $this->a['disp_posts']);
}
}

View file

@ -81,12 +81,6 @@ msgstr "Edit"
msgid "Remove"
msgstr "Remove"
msgid "Yes"
msgstr "Yes"
msgid "No"
msgstr "No"
msgid "here"
msgstr "here"

View file

@ -57,12 +57,6 @@ msgstr "Default time zone"
msgid "Timezone help"
msgstr "The default time zone for guests and users attempting to register for the board."
msgid "DST label"
msgstr "Adjust for DST"
msgid "DST help"
msgstr "Check if daylight savings is in effect (advances times by 1 hour)."
msgid "Language label"
msgstr "Default language"
@ -147,15 +141,9 @@ msgstr "Topic review"
msgid "Topic review help"
msgstr "Maximum number of posts to display when posting (newest first). Set to 0 to disable."
msgid "Topics per page label"
msgstr "Topics per page"
msgid "Topics per page help"
msgstr "The default number of topics to display per page in a forum. Users can personalize this setting."
msgid "Posts per page label"
msgstr "Posts per page"
msgid "Posts per page help"
msgstr "The default number of posts to display per page in a topic. Users can personalize this setting."

View file

@ -498,3 +498,9 @@ msgstr "Save changes"
msgid "Save"
msgstr "Save"
msgid "Yes"
msgstr "Yes"
msgid "No"
msgstr "No"

View file

@ -279,26 +279,41 @@ msgstr "Include a plain text version of new posts in subscription notification e
msgid "Auto notify full"
msgstr "Automatically subscribe to every topic you post in."
msgid "Show smilies"
msgid "Smilies label"
msgstr "Smilies"
msgid "Smilies info"
msgstr "Show smilies as graphic icons."
msgid "Show images"
msgid "Images label"
msgstr "Images in posts"
msgid "Images info"
msgstr "Show images in posts."
msgid "Show images sigs"
msgid "Images sigs label"
msgstr "Images in signatures"
msgid "Images sigs info"
msgstr "Show images in user signatures."
msgid "Show avatars"
msgid "Avatars label"
msgstr "Avatars"
msgid "Avatars info"
msgstr "Show user avatars in posts."
msgid "Show sigs"
msgid "Sigs label"
msgstr "Signatures"
msgid "Sigs info"
msgstr "Show user signatures."
msgid "Style legend"
msgstr "Select your preferred style"
msgid "Styles"
msgstr "Styles"
msgid "Style"
msgstr "Style"
msgid "Admin note"
msgstr "Admin note"
@ -470,3 +485,30 @@ msgstr "Your passphrase has been updated. You can now login with your new passph
msgid "Pass updated redirect"
msgstr "Passphrase updated. Redirecting …"
msgid "Language"
msgstr "Language"
msgid "Essentials"
msgstr "Essentials"
msgid "Time zone"
msgstr "Time zone"
msgid "Default"
msgstr "Default"
msgid "For default"
msgstr "Clean this field for the default settings."
msgid "Time format"
msgstr "Time format"
msgid "Date format"
msgstr "Date format"
msgid "Viewing posts"
msgstr "Viewing posts"
msgid "Pagination"
msgstr "Pagination"

View file

@ -140,3 +140,15 @@ msgstr "Hide email address but allow form e-mail"
msgid "Hide both label"
msgstr "Hide email address and disallow form email"
msgid "DST label"
msgstr "Adjust for DST"
msgid "DST help"
msgstr "Check if daylight savings is in effect (advances times by 1 hour)."
msgid "Topics per page label"
msgstr "Topics per page"
msgid "Posts per page label"
msgstr "Posts per page"

View file

@ -81,12 +81,6 @@ msgstr "Править"
msgid "Remove"
msgstr "Убрать"
msgid "Yes"
msgstr "Да"
msgid "No"
msgstr "Нет"
msgid "here"
msgstr "здесь"

View file

@ -57,12 +57,6 @@ msgstr "Часовой пояс по умолчанию"
msgid "Timezone help"
msgstr "Часовой пояс для гостей и новых пользователей."
msgid "DST label"
msgstr "Поправка на летнее время"
msgid "DST help"
msgstr "Отметьте, если в вашем регионе применяется поправка на летнее время (сдвигает время на 1 час)."
msgid "Language label"
msgstr "Язык по умолчанию"
@ -147,15 +141,9 @@ msgstr "Просмотр темы"
msgid "Topic review help"
msgstr "Максимальное количество отображаемых сообщений при ответе (новые сверху). Установите в 0 чтобы выключить."
msgid "Topics per page label"
msgstr "Тем на страницу"
msgid "Topics per page help"
msgstr "Значение по умолчанию сколько заголовков тем выводить на странице раздела. Пользователь может установить своё значение."
msgid "Posts per page label"
msgstr "Сообщений на страницу"
msgid "Posts per page help"
msgstr "Значение по умолчанию сколько сообщений выводить на странице с темой. Пользователь может установить своё значение."

View file

@ -500,3 +500,9 @@ msgstr "Сохранить изменения"
msgid "Save"
msgstr "Сохранить"
msgid "Yes"
msgstr "Да"
msgid "No"
msgstr "Нет"

View file

@ -279,26 +279,41 @@ msgstr "Включать в письмо-уведомление текстову
msgid "Auto notify full"
msgstr "Автоматически подписываться на темы, в которых публикуете сообщения."
msgid "Show smilies"
msgstr "Показывать смайлики как графику"
msgid "Smilies label"
msgstr "Смайлы"
msgid "Show images"
msgstr "Показывать изображения в сообщениях"
msgid "Smilies info"
msgstr "Показывать смайлики как графику."
msgid "Show images sigs"
msgstr "Показывать изображения в подписях"
msgid "Images label"
msgstr "Изображения в сообщениях"
msgid "Show avatars"
msgstr "Показывать аватары пользователей"
msgid "Images info"
msgstr "Показывать изображения в сообщениях."
msgid "Show sigs"
msgstr "Показывать подписи пользователей"
msgid "Images sigs label"
msgstr "Изображения в подписях"
msgid "Images sigs info"
msgstr "Показывать изображения в подписях."
msgid "Avatars label"
msgstr "Аватары"
msgid "Avatars info"
msgstr "Показывать аватары пользователей."
msgid "Sigs label"
msgstr "Подписи"
msgid "Sigs info"
msgstr "Показывать подписи пользователей."
msgid "Style legend"
msgstr "Настройка стиля оформления"
msgid "Styles"
msgstr "Стили"
msgid "Style"
msgstr "Стиль"
msgid "Admin note"
msgstr "Примечание администрации"
@ -470,3 +485,30 @@ msgstr "Ваша кодовая фраза изменена. Вы можете
msgid "Pass updated redirect"
msgstr "Кодовая фраза изменена. Переадресация &hellip;"
msgid "Language"
msgstr "Язык"
msgid "Essentials"
msgstr "Основное"
msgid "Time zone"
msgstr "Часовой пояс"
msgid "Default"
msgstr "По умолчанию"
msgid "For default"
msgstr "Очистите поле для использования значения по умолчанию."
msgid "Time format"
msgstr "Формат времени"
msgid "Date format"
msgstr "Формат даты"
msgid "Viewing posts"
msgstr "Просмотр сообщений"
msgid "Pagination"
msgstr "Постраничный вывод"

View file

@ -140,3 +140,15 @@ msgstr "Спрятать email, но разрешить отправку пис
msgid "Hide both label"
msgstr "Спрятать email и запретить отправку писем"
msgid "DST label"
msgstr "Поправка на летнее время"
msgid "DST help"
msgstr "Отметьте, если в вашем регионе применяется поправка на летнее время (сдвигает время на 1 час)."
msgid "Topics per page label"
msgstr "Тем на странице"
msgid "Posts per page label"
msgstr "Сообщений на странице"