Created
March 17, 2020 23:41
-
-
Save event15/f133698fdaff6ae4819cd6cd12d5a7cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class block_pw_admin | |
{ | |
public function init_queries(array $tableslc) | |
{ | |
$table = qa_db_add_table_prefix('blockedpw'); | |
$sql = 'CREATE TABLE IF NOT EXISTS `qa_blockedpw` ( | |
`from_user_id` int(10) unsigned NOT NULL, | |
`to_user_id` int(10) unsigned NOT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8'; | |
return in_array($table, $tableslc, true) ? null : $sql; | |
} | |
public function admin_form(): array | |
{ | |
$saved = false; | |
if (qa_clicked('plugin_blocked_pw_save_button')) { | |
qa_opt('plugin_blocked_pw_enabled', (int) qa_post_text('plugin_blocked_pw_field')); | |
$saved = true; | |
} | |
return [ | |
'ok' => $saved ? 'Saved' : null, | |
'fields' => [ | |
[ | |
'label' => 'Allow to block usser private messages', | |
'type' => 'checkbox', | |
'value' => (int) qa_opt('plugin_blocked_pw_enabled'), | |
'tags' => 'NAME="plugin_blocked_pw_field"', | |
] | |
], | |
'buttons' => [ | |
[ | |
'label' => 'Save Changes', | |
'tags' => 'NAME="plugin_blocked_pw_save_button"', | |
] | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment