| @@ 117-137 (lines=21) @@ | ||
| 114 | * Callback for submit-button. |
|
| 115 | * |
|
| 116 | */ |
|
| 117 | public function callbackSubmitAddAnswer($form) |
|
| 118 | { |
|
| 119 | // $form->AddOutput("<p>DoSubmit(): Form was submitted.<p>"); |
|
| 120 | // $form->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>"); |
|
| 121 | ||
| 122 | // Save comment to database |
|
| 123 | $now = time(); |
|
| 124 | $this->answers->save([ |
|
| 125 | 'content' => $form->Value('content'), |
|
| 126 | 'user_id' => $this->users->loggedInUser()->id, |
|
| 127 | 'q_id' => $form->Value('question_id'), |
|
| 128 | 'vote' => 0, |
|
| 129 | 'created' => $now, |
|
| 130 | 'accepted' => false, |
|
| 131 | ]); |
|
| 132 | // $form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>"); |
|
| 133 | // $form->AddOutput("<p><b>Email: " . $form->Value('mail') . "</b></p>"); |
|
| 134 | $form->saveInSession = false; |
|
| 135 | $this->session->set('ShowFormCorA', ''); |
|
| 136 | return true; |
|
| 137 | } |
|
| 138 | /** |
|
| 139 | * Callback for submit-button. |
|
| 140 | * |
|
| @@ 90-112 (lines=23) @@ | ||
| 87 | * Callback for submit-button. |
|
| 88 | * |
|
| 89 | */ |
|
| 90 | public function callbackSubmitAddComment($form) |
|
| 91 | { |
|
| 92 | // $form->AddOutput("<p>DoSubmit(): Form was submitted.<p>"); |
|
| 93 | // $form->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>"); |
|
| 94 | // Save comment to database |
|
| 95 | $now = time(); |
|
| 96 | $this->comments->save([ |
|
| 97 | 'content' => $form->Value('content'), |
|
| 98 | 'q_or_a' => $form->Value('q_or_a'), |
|
| 99 | 'q_or_a_id' => $form->Value('q_or_a_id'), |
|
| 100 | 'user_id' => $this->users->loggedInUser()->id, |
|
| 101 | 'created' => $now, |
|
| 102 | ]); |
|
| 103 | ||
| 104 | // $form->AddOutput("<p><b>Id: " . $form->Value('q_or_a_id') . "</b></p>"); |
|
| 105 | // $form->AddOutput("<p><b>Q or A: " . $form->Value('q_or_a') . "</b></p>"); |
|
| 106 | // $form->AddOutput("<p><b>Kommentar: " . $form->Value('content') . "</b></p>"); |
|
| 107 | $form->saveInSession = false; |
|
| 108 | // Unset ShowFormCorA so comment form wont be shown when returning to question. |
|
| 109 | $this->session->set('ShowFormCorA', ''); |
|
| 110 | ||
| 111 | return true; |
|
| 112 | } |
|
| 113 | /** |
|
| 114 | * Callback for submit-button. |
|
| 115 | * |
|