|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Подготавливает данные для шаблона редактирования профиля
|
|
|
*
|