Browse Source

Change forms

Visman 2 năm trước cách đây
mục cha
commit
bb0737e384

+ 1 - 2
app/Core/Test.php

@@ -109,8 +109,7 @@ class Test
     protected function log(string $message): void
     {
         $this->c->Log->debug("TEST: {$message}", [
-//            'user'    => $this->user->fLog(),
-//            'message' => $message,
+            'user'    => $this->user->fLog(),
             'headers' => true,
         ]);
     }

+ 1 - 1
app/Models/Pages/Admin.php

@@ -79,9 +79,9 @@ abstract class Admin extends Page
                 'forums'      => [$r->link('AdminForums'), 'Forums'],
                 'groups'      => [$r->link('AdminGroups'), 'User groups'],
                 'censoring'   => [$r->link('AdminCensoring'), 'Censoring'],
+                'uploads'     => [$r->link('AdminUploads'), 'Uploads'],
                 'logs'        => [$r->link('AdminLogs'), 'Logs'],
                 'maintenance' => [$r->link('AdminMaintenance'), 'Maintenance'],
-                'uploads'     => [$r->link('AdminUploads'), 'Uploads'],
             ];
         }
 

+ 4 - 1
app/Models/Pages/Post.php

@@ -47,7 +47,10 @@ class Post extends Page
         if ('POST' === $method) {
             $v = $this->messageValidator($forum, 'NewTopic', $args, false, true);
 
-            if ($this->user->isGuest) {
+            if (
+                $this->user->isGuest
+                || empty($this->user->last_post)
+            ) {
                 $v = $this->c->Test->beforeValidation($v);
             }
 

+ 13 - 0
app/Models/Pages/PostFormTrait.php

@@ -94,6 +94,19 @@ trait PostFormTrait
             'autofocus' => $autofocus,
             'maxlength' => $this->c->MAX_POST_SIZE,
         ];
+
+        if (
+            $this->user->isGuest
+            || empty($this->user->last_post)
+        ) {
+            $fieldset['terms'] = [
+                'class'   => ['w0'],
+                'type'    => 'checkbox',
+                'label'   => 'I agree to the Terms of Use',
+                'checked' => false,
+            ];
+        }
+
         $form['sets']['uesm'] = [
             'fields' => $fieldset,
         ];

+ 1 - 0
app/Models/Pages/PostValidatorTrait.php

@@ -203,6 +203,7 @@ trait PostValidatorTrait
                 'hide_smilies' => $ruleHideSmilies,
                 'edit_post'    => $ruleEditPost,
                 'subscribe'    => $ruleSubscribe,
+                'terms'        => 'absent',
                 'preview'      => 'string',
                 'submit'       => 'string|check_timeout',
                 'message'      => $ruleMessage,

+ 7 - 0
app/Models/Pages/Register.php

@@ -71,6 +71,7 @@ class Register extends Page
             'email'    => 'required_with:on|string:trim|email:noban',
             'username' => 'required_with:on|string:trim|username|noURL:1',
             'password' => 'required_with:on|string|min:16|max:100000|password',
+            'terms'    => 'absent',
             'register' => 'required|string',
         ];
 
@@ -208,6 +209,12 @@ class Register extends Page
             ];
         }
 
+        $fields['terms'] = [
+            'type'    => 'checkbox',
+            'label'   => 'I agree to the Terms of Use',
+            'checked' => false,
+        ];
+
         $form['sets']['reg']['fields'] = $fields;
 
         if ($this->useOAuth) {

+ 6 - 0
public/style/ForkBB/style.css

@@ -1169,6 +1169,12 @@ body,
   position: relative;
 }
 
+#fork #id-dl-terms {
+  padding: 0;
+  margin: 0;
+  display: none;
+}
+
 #id-dl-passinlogin .f-yhint {
   position: absolute;
   top: 0.5rem;