Skip to content

Instantly share code, notes, and snippets.

@event15
Created March 17, 2020 23:41
Show Gist options
  • Save event15/f133698fdaff6ae4819cd6cd12d5a7cd to your computer and use it in GitHub Desktop.
Save event15/f133698fdaff6ae4819cd6cd12d5a7cd to your computer and use it in GitHub Desktop.
<?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