@@ -5,22 +5,39 @@ class qa_pw_admin
55 public function admin_form (&$ qa_content )
66 {
77 $ isSaved = false ;
8-
8+ $ info = null ;
9+
910 if (qa_clicked ('sendPwMessageOnRegister_save ' )) {
10- qa_opt ('sendPwMessageOnRegister_messageContent ' , qa_post_text ('messageContent ' ));
11- qa_opt ('sendPwMessageOnRegister_enabled ' , qa_post_text ('enablePlugin ' ));
12- qa_opt ('sendPwMessageOnRegister_botId ' , qa_post_text ('botId ' ));
13-
14- $ isSaved = true ;
11+ $ canSave = (bool ) qa_post_text ('enablePlugin ' );
12+ if (empty (qa_post_text ('messageContent ' ))) {
13+ $ canSave = false ;
14+ $ info = 'Empty message content ' ;
15+ }
16+
17+ require_once QA_INCLUDE_DIR . 'db/users.php ' ;
18+
19+ if ([] === qa_db_user_get_userid_handles (qa_post_text ('botId ' ))) {
20+ $ canSave = false ;
21+ $ info = 'Invalid bot id ' ;
22+ }
23+
24+ if ($ canSave ) {
25+ qa_opt ('sendPwMessageOnRegister_messageContent ' , qa_post_text ('messageContent ' ));
26+ qa_opt ('sendPwMessageOnRegister_enabled ' , qa_post_text ('enablePlugin ' ));
27+ qa_opt ('sendPwMessageOnRegister_botId ' , qa_post_text ('botId ' ));
28+ $ isSaved = true ;
29+ } else {
30+ qa_opt ('sendPwMessageOnRegister_enabled ' , false );
31+ }
1532 }
1633
17- return $ this ->prepareAdminForm ($ isSaved );
34+ return $ this ->prepareAdminForm ($ isSaved, $ info );
1835 }
1936
20- private function prepareAdminForm ($ isSaved )
37+ private function prepareAdminForm ($ isSaved, $ info )
2138 {
2239 return [
23- 'ok ' => $ isSaved ? 'Settings saved ' : null ,
40+ 'ok ' => $ isSaved ? 'Settings saved ' : $ info ,
2441 'fields ' => [
2542 [
2643 'label ' => 'Enable plugin ' ,
0 commit comments