diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..acf07d4
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,43 @@
+name: Release
+
+on:
+ push:
+ tags: ['*']
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16
+
+ - name: Create package
+ run: |
+ rm -rf *.tar.gz
+ npx --yes wspackager
+
+ - name: Check file existence
+ id: check_files
+ uses: andstor/file-existence-action@v1
+ with:
+ #files: "${{ github.event.repository.name }}_*.tar.gz"
+ files: "de.softcreatr*.tar.gz"
+
+ - name: On Build Failure
+ if: steps.check_files.outputs.files_exists == 'false'
+ run: |
+ echo "Packaging FAILED" && exit 1
+
+ - name: Release
+ uses: softprops/action-gh-release@v1
+ if: startsWith(github.ref, 'refs/tags/') && steps.check_files.outputs.files_exists == 'true'
+ with:
+ #files: "${{ github.event.repository.name }}_*.tar.gz"
+ files: "de.softcreatr*.tar.gz"
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 0000000..8cec04c
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,132 @@
+exclude('*/vendor/*')
+ ->in(__DIR__)
+ ->notPath('lib/system/api');
+
+return (new PhpCsFixer\Config())
+ ->setRiskyAllowed(true)
+ ->setRules([
+ '@PSR1' => true,
+ '@PSR2' => true,
+
+ 'array_push' => true,
+ 'backtick_to_shell_exec' => true,
+ 'no_alias_language_construct_call' => true,
+ 'no_mixed_echo_print' => true,
+ 'pow_to_exponentiation' => true,
+ 'random_api_migration' => true,
+
+ 'array_syntax' => ['syntax' => 'short'],
+ 'no_multiline_whitespace_around_double_arrow' => true,
+ 'no_trailing_comma_in_singleline_array' => true,
+ 'no_whitespace_before_comma_in_array' => true,
+ 'normalize_index_brace' => true,
+ 'whitespace_after_comma_in_array' => true,
+
+ 'non_printable_character' => ['use_escape_sequences_in_strings' => true],
+
+ 'lowercase_static_reference' => true,
+ 'magic_constant_casing' => true,
+ 'magic_method_casing' => true,
+ 'native_function_casing' => true,
+ 'native_function_type_declaration_casing' => true,
+
+ 'cast_spaces' => ['space' => 'none'],
+ 'lowercase_cast' => true,
+ 'no_unset_cast' => true,
+ 'short_scalar_cast' => true,
+
+ 'class_attributes_separation' => true,
+ 'no_blank_lines_after_class_opening' => true,
+ 'no_null_property_initialization' => true,
+ 'self_accessor' => true,
+ 'single_class_element_per_statement' => true,
+ 'single_trait_insert_per_statement' => true,
+
+ 'no_empty_comment' => true,
+ 'single_line_comment_style' => ['comment_types' => ['hash']],
+
+ 'native_constant_invocation' => ['strict' => false],
+
+ 'no_alternative_syntax' => true,
+ 'no_trailing_comma_in_list_call' => true,
+ 'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from']],
+ 'no_unneeded_curly_braces' => ['namespaces' => true],
+ 'switch_continue_to_break' => true,
+ 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
+
+ 'function_typehint_space' => true,
+ 'lambda_not_used_import' => true,
+ 'native_function_invocation' => ['include' => ['@all']],
+ 'no_unreachable_default_argument_value' => true,
+ 'nullable_type_declaration_for_default_null_value' => true,
+ 'return_type_declaration' => true,
+ 'static_lambda' => true,
+
+ 'fully_qualified_strict_types' => true,
+ 'no_leading_import_slash' => true,
+ 'no_unused_imports' => true,
+ //'ordered_imports' => true,
+
+ 'declare_equal_normalize' => true,
+ 'dir_constant' => true,
+ 'explicit_indirect_variable' => true,
+ 'function_to_constant' => true,
+ 'is_null' => true,
+ 'no_unset_on_property' => true,
+
+ 'list_syntax' => ['syntax' => 'short'],
+
+ 'clean_namespace' => true,
+ 'no_leading_namespace_whitespace' => true,
+ 'single_blank_line_before_namespace' => true,
+
+ 'no_homoglyph_names' => true,
+
+ 'binary_operator_spaces' => true,
+ 'concat_space' => ['spacing' => 'one'],
+ 'increment_style' => ['style' => 'post'],
+ 'logical_operators' => true,
+ 'object_operator_without_whitespace' => true,
+ 'operator_linebreak' => true,
+ 'standardize_increment' => true,
+ 'standardize_not_equals' => true,
+ 'ternary_operator_spaces' => true,
+ 'ternary_to_elvis_operator' => true,
+ 'ternary_to_null_coalescing' => true,
+ 'unary_operator_spaces' => true,
+
+ 'no_useless_return' => true,
+ 'return_assignment' => true,
+
+ 'multiline_whitespace_before_semicolons' => true,
+ 'no_empty_statement' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
+
+ 'escape_implicit_backslashes' => true,
+ 'explicit_string_variable' => true,
+ 'heredoc_to_nowdoc' => true,
+ 'no_binary_string' => true,
+ 'simple_to_complex_string_variable' => true,
+
+ 'array_indentation' => true,
+ 'blank_line_before_statement' => ['statements' => ['return', 'exit']],
+ 'compact_nullable_typehint' => true,
+ 'method_chaining_indentation' => true,
+ 'no_extra_blank_lines' => ['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use']],
+ 'no_spaces_around_offset' => true,
+
+ // SoftCreatR style
+ 'blank_line_between_import_groups' => true,
+ 'global_namespace_import' => [
+ 'import_classes' => true,
+ 'import_constants' => true,
+ 'import_functions' => false,
+ ],
+ 'ordered_imports' => [
+ 'imports_order' => ['class', 'function', 'const'],
+ ],
+ ])
+ ->setFinder($finder);
diff --git a/acptemplates/__uzbotAddNotifyWbb.tpl b/acptemplates/__uzbotAddNotifyWbb.tpl
index 3ac91a6..d2a5dbb 100644
--- a/acptemplates/__uzbotAddNotifyWbb.tpl
+++ b/acptemplates/__uzbotAddNotifyWbb.tpl
@@ -1,64 +1,64 @@
diff --git a/acptemplates/__uzbotAddNotifyWbbJS.tpl b/acptemplates/__uzbotAddNotifyWbbJS.tpl
index 02699f7..ce079ff 100644
--- a/acptemplates/__uzbotAddNotifyWbbJS.tpl
+++ b/acptemplates/__uzbotAddNotifyWbbJS.tpl
@@ -1,10 +1,10 @@
$('.notifyWbbPostSettings, .notifyWbbThreadSettings').hide();
if ($value == 10) {
- $('.notifyWbbThreadSettings, .notifySubject, .notifyTags').show();
- $('#notifyLabelContainer').show();
+ $('.notifyWbbThreadSettings, .notifySubject, .notifyTags').show();
+ $('#notifyLabelContainer').show();
}
if ($value == 11) {
- $('.notifyWbbPostSettings').show();
+ $('.notifyWbbPostSettings').show();
}
diff --git a/acptemplates/__uzbotAddTypeWbb.tpl b/acptemplates/__uzbotAddTypeWbb.tpl
index ae09590..c2ba7cd 100644
--- a/acptemplates/__uzbotAddTypeWbb.tpl
+++ b/acptemplates/__uzbotAddTypeWbb.tpl
@@ -1,282 +1,282 @@
-
-
-
- {lang}wcf.acp.uzbot.wbb.threadNew.threadNewBoardIDs{/lang}
-
-
- {foreach from=$boardNodeList item=boardNode}
- getBoard()->boardID|in_array:$threadNewBoardIDs} selected{/if}>{if $boardNode->getDepth() > 1}{@' '|str_repeat:-1+$boardNode->getDepth()}{/if}{$boardNode->getBoard()->title|language}
- {/foreach}
-
-
- {if $errorField == 'threadNewBoardIDs'}
-
- {lang}wcf.acp.uzbot.wbb.threadNew.threadNewBoardIDs.error.{@$errorType}{/lang}
-
- {/if}
-
-
+
+
+
+ {lang}wcf.acp.uzbot.wbb.threadNew.threadNewBoardIDs{/lang}
+
+
+ {foreach from=$boardNodeList item=boardNode}
+ getBoard()->boardID|in_array:$threadNewBoardIDs} selected{/if}>{if $boardNode->getDepth() > 1}{@' '|str_repeat:-1+$boardNode->getDepth()}{/if}{$boardNode->getBoard()->title|language}
+ {/foreach}
+
+
+ {if $errorField == 'threadNewBoardIDs'}
+
+ {lang}wcf.acp.uzbot.wbb.threadNew.threadNewBoardIDs.error.{@$errorType}{/lang}
+
+ {/if}
+
+
-
-
+
+
-
-
-
{lang}wcf.acp.uzbot.type.description.notifyOnly{/lang}
+
+
+
{lang}wcf.acp.uzbot.type.description.notifyOnly{/lang}
-
- {lang}wcf.acp.uzbot.wbb.uzbotBoardIDs{/lang}
-
-
- {foreach from=$boardNodeList item=boardNode}
- getBoard()->boardID|in_array:$uzbotBoardIDs} selected{/if}>{if $boardNode->getDepth() > 1}{@' '|str_repeat:-1+$boardNode->getDepth()}{/if}{$boardNode->getBoard()->title|language}
- {/foreach}
-
-
- {if $errorField == 'uzbotBoardIDs'}
-
- {lang}wcf.acp.uzbot.wbb.uzbotBoardIDs.error.{@$errorType}{/lang}
-
- {/if}
-
-
+
+ {lang}wcf.acp.uzbot.wbb.uzbotBoardIDs{/lang}
+
+
+ {foreach from=$boardNodeList item=boardNode}
+ getBoard()->boardID|in_array:$uzbotBoardIDs} selected{/if}>{if $boardNode->getDepth() > 1}{@' '|str_repeat:-1+$boardNode->getDepth()}{/if}{$boardNode->getBoard()->title|language}
+ {/foreach}
+
+
+ {if $errorField == 'uzbotBoardIDs'}
+
+ {lang}wcf.acp.uzbot.wbb.uzbotBoardIDs.error.{@$errorType}{/lang}
+
+ {/if}
+
+
-
-
-
- {foreach from=$wbbConditions key='conditionGroup' item='conditionObjectTypes'}
-
-
- {foreach from=$conditionObjectTypes item='condition'}
- {@$condition->getProcessor()->getHtml()}
- {/foreach}
-
-
- {/foreach}
-
+
+
+
+ {foreach from=$wbbConditions key='conditionGroup' item='conditionObjectTypes'}
+
+
+ {foreach from=$conditionObjectTypes item='condition'}
+ {@$condition->getProcessor()->getHtml()}
+ {/foreach}
+
+
+ {/foreach}
+
diff --git a/acptemplates/__uzbotAddTypeWbbJS.tpl b/acptemplates/__uzbotAddTypeWbbJS.tpl
index ef1088b..ba3476f 100644
--- a/acptemplates/__uzbotAddTypeWbbJS.tpl
+++ b/acptemplates/__uzbotAddTypeWbbJS.tpl
@@ -3,46 +3,46 @@ $('.wbb_threadModification, .wbb_threadModeration, .wbb_topPoster, .wbb_statisti
$('.wbbUzbotBoardIDs, .wbbConditionSettings, .wbbBoardIDs').hide();
if (value == 30) {
- $('.wbb_postChange, .wbbUzbotBoardIDs, .uzbotUserConditions').show();
- $('#receiverAffected').show();
+ $('.wbb_postChange, .wbbUzbotBoardIDs, .uzbotUserConditions').show();
+ $('#receiverAffected').show();
}
if (value == 31) {
- $('.wbb_postCount, .uzbotUserConditions, .user_count').show();
- $('#receiverAffected').show();
+ $('.wbb_postCount, .uzbotUserConditions, .user_count').show();
+ $('#receiverAffected').show();
}
if (value == 32) {
- $('.wbb_postModeration, .wbbUzbotBoardIDs, .uzbotUserConditions, .affectedSetting').show();
- $('#receiverAffected').show();
+ $('.wbb_postModeration, .wbbUzbotBoardIDs, .uzbotUserConditions, .affectedSetting').show();
+ $('#receiverAffected').show();
}
if (value == 40) {
- $('.wbb_threadModeration, .wbbUzbotBoardIDs, .uzbotUserConditions, .affectedSetting').show();
- $('#receiverAffected').show();
+ $('.wbb_threadModeration, .wbbUzbotBoardIDs, .uzbotUserConditions, .affectedSetting').show();
+ $('#receiverAffected').show();
}
if (value == 41) {
- $('.wbb_threadModification, .wbbConditionSettings').show();
- $('#receiverAffected, #actionLabelContainer, #conditionLabelContainer').show();
+ $('.wbb_threadModification, .wbbConditionSettings').show();
+ $('#receiverAffected, #actionLabelContainer, #conditionLabelContainer').show();
}
if (value == 42) {
- $('.wbb_threadNew, .uzbotUserConditions').show();
- $('#receiverAffected').show();
+ $('.wbb_threadNew, .uzbotUserConditions').show();
+ $('#receiverAffected').show();
}
if (value == 43) {
- $('.wbb_topPoster, .wbbUzbotBoardIDs, .condenseSetting, .uzbotUserConditions').show();
- $('#receiverAffected').show();
- if ($('#condenseEnable').is(':checked')) { $('.notifyCondense').show(); }
+ $('.wbb_topPoster, .wbbUzbotBoardIDs, .condenseSetting, .uzbotUserConditions').show();
+ $('#receiverAffected').show();
+ if ($('#condenseEnable').is(':checked')) { $('.notifyCondense').show(); }
}
if (value == 44) {
- $('.wbb_statistics').show();
+ $('.wbb_statistics').show();
}
if (value == 45) {
- $('.wbb_bestAnswer, .wbbUzbotBoardIDs').show();
- $('#receiverAffected').show();
+ $('.wbb_bestAnswer, .wbbUzbotBoardIDs').show();
+ $('#receiverAffected').show();
}
diff --git a/cronjob.xml b/cronjob.xml
index 767e0d8..9191378 100644
--- a/cronjob.xml
+++ b/cronjob.xml
@@ -1,46 +1,46 @@
-
-
- wbb\system\cronjob\UzbotThreadModificationCronjob
-
-
- */30
- *
- *
- *
- *
- 1
- 1
- 1
-
-
-
- wbb\system\cronjob\UzbotPostTopPosterCronjob
-
-
- */30
- *
- *
- *
- *
- 1
- 1
- 1
-
-
-
- wbb\system\cronjob\UzbotStatsWbbCronjob
-
-
- 0
- 5
- *
- *
- *
- 1
- 1
- 1
-
-
+
+
+ wbb\system\cronjob\UzbotThreadModificationCronjob
+
+
+ */30
+ *
+ *
+ *
+ *
+ 1
+ 1
+ 1
+
+
+
+ wbb\system\cronjob\UzbotPostTopPosterCronjob
+
+
+ */30
+ *
+ *
+ *
+ *
+ 1
+ 1
+ 1
+
+
+
+ wbb\system\cronjob\UzbotStatsWbbCronjob
+
+
+ 0
+ 5
+ *
+ *
+ *
+ 1
+ 1
+ 1
+
+
diff --git a/eventListener.xml b/eventListener.xml
index 64ed273..8a12c32 100644
--- a/eventListener.xml
+++ b/eventListener.xml
@@ -1,66 +1,66 @@
-
-
- wcf\acp\form\UzbotAddForm
- assignVariables,readFormParameters,save,validate,saved
- wbb\system\event\listener\UzbotAddFormWbbListener
- 1
- admin
-
-
-
- wcf\acp\form\UzbotEditForm
- readData
- wbb\system\event\listener\UzbotAddFormWbbListener
- admin
-
-
-
- wbb\data\thread\ThreadAction
- finalizeAction
- wbb\system\event\listener\UzbotThreadActionListener
- user
-
-
- wbb\data\thread\ThreadAction
- finalizeAction
- wbb\system\event\listener\UzbotThreadActionListener
- admin
-
-
-
- wbb\data\post\PostAction
- finalizeAction
- wbb\system\event\listener\UzbotPostActionListener
- user
-
-
- wbb\data\post\PostAction
- finalizeAction
- wbb\system\event\listener\UzbotPostActionListener
- admin
-
-
-
- wcf\data\modification\log\ModificationLogAction
- finalizeAction
- wbb\system\event\listener\UzbotThreadModerationListener
- user
-
-
-
- wcf\data\modification\log\ModificationLogAction
- finalizeAction
- wbb\system\event\listener\UzbotPostModerationListener
- user
-
-
-
- wcf\data\uzbot\UzbotAction
- finalizeAction
- wbb\system\event\listener\UzbotWbbDeleteBotListener
- admin
-
-
+
+
+ wcf\acp\form\UzbotAddForm
+ assignVariables,readFormParameters,save,validate,saved
+ wbb\system\event\listener\UzbotAddFormWbbListener
+ 1
+ admin
+
+
+
+ wcf\acp\form\UzbotEditForm
+ readData
+ wbb\system\event\listener\UzbotAddFormWbbListener
+ admin
+
+
+
+ wbb\data\thread\ThreadAction
+ finalizeAction
+ wbb\system\event\listener\UzbotThreadActionListener
+ user
+
+
+ wbb\data\thread\ThreadAction
+ finalizeAction
+ wbb\system\event\listener\UzbotThreadActionListener
+ admin
+
+
+
+ wbb\data\post\PostAction
+ finalizeAction
+ wbb\system\event\listener\UzbotPostActionListener
+ user
+
+
+ wbb\data\post\PostAction
+ finalizeAction
+ wbb\system\event\listener\UzbotPostActionListener
+ admin
+
+
+
+ wcf\data\modification\log\ModificationLogAction
+ finalizeAction
+ wbb\system\event\listener\UzbotThreadModerationListener
+ user
+
+
+
+ wcf\data\modification\log\ModificationLogAction
+ finalizeAction
+ wbb\system\event\listener\UzbotPostModerationListener
+ user
+
+
+
+ wcf\data\uzbot\UzbotAction
+ finalizeAction
+ wbb\system\event\listener\UzbotWbbDeleteBotListener
+ admin
+
+
diff --git a/files/acp/install_com.uz.wcf.bot3.wbb.php b/files/acp/install_com.uz.wcf.bot3.wbb.php
index 4c93caf..7b9598f 100644
--- a/files/acp/install_com.uz.wcf.bot3.wbb.php
+++ b/files/acp/install_com.uz.wcf.bot3.wbb.php
@@ -1,28 +1,46 @@
- * @package com.uz.wcf.bot3.wbb
+ * Initializes wbb top data for Bot
*/
// posts
$topPosterID = null;
-$sql = "SELECT userID, wbbPosts
- FROM wcf".WCF_N."_user
- ORDER BY wbbPosts DESC";
+$sql = "SELECT userID, wbbPosts
+ FROM wcf" . WCF_N . "_user
+ ORDER BY wbbPosts DESC";
$statement = WCF::getDB()->prepareStatement($sql, 1);
$statement->execute();
$row = $statement->fetchArray();
-if (!empty($row)) $topPosterID = $row['userID'];
+if (!empty($row)) {
+ $topPosterID = $row['userID'];
+}
$action = new UzbotTopAction([1], 'update', [
- 'data' => [
- 'post' => $topPosterID
- ]
+ 'data' => [
+ 'post' => $topPosterID,
+ ],
]);
-$action->executeAction();
\ No newline at end of file
+$action->executeAction();
diff --git a/files/lib/data/uzbot/notification/UzbotNotifyForumPost.class.php b/files/lib/data/uzbot/notification/UzbotNotifyForumPost.class.php
index 0940c0d..840426d 100644
--- a/files/lib/data/uzbot/notification/UzbotNotifyForumPost.class.php
+++ b/files/lib/data/uzbot/notification/UzbotNotifyForumPost.class.php
@@ -1,11 +1,32 @@
-
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotNotifyForumPost {
- public function send(Uzbot $bot, $content, $subject, $teaser, $language, $receiver, $tags) {
- // prepare texts and data
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- $content = MessageUtil::stripCrap($content);
-
- // ufn no subject
- //$subject = MessageUtil::stripCrap(StringUtil::stripHTML($subject));
- //if (mb_strlen($subject) > 255) $subject = mb_substr($subject, 0, 250) . '...';
- $subject = '';
-
- // set publication time
- $publicationTime = TIME_NOW;
- if (isset($bot->publicationTime) && $bot->publicationTime) {
- $publicationTime = $bot->publicationTime;
- }
-
- if (!$bot->testMode) {
- $htmlInputProcessor = new HtmlInputProcessor();
- $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
-
- // get post data and create
- try {
- $wbbPostData = unserialize($bot->wbbPostData);
-
- // preset thread, maybe 0 on automatic post in affected thread
- if (!$wbbPostData['postNotifyThreadID']) {
- $wbbPostData['postNotifyThreadID'] = $bot->threadID;
- }
-
- $thread = new Thread($wbbPostData['postNotifyThreadID']);
- $board = $thread->getBoard();
-
- $htmlInputProcessor = new HtmlInputProcessor();
- $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
-
- $postData = [
- 'threadID' => $thread->threadID,
- 'subject' => $subject,
- 'message' => $content,
- 'time' => $publicationTime,
- 'userID' => $bot->senderID,
- 'username' => $bot->sendername,
- 'enableTime' => 0,
- 'isClosed' => $wbbPostData['postNotifyIsClosed'],
- 'isDisabled' => $wbbPostData['postNotifyIsDisabled'],
- 'ipAddress' => '',
- 'isOfficial' => $bot->postIsOfficial,
- 'isUzbot' => 1
- ];
-
- $postCreateParameters = [
- 'data' => $postData,
- 'thread' => $thread,
- 'board' => $board,
- 'isFirstPost' => false,
- 'attachmentHandler' => null,
- 'htmlInputProcessor' => $htmlInputProcessor
- ];
-
- $postAction = new PostAction([], 'create', $postCreateParameters);
- $postAction->executeAction();
- }
- catch (SystemException $e) {
- // users may get lost; check sender again to abort
- if (!$bot->checkSender(true, true)) return false;
-
- // thread must exist / disable
- if (!$thread->threadID) {
- $editor = new UzbotEditor($bot);
- $editor->update(['isDisabled' => 1]);
- UzbotEditor::resetCache();
-
- if ($bot->enableLog) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'status' => 2,
- 'additionalData' => 'wcf.acp.uzbot.notify.post.threadID.error.notValid'
- ]);
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'status' => 2,
- 'additionalData' => 'wcf.acp.uzbot.error.disabled'
- ]);
- }
- return false;
- }
-
- // report any other error und continue
- if ($bot->enableLog) {
- $error = $defaultLanguage->get('wcf.acp.uzbot.log.notify.error') . ' ' . $e->getMessage();
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'status' => 1,
- 'count' => 1,
- 'additionalData' => $error
- ]);
- }
- }
- }
- else {
- $teaser = '';
- if (mb_strlen($content) > 63500) $content = mb_substr($content, 0, 63500) . ' ...';
- $result = serialize([$subject, $teaser, $content]);
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => $result
- ]);
- }
- }
+class UzbotNotifyForumPost
+{
+ public function send(Uzbot $bot, $content, $subject, $teaser, $language, $receiver, $tags)
+ {
+ // prepare texts and data
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ $content = MessageUtil::stripCrap($content);
+
+ // ufn no subject
+ //$subject = MessageUtil::stripCrap(StringUtil::stripHTML($subject));
+ //if (mb_strlen($subject) > 255) $subject = mb_substr($subject, 0, 250) . '...';
+ $subject = '';
+
+ // set publication time
+ $publicationTime = TIME_NOW;
+ if (isset($bot->publicationTime) && $bot->publicationTime) {
+ $publicationTime = $bot->publicationTime;
+ }
+
+ if (!$bot->testMode) {
+ $htmlInputProcessor = new HtmlInputProcessor();
+ $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
+
+ // get post data and create
+ try {
+ $wbbPostData = \unserialize($bot->wbbPostData);
+
+ // preset thread, maybe 0 on automatic post in affected thread
+ if (!$wbbPostData['postNotifyThreadID']) {
+ $wbbPostData['postNotifyThreadID'] = $bot->threadID;
+ }
+
+ $thread = new Thread($wbbPostData['postNotifyThreadID']);
+ $board = $thread->getBoard();
+
+ $htmlInputProcessor = new HtmlInputProcessor();
+ $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
+
+ $postData = [
+ 'threadID' => $thread->threadID,
+ 'subject' => $subject,
+ 'message' => $content,
+ 'time' => $publicationTime,
+ 'userID' => $bot->senderID,
+ 'username' => $bot->sendername,
+ 'enableTime' => 0,
+ 'isClosed' => $wbbPostData['postNotifyIsClosed'],
+ 'isDisabled' => $wbbPostData['postNotifyIsDisabled'],
+ 'ipAddress' => '',
+ 'isOfficial' => $bot->postIsOfficial,
+ 'isUzbot' => 1,
+ ];
+
+ $postCreateParameters = [
+ 'data' => $postData,
+ 'thread' => $thread,
+ 'board' => $board,
+ 'isFirstPost' => false,
+ 'attachmentHandler' => null,
+ 'htmlInputProcessor' => $htmlInputProcessor,
+ ];
+
+ $postAction = new PostAction([], 'create', $postCreateParameters);
+ $postAction->executeAction();
+ } catch (SystemException $e) {
+ // users may get lost; check sender again to abort
+ if (!$bot->checkSender(true, true)) {
+ return false;
+ }
+
+ // thread must exist / disable
+ if (!$thread->threadID) {
+ $editor = new UzbotEditor($bot);
+ $editor->update(['isDisabled' => 1]);
+ UzbotEditor::resetCache();
+
+ if ($bot->enableLog) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'status' => 2,
+ 'additionalData' => 'wcf.acp.uzbot.notify.post.threadID.error.notValid',
+ ]);
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'status' => 2,
+ 'additionalData' => 'wcf.acp.uzbot.error.disabled',
+ ]);
+ }
+
+ return false;
+ }
+
+ // report any other error und continue
+ if ($bot->enableLog) {
+ $error = $defaultLanguage->get('wcf.acp.uzbot.log.notify.error') . ' ' . $e->getMessage();
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'status' => 1,
+ 'count' => 1,
+ 'additionalData' => $error,
+ ]);
+ }
+ }
+ } else {
+ $teaser = '';
+ if (\mb_strlen($content) > 63500) {
+ $content = \mb_substr($content, 0, 63500) . ' ...';
+ }
+ $result = \serialize([$subject, $teaser, $content]);
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => $result,
+ ]);
+ }
+ }
}
diff --git a/files/lib/data/uzbot/notification/UzbotNotifyForumThread.class.php b/files/lib/data/uzbot/notification/UzbotNotifyForumThread.class.php
index 54ad67d..5e575db 100644
--- a/files/lib/data/uzbot/notification/UzbotNotifyForumThread.class.php
+++ b/files/lib/data/uzbot/notification/UzbotNotifyForumThread.class.php
@@ -1,13 +1,35 @@
-
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotNotifyForumThread {
- public function send(Uzbot $bot, $content, $subject, $teaser, $language, $receiver, $tags) {
- // prepare text and data
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- $content = MessageUtil::stripCrap($content);
- $subject = MessageUtil::stripCrap(StringUtil::stripHTML($subject));
- if (mb_strlen($subject) > 255) $subject = mb_substr($subject, 0, 250) . '...';
-
- // set publication time
- $publicationTime = TIME_NOW;
- if (isset($bot->publicationTime) && $bot->publicationTime) {
- $publicationTime = $bot->publicationTime;
- }
-
- if (!$bot->testMode) {
- $htmlInputProcessor = new HtmlInputProcessor();
- $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
-
- // get thread / notification data
- $wbbThreadData = unserialize($bot->wbbThreadData);
- $assignedLabels = UzbotNotificationLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
-
- // tags to include feedreader
- if (!MODULE_TAGGING || !WBB_THREAD_ENABLE_TAGS) {
- $tags = [];
- }
- else {
- if (isset($bot->feedreaderUseTags) && $bot->feedreaderUseTags) {
- if (isset($bot->feedreaderTags) && !empty($bot->feedreaderTags)) {
- $tags = array_unique(array_merge($tags, $bot->feedreaderTags));
- }
- }
- }
-
- if (!WBB_MODULE_THREAD_MARKING_AS_DONE) {
- $wbbThreadData['threadNotifyIsDone'] = 0;
- }
-
- // consider multilingualism for threads
- if (!LanguageFactory::getInstance()->multilingualismEnabled() || !$language->languageID) {
- $languageID = null;
- }
- else {
- $languageID = $language->languageID;
- }
-
- $data = [
- 'boardID' => $wbbThreadData['threadNotifyBoardID'],
- 'languageID' => $languageID,
- 'topic' => $subject,
- 'time' => $publicationTime,
- 'userID' => $bot->senderID,
- 'username' => $bot->sendername,
- 'isClosed' => $wbbThreadData['threadNotifyIsClosed'],
- 'isDisabled' => $wbbThreadData['threadNotifyIsDisabled'],
- 'isDone' => $wbbThreadData['threadNotifyIsDone'],
- 'isSticky' => $wbbThreadData['threadNotifyIsSticky'],
- 'hasLabels' => !empty($assignedLabels) ? 1 : 0,
- 'isUzbot' => 1
- ];
-
- // create thread
- try {
- // official post since 5.4
- $postData['isOfficial'] = $bot->threadIsOfficial;
-
- $action = new ThreadAction([], 'create', [
- 'data' => $data,
- 'postData' => $postData,
- 'tags' => $tags,
- 'subscribeThread' => false,
- 'htmlInputProcessor' => $htmlInputProcessor
- ]);
- $resultValues = $action->executeAction();
-
- // set labels
- if (!empty($assignedLabels)) {
- $labelIDs = [];
- foreach ($assignedLabels as $labels) {
- foreach ($labels as $label) {
- $labelIDs[] = $label->labelID;
- }
- }
- ThreadLabelObjectHandler::getInstance()->setLabels($labelIDs, $resultValues['returnValues']->threadID);
- }
-
- // update last post
- $boardEditor = new BoardEditor(BoardCache::getInstance()->getBoard($wbbThreadData['threadNotifyBoardID']));
- $boardEditor->updateLastPost();
- }
- catch (SystemException $e) {
- // users may get lost; check sender again to abort
- if (!$bot->checkSender(true, true)) return false;
-
- // report any other error und continue
- if ($bot->enableLog) {
- $error = $defaultLanguage->get('wcf.acp.uzbot.log.notify.error') . ' ' . $e->getMessage();
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'status' => 1,
- 'count' => 1,
- 'additionalData' => $error
- ]);
- }
- }
- }
- else {
- $teaser = '';
- if (mb_strlen($content) > 63500) $content = mb_substr($content, 0, 63500) . ' ...';
- $result = serialize([$subject, $teaser, $content]);
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => $result
- ]);
- }
- }
+class UzbotNotifyForumThread
+{
+ public function send(Uzbot $bot, $content, $subject, $teaser, $language, $receiver, $tags)
+ {
+ // prepare text and data
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ $content = MessageUtil::stripCrap($content);
+ $subject = MessageUtil::stripCrap(StringUtil::stripHTML($subject));
+ if (\mb_strlen($subject) > 255) {
+ $subject = \mb_substr($subject, 0, 250) . '...';
+ }
+
+ // set publication time
+ $publicationTime = TIME_NOW;
+ if (isset($bot->publicationTime) && $bot->publicationTime) {
+ $publicationTime = $bot->publicationTime;
+ }
+
+ if (!$bot->testMode) {
+ $htmlInputProcessor = new HtmlInputProcessor();
+ $htmlInputProcessor->process($content, 'com.woltlab.wbb.post', 0);
+
+ // get thread / notification data
+ $wbbThreadData = \unserialize($bot->wbbThreadData);
+ $assignedLabels = UzbotNotificationLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
+
+ // tags to include feedreader
+ if (!MODULE_TAGGING || !WBB_THREAD_ENABLE_TAGS) {
+ $tags = [];
+ } else {
+ if (isset($bot->feedreaderUseTags) && $bot->feedreaderUseTags) {
+ if (isset($bot->feedreaderTags) && !empty($bot->feedreaderTags)) {
+ $tags = \array_unique(\array_merge($tags, $bot->feedreaderTags));
+ }
+ }
+ }
+
+ if (!WBB_MODULE_THREAD_MARKING_AS_DONE) {
+ $wbbThreadData['threadNotifyIsDone'] = 0;
+ }
+
+ // consider multilingualism for threads
+ if (!LanguageFactory::getInstance()->multilingualismEnabled() || !$language->languageID) {
+ $languageID = null;
+ } else {
+ $languageID = $language->languageID;
+ }
+
+ $data = [
+ 'boardID' => $wbbThreadData['threadNotifyBoardID'],
+ 'languageID' => $languageID,
+ 'topic' => $subject,
+ 'time' => $publicationTime,
+ 'userID' => $bot->senderID,
+ 'username' => $bot->sendername,
+ 'isClosed' => $wbbThreadData['threadNotifyIsClosed'],
+ 'isDisabled' => $wbbThreadData['threadNotifyIsDisabled'],
+ 'isDone' => $wbbThreadData['threadNotifyIsDone'],
+ 'isSticky' => $wbbThreadData['threadNotifyIsSticky'],
+ 'hasLabels' => !empty($assignedLabels) ? 1 : 0,
+ 'isUzbot' => 1,
+ ];
+
+ // create thread
+ try {
+ // official post since 5.4
+ $postData['isOfficial'] = $bot->threadIsOfficial;
+
+ $action = new ThreadAction([], 'create', [
+ 'data' => $data,
+ 'postData' => $postData,
+ 'tags' => $tags,
+ 'subscribeThread' => false,
+ 'htmlInputProcessor' => $htmlInputProcessor,
+ ]);
+ $resultValues = $action->executeAction();
+
+ // set labels
+ if (!empty($assignedLabels)) {
+ $labelIDs = [];
+ foreach ($assignedLabels as $labels) {
+ foreach ($labels as $label) {
+ $labelIDs[] = $label->labelID;
+ }
+ }
+ ThreadLabelObjectHandler::getInstance()->setLabels($labelIDs, $resultValues['returnValues']->threadID);
+ }
+
+ // update last post
+ $boardEditor = new BoardEditor(BoardCache::getInstance()->getBoard($wbbThreadData['threadNotifyBoardID']));
+ $boardEditor->updateLastPost();
+ } catch (SystemException $e) {
+ // users may get lost; check sender again to abort
+ if (!$bot->checkSender(true, true)) {
+ return false;
+ }
+
+ // report any other error und continue
+ if ($bot->enableLog) {
+ $error = $defaultLanguage->get('wcf.acp.uzbot.log.notify.error') . ' ' . $e->getMessage();
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'status' => 1,
+ 'count' => 1,
+ 'additionalData' => $error,
+ ]);
+ }
+ }
+ } else {
+ $teaser = '';
+ if (\mb_strlen($content) > 63500) {
+ $content = \mb_substr($content, 0, 63500) . ' ...';
+ }
+ $result = \serialize([$subject, $teaser, $content]);
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => $result,
+ ]);
+ }
+ }
}
diff --git a/files/lib/system/condition/uzbot/UzbotThreadIntegerPropertyCondition.class.php b/files/lib/system/condition/uzbot/UzbotThreadIntegerPropertyCondition.class.php
index 213650e..5d980a0 100644
--- a/files/lib/system/condition/uzbot/UzbotThreadIntegerPropertyCondition.class.php
+++ b/files/lib/system/condition/uzbot/UzbotThreadIntegerPropertyCondition.class.php
@@ -1,5 +1,28 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotThreadIntegerPropertyCondition extends ThreadIntegerPropertyCondition {
- /**
- * @inheritDoc
- */
- public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof ThreadList)) {
- throw new \InvalidArgumentException("Object list is no instance of '".ThreadList::class."', instance of '".get_class($objectList)."' given.");
- }
-
- if (isset($conditionData['greaterThan'])) {
- $objectList->getConditionBuilder()->add('thread.'.$this->getPropertyName().' < ?', [TIME_NOW - 86400 * $conditionData['greaterThan']]);
- }
- }
-
- /**
- * @inheritDoc
- */
- protected function getLabel() {
- return WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.days.'.$this->getPropertyName());
- }
-
- /**
- * @inheritDoc
- */
- public function getFieldElement() {
- $greaterThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.greaterThan');
- $lessThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.lessThan');
-
- return <<getConditionBuilder()->add('thread.' . $this->getPropertyName() . ' < ?', [TIME_NOW - 86400 * $conditionData['greaterThan']]);
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected function getLabel()
+ {
+ return WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.days.' . $this->getPropertyName());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFieldElement()
+ {
+ $greaterThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.greaterThan');
+ $lessThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.lessThan');
+
+ return <<getMinMaxAttributes('greaterThan')} class="medium">
HTML;
- }
+ }
}
diff --git a/files/lib/system/condition/uzbot/UzbotThreadLabelStateCondition.class.php b/files/lib/system/condition/uzbot/UzbotThreadLabelStateCondition.class.php
index 769e0fe..114e15f 100644
--- a/files/lib/system/condition/uzbot/UzbotThreadLabelStateCondition.class.php
+++ b/files/lib/system/condition/uzbot/UzbotThreadLabelStateCondition.class.php
@@ -1,5 +1,28 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotThreadLabelStateCondition extends AbstractSingleFieldCondition implements IContentCondition, IObjectCondition, IObjectListCondition {
- /**
- * @inheritDoc
- */
- protected $label = 'wcf.acp.uzbot.wbb.condition.label';
-
- /**
- * values of the possible state
- * @var integer[]
- */
- protected $hasLabels = 0;
- protected $hasNoLabels = 0;
-
- /**
- * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition()
- */
- public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
- if (!($objectList instanceof ThreadList)) {
- throw new \InvalidArgumentException("Object list is no instance of '".ThreadList::class."', instance of '".get_class($objectList)."' given.");
- }
-
- if (isset($conditionData['hasLabels'])) {
- $objectList->getConditionBuilder()->add('thread.hasLabels = ?', [1]);
- }
- if (isset($conditionData['hasNoLabels'])) {
- $objectList->getConditionBuilder()->add('thread.hasLabels = ?', [0]);
- }
- }
-
- /**
- * @inheritDoc
- */
- public function checkObject(DatabaseObject $object, array $conditionData) {
- // don't need it
-
- return true;
- }
-
- /**
- * @see \wcf\system\condition\ICondition::getData()
- */
- public function getData() {
- $data = [];
-
- if ($this->hasLabels) $data['hasLabels'] = 1;
- if ($this->hasNoLabels) $data['hasNoLabels'] = 1;
-
- if (!empty($data)) {
- return $data;
- }
-
- return null;
- }
-
- /**
- * Returns the "checked" attribute for an input element.
- *
- * @param string $propertyName
- * @return string
- */
- protected function getCheckedAttribute($propertyName) {
- if ($this->$propertyName) {
- return ' checked';
- }
-
- return '';
- }
-
- /**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
- */
- protected function getFieldElement() {
- $hasNoLabels = WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.label.hasNoLabels');
- $hasLabels = WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.label.hasLabels');
-
- return <<getConditionBuilder()->add('thread.hasLabels = ?', [1]);
+ }
+ if (isset($conditionData['hasNoLabels'])) {
+ $objectList->getConditionBuilder()->add('thread.hasLabels = ?', [0]);
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function checkObject(DatabaseObject $object, array $conditionData)
+ {
+ // don't need it
+
+ return true;
+ }
+
+ /**
+ * @see \wcf\system\condition\ICondition::getData()
+ */
+ public function getData()
+ {
+ $data = [];
+
+ if ($this->hasLabels) {
+ $data['hasLabels'] = 1;
+ }
+ if ($this->hasNoLabels) {
+ $data['hasNoLabels'] = 1;
+ }
+
+ if (!empty($data)) {
+ return $data;
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the "checked" attribute for an input element.
+ *
+ * @param string $propertyName
+ * @return string
+ */
+ protected function getCheckedAttribute($propertyName)
+ {
+ if ($this->{$propertyName}) {
+ return ' checked';
+ }
+
+ return '';
+ }
+
+ /**
+ * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ */
+ protected function getFieldElement()
+ {
+ $hasNoLabels = WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.label.hasNoLabels');
+ $hasLabels = WCF::getLanguage()->get('wcf.acp.uzbot.wbb.condition.label.hasLabels');
+
+ return << getCheckedAttribute('hasLabels')}> {$hasLabels}
getCheckedAttribute('hasNoLabels')}> {$hasNoLabels}
HTML;
- }
-
- /**
- * @inheritDoc
- */
- public function readFormParameters() {
- if (isset($_POST['uzbotHasLabels'])) $this->hasLabels = 1;
- if (isset($_POST['uzbotHasNoLabels'])) $this->hasNoLabels = 1;
- }
-
- /**
- * @see \wcf\system\condition\ICondition::reset()
- */
- public function reset() {
- $this->hasLabels = 0;
- $this->hasNoLabels = 0;
- }
-
- /**
- * @see \wcf\system\condition\ICondition::setData()
- */
- public function setData(Condition $condition) {
- if ($condition->hasLabels !== null) {
- $this->hasLabels = $condition->hasLabels;
- }
-
- if ($condition->hasNoLabels !== null) {
- $this->hasNoLabels = $condition->hasNoLabels;
- }
- }
-
- /**
- * @inheritDoc
- */
- public function showContent(Condition $condition) {
- // don't need it
- return null;
- }
-
- /**
- * @see \wcf\system\condition\ICondition::validate()
- */
- public function validate() {
- if ($this->hasLabels && $this->hasNoLabels) {
- $this->errorMessage = 'wcf.acp.uzbot.wbb.condition.label.error.conflict';
-
- throw new UserInputException('uzbotHasNoLabels', 'conflict');
- }
- }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function readFormParameters()
+ {
+ if (isset($_POST['uzbotHasLabels'])) {
+ $this->hasLabels = 1;
+ }
+ if (isset($_POST['uzbotHasNoLabels'])) {
+ $this->hasNoLabels = 1;
+ }
+ }
+
+ /**
+ * @see \wcf\system\condition\ICondition::reset()
+ */
+ public function reset()
+ {
+ $this->hasLabels = 0;
+ $this->hasNoLabels = 0;
+ }
+
+ /**
+ * @see \wcf\system\condition\ICondition::setData()
+ */
+ public function setData(Condition $condition)
+ {
+ if ($condition->hasLabels !== null) {
+ $this->hasLabels = $condition->hasLabels;
+ }
+
+ if ($condition->hasNoLabels !== null) {
+ $this->hasNoLabels = $condition->hasNoLabels;
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function showContent(Condition $condition)
+ {
+ // don't need it
+ return null;
+ }
+
+ /**
+ * @see \wcf\system\condition\ICondition::validate()
+ */
+ public function validate()
+ {
+ if ($this->hasLabels && $this->hasNoLabels) {
+ $this->errorMessage = 'wcf.acp.uzbot.wbb.condition.label.error.conflict';
+
+ throw new UserInputException('uzbotHasNoLabels', 'conflict');
+ }
+ }
}
diff --git a/files/lib/system/condition/uzbot/UzbotWbbConditionHandler.class.php b/files/lib/system/condition/uzbot/UzbotWbbConditionHandler.class.php
index c5ab44c..f4fc56c 100644
--- a/files/lib/system/condition/uzbot/UzbotWbbConditionHandler.class.php
+++ b/files/lib/system/condition/uzbot/UzbotWbbConditionHandler.class.php
@@ -1,46 +1,68 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotWbbConditionHandler extends SingletonFactory {
- /**
- * list of grouped user group / inactive assignment condition object types
- * @var array
- */
- protected $groupedObjectTypes = [];
-
- /**
- * Returns the list of grouped user group / inactive assignment condition object types.
- *
- * @return array
- */
- public function getGroupedObjectTypes() {
- return $this->groupedObjectTypes;
- }
-
- /**
- * @see \wcf\system\SingletonFactory::init()
- */
- protected function init() {
- $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.uz.wcf.bot.condition.wbb');
-
- foreach ($objectTypes as $objectType) {
- if (!$objectType->conditiongroup) continue;
-
- if (!isset($this->groupedObjectTypes[$objectType->conditiongroup])) {
- $this->groupedObjectTypes[$objectType->conditiongroup] = [];
- }
-
- $this->groupedObjectTypes[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
- }
- }
+class UzbotWbbConditionHandler extends SingletonFactory
+{
+ /**
+ * list of grouped user group / inactive assignment condition object types
+ * @var array
+ */
+ protected $groupedObjectTypes = [];
+
+ /**
+ * Returns the list of grouped user group / inactive assignment condition object types.
+ *
+ * @return array
+ */
+ public function getGroupedObjectTypes()
+ {
+ return $this->groupedObjectTypes;
+ }
+
+ /**
+ * @see \wcf\system\SingletonFactory::init()
+ */
+ protected function init()
+ {
+ $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.uz.wcf.bot.condition.wbb');
+
+ foreach ($objectTypes as $objectType) {
+ if (!$objectType->conditiongroup) {
+ continue;
+ }
+
+ if (!isset($this->groupedObjectTypes[$objectType->conditiongroup])) {
+ $this->groupedObjectTypes[$objectType->conditiongroup] = [];
+ }
+
+ $this->groupedObjectTypes[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
+ }
+ }
}
diff --git a/files/lib/system/cronjob/UzbotPostTopPosterCronjob.class.php b/files/lib/system/cronjob/UzbotPostTopPosterCronjob.class.php
index 6e4591c..38ddc8c 100644
--- a/files/lib/system/cronjob/UzbotPostTopPosterCronjob.class.php
+++ b/files/lib/system/cronjob/UzbotPostTopPosterCronjob.class.php
@@ -1,11 +1,31 @@
-
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotPostTopPosterCronjob extends AbstractCronjob {
- /**
- * @see wcf\system\cronjob\ICronjob::execute()
- */
- public function execute(Cronjob $cronjob) {
- parent::execute($cronjob);
-
- if (!MODULE_UZBOT) return;
-
- // Read all active, valid activity bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(array('typeDes' => 'wbb_topPoster'));
- if (empty($bots)) return;
-
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- // Step through all bots and get top poster
- foreach ($bots as $bot) {
- // set first next if 0
- if (!$bot->topPosterNext) {
- $month = date('n');
- $year = date('Y');
-
- switch ($bot->topPosterInterval) {
- case 1:
- $next = strtotime('next Monday');
- break;
- case 2:
- $next = gmmktime(0, 0, 0, $month != 12 ? $month + 1 : 1, 1, $month != 12 ? $year : $year + 1);
- break;
- case 3:
- if ($month >= 10) $next = gmmktime(0, 0, 0, 1, 1, $year + 1);
- elseif ($month >= 7) $next = gmmktime(0, 0, 0, 10, 1, $year);
- elseif ($month >= 4) $next = gmmktime(0, 0, 0, 7, 1, $year);
- else $next = gmmktime(0, 0, 0, 4, 1, $year);
- break;
- }
-
- $editor = new UzbotEditor($bot);
- $editor->update(['topPosterNext' => $next]);
- UzbotEditor::resetCache();
-
- $bot->topPosterNext = $next;
- }
-
- // leave if time does not match, unless test mode
- if (!$bot->testMode) {
- if ($bot->topPosterNext > TIME_NOW) continue;
- }
-
- // must execute
- $end = $bot->topPosterNext;
- $month = date('n');
- $year = date('Y');
-
- switch ($bot->topPosterInterval) {
- case 1:
- $start = $end - 7 * 86400;
- $next = $end + 7 * 86400;
- break;
- case 2:
- $start = gmmktime(0, 0, 0, $month > 1 ? $month - 1 : 12, 1, $month > 1 ? $year : $year - 1);
- $next = gmmktime(0, 0, 0, $month != 12 ? $month + 1 : 1, 1, $month != 12 ? $year : $year + 1);
- break;
- case 3:
- $start = gmmktime(0, 0, 0, $month > 3 ? $month - 3 : 10, 1, $month > 3 ? $year : $year - 1);
- if ($month >= 10) $next = gmmktime(0, 0, 0, 1, 1, $year + 1);
- elseif ($month >= 7) $next = gmmktime(0, 0, 0, 10, 1, $year);
- elseif ($month >= 4) $next = gmmktime(0, 0, 0, 7, 1, $year);
- else $next = gmmktime(0, 0, 0, 4, 1, $year);
- break;
- }
-
- // update bot, unless test mode
- if (!$bot->testMode) {
- $editor = new UzbotEditor($bot);
- $editor->update(['topPosterNext' => $next]);
- UzbotEditor::resetCache();
- }
-
- // get top poster
- $affectedUserIDs = $countToUserID = $placeholders = $userIDs = [];
- $rank = 0;
-
- $boardIDs = unserialize($bot->uzbotBoardIDs);
- $conditions = $bot->getUserConditions();
- if (count($conditions)) {
- $userList = new UserList();
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- $temp = $userList->getObjects();
- if (count($temp)) {
- foreach ($temp as $user) {
- $userIDs[] = $user->userID;
- }
- }
- }
-
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('board.boardID IN (?)', [$boardIDs]);
- if (count($userIDs)) $conditionBuilder->add('post.userID IN (?)', [$userIDs]);
- else $conditionBuilder->add('post.userID > ?', [0]);
- $conditionBuilder->add('post.isDeleted = ?', [0]);
- $conditionBuilder->add('post.time > ?', [$start]);
- $conditionBuilder->add('post.time < ?', [$end]);
-
- $sql = "SELECT post.userID as topID, COUNT(*) as count
- FROM wbb".WCF_N."_post post
- LEFT JOIN wbb".WCF_N."_thread thread ON (thread.threadID = post.threadID)
- LEFT JOIN wbb".WCF_N."_board board ON (board.boardID = thread.boardID)
- ".$conditionBuilder."
- GROUP BY topID
- ORDER BY count DESC";
-
- $statement = WCF::getDB()->prepareStatement($sql, $bot->topPosterCount);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $rank ++;
- $affectedUserIDs[] = $row['topID'];
- $countToUserID[$row['topID']] = $row['count'];
- $placeholders['ranks'][$row['topID']] = $rank;
- }
-
- // data
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => count($affectedUserIDs),
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => count($affectedUserIDs),
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => count($affectedUserIDs),
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // notification
- if (!count($affectedUserIDs)) continue;
-
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- $placeholders['date-from'] = $placeholders['time-from'] = $start;
- $placeholders['date-to'] = $placeholders['time-to'] = $end - 1;
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
+class UzbotPostTopPosterCronjob extends AbstractCronjob
+{
+ /**
+ * @see wcf\system\cronjob\ICronjob::execute()
+ */
+ public function execute(Cronjob $cronjob)
+ {
+ parent::execute($cronjob);
+
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // Read all active, valid activity bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_topPoster']);
+ if (empty($bots)) {
+ return;
+ }
+
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ // Step through all bots and get top poster
+ foreach ($bots as $bot) {
+ // set first next if 0
+ if (!$bot->topPosterNext) {
+ $month = \date('n');
+ $year = \date('Y');
+
+ switch ($bot->topPosterInterval) {
+ case 1:
+ $next = \strtotime('next Monday');
+ break;
+ case 2:
+ $next = \gmmktime(0, 0, 0, $month != 12 ? $month + 1 : 1, 1, $month != 12 ? $year : $year + 1);
+ break;
+ case 3:
+ if ($month >= 10) {
+ $next = \gmmktime(0, 0, 0, 1, 1, $year + 1);
+ } elseif ($month >= 7) {
+ $next = \gmmktime(0, 0, 0, 10, 1, $year);
+ } elseif ($month >= 4) {
+ $next = \gmmktime(0, 0, 0, 7, 1, $year);
+ } else {
+ $next = \gmmktime(0, 0, 0, 4, 1, $year);
+ }
+ break;
+ }
+
+ $editor = new UzbotEditor($bot);
+ $editor->update(['topPosterNext' => $next]);
+ UzbotEditor::resetCache();
+
+ $bot->topPosterNext = $next;
+ }
+
+ // leave if time does not match, unless test mode
+ if (!$bot->testMode) {
+ if ($bot->topPosterNext > TIME_NOW) {
+ continue;
+ }
+ }
+
+ // must execute
+ $end = $bot->topPosterNext;
+ $month = \date('n');
+ $year = \date('Y');
+
+ switch ($bot->topPosterInterval) {
+ case 1:
+ $start = $end - 7 * 86400;
+ $next = $end + 7 * 86400;
+ break;
+ case 2:
+ $start = \gmmktime(0, 0, 0, $month > 1 ? $month - 1 : 12, 1, $month > 1 ? $year : $year - 1);
+ $next = \gmmktime(0, 0, 0, $month != 12 ? $month + 1 : 1, 1, $month != 12 ? $year : $year + 1);
+ break;
+ case 3:
+ $start = \gmmktime(0, 0, 0, $month > 3 ? $month - 3 : 10, 1, $month > 3 ? $year : $year - 1);
+ if ($month >= 10) {
+ $next = \gmmktime(0, 0, 0, 1, 1, $year + 1);
+ } elseif ($month >= 7) {
+ $next = \gmmktime(0, 0, 0, 10, 1, $year);
+ } elseif ($month >= 4) {
+ $next = \gmmktime(0, 0, 0, 7, 1, $year);
+ } else {
+ $next = \gmmktime(0, 0, 0, 4, 1, $year);
+ }
+ break;
+ }
+
+ // update bot, unless test mode
+ if (!$bot->testMode) {
+ $editor = new UzbotEditor($bot);
+ $editor->update(['topPosterNext' => $next]);
+ UzbotEditor::resetCache();
+ }
+
+ // get top poster
+ $affectedUserIDs = $countToUserID = $placeholders = $userIDs = [];
+ $rank = 0;
+
+ $boardIDs = \unserialize($bot->uzbotBoardIDs);
+ $conditions = $bot->getUserConditions();
+ if (\count($conditions)) {
+ $userList = new UserList();
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ $temp = $userList->getObjects();
+ if (\count($temp)) {
+ foreach ($temp as $user) {
+ $userIDs[] = $user->userID;
+ }
+ }
+ }
+
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add('board.boardID IN (?)', [$boardIDs]);
+ if (\count($userIDs)) {
+ $conditionBuilder->add('post.userID IN (?)', [$userIDs]);
+ } else {
+ $conditionBuilder->add('post.userID > ?', [0]);
+ }
+ $conditionBuilder->add('post.isDeleted = ?', [0]);
+ $conditionBuilder->add('post.time > ?', [$start]);
+ $conditionBuilder->add('post.time < ?', [$end]);
+
+ $sql = "SELECT post.userID as topID, COUNT(*) as count
+ FROM wbb" . WCF_N . "_post post
+ LEFT JOIN wbb" . WCF_N . "_thread thread ON (thread.threadID = post.threadID)
+ LEFT JOIN wbb" . WCF_N . "_board board ON (board.boardID = thread.boardID)
+ " . $conditionBuilder . "
+ GROUP BY topID
+ ORDER BY count DESC";
+
+ $statement = WCF::getDB()->prepareStatement($sql, $bot->topPosterCount);
+ $statement->execute($conditionBuilder->getParameters());
+ while ($row = $statement->fetchArray()) {
+ $rank++;
+ $affectedUserIDs[] = $row['topID'];
+ $countToUserID[$row['topID']] = $row['count'];
+ $placeholders['ranks'][$row['topID']] = $rank;
+ }
+
+ // data
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => \count($affectedUserIDs),
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => \count($affectedUserIDs),
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => \count($affectedUserIDs),
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // notification
+ if (!\count($affectedUserIDs)) {
+ continue;
+ }
+
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ $placeholders['date-from'] = $placeholders['time-from'] = $start;
+ $placeholders['date-to'] = $placeholders['time-to'] = $end - 1;
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
}
diff --git a/files/lib/system/cronjob/UzbotStatsWbbCronjob.class.php b/files/lib/system/cronjob/UzbotStatsWbbCronjob.class.php
index af8527b..6576ff5 100644
--- a/files/lib/system/cronjob/UzbotStatsWbbCronjob.class.php
+++ b/files/lib/system/cronjob/UzbotStatsWbbCronjob.class.php
@@ -1,5 +1,27 @@
-
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotStatsWbbCronjob extends AbstractCronjob {
- /**
- * @see wcf\system\cronjob\ICronjob::execute()
- */
- public function execute(Cronjob $cronjob) {
- parent::execute($cronjob);
-
- if (!MODULE_UZBOT) return;
-
- // always create stats
-
- // read data
- $statsOld = new UzBotStats(1);
- $stats = new UzBotStats(1);
-
- // Make new stats
- // Board
- $sql = "SELECT COUNT(*) as board,
- COALESCE(SUM(isClosed), 0) AS boardClosed,
- COALESCE(SUM(isInvisible), 0) AS boardInvisible
- FROM wbb".WCF_N."_board";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute();
- $row = $statement->fetchArray();
- $stats->board = $row['board'];
- $stats->boardClosed = $row['boardClosed'];
- $stats->boardInvisible = $row['boardInvisible'];
-
- $sql = "SELECT COUNT(*) as total
- FROM wbb".WCF_N."_board
- WHERE boardType = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([Board::TYPE_CATEGORY]);
- $row = $statement->fetchArray();
- $stats->boardCategory = $row['total'];
-
- $sql = "SELECT COUNT(*) as total
- FROM wbb".WCF_N."_board
- WHERE boardType = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([Board::TYPE_LINK]);
- $row = $statement->fetchArray();
- $stats->boardLink = $row['total'];
-
- // Thread
- $sql = "SELECT COUNT(*) as thread,
- COALESCE(SUM(isAnnouncement), 0) AS threadAnnouncement,
- COALESCE(SUM(polls), 0) AS threadPoll,
- COALESCE(SUM(isSticky), 0) AS threadSticky,
- COALESCE(SUM(isDisabled), 0) AS threadDisabled,
- COALESCE(SUM(isClosed), 0) AS threadClosed,
- COALESCE(SUM(isDeleted), 0) AS threadDeleted,
- COALESCE(SUM(views), 0) AS threadView
- FROM wbb".WCF_N."_thread";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute();
- $row = $statement->fetchArray();
- $stats->thread = $row['thread'];
- $stats->threadAnnouncement = $row['threadAnnouncement'];
- $stats->threadPoll = $row['threadPoll'];
- $stats->threadSticky = $row['threadSticky'];
- $stats->threadDisabled = $row['threadDisabled'];
- $stats->threadClosed = $row['threadClosed'];
- $stats->threadDeleted = $row['threadDeleted'];
- $stats->threadView = $row['threadView'];
-
- // Post
- $sql = "SELECT COUNT(postID) as post,
- COALESCE(SUM(isDisabled), 0) AS postDisabled,
- COALESCE(SUM(isClosed), 0) AS postClosed,
- COALESCE(SUM(isDeleted), 0) AS postDeleted,
- COALESCE(SUM(editCount), 0) AS postEdit
- FROM wbb".WCF_N."_post";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute();
- $row = $statement->fetchArray();
- $stats->post = $row['post'];
- $stats->postDisabled = $row['postDisabled'];
- $stats->postClosed = $row['postClosed'];
- $stats->postDeleted = $row['postDeleted'];
- $stats->postEdit = $row['postEdit'];
-
- // don't update stats here
-
- // Read all active, valid activity bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_statistics']);
- if (!count($bots)) return;
-
- $result = [
- 'board' => $stats->board,
- 'boardOld' => $statsOld->board,
- 'boardClosed' => $stats->boardClosed,
- 'boardClosedOld' => $statsOld->boardClosed,
- 'boardInvisible' => $stats->boardInvisible,
- 'boardInvisibleOld' => $statsOld->boardInvisible,
- 'boardCategory' => $stats->boardCategory,
- 'boardCategoryOld' => $statsOld->boardCategory,
- 'boardLink' => $stats->boardLink,
- 'boardLinkOld' => $statsOld->boardLink,
- 'thread' => $stats->thread,
- 'threadOld' => $statsOld->thread,
- 'threadAnnouncement' => $stats->threadAnnouncement,
- 'threadAnnouncementOld' => $statsOld->threadAnnouncement,
- 'threadPoll' => $stats->threadPoll,
- 'threadPollOld' => $statsOld->threadPoll,
- 'threadSticky' => $stats->threadSticky,
- 'threadStickyOld' => $statsOld->threadSticky,
- 'threadDisabled' => $stats->threadDisabled,
- 'threadDisabledOld' => $statsOld->threadDisabled,
- 'threadClosed' => $stats->threadClosed,
- 'threadClosedOld' => $statsOld->threadClosed,
- 'threadClosed' => $stats->threadClosed,
- 'threadClosedOld' => $statsOld->threadClosed,
- 'threadDeleted' => $stats->threadDeleted,
- 'threadDeletedOld' => $statsOld->threadDeleted,
- 'threadView' => $stats->threadView,
- 'threadViewOld' => $statsOld->threadView,
- 'post' => $stats->post,
- 'postOld' => $statsOld->post,
- 'postDisabled' => $stats->postDisabled,
- 'postDisabledOld' => $statsOld->postDisabled,
- 'postClosed' => $stats->postClosed,
- 'postClosedOld' => $statsOld->postClosed,
- 'postDeleted' => $stats->postDeleted,
- 'postDeletedOld' => $statsOld->postDeleted,
- 'postEdit' => $stats->postEdit,
- 'postEditOld' => $statsOld->postEdit,
- ];
-
- $placeholders['stats'] = $result;
- $placeholders['stats-lang'] = 'wcf.uzbot.wbb.stats';
- $placeholders['date-from'] = $statsOld->timeWbb;
- $placeholders['time-from'] = $statsOld->timeWbb;
- $placeholders['date-to'] = TIME_NOW;
- $placeholders['time-to'] = TIME_NOW;
-
- // Step through all bots and get updates
- foreach ($bots as $bot) {
- // update stats unless test mode
- if (!$bot->testMode) {
- $editor = new UzbotStatsEditor($stats);
- $editor->update([
- 'board' => $stats->board,
- 'boardClosed' => $stats->boardClosed,
- 'boardInvisible' => $stats->boardInvisible,
- 'boardCategory' => $stats->boardCategory,
- 'boardLink' => $stats->boardLink,
- 'thread' => $stats->thread,
- 'threadAnnouncement' => $stats->threadAnnouncement,
- 'threadPoll' => $stats->threadPoll,
- 'threadSticky' => $stats->threadSticky,
- 'threadDisabled' => $stats->threadDisabled,
- 'threadClosed' => $stats->threadClosed,
- 'threadDeleted' => $stats->threadDeleted,
- 'threadView' => $stats->threadView,
- 'post' => $stats->post,
- 'postDisabled' => $stats->postDisabled,
- 'postClosed' => $stats->postClosed,
- 'postDeleted' => $stats->postDeleted,
- 'postEdit' => $stats->postEdit,
- 'timeWbb' => TIME_NOW
- ]);
- }
-
- // send to scheduler
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => [],
- 'countToUserID' => []
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
-
- }
+class UzbotStatsWbbCronjob extends AbstractCronjob
+{
+ /**
+ * @see wcf\system\cronjob\ICronjob::execute()
+ */
+ public function execute(Cronjob $cronjob)
+ {
+ parent::execute($cronjob);
+
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // always create stats
+
+ // read data
+ $statsOld = new UzBotStats(1);
+ $stats = new UzBotStats(1);
+
+ // Make new stats
+ // Board
+ $sql = "SELECT COUNT(*) as board,
+ COALESCE(SUM(isClosed), 0) AS boardClosed,
+ COALESCE(SUM(isInvisible), 0) AS boardInvisible
+ FROM wbb" . WCF_N . "_board";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ $row = $statement->fetchArray();
+ $stats->board = $row['board'];
+ $stats->boardClosed = $row['boardClosed'];
+ $stats->boardInvisible = $row['boardInvisible'];
+
+ $sql = "SELECT COUNT(*) as total
+ FROM wbb" . WCF_N . "_board
+ WHERE boardType = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([Board::TYPE_CATEGORY]);
+ $row = $statement->fetchArray();
+ $stats->boardCategory = $row['total'];
+
+ $sql = "SELECT COUNT(*) as total
+ FROM wbb" . WCF_N . "_board
+ WHERE boardType = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([Board::TYPE_LINK]);
+ $row = $statement->fetchArray();
+ $stats->boardLink = $row['total'];
+
+ // Thread
+ $sql = "SELECT COUNT(*) as thread,
+ COALESCE(SUM(isAnnouncement), 0) AS threadAnnouncement,
+ COALESCE(SUM(polls), 0) AS threadPoll,
+ COALESCE(SUM(isSticky), 0) AS threadSticky,
+ COALESCE(SUM(isDisabled), 0) AS threadDisabled,
+ COALESCE(SUM(isClosed), 0) AS threadClosed,
+ COALESCE(SUM(isDeleted), 0) AS threadDeleted,
+ COALESCE(SUM(views), 0) AS threadView
+ FROM wbb" . WCF_N . "_thread";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ $row = $statement->fetchArray();
+ $stats->thread = $row['thread'];
+ $stats->threadAnnouncement = $row['threadAnnouncement'];
+ $stats->threadPoll = $row['threadPoll'];
+ $stats->threadSticky = $row['threadSticky'];
+ $stats->threadDisabled = $row['threadDisabled'];
+ $stats->threadClosed = $row['threadClosed'];
+ $stats->threadDeleted = $row['threadDeleted'];
+ $stats->threadView = $row['threadView'];
+
+ // Post
+ $sql = "SELECT COUNT(postID) as post,
+ COALESCE(SUM(isDisabled), 0) AS postDisabled,
+ COALESCE(SUM(isClosed), 0) AS postClosed,
+ COALESCE(SUM(isDeleted), 0) AS postDeleted,
+ COALESCE(SUM(editCount), 0) AS postEdit
+ FROM wbb" . WCF_N . "_post";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ $row = $statement->fetchArray();
+ $stats->post = $row['post'];
+ $stats->postDisabled = $row['postDisabled'];
+ $stats->postClosed = $row['postClosed'];
+ $stats->postDeleted = $row['postDeleted'];
+ $stats->postEdit = $row['postEdit'];
+
+ // don't update stats here
+
+ // Read all active, valid activity bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_statistics']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ $result = [
+ 'board' => $stats->board,
+ 'boardOld' => $statsOld->board,
+ 'boardClosed' => $stats->boardClosed,
+ 'boardClosedOld' => $statsOld->boardClosed,
+ 'boardInvisible' => $stats->boardInvisible,
+ 'boardInvisibleOld' => $statsOld->boardInvisible,
+ 'boardCategory' => $stats->boardCategory,
+ 'boardCategoryOld' => $statsOld->boardCategory,
+ 'boardLink' => $stats->boardLink,
+ 'boardLinkOld' => $statsOld->boardLink,
+ 'thread' => $stats->thread,
+ 'threadOld' => $statsOld->thread,
+ 'threadAnnouncement' => $stats->threadAnnouncement,
+ 'threadAnnouncementOld' => $statsOld->threadAnnouncement,
+ 'threadPoll' => $stats->threadPoll,
+ 'threadPollOld' => $statsOld->threadPoll,
+ 'threadSticky' => $stats->threadSticky,
+ 'threadStickyOld' => $statsOld->threadSticky,
+ 'threadDisabled' => $stats->threadDisabled,
+ 'threadDisabledOld' => $statsOld->threadDisabled,
+ 'threadClosed' => $stats->threadClosed,
+ 'threadClosedOld' => $statsOld->threadClosed,
+ 'threadClosed' => $stats->threadClosed,
+ 'threadClosedOld' => $statsOld->threadClosed,
+ 'threadDeleted' => $stats->threadDeleted,
+ 'threadDeletedOld' => $statsOld->threadDeleted,
+ 'threadView' => $stats->threadView,
+ 'threadViewOld' => $statsOld->threadView,
+ 'post' => $stats->post,
+ 'postOld' => $statsOld->post,
+ 'postDisabled' => $stats->postDisabled,
+ 'postDisabledOld' => $statsOld->postDisabled,
+ 'postClosed' => $stats->postClosed,
+ 'postClosedOld' => $statsOld->postClosed,
+ 'postDeleted' => $stats->postDeleted,
+ 'postDeletedOld' => $statsOld->postDeleted,
+ 'postEdit' => $stats->postEdit,
+ 'postEditOld' => $statsOld->postEdit,
+ ];
+
+ $placeholders['stats'] = $result;
+ $placeholders['stats-lang'] = 'wcf.uzbot.wbb.stats';
+ $placeholders['date-from'] = $statsOld->timeWbb;
+ $placeholders['time-from'] = $statsOld->timeWbb;
+ $placeholders['date-to'] = TIME_NOW;
+ $placeholders['time-to'] = TIME_NOW;
+
+ // Step through all bots and get updates
+ foreach ($bots as $bot) {
+ // update stats unless test mode
+ if (!$bot->testMode) {
+ $editor = new UzbotStatsEditor($stats);
+ $editor->update([
+ 'board' => $stats->board,
+ 'boardClosed' => $stats->boardClosed,
+ 'boardInvisible' => $stats->boardInvisible,
+ 'boardCategory' => $stats->boardCategory,
+ 'boardLink' => $stats->boardLink,
+ 'thread' => $stats->thread,
+ 'threadAnnouncement' => $stats->threadAnnouncement,
+ 'threadPoll' => $stats->threadPoll,
+ 'threadSticky' => $stats->threadSticky,
+ 'threadDisabled' => $stats->threadDisabled,
+ 'threadClosed' => $stats->threadClosed,
+ 'threadDeleted' => $stats->threadDeleted,
+ 'threadView' => $stats->threadView,
+ 'post' => $stats->post,
+ 'postDisabled' => $stats->postDisabled,
+ 'postClosed' => $stats->postClosed,
+ 'postDeleted' => $stats->postDeleted,
+ 'postEdit' => $stats->postEdit,
+ 'timeWbb' => TIME_NOW,
+ ]);
+ }
+
+ // send to scheduler
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => [],
+ 'countToUserID' => [],
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
}
diff --git a/files/lib/system/cronjob/UzbotThreadModificationCronjob.class.php b/files/lib/system/cronjob/UzbotThreadModificationCronjob.class.php
index dfde99e..232eb67 100644
--- a/files/lib/system/cronjob/UzbotThreadModificationCronjob.class.php
+++ b/files/lib/system/cronjob/UzbotThreadModificationCronjob.class.php
@@ -1,5 +1,27 @@
-
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotThreadModificationCronjob extends AbstractCronjob {
- /**
- * list with threads to be modified
- */
- protected $threadList = null;
-
- // thread limit per action
- // made configurable: UZBOT_DATA_LIMIT_THREAD
- // const THREAD_LIMIT = 200;
-
- /**
- * @see wcf\system\cronjob\ICronjob::execute()
- */
- public function execute(Cronjob $cronjob) {
- parent::execute($cronjob);
-
- if (!MODULE_UZBOT) return;
-
- // Read all active, valid bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(array('typeDes' => 'wbb_threadModification'));
- if (empty($bots)) return;
-
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- // Step through all bots and get threads to be modified
- foreach ($bots as $bot) {
- // set data
- $modifications = unserialize($bot->wbbThreadModificationData);
- $userData = [];
-
- // check executer
- $user = new User($modifications['threadModificationExecuterID']);
- if (!$user->userID) {
- $editor = new UzbotEditor($bot);
- $editor->update(['isDisabled' => 1]);
- UzbotEditor::resetCache();
-
- if ($bot->enableLog) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 0,
- 'status' => 2,
- 'additionalData' => $defaultLanguage->get('wcf.acp.uzbot.wbb.error.executerInvalid')
- ]);
- }
- continue;
- }
-
- // change user to fix for some plugin modifying ThreadList :-(
- $oldUser = WCF::getUser();
- WCF::getSession()->changeUser(new User($modifications['threadModificationExecuterID']), true);
-
- // get all threadIDs matching conditions
- $conditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $bot->botID);
- $conditionThreadIDs = [];
- if (count($conditions)) {
- $threadList = new ThreadList();
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addObjectListCondition($threadList, $condition->conditionData);
- }
- $threadList->readObjectIDs();
- $conditionThreadIDs = $threadList->getObjectIDs();
- if (empty($conditionThreadIDs)) $conditionThreadIDs[] = 0;
- }
- $conditionCount = count($conditionThreadIDs);
-
- // same for labels
- $labelThreadIDs = [];
- $useLabels = 0;
- $labels = UzbotConditionLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
- if (!empty($labels)) {
- $useLabels = 1;
- $labelIDs = [];
- foreach ($labels as $temp) {
- foreach ($temp as $labelID => $label) {
- $labelIDs[] = $labelID;
- }
- }
-
- $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
- $threadList = new ThreadList();
- foreach ($labelIDs as $labelID) {
- $threadList->getConditionBuilder()->add('thread.threadID IN (SELECT objectID FROM wcf'.WCF_N.'_label_object WHERE objectTypeID = ? AND labelID = ?)', [$objectType->objectTypeID, $labelID]);
- }
- $threadList->readObjectIDs();
- $labelThreadIDs = $threadList->getObjectIDs();
- if (empty($labelThreadIDs)) $labelThreadIDs[] = 0;
- }
- $labelCount = count($labelThreadIDs);
-
- // merge threadIDs
- if (!$conditionCount && !$labelCount) { // all threads
- $threadList = new ThreadList();
- $threadList->readObjectIDs();
- $threadIDs = $threadList->getObjectIDs();
- }
- elseif ($conditionCount && $labelCount) {
- $threadIDs = array_intersect($labelThreadIDs, $conditionThreadIDs);
- }
- else {
- $threadIDs = array_merge($labelThreadIDs, $conditionThreadIDs);
- }
-
- // if no threads, log and abort
- $threadCount = count($threadIDs);
-
- // log found threads (not action)
- if ($bot->enableLog) {
- if ($threadCount == 1 && isset($threadIDs[0]) && $threadIDs[0] == 0) $count = 0;
- else $count = $threadCount;
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.affected', ['count' => $count]);
-
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'additionalData' => $result
- ]);
- }
- else {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // abort if no threads
- if ($threadCount == 1 && isset($threadIDs[0]) && $threadIDs[0] == 0) {
- // Reset to old user
- WCF::getSession()->changeUser($oldUser, true);
- continue;
- }
-
- // get actionLabelIDs and related data
- $actionLabelIDs = [];
- $actionLabels = UzbotActionLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
- if (count($actionLabels)) {
- foreach ($actionLabels as $temp) {
- foreach ($temp as $label) {
- $actionLabelIDs[] = $label->labelID;
- }
- }
- }
- $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
- $labelObjectTypeID = $objectType->objectTypeID;
-
- // step through threads until at least one thread was modified
- $found = 0;
- for ($i = 0; $i < $threadCount; $i += UZBOT_DATA_LIMIT_THREAD) {
- $ids = array_slice($threadIDs, $i, UZBOT_DATA_LIMIT_THREAD);
-
- // step through action in sequence of add form
- if ($modifications['threadModificationEnable']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDisabled = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'enable', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationDisable']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDisabled = ?', [0]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'disable', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationDone']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDone = ?', [0]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'markAsDone', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationUndone']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDone = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'markAsUndone', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if (isset($modifications['threadModificationUnannounce'])) {
- if ($modifications['threadModificationUnannounce']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isAnnouncement = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'unannounce', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
- }
-
- if ($modifications['threadModificationSetLabel']) {
- // user wants to delete labels
- if (!count($actionLabelIDs)) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.hasLabels = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'deleteLabels', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- // user wants to add / change labels
- else {
- // read actual label assignment and get threads to be modified
- $assign = $modifyID = [];
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('objectTypeID = ?', [$labelObjectTypeID]);
- $conditionBuilder->add('objectID IN (?)', [$ids]);
- $sql = "SELECT objectID, labelID
- FROM wcf".WCF_N."_label_object
- ".$conditionBuilder;
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $assign[$row['objectID']][] = $row['labelID'];
- }
-
- $modifyID = [];
- foreach ($ids as $threadID) {
- if (!isset($assign[$threadID])) {
- $modifyID[] = $threadID;
- continue;
- }
- if (count($assign[$threadID]) != count($actionLabelIDs)) {
- $modifyID[] = $threadID;
- continue;
- }
- if (!empty(array_diff($actionLabelIDs, $assign[$threadID]))) {
- $modifyID[] = $threadID;
- }
- }
-
- if (count($modifyID)) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$modifyID]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'setLabels', $modifications['threadModificationAuthorOnly'], $defaultLanguage, $actionLabels);
- }
- }
- }
- }
-
- if ($modifications['threadModificationTrash']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDeleted = ?', [0]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'trash', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationRestore']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isDeleted = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'restore', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationSticky']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isSticky = ?', [0]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'sticky', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationScrape']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isSticky = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'scrape', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationOpen']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isClosed = ?', [1]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'open', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationClose']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.isClosed = ?', [0]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'close', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- if ($modifications['threadModificationMove']) {
- $threadList = new ThreadList();
- $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
- $threadList->getConditionBuilder()->add('thread.boardID <> ?', [$modifications['threadModificationBoardID']]);
- $threadList->readObjects();
- $threads = $threadList->getObjects();
- if (count($threads)) {
- $found = 1;
- $this->executeBot($bot, $threads, 'move', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
- }
- }
-
- // break if thread was found
- if ($found) break;
- }
-
- // Reset to old user
- WCF::getSession()->changeUser($oldUser, true);
- }
- }
-
- protected function executeBot($bot, $threads, $action, $authorOnly, $defaultLanguage, $labels = []) {
- $affectedUserIDs = $countToUserID = $placeholders = $threadIDs = $threadToUser = [];
-
- if (!count($threads)) {
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 0,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.modified', [
- 'action' => $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action),
- 'threadIDs' => ''
- ])
- ]);
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => count($affectedUserIDs),
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => 0,
- 'userIDs' => ''
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => 0,
- 'users' => 0,
- 'userIDs' => ''
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => count($threadIDs),
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
- return;
- }
-
- foreach ($threads as $thread) {
- $threadIDs[] = $thread->threadID;
-
- if ($authorOnly) {
- if (!$thread->userID) continue;
-
- $threadToUser[$thread->threadID] = $thread->userID;
-
- $affectedUserIDs[] = $thread->userID;
- if (isset($countToUserID[$thread->userID])) $countToUserID[$thread->userID] ++;
- else $countToUserID[$thread->userID] = 1;
- }
- else {
- $postList = new PostList();
- $postList->getConditionBuilder()->add('post.threadID = ?', [$thread->threadID]);
- $postList->getConditionBuilder()->add('post.userID > ?', [0]);
- // $postList->getConditionBuilder()->add('post.isDeleted = ?', [0]);
- // $postList->getConditionBuilder()->add('post.isDisabled = ?', [0]);
- $postList->readObjects();
- $posts = $postList->getObjects();
- foreach ($posts as $post) {
- $affectedUserIDs[] = $post->userID;
- if (isset($countToUserID[$post->userID])) $countToUserID[$post->userID] ++;
- else $countToUserID[$post->userID] = 1;
- }
- }
- }
-
- $affectedUserIDs = array_unique($affectedUserIDs);
-
- // change user for action + execute unless test mode
- if (!$bot->testMode) {
- if ($action != 'setLabels' && $action != 'deleteLabels' && $action != 'move' && $action != 'unannounce') {
- $threadAction = new ThreadAction($threads, $action);
- $threadAction->executeAction();
- }
- else if ($action == 'move') {
- $modifications = unserialize($bot->wbbThreadModificationData);
- $threadAction = new ThreadAction($threads, 'move', [
- 'boardID' => $modifications['threadModificationBoardID'],
- 'isBulkProcessing' => false,
- 'showMoveNotice' => false
- ]);
- $threadAction->executeAction();
- }
- else if ($action == 'unannounce') {
- $threadAction = new ThreadAction($threads, 'update', [
- 'data' => ['isAnnouncement' => 0],
- 'announcementBoardIDs' => [],
- 'isBulkProcessing' => false
- ]);
- $threadAction->executeAction();
- }
- else {
- // label object type
- $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
- $objectTypeID = $objectType->objectTypeID;
-
- // delete ...
- if ($action == 'deleteLabels') {
- $objectTypeID = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread')->objectTypeID;
- $oldLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
-
- // remove labels
- foreach ($threads as $thread) {
- LabelHandler::getInstance()->setLabels([], $objectTypeID, $thread->threadID, false);
-
- // update hasLabels flag
- $editor = new ThreadEditor($thread);
- $editor->update(['hasLabels' => 0]);
- }
-
- $assignedLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
- $labelList = null;
-
- // clear log
- WCF::getDB()->beginTransaction();
- foreach ($threads as $thread) {
- $groupedOldLabels = [];
- if (!empty($oldLabels[$thread->threadID])) {
- foreach ($oldLabels[$thread->threadID] as $oldLabel) {
- $groupedOldLabels[$oldLabel->groupID] = $oldLabel;
- }
- }
-
- if ($labelList !== null) {
- foreach ($labelList as $label) {
- if (!isset($groupedOldLabels[$label->groupID]) || $label->labelID != $groupedOldLabels[$label->groupID]->labelID) {
- ThreadModificationLogHandler::getInstance()->setLabel($thread, $label, (isset($groupedOldLabels[$label->groupID]) ? $groupedOldLabels[$label->groupID] : null));
- }
- if (isset($groupedOldLabels[$label->groupID])) unset($groupedOldLabels[$label->groupID]);
- }
- }
- foreach ($groupedOldLabels as $groupID => $label) {
- ThreadModificationLogHandler::getInstance()->setLabel($thread, null, $label);
- }
- }
- WCF::getDB()->commitTransaction();
-
- }
-
- // set ...
- if ($action == 'setLabels') {
- foreach ($labels as $temp) {
- foreach ($temp as $label) {
- $labelIDs[] = $label->labelID;
- }
- }
- $botLabels = $labels;
- $botLabelIDs = $labelIDs;
-
- // almost same as above
- $objectTypeID = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread')->objectTypeID;
- $oldLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
-
- foreach ($threads as $thread) {
- LabelHandler::getInstance()->setLabels($botLabelIDs, $objectTypeID, $thread->threadID, false);
-
- $editor = new ThreadEditor($thread);
- $editor->update(['hasLabels' => !empty($botLabelIDs) ? 1 : 0]);
- }
-
- $assignedLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
- $labelList = null;
- if (!empty($assignedLabels)) {
- $labelList = reset($assignedLabels);
- }
-
- // log changes
- WCF::getDB()->beginTransaction();
- foreach ($threads as $thread) {
- $groupedOldLabels = [];
- if (!empty($oldLabels[$thread->threadID])) {
- foreach ($oldLabels[$thread->threadID] as $oldLabel) {
- $groupedOldLabels[$oldLabel->groupID] = $oldLabel;
- }
- }
-
- if ($labelList !== null) {
- foreach ($labelList as $label) {
- if (!isset($groupedOldLabels[$label->groupID]) || $label->labelID != $groupedOldLabels[$label->groupID]->labelID) {
- ThreadModificationLogHandler::getInstance()->setLabel($thread, $label, (isset($groupedOldLabels[$label->groupID]) ? $groupedOldLabels[$label->groupID] : null));
- }
- if (isset($groupedOldLabels[$label->groupID])) unset($groupedOldLabels[$label->groupID]);
- }
- }
- foreach ($groupedOldLabels as $groupID => $label) {
- ThreadModificationLogHandler::getInstance()->setLabel($thread, null, $label);
- }
- }
- WCF::getDB()->commitTransaction();
- }
- }
- }
-
- if ($bot->enableLog) {
- $result1 = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.modified', [
- 'action' => $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action),
- 'threadIDs' => implode(', ', $threadIDs)
- ]);
- if (mb_strlen($result1) > 64000) $result1 = mb_substr($result1, 0, 64000) . ' ...';
-
- $result2 = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result2) > 64000) $result2 = mb_substr($result2, 0, 64000) . ' ...';
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'testMode' => !$bot->testMode ? 0 : 1,
- 'count' => count($threadIDs),
- 'additionalData' => !$bot->testMode ? $result1 : serialize(['', '', $result1])
- ]);
-
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'testMode' => !$bot->testMode ? 0 : 1,
- 'count' => count($affectedUserIDs),
- 'additionalData' => !$bot->testMode ? $result2 : serialize(['', '', $result2])
- ]);
- }
-
- // check for and prepare notification
- if ($bot->notifyID) {
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) return;
-
- $placeholders['count'] = count($threadIDs);
- $placeholders['object-ids'] = implode(', ', $threadIDs);
- $placeholders['action'] = $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action);
-
- // test mode
- $testUserIDs = $testToUserIDs = [];
- if (count($affectedUserIDs)) {
- $userID = reset($affectedUserIDs);
- $testUserIDs[] = $userID;
- $testToUserIDs[$userID] = $countToUserID[$userID];
- }
-
- // send to scheduler, if not test mode
- if ($bot->testMode) {
- // only one notification
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- else {
-
- // not post - only one
- if ($bot->notifyDes != 'post') {
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- else {
- $wbbPostData = unserialize($bot->wbbPostData);
-
- // threadID given - only one
- if ($wbbPostData['postNotifyThreadID']) {
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- // threadID = 0 - one post in each thread
- else {
- // there must be threads
- if (count($threadIDs)) {
- // preset
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- foreach ($threadIDs as $threadID) {
- $bot->threadID = $threadID;
-
- // limit affected user to one if author only
- if ($authorOnly && !$bot->testMode) {
- $affectedUserIDs = $countToUserID = [];
-
- $affectedUserIDs[] = $threadToUser[$threadID];
- $countToUserID[$threadToUser[$threadID]] = 1;
-
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
- }
- else {
- $data['bot'] = $bot;
- }
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
- }
- }
- }
- }
- }
+class UzbotThreadModificationCronjob extends AbstractCronjob
+{
+ /**
+ * list with threads to be modified
+ */
+ protected $threadList;
+
+ // thread limit per action
+ // made configurable: UZBOT_DATA_LIMIT_THREAD
+ // const THREAD_LIMIT = 200;
+
+ /**
+ * @see wcf\system\cronjob\ICronjob::execute()
+ */
+ public function execute(Cronjob $cronjob)
+ {
+ parent::execute($cronjob);
+
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // Read all active, valid bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_threadModification']);
+ if (empty($bots)) {
+ return;
+ }
+
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ // Step through all bots and get threads to be modified
+ foreach ($bots as $bot) {
+ // set data
+ $modifications = \unserialize($bot->wbbThreadModificationData);
+ $userData = [];
+
+ // check executer
+ $user = new User($modifications['threadModificationExecuterID']);
+ if (!$user->userID) {
+ $editor = new UzbotEditor($bot);
+ $editor->update(['isDisabled' => 1]);
+ UzbotEditor::resetCache();
+
+ if ($bot->enableLog) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 0,
+ 'status' => 2,
+ 'additionalData' => $defaultLanguage->get('wcf.acp.uzbot.wbb.error.executerInvalid'),
+ ]);
+ }
+ continue;
+ }
+
+ // change user to fix for some plugin modifying ThreadList :-(
+ $oldUser = WCF::getUser();
+ WCF::getSession()->changeUser(new User($modifications['threadModificationExecuterID']), true);
+
+ // get all threadIDs matching conditions
+ $conditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $bot->botID);
+ $conditionThreadIDs = [];
+ if (\count($conditions)) {
+ $threadList = new ThreadList();
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addObjectListCondition($threadList, $condition->conditionData);
+ }
+ $threadList->readObjectIDs();
+ $conditionThreadIDs = $threadList->getObjectIDs();
+ if (empty($conditionThreadIDs)) {
+ $conditionThreadIDs[] = 0;
+ }
+ }
+ $conditionCount = \count($conditionThreadIDs);
+
+ // same for labels
+ $labelThreadIDs = [];
+ $useLabels = 0;
+ $labels = UzbotConditionLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
+ if (!empty($labels)) {
+ $useLabels = 1;
+ $labelIDs = [];
+ foreach ($labels as $temp) {
+ foreach ($temp as $labelID => $label) {
+ $labelIDs[] = $labelID;
+ }
+ }
+
+ $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
+ $threadList = new ThreadList();
+ foreach ($labelIDs as $labelID) {
+ $threadList->getConditionBuilder()->add('thread.threadID IN (SELECT objectID FROM wcf' . WCF_N . '_label_object WHERE objectTypeID = ? AND labelID = ?)', [$objectType->objectTypeID, $labelID]);
+ }
+ $threadList->readObjectIDs();
+ $labelThreadIDs = $threadList->getObjectIDs();
+ if (empty($labelThreadIDs)) {
+ $labelThreadIDs[] = 0;
+ }
+ }
+ $labelCount = \count($labelThreadIDs);
+
+ // merge threadIDs
+ if (!$conditionCount && !$labelCount) { // all threads
+ $threadList = new ThreadList();
+ $threadList->readObjectIDs();
+ $threadIDs = $threadList->getObjectIDs();
+ } elseif ($conditionCount && $labelCount) {
+ $threadIDs = \array_intersect($labelThreadIDs, $conditionThreadIDs);
+ } else {
+ $threadIDs = \array_merge($labelThreadIDs, $conditionThreadIDs);
+ }
+
+ // if no threads, log and abort
+ $threadCount = \count($threadIDs);
+
+ // log found threads (not action)
+ if ($bot->enableLog) {
+ if ($threadCount == 1 && isset($threadIDs[0]) && $threadIDs[0] == 0) {
+ $count = 0;
+ } else {
+ $count = $threadCount;
+ }
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.affected', ['count' => $count]);
+
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'additionalData' => $result,
+ ]);
+ } else {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // abort if no threads
+ if ($threadCount == 1 && isset($threadIDs[0]) && $threadIDs[0] == 0) {
+ // Reset to old user
+ WCF::getSession()->changeUser($oldUser, true);
+ continue;
+ }
+
+ // get actionLabelIDs and related data
+ $actionLabelIDs = [];
+ $actionLabels = UzbotActionLabelObjectHandler::getInstance()->getAssignedLabels([$bot->botID], false);
+ if (\count($actionLabels)) {
+ foreach ($actionLabels as $temp) {
+ foreach ($temp as $label) {
+ $actionLabelIDs[] = $label->labelID;
+ }
+ }
+ }
+ $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
+ $labelObjectTypeID = $objectType->objectTypeID;
+
+ // step through threads until at least one thread was modified
+ $found = 0;
+ for ($i = 0; $i < $threadCount; $i += UZBOT_DATA_LIMIT_THREAD) {
+ $ids = \array_slice($threadIDs, $i, UZBOT_DATA_LIMIT_THREAD);
+
+ // step through action in sequence of add form
+ if ($modifications['threadModificationEnable']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDisabled = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'enable', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationDisable']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDisabled = ?', [0]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'disable', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationDone']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDone = ?', [0]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'markAsDone', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationUndone']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDone = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'markAsUndone', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if (isset($modifications['threadModificationUnannounce'])) {
+ if ($modifications['threadModificationUnannounce']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isAnnouncement = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'unannounce', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+ }
+
+ if ($modifications['threadModificationSetLabel']) {
+ // user wants to delete labels
+ if (!\count($actionLabelIDs)) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.hasLabels = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'deleteLabels', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ // user wants to add / change labels
+ else {
+ // read actual label assignment and get threads to be modified
+ $assign = $modifyID = [];
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add('objectTypeID = ?', [$labelObjectTypeID]);
+ $conditionBuilder->add('objectID IN (?)', [$ids]);
+ $sql = "SELECT objectID, labelID
+ FROM wcf" . WCF_N . "_label_object
+ " . $conditionBuilder;
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+ while ($row = $statement->fetchArray()) {
+ $assign[$row['objectID']][] = $row['labelID'];
+ }
+
+ $modifyID = [];
+ foreach ($ids as $threadID) {
+ if (!isset($assign[$threadID])) {
+ $modifyID[] = $threadID;
+ continue;
+ }
+ if (\count($assign[$threadID]) != \count($actionLabelIDs)) {
+ $modifyID[] = $threadID;
+ continue;
+ }
+ if (!empty(\array_diff($actionLabelIDs, $assign[$threadID]))) {
+ $modifyID[] = $threadID;
+ }
+ }
+
+ if (\count($modifyID)) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$modifyID]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'setLabels', $modifications['threadModificationAuthorOnly'], $defaultLanguage, $actionLabels);
+ }
+ }
+ }
+ }
+
+ if ($modifications['threadModificationTrash']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDeleted = ?', [0]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'trash', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationRestore']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isDeleted = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'restore', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationSticky']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isSticky = ?', [0]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'sticky', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationScrape']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isSticky = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'scrape', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationOpen']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isClosed = ?', [1]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'open', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationClose']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.isClosed = ?', [0]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'close', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ if ($modifications['threadModificationMove']) {
+ $threadList = new ThreadList();
+ $threadList->getConditionBuilder()->add('thread.threadID IN (?)', [$ids]);
+ $threadList->getConditionBuilder()->add('thread.boardID <> ?', [$modifications['threadModificationBoardID']]);
+ $threadList->readObjects();
+ $threads = $threadList->getObjects();
+ if (\count($threads)) {
+ $found = 1;
+ $this->executeBot($bot, $threads, 'move', $modifications['threadModificationAuthorOnly'], $defaultLanguage);
+ }
+ }
+
+ // break if thread was found
+ if ($found) {
+ break;
+ }
+ }
+
+ // Reset to old user
+ WCF::getSession()->changeUser($oldUser, true);
+ }
+ }
+
+ protected function executeBot($bot, $threads, $action, $authorOnly, $defaultLanguage, $labels = [])
+ {
+ $affectedUserIDs = $countToUserID = $placeholders = $threadIDs = $threadToUser = [];
+
+ if (!\count($threads)) {
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 0,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.modified', [
+ 'action' => $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action),
+ 'threadIDs' => '',
+ ]),
+ ]);
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => \count($affectedUserIDs),
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => 0,
+ 'userIDs' => '',
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => 0,
+ 'users' => 0,
+ 'userIDs' => '',
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => \count($threadIDs),
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ return;
+ }
+
+ foreach ($threads as $thread) {
+ $threadIDs[] = $thread->threadID;
+
+ if ($authorOnly) {
+ if (!$thread->userID) {
+ continue;
+ }
+
+ $threadToUser[$thread->threadID] = $thread->userID;
+
+ $affectedUserIDs[] = $thread->userID;
+ if (isset($countToUserID[$thread->userID])) {
+ $countToUserID[$thread->userID]++;
+ } else {
+ $countToUserID[$thread->userID] = 1;
+ }
+ } else {
+ $postList = new PostList();
+ $postList->getConditionBuilder()->add('post.threadID = ?', [$thread->threadID]);
+ $postList->getConditionBuilder()->add('post.userID > ?', [0]);
+ // $postList->getConditionBuilder()->add('post.isDeleted = ?', [0]);
+ // $postList->getConditionBuilder()->add('post.isDisabled = ?', [0]);
+ $postList->readObjects();
+ $posts = $postList->getObjects();
+ foreach ($posts as $post) {
+ $affectedUserIDs[] = $post->userID;
+ if (isset($countToUserID[$post->userID])) {
+ $countToUserID[$post->userID]++;
+ } else {
+ $countToUserID[$post->userID] = 1;
+ }
+ }
+ }
+ }
+
+ $affectedUserIDs = \array_unique($affectedUserIDs);
+
+ // change user for action + execute unless test mode
+ if (!$bot->testMode) {
+ if ($action != 'setLabels' && $action != 'deleteLabels' && $action != 'move' && $action != 'unannounce') {
+ $threadAction = new ThreadAction($threads, $action);
+ $threadAction->executeAction();
+ } elseif ($action == 'move') {
+ $modifications = \unserialize($bot->wbbThreadModificationData);
+ $threadAction = new ThreadAction($threads, 'move', [
+ 'boardID' => $modifications['threadModificationBoardID'],
+ 'isBulkProcessing' => false,
+ 'showMoveNotice' => false,
+ ]);
+ $threadAction->executeAction();
+ } elseif ($action == 'unannounce') {
+ $threadAction = new ThreadAction($threads, 'update', [
+ 'data' => ['isAnnouncement' => 0],
+ 'announcementBoardIDs' => [],
+ 'isBulkProcessing' => false,
+ ]);
+ $threadAction->executeAction();
+ } else {
+ // label object type
+ $objectType = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread');
+ $objectTypeID = $objectType->objectTypeID;
+
+ // delete ...
+ if ($action == 'deleteLabels') {
+ $objectTypeID = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread')->objectTypeID;
+ $oldLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
+
+ // remove labels
+ foreach ($threads as $thread) {
+ LabelHandler::getInstance()->setLabels([], $objectTypeID, $thread->threadID, false);
+
+ // update hasLabels flag
+ $editor = new ThreadEditor($thread);
+ $editor->update(['hasLabels' => 0]);
+ }
+
+ $assignedLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
+ $labelList = null;
+
+ // clear log
+ WCF::getDB()->beginTransaction();
+ foreach ($threads as $thread) {
+ $groupedOldLabels = [];
+ if (!empty($oldLabels[$thread->threadID])) {
+ foreach ($oldLabels[$thread->threadID] as $oldLabel) {
+ $groupedOldLabels[$oldLabel->groupID] = $oldLabel;
+ }
+ }
+
+ if ($labelList !== null) {
+ foreach ($labelList as $label) {
+ if (!isset($groupedOldLabels[$label->groupID]) || $label->labelID != $groupedOldLabels[$label->groupID]->labelID) {
+ ThreadModificationLogHandler::getInstance()->setLabel($thread, $label, ($groupedOldLabels[$label->groupID] ?? null));
+ }
+ if (isset($groupedOldLabels[$label->groupID])) {
+ unset($groupedOldLabels[$label->groupID]);
+ }
+ }
+ }
+ foreach ($groupedOldLabels as $groupID => $label) {
+ ThreadModificationLogHandler::getInstance()->setLabel($thread, null, $label);
+ }
+ }
+ WCF::getDB()->commitTransaction();
+ }
+
+ // set ...
+ if ($action == 'setLabels') {
+ foreach ($labels as $temp) {
+ foreach ($temp as $label) {
+ $labelIDs[] = $label->labelID;
+ }
+ }
+ $botLabels = $labels;
+ $botLabelIDs = $labelIDs;
+
+ // almost same as above
+ $objectTypeID = LabelHandler::getInstance()->getObjectType('com.woltlab.wbb.thread')->objectTypeID;
+ $oldLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
+
+ foreach ($threads as $thread) {
+ LabelHandler::getInstance()->setLabels($botLabelIDs, $objectTypeID, $thread->threadID, false);
+
+ $editor = new ThreadEditor($thread);
+ $editor->update(['hasLabels' => !empty($botLabelIDs) ? 1 : 0]);
+ }
+
+ $assignedLabels = LabelHandler::getInstance()->getAssignedLabels($objectTypeID, $threadIDs, false);
+ $labelList = null;
+ if (!empty($assignedLabels)) {
+ $labelList = \reset($assignedLabels);
+ }
+
+ // log changes
+ WCF::getDB()->beginTransaction();
+ foreach ($threads as $thread) {
+ $groupedOldLabels = [];
+ if (!empty($oldLabels[$thread->threadID])) {
+ foreach ($oldLabels[$thread->threadID] as $oldLabel) {
+ $groupedOldLabels[$oldLabel->groupID] = $oldLabel;
+ }
+ }
+
+ if ($labelList !== null) {
+ foreach ($labelList as $label) {
+ if (!isset($groupedOldLabels[$label->groupID]) || $label->labelID != $groupedOldLabels[$label->groupID]->labelID) {
+ ThreadModificationLogHandler::getInstance()->setLabel($thread, $label, ($groupedOldLabels[$label->groupID] ?? null));
+ }
+ if (isset($groupedOldLabels[$label->groupID])) {
+ unset($groupedOldLabels[$label->groupID]);
+ }
+ }
+ }
+ foreach ($groupedOldLabels as $groupID => $label) {
+ ThreadModificationLogHandler::getInstance()->setLabel($thread, null, $label);
+ }
+ }
+ WCF::getDB()->commitTransaction();
+ }
+ }
+ }
+
+ if ($bot->enableLog) {
+ $result1 = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.wbb.thread.modified', [
+ 'action' => $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action),
+ 'threadIDs' => \implode(', ', $threadIDs),
+ ]);
+ if (\mb_strlen($result1) > 64000) {
+ $result1 = \mb_substr($result1, 0, 64000) . ' ...';
+ }
+
+ $result2 = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result2) > 64000) {
+ $result2 = \mb_substr($result2, 0, 64000) . ' ...';
+ }
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'testMode' => !$bot->testMode ? 0 : 1,
+ 'count' => \count($threadIDs),
+ 'additionalData' => !$bot->testMode ? $result1 : \serialize(['', '', $result1]),
+ ]);
+
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'testMode' => !$bot->testMode ? 0 : 1,
+ 'count' => \count($affectedUserIDs),
+ 'additionalData' => !$bot->testMode ? $result2 : \serialize(['', '', $result2]),
+ ]);
+ }
+
+ // check for and prepare notification
+ if ($bot->notifyID) {
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ return;
+ }
+
+ $placeholders['count'] = \count($threadIDs);
+ $placeholders['object-ids'] = \implode(', ', $threadIDs);
+ $placeholders['action'] = $defaultLanguage->get('wcf.acp.uzbot.wbb.threadModification.action.' . $action);
+
+ // test mode
+ $testUserIDs = $testToUserIDs = [];
+ if (\count($affectedUserIDs)) {
+ $userID = \reset($affectedUserIDs);
+ $testUserIDs[] = $userID;
+ $testToUserIDs[$userID] = $countToUserID[$userID];
+ }
+
+ // send to scheduler, if not test mode
+ if ($bot->testMode) {
+ // only one notification
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ } else {
+ // not post - only one
+ if ($bot->notifyDes != 'post') {
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ } else {
+ $wbbPostData = \unserialize($bot->wbbPostData);
+
+ // threadID given - only one
+ if ($wbbPostData['postNotifyThreadID']) {
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ // threadID = 0 - one post in each thread
+ else {
+ // there must be threads
+ if (\count($threadIDs)) {
+ // preset
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ foreach ($threadIDs as $threadID) {
+ $bot->threadID = $threadID;
+
+ // limit affected user to one if author only
+ if ($authorOnly && !$bot->testMode) {
+ $affectedUserIDs = $countToUserID = [];
+
+ $affectedUserIDs[] = $threadToUser[$threadID];
+ $countToUserID[$threadToUser[$threadID]] = 1;
+
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+ } else {
+ $data['bot'] = $bot;
+ }
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/files/lib/system/event/listener/UzbotAddFormWbbListener.class.php b/files/lib/system/event/listener/UzbotAddFormWbbListener.class.php
index c14de9d..4fbf721 100644
--- a/files/lib/system/event/listener/UzbotAddFormWbbListener.class.php
+++ b/files/lib/system/event/listener/UzbotAddFormWbbListener.class.php
@@ -1,5 +1,27 @@
- * @package com.uz.wcf.bot3.wbb
+ * Listen to addForm events for Bot
*/
-class UzbotAddFormWbbListener implements IParameterizedEventListener {
- /**
- * instance of UzbotAddForm
- */
- protected $eventObj;
-
- /**
- * general data
- */
- protected $boardNodeList;
-
- /**
- * thread and post data
- */
- protected $threadNotifyBoardID = 0;
- protected $threadNotifyDelayed = 0;
- protected $threadNotifyIsClosed = 0;
- protected $threadNotifyIsDisabled = 0;
- protected $threadNotifyIsDone = 0;
- protected $threadNotifyIsSticky = 0;
-
- protected $postNotifyThreadID = 0;
- protected $postNotifyIsClosed = 0;
- protected $postNotifyIsDisabled = 0;
-
- protected $wbbThreadModerationData = 0;
- protected $threadModerationAuthorOnly = 0;
- protected $threadModerationChangeTopic = 0;
- protected $threadModerationClose = 0;
- protected $threadModerationDisable = 0;
- protected $threadModerationDone = 0;
- protected $threadModerationEnable = 0;
- protected $threadModerationMerge = 0;
- protected $threadModerationMove = 0;
- protected $threadModerationOpen = 0;
- protected $threadModerationRestore = 0;
- protected $threadModerationScrape = 0;
- protected $threadModerationSetAsAnnouncement = 0;
- protected $threadModerationSetLabel = 0;
- protected $threadModerationSticky = 0;
- protected $threadModerationTrash = 0;
- protected $threadModerationUndone = 0;
- protected $threadModerationUnsetAsAnnouncement = 0;
-
- protected $wbbThreadModificationData = 0;
- protected $threadModificationAuthorOnly = 0;
- protected $threadModificationBoardID = 0;
- protected $threadModificationExecuter = '';
- protected $threadModificationExecuterID = 0;
- protected $threadModificationClose = 0;
- protected $threadModificationDisable = 0;
- protected $threadModificationDone = 0;
- protected $threadModificationEnable = 0;
- protected $threadModificationMove = 0;
- protected $threadModificationOpen = 0;
- protected $threadModificationRestore = 0;
- protected $threadModificationScrape = 0;
- protected $threadModificationSetLabel = 0;
- protected $threadModificationSticky = 0;
- protected $threadModificationTrash = 0;
- protected $threadModificationUndone = 0;
- protected $threadModificationUnannounce = 0;
-
- protected $wbbPostModerationData = 0;
- protected $postModerationClose = 0;
- protected $postModerationDelete = 0;
- protected $postModerationDisable = 0;
- protected $postModerationEdit = 0;
- protected $postModerationEnable = 0;
- protected $postModerationMerge = 0;
- protected $postModerationMove = 0;
- protected $postModerationOpen = 0;
- protected $postModerationRestore = 0;
- protected $postModerationTrash = 0;
-
- /**
- * further bot data
- */
- protected $postCountAction = 'postTotal';
- protected $topPosterCount = 1;
- protected $topPosterInterval = 1;
- protected $threadNewBoardIDs = [];
- protected $uzbotBoardIDs = [];
-
- protected $postIsOfficial = 0;
- protected $threadIsOfficial = 0;
-
- /**
- * postChange switches
- */
- protected $postChangeUpdate = 1;
- protected $postChangeDelete = 1;
-
- /**
- * condition data
- */
- public $wbbConditions = [];
-
- /**
- * @inheritDoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- $this->eventObj = $eventObj;
- $this->$eventName();
- }
-
- /**
- * Handles the readData event. Only in UzbotEdit!
- */
- protected function readData() {
-
- if (empty($_POST)) {
- if (!empty($this->eventObj->uzbot->wbbThreadData)) {
- $wbbThreadData = unserialize($this->eventObj->uzbot->wbbThreadData);
- $this->threadNotifyBoardID = $wbbThreadData['threadNotifyBoardID'];
- $this->threadNotifyDelayed = $wbbThreadData['threadNotifyDelayed'];
- $this->threadNotifyIsClosed = $wbbThreadData['threadNotifyIsClosed'];
- $this->threadNotifyIsDisabled = $wbbThreadData['threadNotifyIsDisabled'];
- $this->threadNotifyIsDone = $wbbThreadData['threadNotifyIsDone'];
- $this->threadNotifyIsSticky = $wbbThreadData['threadNotifyIsSticky'];
- }
-
- if (!empty($this->eventObj->uzbot->wbbPostData)) {
- $wbbPostData = unserialize($this->eventObj->uzbot->wbbPostData);
- $this->postNotifyThreadID = $wbbPostData['postNotifyThreadID'];
- $this->postNotifyIsClosed = $wbbPostData['postNotifyIsClosed'];
- $this->postNotifyIsDisabled = $wbbPostData['postNotifyIsDisabled'];
- }
-
- if (!empty($this->eventObj->uzbot->wbbThreadModerationData)) {
- $wbbThreadModerationData = unserialize($this->eventObj->uzbot->wbbThreadModerationData);
- $this->threadModerationAuthorOnly = $wbbThreadModerationData['threadModerationAuthorOnly'];
- $this->threadModerationChangeTopic = $wbbThreadModerationData['threadModerationChangeTopic'];
- $this->threadModerationClose = $wbbThreadModerationData['threadModerationClose'];
- $this->threadModerationDisable = $wbbThreadModerationData['threadModerationDisable'];
- $this->threadModerationDone = $wbbThreadModerationData['threadModerationDone'];
- $this->threadModerationEnable = $wbbThreadModerationData['threadModerationEnable'];
- $this->threadModerationMerge = $wbbThreadModerationData['threadModerationMerge'];
- $this->threadModerationMove = $wbbThreadModerationData['threadModerationMove'];
- $this->threadModerationOpen = $wbbThreadModerationData['threadModerationOpen'];
- $this->threadModerationRestore = $wbbThreadModerationData['threadModerationRestore'];
- $this->threadModerationScrape = $wbbThreadModerationData['threadModerationScrape'];
- $this->threadModerationSetAsAnnouncement = $wbbThreadModerationData['threadModerationSetAsAnnouncement'];
- $this->threadModerationSetLabel = $wbbThreadModerationData['threadModerationSetLabel'];
- $this->threadModerationSticky = $wbbThreadModerationData['threadModerationSticky'];
- $this->threadModerationTrash = $wbbThreadModerationData['threadModerationTrash'];
- $this->threadModerationUndone = $wbbThreadModerationData['threadModerationUndone'];
- $this->threadModerationUnsetAsAnnouncement = $wbbThreadModerationData['threadModerationUnsetAsAnnouncement'];
- }
-
- if (!empty($this->eventObj->uzbot->wbbThreadModificationData)) {
- $wbbThreadModificationData = unserialize($this->eventObj->uzbot->wbbThreadModificationData);
- $this->threadModificationAuthorOnly = $wbbThreadModificationData['threadModificationAuthorOnly'];
- $this->threadModificationBoardID = $wbbThreadModificationData['threadModificationBoardID'];
- $this->threadModificationExecuter = $wbbThreadModificationData['threadModificationExecuter'];
- $this->threadModificationExecuterID = $wbbThreadModificationData['threadModificationExecuterID'];
- $this->threadModificationClose = $wbbThreadModificationData['threadModificationClose'];
- $this->threadModificationDisable = $wbbThreadModificationData['threadModificationDisable'];
- $this->threadModificationDone = $wbbThreadModificationData['threadModificationDone'];
- $this->threadModificationEnable = $wbbThreadModificationData['threadModificationEnable'];
- $this->threadModificationMove = $wbbThreadModificationData['threadModificationMove'];
- $this->threadModificationOpen = $wbbThreadModificationData['threadModificationOpen'];
- $this->threadModificationRestore = $wbbThreadModificationData['threadModificationRestore'];
- $this->threadModificationScrape = $wbbThreadModificationData['threadModificationScrape'];
- $this->threadModificationSetLabel = $wbbThreadModificationData['threadModificationSetLabel'];
- $this->threadModificationSticky = $wbbThreadModificationData['threadModificationSticky'];
- $this->threadModificationTrash = $wbbThreadModificationData['threadModificationTrash'];
- $this->threadModificationUndone = $wbbThreadModificationData['threadModificationUndone'];
-
- if (isset($wbbThreadModificationData['threadModificationUnannounce'])) {
- $this->threadModificationUnannounce = $wbbThreadModificationData['threadModificationUnannounce'];
- }
- }
-
- if (!empty($this->eventObj->uzbot->wbbPostModerationData)) {
- $wbbPostModerationData = unserialize($this->eventObj->uzbot->wbbPostModerationData);
- $this->postModerationClose = $wbbPostModerationData['postModerationClose'];
- $this->postModerationDelete = $wbbPostModerationData['postModerationDelete'];
- $this->postModerationDisable = $wbbPostModerationData['postModerationDisable'];
- $this->postModerationEdit = $wbbPostModerationData['postModerationEdit'];
- $this->postModerationEnable = $wbbPostModerationData['postModerationEnable'];
- $this->postModerationMerge = $wbbPostModerationData['postModerationMerge'];
- $this->postModerationMove = $wbbPostModerationData['postModerationMove'];
- $this->postModerationOpen = $wbbPostModerationData['postModerationOpen'];
- $this->postModerationRestore = $wbbPostModerationData['postModerationRestore'];
- $this->postModerationTrash = $wbbPostModerationData['postModerationTrash'];
- }
-
- $this->postCountAction = $this->eventObj->uzbot->postCountAction;
- $this->topPosterCount = $this->eventObj->uzbot->topPosterCount;
- $this->topPosterInterval = $this->eventObj->uzbot->topPosterInterval;
-
- $this->postIsOfficial = $this->eventObj->uzbot->postIsOfficial;
- $this->threadIsOfficial = $this->eventObj->uzbot->threadIsOfficial;
-
- $this->postChangeUpdate = $this->eventObj->uzbot->postChangeUpdate;
- $this->postChangeDelete = $this->eventObj->uzbot->postChangeDelete;
-
- $this->threadNewBoardIDs = [];
- if (!empty($this->eventObj->uzbot->threadNewBoardIDs)) {
- $this->threadNewBoardIDs = unserialize($this->eventObj->uzbot->threadNewBoardIDs);
- }
- $this->uzbotBoardIDs = [];
- if (!empty($this->eventObj->uzbot->uzbotBoardIDs)) {
- $this->uzbotBoardIDs = unserialize($this->eventObj->uzbot->uzbotBoardIDs);
- }
-
- // conditions
- $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
- $conditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $this->eventObj->botID);
-
- foreach ($conditions as $condition) {
- $this->wbbConditions[$condition->getObjectType()->conditiongroup][$condition->objectTypeID]->getProcessor()->setData($condition);
- }
- }
- }
-
- /**
- * Handles the assignVariables event.
- */
- protected function assignVariables() {
- $this->boardNodeList = new RealtimeBoardNodeList();
- $this->boardNodeList->readNodeTree();
-
- $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
-
- WCF::getTPL()->assign([
- 'boardNodeList' => $this->boardNodeList->getNodeList(),
-
- 'threadNotifyBoardID' => $this->threadNotifyBoardID,
- 'threadNotifyDelayed' => $this->threadNotifyDelayed,
- 'threadNotifyIsClosed' => $this->threadNotifyIsClosed,
- 'threadNotifyIsDisabled' => $this->threadNotifyIsDisabled,
- 'threadNotifyIsDone' => $this->threadNotifyIsDone,
- 'threadNotifyIsSticky' => $this->threadNotifyIsSticky,
-
- 'postNotifyThreadID' => $this->postNotifyThreadID,
- 'postNotifyIsClosed' => $this->postNotifyIsClosed,
- 'postNotifyIsDisabled' => $this->postNotifyIsDisabled,
-
- 'postCountAction' => $this->postCountAction,
- 'topPosterCount' => $this->topPosterCount,
- 'topPosterInterval' => $this->topPosterInterval,
- 'threadNewBoardIDs' => $this->threadNewBoardIDs,
- 'uzbotBoardIDs' => $this->uzbotBoardIDs,
-
- 'postIsOfficial' => $this->postIsOfficial,
- 'threadIsOfficial' => $this->threadIsOfficial,
-
- 'postChangeUpdate' => $this->postChangeUpdate,
- 'postChangeDelete' => $this->postChangeDelete,
-
- 'threadModerationAuthorOnly' => $this->threadModerationAuthorOnly,
- 'threadModerationChangeTopic' => $this->threadModerationChangeTopic,
- 'threadModerationClose' => $this->threadModerationClose,
- 'threadModerationDisable' => $this->threadModerationDisable,
- 'threadModerationDone' => $this->threadModerationDone,
- 'threadModerationEnable' => $this->threadModerationEnable,
- 'threadModerationMerge' => $this->threadModerationMerge,
- 'threadModerationMove' => $this->threadModerationMove,
- 'threadModerationOpen' => $this->threadModerationOpen,
- 'threadModerationRestore' => $this->threadModerationRestore,
- 'threadModerationScrape' => $this->threadModerationScrape,
- 'threadModerationSetAsAnnouncement' => $this->threadModerationSetAsAnnouncement,
- 'threadModerationSetLabel' => $this->threadModerationSetLabel,
- 'threadModerationSticky' => $this->threadModerationSticky,
- 'threadModerationTrash' => $this->threadModerationTrash,
- 'threadModerationUndone' => $this->threadModerationUndone,
- 'threadModerationUnsetAsAnnouncement' => $this->threadModerationUnsetAsAnnouncement,
-
- 'threadModificationAuthorOnly' => $this->threadModificationAuthorOnly,
- 'threadModificationBoardID' => $this->threadModificationBoardID,
- 'threadModificationExecuter' => $this->threadModificationExecuter,
- 'threadModificationExecuterID' => $this->threadModificationExecuterID,
- 'threadModificationClose' => $this->threadModificationClose,
- 'threadModificationDisable' => $this->threadModificationDisable,
- 'threadModificationDone' => $this->threadModificationDone,
- 'threadModificationEnable' => $this->threadModificationEnable,
- 'threadModificationMove' => $this->threadModificationMove,
- 'threadModificationOpen' => $this->threadModificationOpen,
- 'threadModificationRestore' => $this->threadModificationRestore,
- 'threadModificationScrape' => $this->threadModificationScrape,
- 'threadModificationSetLabel' => $this->threadModificationSetLabel,
- 'threadModificationSticky' => $this->threadModificationSticky,
- 'threadModificationTrash' => $this->threadModificationTrash,
- 'threadModificationUndone' => $this->threadModificationUndone,
- 'threadModificationUnannounce' => $this->threadModificationUnannounce,
-
- 'postModerationClose' => $this->postModerationClose,
- 'postModerationDelete' => $this->postModerationDelete,
- 'postModerationDisable' => $this->postModerationDisable,
- 'postModerationEdit' => $this->postModerationEdit,
- 'postModerationEnable' => $this->postModerationEnable,
- 'postModerationMerge' => $this->postModerationMerge,
- 'postModerationMove' => $this->postModerationMove,
- 'postModerationOpen' => $this->postModerationOpen,
- 'postModerationRestore' => $this->postModerationRestore,
- 'postModerationTrash' => $this->postModerationTrash,
-
- 'wbbConditions' => $this->wbbConditions
- ]);
- }
-
- /**
- * Handles the readFormParameters event.
- */
- protected function readFormParameters() {
- if (isset($_POST['threadNotifyBoardID'])) $this->threadNotifyBoardID = intval($_POST['threadNotifyBoardID']);
- $this->threadNotifyDelayed = $this->threadNotifyIsClosed = $this->threadNotifyIsDisabled = 0;
- $this->threadNotifyIsDone = $this->threadNotifyIsSticky = 0;
- if (isset($_POST['threadNotifyDelayed'])) $this->threadNotifyDelayed = intval($_POST['threadNotifyDelayed']);
- if (isset($_POST['threadNotifyIsClosed'])) $this->threadNotifyIsClosed = intval($_POST['threadNotifyIsClosed']);
- if (isset($_POST['threadNotifyIsDisabled'])) $this->threadNotifyIsDisabled = intval($_POST['threadNotifyIsDisabled']);
- if (isset($_POST['threadNotifyIsDone'])) $this->threadNotifyIsDone = intval($_POST['threadNotifyIsDone']);
- if (isset($_POST['threadNotifyIsSticky'])) $this->threadNotifyIsSticky = intval($_POST['threadNotifyIsSticky']);
-
- $this->postNotifyIsClosed = $this->postNotifyIsDisabled = 0;
- if (isset($_POST['postNotifyThreadID'])) $this->postNotifyThreadID = intval($_POST['postNotifyThreadID']);
- if (isset($_POST['postNotifyIsClosed'])) $this->postNotifyIsClosed = intval($_POST['postNotifyIsClosed']);
- if (isset($_POST['postNotifyIsDisabled'])) $this->postNotifyIsDisabled = intval($_POST['postNotifyIsDisabled']);
-
- if (isset($_POST['postCountAction'])) $this->postCountAction = StringUtil::trim($_POST['postCountAction']);
- if (isset($_POST['topPosterCount'])) $this->topPosterCount = intval($_POST['topPosterCount']);
- if (isset($_POST['topPosterInterval'])) $this->topPosterInterval = intval($_POST['topPosterInterval']);
- if (isset($_POST['threadNewBoardIDs']) && is_array($_POST['threadNewBoardIDs'])) $this->threadNewBoardIDs = ArrayUtil::toIntegerArray($_POST['threadNewBoardIDs']);
- if (isset($_POST['uzbotBoardIDs']) && is_array($_POST['uzbotBoardIDs'])) $this->uzbotBoardIDs = ArrayUtil::toIntegerArray($_POST['uzbotBoardIDs']);
-
- $this->postIsOfficial = $this->threadIsOfficial= 0;
- if (isset($_POST['postIsOfficial'])) $this->postIsOfficial = intval($_POST['postIsOfficial']);
- if (isset($_POST['threadIsOfficial'])) $this->threadIsOfficial = intval($_POST['threadIsOfficial']);
-
- $this->postChangeUpdate = $this->postChangeDelete = 0;
- if (isset($_POST['postChangeUpdate'])) $this->postChangeUpdate = intval($_POST['postChangeUpdate']);
- if (isset($_POST['postChangeDelete'])) $this->postChangeDelete = intval($_POST['postChangeDelete']);
-
- $this->threadModerationChangeTopic = $this->threadModerationClose = $this->threadModerationDisable = 0;
- $this->threadModerationDone = $this->threadModerationEnable = $this->threadModerationMerge = $this->threadModerationMove = $this->threadModerationOpen = 0;
- $this->threadModerationRestore = $this->threadModerationScrape = $this->threadModerationSetAsAnnouncement = $this->threadModerationSetLabel = 0;
- $this->threadModerationSticky = $this->threadModerationTrash = $this->threadModerationUndone = $this->threadModerationAuthorOnly = 0;
- if (isset($_POST['threadModerationAuthorOnly'])) $this->threadModerationAuthorOnly = intval($_POST['threadModerationAuthorOnly']);
- if (isset($_POST['threadModerationChangeTopic'])) $this->threadModerationChangeTopic = intval($_POST['threadModerationChangeTopic']);
- if (isset($_POST['threadModerationClose'])) $this->threadModerationClose = intval($_POST['threadModerationClose']);
- if (isset($_POST['threadModerationDisable'])) $this->threadModerationDisable = intval($_POST['threadModerationDisable']);
- if (isset($_POST['threadModerationDone'])) $this->threadModerationDone = intval($_POST['threadModerationDone']);
- if (isset($_POST['threadModerationEnable'])) $this->threadModerationEnable = intval($_POST['threadModerationEnable']);
- if (isset($_POST['threadModerationMerge'])) $this->threadModerationMerge = intval($_POST['threadModerationMerge']);
- if (isset($_POST['threadModerationMove'])) $this->threadModerationMove = intval($_POST['threadModerationMove']);
- if (isset($_POST['threadModerationOpen'])) $this->threadModerationOpen = intval($_POST['threadModerationOpen']);
- if (isset($_POST['threadModerationRestore'])) $this->threadModerationRestore = intval($_POST['threadModerationRestore']);
- if (isset($_POST['threadModerationScrape'])) $this->threadModerationScrape = intval($_POST['threadModerationScrape']);
- if (isset($_POST['threadModerationSetAsAnnouncement'])) $this->threadModerationSetAsAnnouncement = intval($_POST['threadModerationSetAsAnnouncement']);
- if (isset($_POST['threadModerationSetLabel'])) $this->threadModerationSetLabel = intval($_POST['threadModerationSetLabel']);
- if (isset($_POST['threadModerationSticky'])) $this->threadModerationSticky = intval($_POST['threadModerationSticky']);
- if (isset($_POST['threadModerationTrash'])) $this->threadModerationTrash = intval($_POST['threadModerationTrash']);
- if (isset($_POST['threadModerationUndone'])) $this->threadModerationUndone = intval($_POST['threadModerationUndone']);
- if (isset($_POST['threadModerationUnsetAsAnnouncement'])) $this->threadModerationUnsetAsAnnouncement = intval($_POST['threadModerationUnsetAsAnnouncement']);
-
- $this->threadModificationClose = $this->threadModificationDisable = 0;
- $this->threadModificationDone = $this->threadModificationEnable = $this->threadModificationMove = $this->threadModificationOpen = 0;
- $this->threadModificationRestore = $this->threadModificationScrape = $this->threadModificationSetLabel = 0;
- $this->threadModificationSticky = $this->threadModificationTrash = $this->threadModificationUndone = $this->threadModificationUnannounce = $this->threadModificationAuthorOnly = 0;
- if (isset($_POST['threadModificationAuthorOnly'])) $this->threadModificationAuthorOnly = intval($_POST['threadModificationAuthorOnly']);
- if (isset($_POST['threadModificationBoardID'])) $this->threadModificationBoardID = intval($_POST['threadModificationBoardID']);
- if (isset($_POST['threadModificationExecuter'])) $this->threadModificationExecuter = StringUtil::trim($_POST['threadModificationExecuter']);
- if (isset($_POST['threadModificationExecuterID'])) $this->threadModificationExecuterID = intval($_POST['threadModificationExecuterID']);
- if (isset($_POST['threadModificationClose'])) $this->threadModificationClose = intval($_POST['threadModificationClose']);
- if (isset($_POST['threadModificationDisable'])) $this->threadModificationDisable = intval($_POST['threadModificationDisable']);
- if (isset($_POST['threadModificationDone'])) $this->threadModificationDone = intval($_POST['threadModificationDone']);
- if (isset($_POST['threadModificationEnable'])) $this->threadModificationEnable = intval($_POST['threadModificationEnable']);
- if (isset($_POST['threadModificationMove'])) $this->threadModificationMove = intval($_POST['threadModificationMove']);
- if (isset($_POST['threadModificationOpen'])) $this->threadModificationOpen = intval($_POST['threadModificationOpen']);
- if (isset($_POST['threadModificationRestore'])) $this->threadModificationRestore = intval($_POST['threadModificationRestore']);
- if (isset($_POST['threadModificationScrape'])) $this->threadModificationScrape = intval($_POST['threadModificationScrape']);
- if (isset($_POST['threadModificationSetLabel'])) $this->threadModificationSetLabel = intval($_POST['threadModificationSetLabel']);
- if (isset($_POST['threadModificationSticky'])) $this->threadModificationSticky = intval($_POST['threadModificationSticky']);
- if (isset($_POST['threadModificationTrash'])) $this->threadModificationTrash = intval($_POST['threadModificationTrash']);
- if (isset($_POST['threadModificationUndone'])) $this->threadModificationUndone = intval($_POST['threadModificationUndone']);
- if (isset($_POST['threadModificationUnannounce'])) $this->threadModificationUnannounce = intval($_POST['threadModificationUnannounce']);
-
- $this->postModerationClose = $this->postModerationDelete = $this->postModerationDisable = $this->postModerationEdit = 0;
- $this->postModerationEnable = $this->postModerationMerge = $this->postModerationMove = $this->postModerationOpen = 0;
- $this->postModerationRestore = $this->postModerationTrash = 0;
- if (isset($_POST['postModerationClose'])) $this->postModerationClose = intval($_POST['postModerationClose']);
- if (isset($_POST['postModerationDelete'])) $this->postModerationDelete = intval($_POST['postModerationDelete']);
- if (isset($_POST['postModerationDisable'])) $this->postModerationDisable = intval($_POST['postModerationDisable']);
- if (isset($_POST['postModerationEdit'])) $this->postModerationEdit = intval($_POST['postModerationEdit']);
- if (isset($_POST['postModerationEnable'])) $this->postModerationEnable = intval($_POST['postModerationEnable']);
- if (isset($_POST['postModerationMerge'])) $this->postModerationMerge = intval($_POST['postModerationMerge']);
- if (isset($_POST['postModerationMove'])) $this->postModerationMove = intval($_POST['postModerationMove']);
- if (isset($_POST['postModerationOpen'])) $this->postModerationOpen = intval($_POST['postModerationOpen']);
- if (isset($_POST['postModerationRestore'])) $this->postModerationRestore = intval($_POST['postModerationRestore']);
- if (isset($_POST['postModerationTrash'])) $this->postModerationTrash = intval($_POST['postModerationTrash']);
-
- $this->wbbThreadModerationData = [
- 'threadModerationAuthorOnly' => $this->threadModerationAuthorOnly,
- 'threadModerationChangeTopic' => $this->threadModerationChangeTopic,
- 'threadModerationClose' => $this->threadModerationClose,
- 'threadModerationDisable' => $this->threadModerationDisable,
- 'threadModerationDone' => $this->threadModerationDone,
- 'threadModerationEnable' => $this->threadModerationEnable,
- 'threadModerationMerge' => $this->threadModerationMerge,
- 'threadModerationMove' => $this->threadModerationMove,
- 'threadModerationOpen' => $this->threadModerationOpen,
- 'threadModerationRestore' => $this->threadModerationRestore,
- 'threadModerationScrape' => $this->threadModerationScrape,
- 'threadModerationSetAsAnnouncement' => $this->threadModerationSetAsAnnouncement,
- 'threadModerationSetLabel' => $this->threadModerationSetLabel,
- 'threadModerationSticky' => $this->threadModerationSticky,
- 'threadModerationTrash' => $this->threadModerationTrash,
- 'threadModerationUndone' => $this->threadModerationUndone,
- 'threadModerationUnsetAsAnnouncement' => $this->threadModerationUnsetAsAnnouncement
- ];
-
- $this->wbbThreadModificationData = [
- 'threadModificationAuthorOnly' => $this->threadModificationAuthorOnly,
- 'threadModificationBoardID' => $this->threadModificationBoardID,
- 'threadModificationExecuter' => $this->threadModificationExecuter,
- 'threadModificationExecuterID' => $this->threadModificationExecuterID,
- 'threadModificationClose' => $this->threadModificationClose,
- 'threadModificationDisable' => $this->threadModificationDisable,
- 'threadModificationDone' => $this->threadModificationDone,
- 'threadModificationEnable' => $this->threadModificationEnable,
- 'threadModificationMove' => $this->threadModificationMove,
- 'threadModificationOpen' => $this->threadModificationOpen,
- 'threadModificationRestore' => $this->threadModificationRestore,
- 'threadModificationScrape' => $this->threadModificationScrape,
- 'threadModificationSetLabel' => $this->threadModificationSetLabel,
- 'threadModificationSticky' => $this->threadModificationSticky,
- 'threadModificationTrash' => $this->threadModificationTrash,
- 'threadModificationUndone' => $this->threadModificationUndone,
- 'threadModificationUnannounce' => $this->threadModificationUnannounce
- ];
-
- $this->wbbPostModerationData = [
- 'postModerationClose' => $this->postModerationClose,
- 'postModerationDelete' => $this->postModerationDelete,
- 'postModerationDisable' => $this->postModerationDisable,
- 'postModerationEdit' => $this->postModerationEdit,
- 'postModerationEnable' => $this->postModerationEnable,
- 'postModerationMerge' => $this->postModerationMerge,
- 'postModerationMove' => $this->postModerationMove,
- 'postModerationOpen' => $this->postModerationOpen,
- 'postModerationRestore' => $this->postModerationRestore,
- 'postModerationTrash' => $this->postModerationTrash
- ];
-
- // read conditions
- $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
- foreach ($this->wbbConditions as $conditions) {
- foreach ($conditions as $condition) {
- $condition->getProcessor()->readFormParameters();
- }
- }
- }
-
- /**
- * Handles the validate event.
- */
- protected function validate() {
- // Get type / notify data
- $type = UzbotType::getTypeByID($this->eventObj->typeID);
- $notify = UzbotNotify::getNotifyByID($this->eventObj->notifyID);
-
- // threadNotifyBoardID
- if ($notify->notifyTitle == 'thread') {
- if ($this->threadNotifyBoardID == 0) {
- throw new UserInputException('threadNotifyBoardID', 'notConfigured');
- }
- $board = BoardCache::getInstance()->getBoard($this->threadNotifyBoardID);
- if (!$board->boardID) {
- throw new UserInputException('threadNotifyBoardID', 'notValid');
- }
- if (!$board->isBoard()) {
- throw new UserInputException('threadNotifyBoardID', 'notValid');
- }
- }
-
- // postNotifyThreadID
- if ($notify->notifyTitle == 'post') {
- // threadID may be 0 with certain bots
- $allowed = ['wbb_postModeration', 'wbb_threadModification', 'wbb_threadModeration', 'wbb_threadNew', 'wbb_postCount', 'wbb_postChange', 'wbb_bestAnswer'];
- if (!$this->postNotifyThreadID) {
- if (!in_array($type->typeTitle, $allowed)) {
- throw new UserInputException('postNotifyThreadID', 'notValid');
- }
- }
- else {
- $thread = new Thread($this->postNotifyThreadID);
- if (!$thread->threadID) {
- throw new UserInputException('postNotifyThreadID', 'notValid');
- }
- }
- }
-
- // need notify?
- if ($type->needNotify && !$notify->notifyID) {
- throw new UserInputException('notifyID', 'missing');
- }
-
- // need count for trigger values
- if ($type->needCount && $type->typeTitle == 'wbb_postCount') {
- if ($this->postCountAction == 'postTotal' || $this->postCountAction == 'postX') {
- $counts = ArrayUtil::trim(explode(',', $this->eventObj->userCount));
- $counts = ArrayUtil::toIntegerArray($counts);
-
- if (!count($counts)) throw new UserInputException('userCount', 'empty');
- }
- }
-
- // thread new - wbb_threadNew
- if ($type->typeTitle == 'wbb_threadNew') {
- // board(s) must be selected
- if (!count($this->threadNewBoardIDs)) {
- throw new UserInputException('threadNewBoardIDs', 'notConfigured');
- }
- // no thread notification in monitored boards on threadNew
- if ($notify->notifyTitle == 'thread') {
- if (in_array($this->threadNotifyBoardID, $this->threadNewBoardIDs)) {
- throw new UserInputException('threadNotifyBoardID', 'notAllowedOnThreadNew');
- }
- }
- }
-
- // action needing boardIDs
- $actions = ['wbb_postModeration', 'wbb_threadModeration', 'wbb_postChange', 'wbb_topPoster', 'wbb_bestAnswer'];
- if (in_array($type->typeTitle, $actions)) {
- // board(s) must be selected
- if (!count($this->uzbotBoardIDs)) {
- throw new UserInputException('uzbotBoardIDs', 'notConfigured');
- }
- }
-
- // wbb_threadModeration
- if ($type->typeTitle == 'wbb_threadModeration') {
- if (array_sum($this->wbbThreadModerationData) - $this->wbbThreadModerationData['threadModerationAuthorOnly'] == 0) {
- throw new UserInputException('threadModerationAction', 'notConfigured');
- }
- }
-
- // wbb_threadModification
- if ($type->typeTitle == 'wbb_threadModification') {
- // unset change labels if no labels
- if (empty($this->eventObj->labelGroups) || empty($this->eventObj->availableLabels)) {
- $this->wbbThreadModificationData['threadModificationSetLabel'] = 0;
- $this->threadModificationSetLabel = 0;
- }
-
- if (array_sum($this->wbbThreadModificationData) - $this->wbbThreadModificationData['threadModificationAuthorOnly'] == 0) {
- throw new UserInputException('threadModificationAction', 'notConfigured');
- }
-
- // if move, board must be selected and must exist
- if ($this->threadModificationMove) {
- $board = BoardCache::getInstance()->getBoard($this->threadModificationBoardID);
- if (!$board || !$board->isBoard()) {
- throw new UserInputException('threadModificationBoardID', 'notValid');
- }
- }
-
- // executer must exist
- if (empty($this->threadModificationExecuter)) throw new UserInputException('threadModificationExecuter');
- $user = User::getUserByUsername($this->threadModificationExecuter);
- if (!$user->userID) throw new UserInputException('threadModificationExecuter', 'invalid');
- $this->threadModificationExecuterID = $user->userID;
- $this->wbbThreadModificationData['threadModificationExecuterID'] = $user->userID;
-
- }
-
- // wbb_postModeration
- if ($type->typeTitle == 'wbb_postModeration') {
- if (!array_sum($this->wbbPostModerationData)) {
- throw new UserInputException('postModerationAction', 'notConfigured');
- }
- }
-
- // wbb_postChange
- if ($type->typeTitle == 'wbb_postChange') {
- if (!$this->postChangeUpdate && !$this->postChangeDelete) {
- throw new UserInputException('postChangeAction', 'notConfigured');
- }
- }
- }
-
- /**
- * Handles the save event.
- */
- protected function save() {
- // wbbThreadNotifyData
- $wbbThreadData = [
- 'threadNotifyBoardID' => $this->threadNotifyBoardID,
- 'threadNotifyDelayed' => $this->threadNotifyDelayed,
- 'threadNotifyIsClosed' => $this->threadNotifyIsClosed,
- 'threadNotifyIsDisabled' => $this->threadNotifyIsDisabled,
- 'threadNotifyIsDone' => $this->threadNotifyIsDone,
- 'threadNotifyIsSticky' => $this->threadNotifyIsSticky
- ];
-
- $wbbPostData = [
- 'postNotifyThreadID' => $this->postNotifyThreadID,
- 'postNotifyIsClosed' => $this->postNotifyIsClosed,
- 'postNotifyIsDisabled' => $this->postNotifyIsDisabled
- ];
-
- $this->eventObj->additionalFields = array_merge($this->eventObj->additionalFields, [
- 'wbbThreadData' => serialize($wbbThreadData),
- 'wbbPostData' => serialize($wbbPostData),
- 'wbbPostModerationData' => serialize($this->wbbPostModerationData),
- 'wbbThreadModerationData' => serialize($this->wbbThreadModerationData),
- 'wbbThreadModificationData' => serialize($this->wbbThreadModificationData),
- 'postCountAction' => $this->postCountAction,
- 'topPosterCount' => $this->topPosterCount,
- 'topPosterInterval' => $this->topPosterInterval,
- 'topPosterNext' => 0,
- 'threadNewBoardIDs' => serialize($this->threadNewBoardIDs),
- 'uzbotBoardIDs' => serialize($this->uzbotBoardIDs),
- 'postIsOfficial' => $this->postIsOfficial,
- 'threadIsOfficial' => $this->threadIsOfficial,
- 'postChangeUpdate' => $this->postChangeUpdate,
- 'postChangeDelete' => $this->postChangeDelete
- ]);
- }
-
- /**
- * Handles the saved event.
- */
- protected function saved() {
- // transform conditions array into one-dimensional array and save
- $conditions = [];
- foreach ($this->wbbConditions as $groupedObjectTypes) {
- $conditions = array_merge($conditions, $groupedObjectTypes);
- }
-
- $oldConditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $this->eventObj->botID);
- ConditionHandler::getInstance()->updateConditions($this->eventObj->botID, $oldConditions, $conditions);
- }
+class UzbotAddFormWbbListener implements IParameterizedEventListener
+{
+ /**
+ * instance of UzbotAddForm
+ */
+ protected $eventObj;
+
+ /**
+ * general data
+ */
+ protected $boardNodeList;
+
+ /**
+ * thread and post data
+ */
+ protected $threadNotifyBoardID = 0;
+
+ protected $threadNotifyDelayed = 0;
+
+ protected $threadNotifyIsClosed = 0;
+
+ protected $threadNotifyIsDisabled = 0;
+
+ protected $threadNotifyIsDone = 0;
+
+ protected $threadNotifyIsSticky = 0;
+
+ protected $postNotifyThreadID = 0;
+
+ protected $postNotifyIsClosed = 0;
+
+ protected $postNotifyIsDisabled = 0;
+
+ protected $wbbThreadModerationData = 0;
+
+ protected $threadModerationAuthorOnly = 0;
+
+ protected $threadModerationChangeTopic = 0;
+
+ protected $threadModerationClose = 0;
+
+ protected $threadModerationDisable = 0;
+
+ protected $threadModerationDone = 0;
+
+ protected $threadModerationEnable = 0;
+
+ protected $threadModerationMerge = 0;
+
+ protected $threadModerationMove = 0;
+
+ protected $threadModerationOpen = 0;
+
+ protected $threadModerationRestore = 0;
+
+ protected $threadModerationScrape = 0;
+
+ protected $threadModerationSetAsAnnouncement = 0;
+
+ protected $threadModerationSetLabel = 0;
+
+ protected $threadModerationSticky = 0;
+
+ protected $threadModerationTrash = 0;
+
+ protected $threadModerationUndone = 0;
+
+ protected $threadModerationUnsetAsAnnouncement = 0;
+
+ protected $wbbThreadModificationData = 0;
+
+ protected $threadModificationAuthorOnly = 0;
+
+ protected $threadModificationBoardID = 0;
+
+ protected $threadModificationExecuter = '';
+
+ protected $threadModificationExecuterID = 0;
+
+ protected $threadModificationClose = 0;
+
+ protected $threadModificationDisable = 0;
+
+ protected $threadModificationDone = 0;
+
+ protected $threadModificationEnable = 0;
+
+ protected $threadModificationMove = 0;
+
+ protected $threadModificationOpen = 0;
+
+ protected $threadModificationRestore = 0;
+
+ protected $threadModificationScrape = 0;
+
+ protected $threadModificationSetLabel = 0;
+
+ protected $threadModificationSticky = 0;
+
+ protected $threadModificationTrash = 0;
+
+ protected $threadModificationUndone = 0;
+
+ protected $threadModificationUnannounce = 0;
+
+ protected $wbbPostModerationData = 0;
+
+ protected $postModerationClose = 0;
+
+ protected $postModerationDelete = 0;
+
+ protected $postModerationDisable = 0;
+
+ protected $postModerationEdit = 0;
+
+ protected $postModerationEnable = 0;
+
+ protected $postModerationMerge = 0;
+
+ protected $postModerationMove = 0;
+
+ protected $postModerationOpen = 0;
+
+ protected $postModerationRestore = 0;
+
+ protected $postModerationTrash = 0;
+
+ /**
+ * further bot data
+ */
+ protected $postCountAction = 'postTotal';
+
+ protected $topPosterCount = 1;
+
+ protected $topPosterInterval = 1;
+
+ protected $threadNewBoardIDs = [];
+
+ protected $uzbotBoardIDs = [];
+
+ protected $postIsOfficial = 0;
+
+ protected $threadIsOfficial = 0;
+
+ /**
+ * postChange switches
+ */
+ protected $postChangeUpdate = 1;
+
+ protected $postChangeDelete = 1;
+
+ /**
+ * condition data
+ */
+ public $wbbConditions = [];
+
+ /**
+ * @inheritDoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ $this->eventObj = $eventObj;
+ $this->{$eventName}();
+ }
+
+ /**
+ * Handles the readData event. Only in UzbotEdit!
+ */
+ protected function readData()
+ {
+ if (empty($_POST)) {
+ if (!empty($this->eventObj->uzbot->wbbThreadData)) {
+ $wbbThreadData = \unserialize($this->eventObj->uzbot->wbbThreadData);
+ $this->threadNotifyBoardID = $wbbThreadData['threadNotifyBoardID'];
+ $this->threadNotifyDelayed = $wbbThreadData['threadNotifyDelayed'];
+ $this->threadNotifyIsClosed = $wbbThreadData['threadNotifyIsClosed'];
+ $this->threadNotifyIsDisabled = $wbbThreadData['threadNotifyIsDisabled'];
+ $this->threadNotifyIsDone = $wbbThreadData['threadNotifyIsDone'];
+ $this->threadNotifyIsSticky = $wbbThreadData['threadNotifyIsSticky'];
+ }
+
+ if (!empty($this->eventObj->uzbot->wbbPostData)) {
+ $wbbPostData = \unserialize($this->eventObj->uzbot->wbbPostData);
+ $this->postNotifyThreadID = $wbbPostData['postNotifyThreadID'];
+ $this->postNotifyIsClosed = $wbbPostData['postNotifyIsClosed'];
+ $this->postNotifyIsDisabled = $wbbPostData['postNotifyIsDisabled'];
+ }
+
+ if (!empty($this->eventObj->uzbot->wbbThreadModerationData)) {
+ $wbbThreadModerationData = \unserialize($this->eventObj->uzbot->wbbThreadModerationData);
+ $this->threadModerationAuthorOnly = $wbbThreadModerationData['threadModerationAuthorOnly'];
+ $this->threadModerationChangeTopic = $wbbThreadModerationData['threadModerationChangeTopic'];
+ $this->threadModerationClose = $wbbThreadModerationData['threadModerationClose'];
+ $this->threadModerationDisable = $wbbThreadModerationData['threadModerationDisable'];
+ $this->threadModerationDone = $wbbThreadModerationData['threadModerationDone'];
+ $this->threadModerationEnable = $wbbThreadModerationData['threadModerationEnable'];
+ $this->threadModerationMerge = $wbbThreadModerationData['threadModerationMerge'];
+ $this->threadModerationMove = $wbbThreadModerationData['threadModerationMove'];
+ $this->threadModerationOpen = $wbbThreadModerationData['threadModerationOpen'];
+ $this->threadModerationRestore = $wbbThreadModerationData['threadModerationRestore'];
+ $this->threadModerationScrape = $wbbThreadModerationData['threadModerationScrape'];
+ $this->threadModerationSetAsAnnouncement = $wbbThreadModerationData['threadModerationSetAsAnnouncement'];
+ $this->threadModerationSetLabel = $wbbThreadModerationData['threadModerationSetLabel'];
+ $this->threadModerationSticky = $wbbThreadModerationData['threadModerationSticky'];
+ $this->threadModerationTrash = $wbbThreadModerationData['threadModerationTrash'];
+ $this->threadModerationUndone = $wbbThreadModerationData['threadModerationUndone'];
+ $this->threadModerationUnsetAsAnnouncement = $wbbThreadModerationData['threadModerationUnsetAsAnnouncement'];
+ }
+
+ if (!empty($this->eventObj->uzbot->wbbThreadModificationData)) {
+ $wbbThreadModificationData = \unserialize($this->eventObj->uzbot->wbbThreadModificationData);
+ $this->threadModificationAuthorOnly = $wbbThreadModificationData['threadModificationAuthorOnly'];
+ $this->threadModificationBoardID = $wbbThreadModificationData['threadModificationBoardID'];
+ $this->threadModificationExecuter = $wbbThreadModificationData['threadModificationExecuter'];
+ $this->threadModificationExecuterID = $wbbThreadModificationData['threadModificationExecuterID'];
+ $this->threadModificationClose = $wbbThreadModificationData['threadModificationClose'];
+ $this->threadModificationDisable = $wbbThreadModificationData['threadModificationDisable'];
+ $this->threadModificationDone = $wbbThreadModificationData['threadModificationDone'];
+ $this->threadModificationEnable = $wbbThreadModificationData['threadModificationEnable'];
+ $this->threadModificationMove = $wbbThreadModificationData['threadModificationMove'];
+ $this->threadModificationOpen = $wbbThreadModificationData['threadModificationOpen'];
+ $this->threadModificationRestore = $wbbThreadModificationData['threadModificationRestore'];
+ $this->threadModificationScrape = $wbbThreadModificationData['threadModificationScrape'];
+ $this->threadModificationSetLabel = $wbbThreadModificationData['threadModificationSetLabel'];
+ $this->threadModificationSticky = $wbbThreadModificationData['threadModificationSticky'];
+ $this->threadModificationTrash = $wbbThreadModificationData['threadModificationTrash'];
+ $this->threadModificationUndone = $wbbThreadModificationData['threadModificationUndone'];
+
+ if (isset($wbbThreadModificationData['threadModificationUnannounce'])) {
+ $this->threadModificationUnannounce = $wbbThreadModificationData['threadModificationUnannounce'];
+ }
+ }
+
+ if (!empty($this->eventObj->uzbot->wbbPostModerationData)) {
+ $wbbPostModerationData = \unserialize($this->eventObj->uzbot->wbbPostModerationData);
+ $this->postModerationClose = $wbbPostModerationData['postModerationClose'];
+ $this->postModerationDelete = $wbbPostModerationData['postModerationDelete'];
+ $this->postModerationDisable = $wbbPostModerationData['postModerationDisable'];
+ $this->postModerationEdit = $wbbPostModerationData['postModerationEdit'];
+ $this->postModerationEnable = $wbbPostModerationData['postModerationEnable'];
+ $this->postModerationMerge = $wbbPostModerationData['postModerationMerge'];
+ $this->postModerationMove = $wbbPostModerationData['postModerationMove'];
+ $this->postModerationOpen = $wbbPostModerationData['postModerationOpen'];
+ $this->postModerationRestore = $wbbPostModerationData['postModerationRestore'];
+ $this->postModerationTrash = $wbbPostModerationData['postModerationTrash'];
+ }
+
+ $this->postCountAction = $this->eventObj->uzbot->postCountAction;
+ $this->topPosterCount = $this->eventObj->uzbot->topPosterCount;
+ $this->topPosterInterval = $this->eventObj->uzbot->topPosterInterval;
+
+ $this->postIsOfficial = $this->eventObj->uzbot->postIsOfficial;
+ $this->threadIsOfficial = $this->eventObj->uzbot->threadIsOfficial;
+
+ $this->postChangeUpdate = $this->eventObj->uzbot->postChangeUpdate;
+ $this->postChangeDelete = $this->eventObj->uzbot->postChangeDelete;
+
+ $this->threadNewBoardIDs = [];
+ if (!empty($this->eventObj->uzbot->threadNewBoardIDs)) {
+ $this->threadNewBoardIDs = \unserialize($this->eventObj->uzbot->threadNewBoardIDs);
+ }
+ $this->uzbotBoardIDs = [];
+ if (!empty($this->eventObj->uzbot->uzbotBoardIDs)) {
+ $this->uzbotBoardIDs = \unserialize($this->eventObj->uzbot->uzbotBoardIDs);
+ }
+
+ // conditions
+ $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
+ $conditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $this->eventObj->botID);
+
+ foreach ($conditions as $condition) {
+ $this->wbbConditions[$condition->getObjectType()->conditiongroup][$condition->objectTypeID]->getProcessor()->setData($condition);
+ }
+ }
+ }
+
+ /**
+ * Handles the assignVariables event.
+ */
+ protected function assignVariables()
+ {
+ $this->boardNodeList = new RealtimeBoardNodeList();
+ $this->boardNodeList->readNodeTree();
+
+ $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
+
+ WCF::getTPL()->assign([
+ 'boardNodeList' => $this->boardNodeList->getNodeList(),
+
+ 'threadNotifyBoardID' => $this->threadNotifyBoardID,
+ 'threadNotifyDelayed' => $this->threadNotifyDelayed,
+ 'threadNotifyIsClosed' => $this->threadNotifyIsClosed,
+ 'threadNotifyIsDisabled' => $this->threadNotifyIsDisabled,
+ 'threadNotifyIsDone' => $this->threadNotifyIsDone,
+ 'threadNotifyIsSticky' => $this->threadNotifyIsSticky,
+
+ 'postNotifyThreadID' => $this->postNotifyThreadID,
+ 'postNotifyIsClosed' => $this->postNotifyIsClosed,
+ 'postNotifyIsDisabled' => $this->postNotifyIsDisabled,
+
+ 'postCountAction' => $this->postCountAction,
+ 'topPosterCount' => $this->topPosterCount,
+ 'topPosterInterval' => $this->topPosterInterval,
+ 'threadNewBoardIDs' => $this->threadNewBoardIDs,
+ 'uzbotBoardIDs' => $this->uzbotBoardIDs,
+
+ 'postIsOfficial' => $this->postIsOfficial,
+ 'threadIsOfficial' => $this->threadIsOfficial,
+
+ 'postChangeUpdate' => $this->postChangeUpdate,
+ 'postChangeDelete' => $this->postChangeDelete,
+
+ 'threadModerationAuthorOnly' => $this->threadModerationAuthorOnly,
+ 'threadModerationChangeTopic' => $this->threadModerationChangeTopic,
+ 'threadModerationClose' => $this->threadModerationClose,
+ 'threadModerationDisable' => $this->threadModerationDisable,
+ 'threadModerationDone' => $this->threadModerationDone,
+ 'threadModerationEnable' => $this->threadModerationEnable,
+ 'threadModerationMerge' => $this->threadModerationMerge,
+ 'threadModerationMove' => $this->threadModerationMove,
+ 'threadModerationOpen' => $this->threadModerationOpen,
+ 'threadModerationRestore' => $this->threadModerationRestore,
+ 'threadModerationScrape' => $this->threadModerationScrape,
+ 'threadModerationSetAsAnnouncement' => $this->threadModerationSetAsAnnouncement,
+ 'threadModerationSetLabel' => $this->threadModerationSetLabel,
+ 'threadModerationSticky' => $this->threadModerationSticky,
+ 'threadModerationTrash' => $this->threadModerationTrash,
+ 'threadModerationUndone' => $this->threadModerationUndone,
+ 'threadModerationUnsetAsAnnouncement' => $this->threadModerationUnsetAsAnnouncement,
+
+ 'threadModificationAuthorOnly' => $this->threadModificationAuthorOnly,
+ 'threadModificationBoardID' => $this->threadModificationBoardID,
+ 'threadModificationExecuter' => $this->threadModificationExecuter,
+ 'threadModificationExecuterID' => $this->threadModificationExecuterID,
+ 'threadModificationClose' => $this->threadModificationClose,
+ 'threadModificationDisable' => $this->threadModificationDisable,
+ 'threadModificationDone' => $this->threadModificationDone,
+ 'threadModificationEnable' => $this->threadModificationEnable,
+ 'threadModificationMove' => $this->threadModificationMove,
+ 'threadModificationOpen' => $this->threadModificationOpen,
+ 'threadModificationRestore' => $this->threadModificationRestore,
+ 'threadModificationScrape' => $this->threadModificationScrape,
+ 'threadModificationSetLabel' => $this->threadModificationSetLabel,
+ 'threadModificationSticky' => $this->threadModificationSticky,
+ 'threadModificationTrash' => $this->threadModificationTrash,
+ 'threadModificationUndone' => $this->threadModificationUndone,
+ 'threadModificationUnannounce' => $this->threadModificationUnannounce,
+
+ 'postModerationClose' => $this->postModerationClose,
+ 'postModerationDelete' => $this->postModerationDelete,
+ 'postModerationDisable' => $this->postModerationDisable,
+ 'postModerationEdit' => $this->postModerationEdit,
+ 'postModerationEnable' => $this->postModerationEnable,
+ 'postModerationMerge' => $this->postModerationMerge,
+ 'postModerationMove' => $this->postModerationMove,
+ 'postModerationOpen' => $this->postModerationOpen,
+ 'postModerationRestore' => $this->postModerationRestore,
+ 'postModerationTrash' => $this->postModerationTrash,
+
+ 'wbbConditions' => $this->wbbConditions,
+ ]);
+ }
+
+ /**
+ * Handles the readFormParameters event.
+ */
+ protected function readFormParameters()
+ {
+ if (isset($_POST['threadNotifyBoardID'])) {
+ $this->threadNotifyBoardID = \intval($_POST['threadNotifyBoardID']);
+ }
+ $this->threadNotifyDelayed = $this->threadNotifyIsClosed = $this->threadNotifyIsDisabled = 0;
+ $this->threadNotifyIsDone = $this->threadNotifyIsSticky = 0;
+ if (isset($_POST['threadNotifyDelayed'])) {
+ $this->threadNotifyDelayed = \intval($_POST['threadNotifyDelayed']);
+ }
+ if (isset($_POST['threadNotifyIsClosed'])) {
+ $this->threadNotifyIsClosed = \intval($_POST['threadNotifyIsClosed']);
+ }
+ if (isset($_POST['threadNotifyIsDisabled'])) {
+ $this->threadNotifyIsDisabled = \intval($_POST['threadNotifyIsDisabled']);
+ }
+ if (isset($_POST['threadNotifyIsDone'])) {
+ $this->threadNotifyIsDone = \intval($_POST['threadNotifyIsDone']);
+ }
+ if (isset($_POST['threadNotifyIsSticky'])) {
+ $this->threadNotifyIsSticky = \intval($_POST['threadNotifyIsSticky']);
+ }
+
+ $this->postNotifyIsClosed = $this->postNotifyIsDisabled = 0;
+ if (isset($_POST['postNotifyThreadID'])) {
+ $this->postNotifyThreadID = \intval($_POST['postNotifyThreadID']);
+ }
+ if (isset($_POST['postNotifyIsClosed'])) {
+ $this->postNotifyIsClosed = \intval($_POST['postNotifyIsClosed']);
+ }
+ if (isset($_POST['postNotifyIsDisabled'])) {
+ $this->postNotifyIsDisabled = \intval($_POST['postNotifyIsDisabled']);
+ }
+
+ if (isset($_POST['postCountAction'])) {
+ $this->postCountAction = StringUtil::trim($_POST['postCountAction']);
+ }
+ if (isset($_POST['topPosterCount'])) {
+ $this->topPosterCount = \intval($_POST['topPosterCount']);
+ }
+ if (isset($_POST['topPosterInterval'])) {
+ $this->topPosterInterval = \intval($_POST['topPosterInterval']);
+ }
+ if (isset($_POST['threadNewBoardIDs']) && \is_array($_POST['threadNewBoardIDs'])) {
+ $this->threadNewBoardIDs = ArrayUtil::toIntegerArray($_POST['threadNewBoardIDs']);
+ }
+ if (isset($_POST['uzbotBoardIDs']) && \is_array($_POST['uzbotBoardIDs'])) {
+ $this->uzbotBoardIDs = ArrayUtil::toIntegerArray($_POST['uzbotBoardIDs']);
+ }
+
+ $this->postIsOfficial = $this->threadIsOfficial = 0;
+ if (isset($_POST['postIsOfficial'])) {
+ $this->postIsOfficial = \intval($_POST['postIsOfficial']);
+ }
+ if (isset($_POST['threadIsOfficial'])) {
+ $this->threadIsOfficial = \intval($_POST['threadIsOfficial']);
+ }
+
+ $this->postChangeUpdate = $this->postChangeDelete = 0;
+ if (isset($_POST['postChangeUpdate'])) {
+ $this->postChangeUpdate = \intval($_POST['postChangeUpdate']);
+ }
+ if (isset($_POST['postChangeDelete'])) {
+ $this->postChangeDelete = \intval($_POST['postChangeDelete']);
+ }
+
+ $this->threadModerationChangeTopic = $this->threadModerationClose = $this->threadModerationDisable = 0;
+ $this->threadModerationDone = $this->threadModerationEnable = $this->threadModerationMerge = $this->threadModerationMove = $this->threadModerationOpen = 0;
+ $this->threadModerationRestore = $this->threadModerationScrape = $this->threadModerationSetAsAnnouncement = $this->threadModerationSetLabel = 0;
+ $this->threadModerationSticky = $this->threadModerationTrash = $this->threadModerationUndone = $this->threadModerationAuthorOnly = 0;
+ if (isset($_POST['threadModerationAuthorOnly'])) {
+ $this->threadModerationAuthorOnly = \intval($_POST['threadModerationAuthorOnly']);
+ }
+ if (isset($_POST['threadModerationChangeTopic'])) {
+ $this->threadModerationChangeTopic = \intval($_POST['threadModerationChangeTopic']);
+ }
+ if (isset($_POST['threadModerationClose'])) {
+ $this->threadModerationClose = \intval($_POST['threadModerationClose']);
+ }
+ if (isset($_POST['threadModerationDisable'])) {
+ $this->threadModerationDisable = \intval($_POST['threadModerationDisable']);
+ }
+ if (isset($_POST['threadModerationDone'])) {
+ $this->threadModerationDone = \intval($_POST['threadModerationDone']);
+ }
+ if (isset($_POST['threadModerationEnable'])) {
+ $this->threadModerationEnable = \intval($_POST['threadModerationEnable']);
+ }
+ if (isset($_POST['threadModerationMerge'])) {
+ $this->threadModerationMerge = \intval($_POST['threadModerationMerge']);
+ }
+ if (isset($_POST['threadModerationMove'])) {
+ $this->threadModerationMove = \intval($_POST['threadModerationMove']);
+ }
+ if (isset($_POST['threadModerationOpen'])) {
+ $this->threadModerationOpen = \intval($_POST['threadModerationOpen']);
+ }
+ if (isset($_POST['threadModerationRestore'])) {
+ $this->threadModerationRestore = \intval($_POST['threadModerationRestore']);
+ }
+ if (isset($_POST['threadModerationScrape'])) {
+ $this->threadModerationScrape = \intval($_POST['threadModerationScrape']);
+ }
+ if (isset($_POST['threadModerationSetAsAnnouncement'])) {
+ $this->threadModerationSetAsAnnouncement = \intval($_POST['threadModerationSetAsAnnouncement']);
+ }
+ if (isset($_POST['threadModerationSetLabel'])) {
+ $this->threadModerationSetLabel = \intval($_POST['threadModerationSetLabel']);
+ }
+ if (isset($_POST['threadModerationSticky'])) {
+ $this->threadModerationSticky = \intval($_POST['threadModerationSticky']);
+ }
+ if (isset($_POST['threadModerationTrash'])) {
+ $this->threadModerationTrash = \intval($_POST['threadModerationTrash']);
+ }
+ if (isset($_POST['threadModerationUndone'])) {
+ $this->threadModerationUndone = \intval($_POST['threadModerationUndone']);
+ }
+ if (isset($_POST['threadModerationUnsetAsAnnouncement'])) {
+ $this->threadModerationUnsetAsAnnouncement = \intval($_POST['threadModerationUnsetAsAnnouncement']);
+ }
+
+ $this->threadModificationClose = $this->threadModificationDisable = 0;
+ $this->threadModificationDone = $this->threadModificationEnable = $this->threadModificationMove = $this->threadModificationOpen = 0;
+ $this->threadModificationRestore = $this->threadModificationScrape = $this->threadModificationSetLabel = 0;
+ $this->threadModificationSticky = $this->threadModificationTrash = $this->threadModificationUndone = $this->threadModificationUnannounce = $this->threadModificationAuthorOnly = 0;
+ if (isset($_POST['threadModificationAuthorOnly'])) {
+ $this->threadModificationAuthorOnly = \intval($_POST['threadModificationAuthorOnly']);
+ }
+ if (isset($_POST['threadModificationBoardID'])) {
+ $this->threadModificationBoardID = \intval($_POST['threadModificationBoardID']);
+ }
+ if (isset($_POST['threadModificationExecuter'])) {
+ $this->threadModificationExecuter = StringUtil::trim($_POST['threadModificationExecuter']);
+ }
+ if (isset($_POST['threadModificationExecuterID'])) {
+ $this->threadModificationExecuterID = \intval($_POST['threadModificationExecuterID']);
+ }
+ if (isset($_POST['threadModificationClose'])) {
+ $this->threadModificationClose = \intval($_POST['threadModificationClose']);
+ }
+ if (isset($_POST['threadModificationDisable'])) {
+ $this->threadModificationDisable = \intval($_POST['threadModificationDisable']);
+ }
+ if (isset($_POST['threadModificationDone'])) {
+ $this->threadModificationDone = \intval($_POST['threadModificationDone']);
+ }
+ if (isset($_POST['threadModificationEnable'])) {
+ $this->threadModificationEnable = \intval($_POST['threadModificationEnable']);
+ }
+ if (isset($_POST['threadModificationMove'])) {
+ $this->threadModificationMove = \intval($_POST['threadModificationMove']);
+ }
+ if (isset($_POST['threadModificationOpen'])) {
+ $this->threadModificationOpen = \intval($_POST['threadModificationOpen']);
+ }
+ if (isset($_POST['threadModificationRestore'])) {
+ $this->threadModificationRestore = \intval($_POST['threadModificationRestore']);
+ }
+ if (isset($_POST['threadModificationScrape'])) {
+ $this->threadModificationScrape = \intval($_POST['threadModificationScrape']);
+ }
+ if (isset($_POST['threadModificationSetLabel'])) {
+ $this->threadModificationSetLabel = \intval($_POST['threadModificationSetLabel']);
+ }
+ if (isset($_POST['threadModificationSticky'])) {
+ $this->threadModificationSticky = \intval($_POST['threadModificationSticky']);
+ }
+ if (isset($_POST['threadModificationTrash'])) {
+ $this->threadModificationTrash = \intval($_POST['threadModificationTrash']);
+ }
+ if (isset($_POST['threadModificationUndone'])) {
+ $this->threadModificationUndone = \intval($_POST['threadModificationUndone']);
+ }
+ if (isset($_POST['threadModificationUnannounce'])) {
+ $this->threadModificationUnannounce = \intval($_POST['threadModificationUnannounce']);
+ }
+
+ $this->postModerationClose = $this->postModerationDelete = $this->postModerationDisable = $this->postModerationEdit = 0;
+ $this->postModerationEnable = $this->postModerationMerge = $this->postModerationMove = $this->postModerationOpen = 0;
+ $this->postModerationRestore = $this->postModerationTrash = 0;
+ if (isset($_POST['postModerationClose'])) {
+ $this->postModerationClose = \intval($_POST['postModerationClose']);
+ }
+ if (isset($_POST['postModerationDelete'])) {
+ $this->postModerationDelete = \intval($_POST['postModerationDelete']);
+ }
+ if (isset($_POST['postModerationDisable'])) {
+ $this->postModerationDisable = \intval($_POST['postModerationDisable']);
+ }
+ if (isset($_POST['postModerationEdit'])) {
+ $this->postModerationEdit = \intval($_POST['postModerationEdit']);
+ }
+ if (isset($_POST['postModerationEnable'])) {
+ $this->postModerationEnable = \intval($_POST['postModerationEnable']);
+ }
+ if (isset($_POST['postModerationMerge'])) {
+ $this->postModerationMerge = \intval($_POST['postModerationMerge']);
+ }
+ if (isset($_POST['postModerationMove'])) {
+ $this->postModerationMove = \intval($_POST['postModerationMove']);
+ }
+ if (isset($_POST['postModerationOpen'])) {
+ $this->postModerationOpen = \intval($_POST['postModerationOpen']);
+ }
+ if (isset($_POST['postModerationRestore'])) {
+ $this->postModerationRestore = \intval($_POST['postModerationRestore']);
+ }
+ if (isset($_POST['postModerationTrash'])) {
+ $this->postModerationTrash = \intval($_POST['postModerationTrash']);
+ }
+
+ $this->wbbThreadModerationData = [
+ 'threadModerationAuthorOnly' => $this->threadModerationAuthorOnly,
+ 'threadModerationChangeTopic' => $this->threadModerationChangeTopic,
+ 'threadModerationClose' => $this->threadModerationClose,
+ 'threadModerationDisable' => $this->threadModerationDisable,
+ 'threadModerationDone' => $this->threadModerationDone,
+ 'threadModerationEnable' => $this->threadModerationEnable,
+ 'threadModerationMerge' => $this->threadModerationMerge,
+ 'threadModerationMove' => $this->threadModerationMove,
+ 'threadModerationOpen' => $this->threadModerationOpen,
+ 'threadModerationRestore' => $this->threadModerationRestore,
+ 'threadModerationScrape' => $this->threadModerationScrape,
+ 'threadModerationSetAsAnnouncement' => $this->threadModerationSetAsAnnouncement,
+ 'threadModerationSetLabel' => $this->threadModerationSetLabel,
+ 'threadModerationSticky' => $this->threadModerationSticky,
+ 'threadModerationTrash' => $this->threadModerationTrash,
+ 'threadModerationUndone' => $this->threadModerationUndone,
+ 'threadModerationUnsetAsAnnouncement' => $this->threadModerationUnsetAsAnnouncement,
+ ];
+
+ $this->wbbThreadModificationData = [
+ 'threadModificationAuthorOnly' => $this->threadModificationAuthorOnly,
+ 'threadModificationBoardID' => $this->threadModificationBoardID,
+ 'threadModificationExecuter' => $this->threadModificationExecuter,
+ 'threadModificationExecuterID' => $this->threadModificationExecuterID,
+ 'threadModificationClose' => $this->threadModificationClose,
+ 'threadModificationDisable' => $this->threadModificationDisable,
+ 'threadModificationDone' => $this->threadModificationDone,
+ 'threadModificationEnable' => $this->threadModificationEnable,
+ 'threadModificationMove' => $this->threadModificationMove,
+ 'threadModificationOpen' => $this->threadModificationOpen,
+ 'threadModificationRestore' => $this->threadModificationRestore,
+ 'threadModificationScrape' => $this->threadModificationScrape,
+ 'threadModificationSetLabel' => $this->threadModificationSetLabel,
+ 'threadModificationSticky' => $this->threadModificationSticky,
+ 'threadModificationTrash' => $this->threadModificationTrash,
+ 'threadModificationUndone' => $this->threadModificationUndone,
+ 'threadModificationUnannounce' => $this->threadModificationUnannounce,
+ ];
+
+ $this->wbbPostModerationData = [
+ 'postModerationClose' => $this->postModerationClose,
+ 'postModerationDelete' => $this->postModerationDelete,
+ 'postModerationDisable' => $this->postModerationDisable,
+ 'postModerationEdit' => $this->postModerationEdit,
+ 'postModerationEnable' => $this->postModerationEnable,
+ 'postModerationMerge' => $this->postModerationMerge,
+ 'postModerationMove' => $this->postModerationMove,
+ 'postModerationOpen' => $this->postModerationOpen,
+ 'postModerationRestore' => $this->postModerationRestore,
+ 'postModerationTrash' => $this->postModerationTrash,
+ ];
+
+ // read conditions
+ $this->wbbConditions = UzbotWbbConditionHandler::getInstance()->getGroupedObjectTypes();
+ foreach ($this->wbbConditions as $conditions) {
+ foreach ($conditions as $condition) {
+ $condition->getProcessor()->readFormParameters();
+ }
+ }
+ }
+
+ /**
+ * Handles the validate event.
+ */
+ protected function validate()
+ {
+ // Get type / notify data
+ $type = UzbotType::getTypeByID($this->eventObj->typeID);
+ $notify = UzbotNotify::getNotifyByID($this->eventObj->notifyID);
+
+ // threadNotifyBoardID
+ if ($notify->notifyTitle == 'thread') {
+ if ($this->threadNotifyBoardID == 0) {
+ throw new UserInputException('threadNotifyBoardID', 'notConfigured');
+ }
+ $board = BoardCache::getInstance()->getBoard($this->threadNotifyBoardID);
+ if (!$board->boardID) {
+ throw new UserInputException('threadNotifyBoardID', 'notValid');
+ }
+ if (!$board->isBoard()) {
+ throw new UserInputException('threadNotifyBoardID', 'notValid');
+ }
+ }
+
+ // postNotifyThreadID
+ if ($notify->notifyTitle == 'post') {
+ // threadID may be 0 with certain bots
+ $allowed = ['wbb_postModeration', 'wbb_threadModification', 'wbb_threadModeration', 'wbb_threadNew', 'wbb_postCount', 'wbb_postChange', 'wbb_bestAnswer'];
+ if (!$this->postNotifyThreadID) {
+ if (!\in_array($type->typeTitle, $allowed)) {
+ throw new UserInputException('postNotifyThreadID', 'notValid');
+ }
+ } else {
+ $thread = new Thread($this->postNotifyThreadID);
+ if (!$thread->threadID) {
+ throw new UserInputException('postNotifyThreadID', 'notValid');
+ }
+ }
+ }
+
+ // need notify?
+ if ($type->needNotify && !$notify->notifyID) {
+ throw new UserInputException('notifyID', 'missing');
+ }
+
+ // need count for trigger values
+ if ($type->needCount && $type->typeTitle == 'wbb_postCount') {
+ if ($this->postCountAction == 'postTotal' || $this->postCountAction == 'postX') {
+ $counts = ArrayUtil::trim(\explode(',', $this->eventObj->userCount));
+ $counts = ArrayUtil::toIntegerArray($counts);
+
+ if (!\count($counts)) {
+ throw new UserInputException('userCount', 'empty');
+ }
+ }
+ }
+
+ // thread new - wbb_threadNew
+ if ($type->typeTitle == 'wbb_threadNew') {
+ // board(s) must be selected
+ if (!\count($this->threadNewBoardIDs)) {
+ throw new UserInputException('threadNewBoardIDs', 'notConfigured');
+ }
+ // no thread notification in monitored boards on threadNew
+ if ($notify->notifyTitle == 'thread') {
+ if (\in_array($this->threadNotifyBoardID, $this->threadNewBoardIDs)) {
+ throw new UserInputException('threadNotifyBoardID', 'notAllowedOnThreadNew');
+ }
+ }
+ }
+
+ // action needing boardIDs
+ $actions = ['wbb_postModeration', 'wbb_threadModeration', 'wbb_postChange', 'wbb_topPoster', 'wbb_bestAnswer'];
+ if (\in_array($type->typeTitle, $actions)) {
+ // board(s) must be selected
+ if (!\count($this->uzbotBoardIDs)) {
+ throw new UserInputException('uzbotBoardIDs', 'notConfigured');
+ }
+ }
+
+ // wbb_threadModeration
+ if ($type->typeTitle == 'wbb_threadModeration') {
+ if (\array_sum($this->wbbThreadModerationData) - $this->wbbThreadModerationData['threadModerationAuthorOnly'] == 0) {
+ throw new UserInputException('threadModerationAction', 'notConfigured');
+ }
+ }
+
+ // wbb_threadModification
+ if ($type->typeTitle == 'wbb_threadModification') {
+ // unset change labels if no labels
+ if (empty($this->eventObj->labelGroups) || empty($this->eventObj->availableLabels)) {
+ $this->wbbThreadModificationData['threadModificationSetLabel'] = 0;
+ $this->threadModificationSetLabel = 0;
+ }
+
+ if (\array_sum($this->wbbThreadModificationData) - $this->wbbThreadModificationData['threadModificationAuthorOnly'] == 0) {
+ throw new UserInputException('threadModificationAction', 'notConfigured');
+ }
+
+ // if move, board must be selected and must exist
+ if ($this->threadModificationMove) {
+ $board = BoardCache::getInstance()->getBoard($this->threadModificationBoardID);
+ if (!$board || !$board->isBoard()) {
+ throw new UserInputException('threadModificationBoardID', 'notValid');
+ }
+ }
+
+ // executer must exist
+ if (empty($this->threadModificationExecuter)) {
+ throw new UserInputException('threadModificationExecuter');
+ }
+ $user = User::getUserByUsername($this->threadModificationExecuter);
+ if (!$user->userID) {
+ throw new UserInputException('threadModificationExecuter', 'invalid');
+ }
+ $this->threadModificationExecuterID = $user->userID;
+ $this->wbbThreadModificationData['threadModificationExecuterID'] = $user->userID;
+ }
+
+ // wbb_postModeration
+ if ($type->typeTitle == 'wbb_postModeration') {
+ if (!\array_sum($this->wbbPostModerationData)) {
+ throw new UserInputException('postModerationAction', 'notConfigured');
+ }
+ }
+
+ // wbb_postChange
+ if ($type->typeTitle == 'wbb_postChange') {
+ if (!$this->postChangeUpdate && !$this->postChangeDelete) {
+ throw new UserInputException('postChangeAction', 'notConfigured');
+ }
+ }
+ }
+
+ /**
+ * Handles the save event.
+ */
+ protected function save()
+ {
+ // wbbThreadNotifyData
+ $wbbThreadData = [
+ 'threadNotifyBoardID' => $this->threadNotifyBoardID,
+ 'threadNotifyDelayed' => $this->threadNotifyDelayed,
+ 'threadNotifyIsClosed' => $this->threadNotifyIsClosed,
+ 'threadNotifyIsDisabled' => $this->threadNotifyIsDisabled,
+ 'threadNotifyIsDone' => $this->threadNotifyIsDone,
+ 'threadNotifyIsSticky' => $this->threadNotifyIsSticky,
+ ];
+
+ $wbbPostData = [
+ 'postNotifyThreadID' => $this->postNotifyThreadID,
+ 'postNotifyIsClosed' => $this->postNotifyIsClosed,
+ 'postNotifyIsDisabled' => $this->postNotifyIsDisabled,
+ ];
+
+ $this->eventObj->additionalFields = \array_merge($this->eventObj->additionalFields, [
+ 'wbbThreadData' => \serialize($wbbThreadData),
+ 'wbbPostData' => \serialize($wbbPostData),
+ 'wbbPostModerationData' => \serialize($this->wbbPostModerationData),
+ 'wbbThreadModerationData' => \serialize($this->wbbThreadModerationData),
+ 'wbbThreadModificationData' => \serialize($this->wbbThreadModificationData),
+ 'postCountAction' => $this->postCountAction,
+ 'topPosterCount' => $this->topPosterCount,
+ 'topPosterInterval' => $this->topPosterInterval,
+ 'topPosterNext' => 0,
+ 'threadNewBoardIDs' => \serialize($this->threadNewBoardIDs),
+ 'uzbotBoardIDs' => \serialize($this->uzbotBoardIDs),
+ 'postIsOfficial' => $this->postIsOfficial,
+ 'threadIsOfficial' => $this->threadIsOfficial,
+ 'postChangeUpdate' => $this->postChangeUpdate,
+ 'postChangeDelete' => $this->postChangeDelete,
+ ]);
+ }
+
+ /**
+ * Handles the saved event.
+ */
+ protected function saved()
+ {
+ // transform conditions array into one-dimensional array and save
+ $conditions = [];
+ foreach ($this->wbbConditions as $groupedObjectTypes) {
+ $conditions = \array_merge($conditions, $groupedObjectTypes);
+ }
+
+ $oldConditions = ConditionHandler::getInstance()->getConditions('com.uz.wcf.bot.condition.wbb', $this->eventObj->botID);
+ ConditionHandler::getInstance()->updateConditions($this->eventObj->botID, $oldConditions, $conditions);
+ }
}
diff --git a/files/lib/system/event/listener/UzbotPostActionListener.class.php b/files/lib/system/event/listener/UzbotPostActionListener.class.php
index 99e8237..e57283e 100644
--- a/files/lib/system/event/listener/UzbotPostActionListener.class.php
+++ b/files/lib/system/event/listener/UzbotPostActionListener.class.php
@@ -1,5 +1,27 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotPostActionListener implements IParameterizedEventListener {
-
- /**
- * @inheritDoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- if (!MODULE_UZBOT) return;
-
- $action = $eventObj->getActionName();
-
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- // on new posts get user post count, top poster and total post count
- if ($action == 'triggerPublication') {
- // Read all active, valid bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postCount']);
- if (!count($bots)) return;
-
- // get posts
- $posts = $eventObj->getObjects();
- if (!count($posts)) return;
-
- foreach ($posts as $editor) {
- $post = $editor->getDecoratedObject();
-
- // check later, whether post is counted
- $thread = $post->getThread();
- if (!$thread->threadID) return;
- $board = $thread->getBoard();
- if (!$board->boardID) return;
-
- // top poster
- $top = new UzbotTop(1);
- $topUser = new User($top->post);
-
- // total post count
- $sql = "SELECT COUNT(*) AS count
- FROM wbb".WCF_N."_post
- WHERE isDeleted = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([0]);
- $countTotal = $statement->fetchColumn();
-
- $user = new User($post->userID);
-
- foreach ($bots as $bot) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
- $count = 1;
-
- // only users if not postTop
- if ($bot->postCountAction != 'postTotal' && !$user->userID) {
- continue;
- }
-
- // user condition relevant on postX only
- if ($bot->postCountAction == 'postX') {
- $conditions = $bot->getUserConditions();
-
- if (count($conditions)) {
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID = ?', [$user->userID]);
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- if (!count($userList->getObjects())) {
- continue;
- }
- }
- }
-
- // only on count match or new top poster
- $counts = explode(',', $bot->userCount);
- $hit = false;
-
- switch ($bot->postCountAction) {
- case 'postTotal':
- if (in_array($countTotal, $counts)) $hit = true;
- break;
-
- case 'postX':
- if ($board->countUserPosts) {
- if (in_array($user->wbbPosts, $counts)) {
- $hit = true;
- }
- }
- break;
-
- case 'postTop':
- if ($board->countUserPosts) {
- if ($user->wbbPosts > $topUser->wbbPosts && $user->userID != $topUser->userID) {
- $hit = true;
- if (!$bot->testMode) {
- $editor = new UzbotTopEditor($top);
- $editor->update(['post' => $user->userID]);
- }
- }
- }
- break;
- }
-
- if ($hit) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
-
- if ($user->userID) {
- $affectedUserIDs[] = $user->userID;
- $countToUserID[$user->userID] = $user->wbbPosts;
- }
-
- // post, thread etc. data
- // $thread = $post->getThread(); $board = $thread->getBoard(); see above
- $quote = $this->getQuote($post);
-
- // set placeholders
- $placeholders['board-id'] = $board->boardID;
- $placeholders['board-name'] = $board->title;
- $placeholders['count'] = $countTotal;
- $placeholders['count-user'] = $user->userID ? $user->wbbPosts : 0;
- $placeholders['post-id'] = $post->postID;
- $placeholders['post-link'] = $post->getLink();
- $placeholders['post-subject'] = $post->getTitle();
- $placeholders['post-text'] = $post->getMessage();
- $placeholders['quote'] = $quote;
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- $placeholders['translate'] = ['board-name'];
-
- // add guest placeholders
- if (!$user->userID) {
- $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
- $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
- $placeholders['user-age'] = 'x';
- $placeholders['user-id'] = 0;
-
- $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
- }
-
- // save threadID for post in affected thread
- $bot->threadID = $thread->threadID;
-
- // log action
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => 1,
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
-
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => 1,
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
- }
- }
-
- // post change by user himself
- if ($action == 'update' || $action == 'trash') {
- // Read all active, valid bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postChange']);
- if (!count($bots)) return;
-
- // get posts / data
- $posts = $eventObj->getObjects();
- if (!count($posts)) return;
-
- $params = $eventObj->getParameters();
-
- foreach ($posts as $editor) {
- $post = $editor->getDecoratedObject();
-
- if ($post->userID && WCF::getUser()->userID == $post->userID) {
- //preset data
- $user = WCF::getUser();
- $thread = $post->getThread();
-
- // get reason
- $reason = '';
- if (isset($params['reason'])) {
- $reason = $params['reason'];
- }
- elseif (isset($params['data']['editReason'])) {
- $reason = $params['data']['editReason'];
- }
-
- foreach ($bots as $bot) {
- // check type of change
- if ($action == 'update' && !$bot->postChangeUpdate) continue;
- if ($action == 'trash' && !$bot->postChangeDelete) continue;
-
- $affectedUserIDs = $countToUserID = $placeholders = [];
- $count = 1;
-
- // must be in monitored boards
- if (!in_array($thread->boardID, unserialize($bot->uzbotBoardIDs))) continue;
-
- $conditions = $bot->getUserConditions();
- if (count($conditions)) {
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID = ?', [$user->userID]);
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- if (!count($userList->getObjects())) continue;
- }
-
- // found one
- $affectedUserIDs[] = $user->userID;
- $countToUserID[$user->userID] = $user->wbbPosts;
-
- // post, thread and etc. data
- $thread = $post->getThread();
- $board = $thread->getBoard();
- $quote = $this->getQuote($post);
-
- // set placeholders
- $placeholders['action'] = $action == 'update' ? 'wcf.acp.uzbot.wbb.action.changed' : 'wcf.acp.uzbot.wbb.action.deleted';
- $placeholders['board-id'] = $board->boardID;
- $placeholders['board-name'] = $board->title;
- $placeholders['count'] = 1;
- $placeholders['count-user'] = 1;
- $placeholders['post-id'] = $post->postID;
- $placeholders['post-link'] = $post->getLink();
- $placeholders['post-subject'] = $post->getTitle();
- $placeholders['post-text'] = $post->getMessage();
- $placeholders['quote'] = $quote;
- $placeholders['reason'] = $reason;
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- $placeholders['translate'] = ['board-name', 'action'];
-
- // save threadID for post in affected thread
- $bot->threadID = $thread->threadID;
-
- // log action
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => 1,
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => 1,
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
- }
- }
- }
-
- /**
- * Create qoute from post / thread
- */
- protected function getQuote($post) {
- $quoteID = MessageQuoteManager::getInstance()->addQuote(
- 'com.woltlab.wbb.post',
- $post->threadID,
- $post->postID,
- $post->getExcerpt(),
- $post->getMessage()
- );
-
- if ($quoteID === false) {
- $removeQuoteID = MessageQuoteManager::getInstance()->getQuoteID(
- 'com.woltlab.wbb.post',
- $post->postID,
- $post->getExcerpt(),
- $post->getMessage()
- );
- MessageQuoteManager::getInstance()->removeQuote($removeQuoteID);
- }
-
- $returnValues = [
- 'count' => MessageQuoteManager::getInstance()->countQuotes(),
- 'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(['com.woltlab.wbb.post'])
- ];
- if ($quoteID) {
- $returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
-
- $username = str_replace(["\\", "'"], ["\\\\", "\'"], $returnValues['renderedQuote']['username']);
- $link = str_replace(["\\", "'"], ["\\\\", "\'"], $returnValues['renderedQuote']['link']);
- $message = $returnValues['renderedQuote']['text'];
-
- // build quote and replace
- $quote = '';
- $quote .= $message;
- $quote .= ' ';
- }
- else $quote = '';
-
- return $quote;
- }
+class UzbotPostActionListener implements IParameterizedEventListener
+{
+ /**
+ * @inheritDoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ $action = $eventObj->getActionName();
+
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ // on new posts get user post count, top poster and total post count
+ if ($action == 'triggerPublication') {
+ // Read all active, valid bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postCount']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ // get posts
+ $posts = $eventObj->getObjects();
+ if (!\count($posts)) {
+ return;
+ }
+
+ foreach ($posts as $editor) {
+ $post = $editor->getDecoratedObject();
+
+ // check later, whether post is counted
+ $thread = $post->getThread();
+ if (!$thread->threadID) {
+ return;
+ }
+ $board = $thread->getBoard();
+ if (!$board->boardID) {
+ return;
+ }
+
+ // top poster
+ $top = new UzbotTop(1);
+ $topUser = new User($top->post);
+
+ // total post count
+ $sql = "SELECT COUNT(*) AS count
+ FROM wbb" . WCF_N . "_post
+ WHERE isDeleted = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([0]);
+ $countTotal = $statement->fetchColumn();
+
+ $user = new User($post->userID);
+
+ foreach ($bots as $bot) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+ $count = 1;
+
+ // only users if not postTop
+ if ($bot->postCountAction != 'postTotal' && !$user->userID) {
+ continue;
+ }
+
+ // user condition relevant on postX only
+ if ($bot->postCountAction == 'postX') {
+ $conditions = $bot->getUserConditions();
+
+ if (\count($conditions)) {
+ $userList = new UserList();
+ $userList->getConditionBuilder()->add('user_table.userID = ?', [$user->userID]);
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ if (!\count($userList->getObjects())) {
+ continue;
+ }
+ }
+ }
+
+ // only on count match or new top poster
+ $counts = \explode(',', $bot->userCount);
+ $hit = false;
+
+ switch ($bot->postCountAction) {
+ case 'postTotal':
+ if (\in_array($countTotal, $counts)) {
+ $hit = true;
+ }
+ break;
+
+ case 'postX':
+ if ($board->countUserPosts) {
+ if (\in_array($user->wbbPosts, $counts)) {
+ $hit = true;
+ }
+ }
+ break;
+
+ case 'postTop':
+ if ($board->countUserPosts) {
+ if ($user->wbbPosts > $topUser->wbbPosts && $user->userID != $topUser->userID) {
+ $hit = true;
+ if (!$bot->testMode) {
+ $editor = new UzbotTopEditor($top);
+ $editor->update(['post' => $user->userID]);
+ }
+ }
+ }
+ break;
+ }
+
+ if ($hit) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+
+ if ($user->userID) {
+ $affectedUserIDs[] = $user->userID;
+ $countToUserID[$user->userID] = $user->wbbPosts;
+ }
+
+ // post, thread etc. data
+ // $thread = $post->getThread(); $board = $thread->getBoard(); see above
+ $quote = $this->getQuote($post);
+
+ // set placeholders
+ $placeholders['board-id'] = $board->boardID;
+ $placeholders['board-name'] = $board->title;
+ $placeholders['count'] = $countTotal;
+ $placeholders['count-user'] = $user->userID ? $user->wbbPosts : 0;
+ $placeholders['post-id'] = $post->postID;
+ $placeholders['post-link'] = $post->getLink();
+ $placeholders['post-subject'] = $post->getTitle();
+ $placeholders['post-text'] = $post->getMessage();
+ $placeholders['quote'] = $quote;
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ $placeholders['translate'] = ['board-name'];
+
+ // add guest placeholders
+ if (!$user->userID) {
+ $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
+ $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
+ $placeholders['user-age'] = 'x';
+ $placeholders['user-id'] = 0;
+
+ $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
+ }
+
+ // save threadID for post in affected thread
+ $bot->threadID = $thread->threadID;
+
+ // log action
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => 1,
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ }
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => 1,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ }
+ }
+
+ // post change by user himself
+ if ($action == 'update' || $action == 'trash') {
+ // Read all active, valid bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postChange']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ // get posts / data
+ $posts = $eventObj->getObjects();
+ if (!\count($posts)) {
+ return;
+ }
+
+ $params = $eventObj->getParameters();
+
+ foreach ($posts as $editor) {
+ $post = $editor->getDecoratedObject();
+
+ if ($post->userID && WCF::getUser()->userID == $post->userID) {
+ //preset data
+ $user = WCF::getUser();
+ $thread = $post->getThread();
+
+ // get reason
+ $reason = '';
+ if (isset($params['reason'])) {
+ $reason = $params['reason'];
+ } elseif (isset($params['data']['editReason'])) {
+ $reason = $params['data']['editReason'];
+ }
+
+ foreach ($bots as $bot) {
+ // check type of change
+ if ($action == 'update' && !$bot->postChangeUpdate) {
+ continue;
+ }
+ if ($action == 'trash' && !$bot->postChangeDelete) {
+ continue;
+ }
+
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+ $count = 1;
+
+ // must be in monitored boards
+ if (!\in_array($thread->boardID, \unserialize($bot->uzbotBoardIDs))) {
+ continue;
+ }
+
+ $conditions = $bot->getUserConditions();
+ if (\count($conditions)) {
+ $userList = new UserList();
+ $userList->getConditionBuilder()->add('user_table.userID = ?', [$user->userID]);
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ if (!\count($userList->getObjects())) {
+ continue;
+ }
+ }
+
+ // found one
+ $affectedUserIDs[] = $user->userID;
+ $countToUserID[$user->userID] = $user->wbbPosts;
+
+ // post, thread and etc. data
+ $thread = $post->getThread();
+ $board = $thread->getBoard();
+ $quote = $this->getQuote($post);
+
+ // set placeholders
+ $placeholders['action'] = $action == 'update' ? 'wcf.acp.uzbot.wbb.action.changed' : 'wcf.acp.uzbot.wbb.action.deleted';
+ $placeholders['board-id'] = $board->boardID;
+ $placeholders['board-name'] = $board->title;
+ $placeholders['count'] = 1;
+ $placeholders['count-user'] = 1;
+ $placeholders['post-id'] = $post->postID;
+ $placeholders['post-link'] = $post->getLink();
+ $placeholders['post-subject'] = $post->getTitle();
+ $placeholders['post-text'] = $post->getMessage();
+ $placeholders['quote'] = $quote;
+ $placeholders['reason'] = $reason;
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ $placeholders['translate'] = ['board-name', 'action'];
+
+ // save threadID for post in affected thread
+ $bot->threadID = $thread->threadID;
+
+ // log action
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => 1,
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => 1,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create qoute from post / thread
+ */
+ protected function getQuote($post)
+ {
+ $quoteID = MessageQuoteManager::getInstance()->addQuote(
+ 'com.woltlab.wbb.post',
+ $post->threadID,
+ $post->postID,
+ $post->getExcerpt(),
+ $post->getMessage()
+ );
+
+ if ($quoteID === false) {
+ $removeQuoteID = MessageQuoteManager::getInstance()->getQuoteID(
+ 'com.woltlab.wbb.post',
+ $post->postID,
+ $post->getExcerpt(),
+ $post->getMessage()
+ );
+ MessageQuoteManager::getInstance()->removeQuote($removeQuoteID);
+ }
+
+ $returnValues = [
+ 'count' => MessageQuoteManager::getInstance()->countQuotes(),
+ 'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(['com.woltlab.wbb.post']),
+ ];
+ if ($quoteID) {
+ $returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
+
+ $username = \str_replace(["\\", "'"], ["\\\\", "\\'"], $returnValues['renderedQuote']['username']);
+ $link = \str_replace(["\\", "'"], ["\\\\", "\\'"], $returnValues['renderedQuote']['link']);
+ $message = $returnValues['renderedQuote']['text'];
+
+ // build quote and replace
+ $quote = '';
+ $quote .= $message;
+ $quote .= ' ';
+ } else {
+ $quote = '';
+ }
+
+ return $quote;
+ }
}
diff --git a/files/lib/system/event/listener/UzbotPostModerationListener.class.php b/files/lib/system/event/listener/UzbotPostModerationListener.class.php
index 0147d36..1c94ecb 100644
--- a/files/lib/system/event/listener/UzbotPostModerationListener.class.php
+++ b/files/lib/system/event/listener/UzbotPostModerationListener.class.php
@@ -1,5 +1,27 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotPostModerationListener implements IParameterizedEventListener {
- /**
- * @inheritDoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- // check module
- if (!MODULE_UZBOT) return;
-
- // only action create and user
- if ($eventObj->getActionName() != 'create') return;
- if (!WCF::getUser()->userID) return;
-
- // only post modification
- $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.modifiableContent', 'com.woltlab.wbb.post');
- $params = $eventObj->getParameters();
- if ($params['data']['objectTypeID'] != $objectTypeID) return;
-
- // only if bots
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postModeration']);
- if (!count($bots)) return;
-
- // preset data
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
- $postID = $params['data']['objectID'];
- $threadID = $params['data']['parentObjectID'];
-
- $action = $params['data']['action'];
- $moderatorID = $params['data']['userID'];
- $additional = [];
- if (isset($params['data']['additionalData'])) $additional = unserialize($params['data']['additionalData']);
-
- // allow 'delete'
- $validActions = ['close', 'delete', 'disable', 'edit', 'enable', 'merge', 'move', 'open', 'restore', 'trash'];
- if (!in_array($action, $validActions)) return;
-
- // only moderation
- $post = new Post($postID); // may be null (delete)
- $thread = new Thread($threadID);
-
- if ($post && $post->userID == $moderatorID) return;
-
- // Step through bots
- foreach ($bots as $bot) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
- $count = 0;
-
- // check action
- if (!stripos($bot->wbbPostModerationData, $action)) continue; // 0/false doesn't matter
-
- // check board
- if (!in_array($thread->boardID, unserialize($bot->uzbotBoardIDs))) continue;
-
- // check action
- $moderations = unserialize($bot->wbbPostModerationData);
- $act = 0;
- foreach ($moderations as $key => $value) {
- if (0 == strcasecmp($key, 'postModeration'.$action) && $value == 1) {
- $act = 1;
- break;
- }
- }
-
- if (!$act) continue;
-
- // get affected users
- if ($bot->changeAffected) {
- $affectedUserIDs[] = $moderatorID;
- $countToUserID[$moderatorID] = 1;
- $count = 1;
- }
- else {
- if ($action != 'delete') {
- $affectedUserIDs[] = $post->userID;
- $countToUserID[$post->userID] = 1;
- $count = 1;
- }
- else {
- // leave if no user
- if (isset($additional['username'])) {
- $user = User::getUserByUsername($additional['username']);
- if (!$user->userID) continue;
-
- $affectedUserIDs[] = $user->userID;
- $countToUserID[$user->userID] = 1;
- $count = 1;
- }
- else continue;
- }
- }
-
- // check users
- $conditions = $bot->getUserConditions();
- if (count($conditions)) {
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$affectedUserIDs]);
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- if (!count($userList->getObjects())) continue;
- }
-
- // found users, board and a valid action, get data
- // log action
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => $count,
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- $bot->threadID = $thread->threadID;
- $board = $thread->getBoard();
- $moderator = WCF::getUser();
-
- $placeholders['board-id'] = $thread->boardID;
- $placeholders['board-name'] = $thread->getBoard()->title;
- $placeholders['count'] = count($affectedUserIDs);
-
- $placeholders['moderation-action'] = 'wcf.uzbot.wbb.moderation.post.' . $action;
- $placeholders['moderation-reason'] = '';
- if (isset($additional['reason'])) $placeholders['moderation-reason'] = $additional['reason'];
- $placeholders['moderator-id'] = $moderator->userID;
- $placeholders['moderator-link'] = $moderator->getLink();
- $placeholders['moderator-link2'] = StringUtil::getAnchorTag($moderator->getLink(), $moderator->username);
- $placeholders['moderator-name'] = $moderator->username;
-
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- if ($action != 'delete') {
- $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
- }
- else {
- // cancel placeholder. Might be only post; cached.
- $placeholders['thread-text'] = 'thread-text';
- }
- $placeholders['translate'] = ['board-name', 'moderation-action'];
-
- if ($action != 'delete') {
- $placeholders['post-link'] = $post->getLink();
- $placeholders['post-subject'] = $post->getTitle();
- $placeholders['post-text'] = $post->getMessage();
- }
- else {
- $placeholders['post-link'] = $placeholders['post-subject'] = $placeholders['post-text'] = 'wcf.uzbot.wbb.moderation.post.deleted';
- $placeholders['translate'][] = 'post-link';
- $placeholders['translate'][] = 'post-subject';
- $placeholders['translate'][] = 'post-text';
- }
-
- // test mode
- $testUserIDs = $testToUserIDs = [];
- $testUserIDs[] = $affectedUserIDs[0];
- $testToUserIDs[$affectedUserIDs[0]] = $countToUserID[$affectedUserIDs[0]];
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
+class UzbotPostModerationListener implements IParameterizedEventListener
+{
+ /**
+ * @inheritDoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ // check module
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // only action create and user
+ if ($eventObj->getActionName() != 'create') {
+ return;
+ }
+ if (!WCF::getUser()->userID) {
+ return;
+ }
+
+ // only post modification
+ $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.modifiableContent', 'com.woltlab.wbb.post');
+ $params = $eventObj->getParameters();
+ if ($params['data']['objectTypeID'] != $objectTypeID) {
+ return;
+ }
+
+ // only if bots
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_postModeration']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ // preset data
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+ $postID = $params['data']['objectID'];
+ $threadID = $params['data']['parentObjectID'];
+
+ $action = $params['data']['action'];
+ $moderatorID = $params['data']['userID'];
+ $additional = [];
+ if (isset($params['data']['additionalData'])) {
+ $additional = \unserialize($params['data']['additionalData']);
+ }
+
+ // allow 'delete'
+ $validActions = ['close', 'delete', 'disable', 'edit', 'enable', 'merge', 'move', 'open', 'restore', 'trash'];
+ if (!\in_array($action, $validActions)) {
+ return;
+ }
+
+ // only moderation
+ $post = new Post($postID); // may be null (delete)
+ $thread = new Thread($threadID);
+
+ if ($post && $post->userID == $moderatorID) {
+ return;
+ }
+
+ // Step through bots
+ foreach ($bots as $bot) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+ $count = 0;
+
+ // check action
+ if (!\stripos($bot->wbbPostModerationData, $action)) {
+ continue;
+ } // 0/false doesn't matter
+
+ // check board
+ if (!\in_array($thread->boardID, \unserialize($bot->uzbotBoardIDs))) {
+ continue;
+ }
+
+ // check action
+ $moderations = \unserialize($bot->wbbPostModerationData);
+ $act = 0;
+ foreach ($moderations as $key => $value) {
+ if (0 == \strcasecmp($key, 'postModeration' . $action) && $value == 1) {
+ $act = 1;
+ break;
+ }
+ }
+
+ if (!$act) {
+ continue;
+ }
+
+ // get affected users
+ if ($bot->changeAffected) {
+ $affectedUserIDs[] = $moderatorID;
+ $countToUserID[$moderatorID] = 1;
+ $count = 1;
+ } else {
+ if ($action != 'delete') {
+ $affectedUserIDs[] = $post->userID;
+ $countToUserID[$post->userID] = 1;
+ $count = 1;
+ } else {
+ // leave if no user
+ if (isset($additional['username'])) {
+ $user = User::getUserByUsername($additional['username']);
+ if (!$user->userID) {
+ continue;
+ }
+
+ $affectedUserIDs[] = $user->userID;
+ $countToUserID[$user->userID] = 1;
+ $count = 1;
+ } else {
+ continue;
+ }
+ }
+ }
+
+ // check users
+ $conditions = $bot->getUserConditions();
+ if (\count($conditions)) {
+ $userList = new UserList();
+ $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$affectedUserIDs]);
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ if (!\count($userList->getObjects())) {
+ continue;
+ }
+ }
+
+ // found users, board and a valid action, get data
+ // log action
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => $count,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ $bot->threadID = $thread->threadID;
+ $board = $thread->getBoard();
+ $moderator = WCF::getUser();
+
+ $placeholders['board-id'] = $thread->boardID;
+ $placeholders['board-name'] = $thread->getBoard()->title;
+ $placeholders['count'] = \count($affectedUserIDs);
+
+ $placeholders['moderation-action'] = 'wcf.uzbot.wbb.moderation.post.' . $action;
+ $placeholders['moderation-reason'] = '';
+ if (isset($additional['reason'])) {
+ $placeholders['moderation-reason'] = $additional['reason'];
+ }
+ $placeholders['moderator-id'] = $moderator->userID;
+ $placeholders['moderator-link'] = $moderator->getLink();
+ $placeholders['moderator-link2'] = StringUtil::getAnchorTag($moderator->getLink(), $moderator->username);
+ $placeholders['moderator-name'] = $moderator->username;
+
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ if ($action != 'delete') {
+ $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
+ } else {
+ // cancel placeholder. Might be only post; cached.
+ $placeholders['thread-text'] = 'thread-text';
+ }
+ $placeholders['translate'] = ['board-name', 'moderation-action'];
+
+ if ($action != 'delete') {
+ $placeholders['post-link'] = $post->getLink();
+ $placeholders['post-subject'] = $post->getTitle();
+ $placeholders['post-text'] = $post->getMessage();
+ } else {
+ $placeholders['post-link'] = $placeholders['post-subject'] = $placeholders['post-text'] = 'wcf.uzbot.wbb.moderation.post.deleted';
+ $placeholders['translate'][] = 'post-link';
+ $placeholders['translate'][] = 'post-subject';
+ $placeholders['translate'][] = 'post-text';
+ }
+
+ // test mode
+ $testUserIDs = $testToUserIDs = [];
+ $testUserIDs[] = $affectedUserIDs[0];
+ $testToUserIDs[$affectedUserIDs[0]] = $countToUserID[$affectedUserIDs[0]];
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
}
diff --git a/files/lib/system/event/listener/UzbotThreadActionListener.class.php b/files/lib/system/event/listener/UzbotThreadActionListener.class.php
index 89280a6..f78e1c3 100644
--- a/files/lib/system/event/listener/UzbotThreadActionListener.class.php
+++ b/files/lib/system/event/listener/UzbotThreadActionListener.class.php
@@ -1,5 +1,27 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotThreadActionListener implements IParameterizedEventListener {
- /**
- * @inheritdoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- // check module
- if (!MODULE_UZBOT) return;
-
- $action = $eventObj->getActionName();
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
-
- // Thread publication
- if ($action == 'triggerPublication') {
- // Read all active, valid bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_threadNew']);
- if (!count($bots)) return;
-
- // get threads
- $threads = $eventObj->getObjects();
- if (!count($threads)) return;
-
- foreach ($threads as $editor) {
- $thread = $editor->getDecoratedObject();
-
- // not if created by bot
- if ($thread->isUzbot) continue;
-
- foreach ($bots as $bot) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
- $count = 1;
-
- //monitored boards
- if (!in_array($thread->boardID, unserialize($bot->threadNewBoardIDs))) continue;
-
- // user conditions
- $conditions = $bot->getUserConditions();
- if (count($conditions)) {
- if (!$thread->userID) {
- continue;
- }
- else {
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID = ?', [$thread->userID]);
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- if (!count($userList->getObjects())) {
- continue;
- }
- }
- }
-
- // affected user
- $user = null;
- if ($thread->userID) {
- $user = new User($thread->userID);
- if (!$user->userID) {
- $user = null;
- }
- }
-
- // save threadID for post in affected thread
- $bot->threadID = $thread->threadID;
-
- if ($user) {
- $affectedUserIDs[] = $user->userID;
- $countToUserID[$user->userID] = 1;
- }
- else {
- $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
- $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
- $placeholders['user-age'] = 'x';
- $placeholders['user-id'] = 0;
- }
-
- $placeholders['board-id'] = $thread->boardID;
- $placeholders['board-name'] = $thread->getBoard()->title;
- $placeholders['count'] = 1;
- $placeholders['count-user'] = $user ? $user->wbbPosts : 0;
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
- if ($user) {
- $placeholders['translate'] = ['board-name'];
- }
- else {
- $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
- }
-
- // get quote
- $post = $thread->getFirstPost();
- $quote = $this->getQuote($post);
- $placeholders['quote'] = $quote;
-
- // get options; >= 5.2.0
- $optionValues = [];
- $sql = "SELECT thread_form_option.optionTitle, thread_form_option_value.optionValue
- FROM wbb".WCF_N."_thread_form_option_value thread_form_option_value
- LEFT JOIN wbb".WCF_N."_thread_form_option thread_form_option
- ON (thread_form_option_value.optionID = thread_form_option.optionID)
- WHERE postID = ?
- ORDER BY thread_form_option.showOrder";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([$post->postID]);
- $optionValues = $statement->fetchMap('optionTitle', 'optionValue');
-
- $placeholders['options'] = $optionValues;
-
- // log action
- if ($bot->enableLog) {
- // userIDs string
- if (count($affectedUserIDs)) {
- $userIDs = implode(', ', $affectedUserIDs);
- }
- else {
- $userIDs = $defaultLanguage->get('wcf.user.guest');
- }
-
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => 1,
- 'userIDs' => $userIDs
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => 1,
- 'users' => count($affectedUserIDs),
- 'userIDs' => $userIDs
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
- }
-
- // best answer
- if ($action == 'markAsBestAnswer') {
- // Read all active, valid activity bots, abort if none
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_bestAnswer']);
-
- if (count($bots)) {
- // data
- $params = $eventObj->getParameters();
- $thread = $eventObj->thread;
- $board = $thread->getBoard();
- $post = new Post($params['postID']);
- if (!$post->postID) return;
- $quote = $this->getQuote($post);
- $user = null;
- if ($post->userID) {
- $user = new User($post->userID);
- if (!$user->userID) $user = null;
- }
-
- foreach ($bots as $bot) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
-
- // must be in monitored boards
- if (!in_array($thread->boardID, unserialize($bot->uzbotBoardIDs))) continue;
-
- // user
- if ($user) {
- $affectedUserIDs[] = $user->userID;
- $countToUserID[$user->userID] = $user->wbbPosts;
- }
- else {
- $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
- $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
- $placeholders['user-age'] = 'x';
- $placeholders['user-id'] = 0;
- }
-
- // set placeholders
- $placeholders['board-id'] = $board->boardID;
- $placeholders['board-name'] = $board->title;
- $placeholders['count'] = 1;
- $placeholders['count-user'] = $user ? $user->wbbPosts : 0;
- $placeholders['post-id'] = $post->postID;
- $placeholders['post-link'] = $post->getLink();
- $placeholders['post-subject'] = $post->getTitle();
- $placeholders['post-text'] = $post->getMessage();
- $placeholders['quote'] = $quote;
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- if ($user) {
- $placeholders['translate'] = ['board-name'];
- }
- else {
- $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
- }
-
- // save threadID for post in affected thread
- $bot->threadID = $thread->threadID;
-
- // log action
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => 1,
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => 1,
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => 1,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => $affectedUserIDs,
- 'countToUserID' => $countToUserID
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
- }
- }
-
- /**
- * Create qoute from post / thread
- */
- protected function getQuote($post) {
- $quoteID = MessageQuoteManager::getInstance()->addQuote(
- 'com.woltlab.wbb.post',
- $post->threadID,
- $post->postID,
- $post->getExcerpt(),
- $post->getMessage()
- );
-
- if ($quoteID === false) {
- $removeQuoteID = MessageQuoteManager::getInstance()->getQuoteID(
- 'com.woltlab.wbb.post',
- $post->postID,
- $post->getExcerpt(),
- $post->getMessage()
- );
- MessageQuoteManager::getInstance()->removeQuote($removeQuoteID);
- }
-
- $returnValues = [
- 'count' => MessageQuoteManager::getInstance()->countQuotes(),
- 'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(['com.woltlab.wbb.post'])
- ];
- if ($quoteID) {
- $returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
-
- $username = str_replace(["\\", "'"], ["\\\\", "\'"], $returnValues['renderedQuote']['username']);
- $link = str_replace(["\\", "'"], ["\\\\", "\'"], $returnValues['renderedQuote']['link']);
- $message = $returnValues['renderedQuote']['text'];
-
- // build quote and replace
- $quote = '';
- $quote .= $message;
- $quote .= ' ';
- }
- else $quote = '';
-
- return $quote;
- }
+class UzbotThreadActionListener implements IParameterizedEventListener
+{
+ /**
+ * @inheritdoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ // check module
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ $action = $eventObj->getActionName();
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+
+ // Thread publication
+ if ($action == 'triggerPublication') {
+ // Read all active, valid bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_threadNew']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ // get threads
+ $threads = $eventObj->getObjects();
+ if (!\count($threads)) {
+ return;
+ }
+
+ foreach ($threads as $editor) {
+ $thread = $editor->getDecoratedObject();
+
+ // not if created by bot
+ if ($thread->isUzbot) {
+ continue;
+ }
+
+ foreach ($bots as $bot) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+ $count = 1;
+
+ //monitored boards
+ if (!\in_array($thread->boardID, \unserialize($bot->threadNewBoardIDs))) {
+ continue;
+ }
+
+ // user conditions
+ $conditions = $bot->getUserConditions();
+ if (\count($conditions)) {
+ if (!$thread->userID) {
+ continue;
+ } else {
+ $userList = new UserList();
+ $userList->getConditionBuilder()->add('user_table.userID = ?', [$thread->userID]);
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ if (!\count($userList->getObjects())) {
+ continue;
+ }
+ }
+ }
+
+ // affected user
+ $user = null;
+ if ($thread->userID) {
+ $user = new User($thread->userID);
+ if (!$user->userID) {
+ $user = null;
+ }
+ }
+
+ // save threadID for post in affected thread
+ $bot->threadID = $thread->threadID;
+
+ if ($user) {
+ $affectedUserIDs[] = $user->userID;
+ $countToUserID[$user->userID] = 1;
+ } else {
+ $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
+ $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
+ $placeholders['user-age'] = 'x';
+ $placeholders['user-id'] = 0;
+ }
+
+ $placeholders['board-id'] = $thread->boardID;
+ $placeholders['board-name'] = $thread->getBoard()->title;
+ $placeholders['count'] = 1;
+ $placeholders['count-user'] = $user ? $user->wbbPosts : 0;
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
+ if ($user) {
+ $placeholders['translate'] = ['board-name'];
+ } else {
+ $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
+ }
+
+ // get quote
+ $post = $thread->getFirstPost();
+ $quote = $this->getQuote($post);
+ $placeholders['quote'] = $quote;
+
+ // get options; >= 5.2.0
+ $optionValues = [];
+ $sql = "SELECT thread_form_option.optionTitle, thread_form_option_value.optionValue
+ FROM wbb" . WCF_N . "_thread_form_option_value thread_form_option_value
+ LEFT JOIN wbb" . WCF_N . "_thread_form_option thread_form_option
+ ON (thread_form_option_value.optionID = thread_form_option.optionID)
+ WHERE postID = ?
+ ORDER BY thread_form_option.showOrder";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$post->postID]);
+ $optionValues = $statement->fetchMap('optionTitle', 'optionValue');
+
+ $placeholders['options'] = $optionValues;
+
+ // log action
+ if ($bot->enableLog) {
+ // userIDs string
+ if (\count($affectedUserIDs)) {
+ $userIDs = \implode(', ', $affectedUserIDs);
+ } else {
+ $userIDs = $defaultLanguage->get('wcf.user.guest');
+ }
+
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => 1,
+ 'userIDs' => $userIDs,
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => 1,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => $userIDs,
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ }
+
+ // best answer
+ if ($action == 'markAsBestAnswer') {
+ // Read all active, valid activity bots, abort if none
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_bestAnswer']);
+
+ if (\count($bots)) {
+ // data
+ $params = $eventObj->getParameters();
+ $thread = $eventObj->thread;
+ $board = $thread->getBoard();
+ $post = new Post($params['postID']);
+ if (!$post->postID) {
+ return;
+ }
+ $quote = $this->getQuote($post);
+ $user = null;
+ if ($post->userID) {
+ $user = new User($post->userID);
+ if (!$user->userID) {
+ $user = null;
+ }
+ }
+
+ foreach ($bots as $bot) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+
+ // must be in monitored boards
+ if (!\in_array($thread->boardID, \unserialize($bot->uzbotBoardIDs))) {
+ continue;
+ }
+
+ // user
+ if ($user) {
+ $affectedUserIDs[] = $user->userID;
+ $countToUserID[$user->userID] = $user->wbbPosts;
+ } else {
+ $placeholders['user-email'] = $placeholders['user-groups'] = 'wcf.user.guest';
+ $placeholders['user-name'] = $placeholders['user-profile'] = $placeholders['@user-profile'] = 'wcf.user.guest';
+ $placeholders['user-age'] = 'x';
+ $placeholders['user-id'] = 0;
+ }
+
+ // set placeholders
+ $placeholders['board-id'] = $board->boardID;
+ $placeholders['board-name'] = $board->title;
+ $placeholders['count'] = 1;
+ $placeholders['count-user'] = $user ? $user->wbbPosts : 0;
+ $placeholders['post-id'] = $post->postID;
+ $placeholders['post-link'] = $post->getLink();
+ $placeholders['post-subject'] = $post->getTitle();
+ $placeholders['post-text'] = $post->getMessage();
+ $placeholders['quote'] = $quote;
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ if ($user) {
+ $placeholders['translate'] = ['board-name'];
+ } else {
+ $placeholders['translate'] = ['board-name', 'user-email', 'user-groups', 'user-name', 'user-profile', '@user-profile', 'user-age'];
+ }
+
+ // save threadID for post in affected thread
+ $bot->threadID = $thread->threadID;
+
+ // log action
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => 1,
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => 1,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => 1,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => $affectedUserIDs,
+ 'countToUserID' => $countToUserID,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create qoute from post / thread
+ */
+ protected function getQuote($post)
+ {
+ $quoteID = MessageQuoteManager::getInstance()->addQuote(
+ 'com.woltlab.wbb.post',
+ $post->threadID,
+ $post->postID,
+ $post->getExcerpt(),
+ $post->getMessage()
+ );
+
+ if ($quoteID === false) {
+ $removeQuoteID = MessageQuoteManager::getInstance()->getQuoteID(
+ 'com.woltlab.wbb.post',
+ $post->postID,
+ $post->getExcerpt(),
+ $post->getMessage()
+ );
+ MessageQuoteManager::getInstance()->removeQuote($removeQuoteID);
+ }
+
+ $returnValues = [
+ 'count' => MessageQuoteManager::getInstance()->countQuotes(),
+ 'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(['com.woltlab.wbb.post']),
+ ];
+ if ($quoteID) {
+ $returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
+
+ $username = \str_replace(["\\", "'"], ["\\\\", "\\'"], $returnValues['renderedQuote']['username']);
+ $link = \str_replace(["\\", "'"], ["\\\\", "\\'"], $returnValues['renderedQuote']['link']);
+ $message = $returnValues['renderedQuote']['text'];
+
+ // build quote and replace
+ $quote = '';
+ $quote .= $message;
+ $quote .= ' ';
+ } else {
+ $quote = '';
+ }
+
+ return $quote;
+ }
}
diff --git a/files/lib/system/event/listener/UzbotThreadModerationListener.class.php b/files/lib/system/event/listener/UzbotThreadModerationListener.class.php
index bb2c534..089a8d8 100644
--- a/files/lib/system/event/listener/UzbotThreadModerationListener.class.php
+++ b/files/lib/system/event/listener/UzbotThreadModerationListener.class.php
@@ -1,5 +1,27 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotThreadModerationListener implements IParameterizedEventListener {
- /**
- * @inheritDoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- // check module
- if (!MODULE_UZBOT) return;
-
- // only action create and user
- if ($eventObj->getActionName() != 'create') return;
- if (!WCF::getUser()->userID) return;
-
- // only thread modification
- $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.modifiableContent', 'com.woltlab.wbb.thread');
- $params = $eventObj->getParameters();
- if ($params['data']['objectTypeID'] != $objectTypeID) return;
-
- // only if bots
- $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_threadModeration']);
- if (!count($bots)) return;
-
- // preset data
- $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
- $threadID = $params['data']['objectID'];
- $action = $params['data']['action'];
- $moderatorID = $params['data']['userID'];
- $additional = [];
- if (isset($params['data']['additionalData'])) $additional = unserialize($params['data']['additionalData']);
-
- // skip 'delete'
- $validActions = ['changeTopic', 'close', 'disable', 'done', 'enable', 'merge', 'move', 'open', 'restore', 'scrape', 'setAsAnnouncement', 'setLabel', 'sticky', 'trash', 'undone', 'unsetAsAnnouncement'];
-
- if (!in_array($action, $validActions)) return;
-
- // only moderation
- $thread = new Thread($threadID);
- if ($thread && $thread->userID == $moderatorID) return;
-
- // Step through bots
- foreach ($bots as $bot) {
- $affectedUserIDs = $countToUserID = $placeholders = [];
- $count = 0;
-
- // check action
- if (!stripos($bot->wbbThreadModerationData, $action)) continue; // 0/false doesn't matter
-
- // check board
- if (!in_array($thread->boardID, unserialize($bot->uzbotBoardIDs))) continue;
-
- // check action
- $moderations = unserialize($bot->wbbThreadModerationData);
- $act = 0;
- foreach ($moderations as $key => $value) {
- if ($key == 'threadModerationAuthorOnly') continue;
- if (0 == strcasecmp($key, 'threadModeration'.$action) && $value == 1) {
- $act = 1;
- break;
- }
- }
- if (!$act) continue;
-
- // get potentially affected users
- if ($bot->changeAffected) {
- $affectedUserIDs[] = $moderatorID;
- $countToUserID[$moderatorID] = 1;
- $count = 1;
- }
- else {
- if ($moderations['threadModerationAuthorOnly']) {
- // leave if thread without author
- if (!$thread->userID) continue;
-
- $affectedUserIDs[] = $thread->userID;
- $countToUserID[$thread->userID] = 1;
- $count = 1;
- }
- else {
- // authors of posts are affected, only active posts
- $sql = "SELECT userID
- FROM wbb".WCF_N."_post
- WHERE threadID = ? AND userID > ? AND isDeleted = ? AND isDisabled = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([$threadID, 0, 0, 0]);
- while ($row = $statement->fetchArray()) {
- $count ++;
- $affectedUserIDs[] = $row['userID'];
- if (isset($countToUserID[$row['userID']])) $countToUserID[$row['userID']] ++;
- else $countToUserID[$row['userID']] = 1;
- }
- // leave if no users
- if (!count($affectedUserIDs)) continue;
-
- $affectedUserIDs = array_unique($affectedUserIDs);
- }
- }
-
- // check users
- $conditions = $bot->getUserConditions();
- if (count($conditions)) {
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$affectedUserIDs]);
- foreach ($conditions as $condition) {
- $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
- }
- $userList->readObjects();
- if (!count($userList->getObjects())) continue;
- }
-
- // found users, board and a valid action, get data
- // log action
- if ($bot->enableLog) {
- if (!$bot->testMode) {
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
- 'total' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ])
- ]);
- }
- else {
- $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
- 'objects' => $count,
- 'users' => count($affectedUserIDs),
- 'userIDs' => implode(', ', $affectedUserIDs)
- ]);
- if (mb_strlen($result) > 64000) $result = mb_substr($result, 0, 64000) . ' ...';
- UzbotLogEditor::create([
- 'bot' => $bot,
- 'count' => $count,
- 'testMode' => 1,
- 'additionalData' => serialize(['', '', $result])
- ]);
- }
- }
-
- // check for and prepare notification
- $notify = $bot->checkNotify(true, true);
- if ($notify === null) continue;
-
- $bot->threadID = $thread->threadID;
- $board = $thread->getBoard();
- $moderator = WCF::getUser();
-
- $placeholders['board-id'] = $thread->boardID;
- $placeholders['board-name'] = $thread->getBoard()->title;
- $placeholders['count'] = count($affectedUserIDs);
-
- $placeholders['moderation-action'] = 'wcf.uzbot.wbb.moderation.' . $action;
- $placeholders['moderation-reason'] = '';
- if (isset($additional['reason'])) $placeholders['moderation-reason'] = $additional['reason'];
- $placeholders['moderator-id'] = $moderator->userID;
- $placeholders['moderator-link'] = $moderator->getLink();
- $placeholders['moderator-link2'] = StringUtil::getAnchorTag($moderator->getLink(), $moderator->username);
- $placeholders['moderator-name'] = $moderator->username;
-
- $placeholders['thread-link'] = $thread->getLink();
- $placeholders['thread-subject'] = $thread->getTitle();
- $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
- $placeholders['translate'] = ['board-name', 'moderation-action'];
-
- // test mode
- $testUserIDs = $testToUserIDs = [];
- $testUserIDs[] = $affectedUserIDs[0];
- $testToUserIDs[$affectedUserIDs[0]] = $countToUserID[$affectedUserIDs[0]];
-
- // send to scheduler
- $data = [
- 'bot' => $bot,
- 'placeholders' => $placeholders,
- 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
- 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs
- ];
-
- $job = new NotifyScheduleBackgroundJob($data);
- BackgroundQueueHandler::getInstance()->performJob($job);
- }
- }
+class UzbotThreadModerationListener implements IParameterizedEventListener
+{
+ /**
+ * @inheritDoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ // check module
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // only action create and user
+ if ($eventObj->getActionName() != 'create') {
+ return;
+ }
+ if (!WCF::getUser()->userID) {
+ return;
+ }
+
+ // only thread modification
+ $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.modifiableContent', 'com.woltlab.wbb.thread');
+ $params = $eventObj->getParameters();
+ if ($params['data']['objectTypeID'] != $objectTypeID) {
+ return;
+ }
+
+ // only if bots
+ $bots = UzbotValidBotCacheBuilder::getInstance()->getData(['typeDes' => 'wbb_threadModeration']);
+ if (!\count($bots)) {
+ return;
+ }
+
+ // preset data
+ $defaultLanguage = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
+ $threadID = $params['data']['objectID'];
+ $action = $params['data']['action'];
+ $moderatorID = $params['data']['userID'];
+ $additional = [];
+ if (isset($params['data']['additionalData'])) {
+ $additional = \unserialize($params['data']['additionalData']);
+ }
+
+ // skip 'delete'
+ $validActions = ['changeTopic', 'close', 'disable', 'done', 'enable', 'merge', 'move', 'open', 'restore', 'scrape', 'setAsAnnouncement', 'setLabel', 'sticky', 'trash', 'undone', 'unsetAsAnnouncement'];
+
+ if (!\in_array($action, $validActions)) {
+ return;
+ }
+
+ // only moderation
+ $thread = new Thread($threadID);
+ if ($thread && $thread->userID == $moderatorID) {
+ return;
+ }
+
+ // Step through bots
+ foreach ($bots as $bot) {
+ $affectedUserIDs = $countToUserID = $placeholders = [];
+ $count = 0;
+
+ // check action
+ if (!\stripos($bot->wbbThreadModerationData, $action)) {
+ continue;
+ } // 0/false doesn't matter
+
+ // check board
+ if (!\in_array($thread->boardID, \unserialize($bot->uzbotBoardIDs))) {
+ continue;
+ }
+
+ // check action
+ $moderations = \unserialize($bot->wbbThreadModerationData);
+ $act = 0;
+ foreach ($moderations as $key => $value) {
+ if ($key == 'threadModerationAuthorOnly') {
+ continue;
+ }
+ if (0 == \strcasecmp($key, 'threadModeration' . $action) && $value == 1) {
+ $act = 1;
+ break;
+ }
+ }
+ if (!$act) {
+ continue;
+ }
+
+ // get potentially affected users
+ if ($bot->changeAffected) {
+ $affectedUserIDs[] = $moderatorID;
+ $countToUserID[$moderatorID] = 1;
+ $count = 1;
+ } else {
+ if ($moderations['threadModerationAuthorOnly']) {
+ // leave if thread without author
+ if (!$thread->userID) {
+ continue;
+ }
+
+ $affectedUserIDs[] = $thread->userID;
+ $countToUserID[$thread->userID] = 1;
+ $count = 1;
+ } else {
+ // authors of posts are affected, only active posts
+ $sql = "SELECT userID
+ FROM wbb" . WCF_N . "_post
+ WHERE threadID = ? AND userID > ? AND isDeleted = ? AND isDisabled = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$threadID, 0, 0, 0]);
+ while ($row = $statement->fetchArray()) {
+ $count++;
+ $affectedUserIDs[] = $row['userID'];
+ if (isset($countToUserID[$row['userID']])) {
+ $countToUserID[$row['userID']]++;
+ } else {
+ $countToUserID[$row['userID']] = 1;
+ }
+ }
+ // leave if no users
+ if (!\count($affectedUserIDs)) {
+ continue;
+ }
+
+ $affectedUserIDs = \array_unique($affectedUserIDs);
+ }
+ }
+
+ // check users
+ $conditions = $bot->getUserConditions();
+ if (\count($conditions)) {
+ $userList = new UserList();
+ $userList->getConditionBuilder()->add('user_table.userID IN (?)', [$affectedUserIDs]);
+ foreach ($conditions as $condition) {
+ $condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
+ }
+ $userList->readObjects();
+ if (!\count($userList->getObjects())) {
+ continue;
+ }
+ }
+
+ // found users, board and a valid action, get data
+ // log action
+ if ($bot->enableLog) {
+ if (!$bot->testMode) {
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'additionalData' => $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.user.affected', [
+ 'total' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]),
+ ]);
+ } else {
+ $result = $defaultLanguage->getDynamicVariable('wcf.acp.uzbot.log.test', [
+ 'objects' => $count,
+ 'users' => \count($affectedUserIDs),
+ 'userIDs' => \implode(', ', $affectedUserIDs),
+ ]);
+ if (\mb_strlen($result) > 64000) {
+ $result = \mb_substr($result, 0, 64000) . ' ...';
+ }
+ UzbotLogEditor::create([
+ 'bot' => $bot,
+ 'count' => $count,
+ 'testMode' => 1,
+ 'additionalData' => \serialize(['', '', $result]),
+ ]);
+ }
+ }
+
+ // check for and prepare notification
+ $notify = $bot->checkNotify(true, true);
+ if ($notify === null) {
+ continue;
+ }
+
+ $bot->threadID = $thread->threadID;
+ $board = $thread->getBoard();
+ $moderator = WCF::getUser();
+
+ $placeholders['board-id'] = $thread->boardID;
+ $placeholders['board-name'] = $thread->getBoard()->title;
+ $placeholders['count'] = \count($affectedUserIDs);
+
+ $placeholders['moderation-action'] = 'wcf.uzbot.wbb.moderation.' . $action;
+ $placeholders['moderation-reason'] = '';
+ if (isset($additional['reason'])) {
+ $placeholders['moderation-reason'] = $additional['reason'];
+ }
+ $placeholders['moderator-id'] = $moderator->userID;
+ $placeholders['moderator-link'] = $moderator->getLink();
+ $placeholders['moderator-link2'] = StringUtil::getAnchorTag($moderator->getLink(), $moderator->username);
+ $placeholders['moderator-name'] = $moderator->username;
+
+ $placeholders['thread-link'] = $thread->getLink();
+ $placeholders['thread-subject'] = $thread->getTitle();
+ $placeholders['thread-text'] = $thread->getFirstPost()->getMessage();
+ $placeholders['translate'] = ['board-name', 'moderation-action'];
+
+ // test mode
+ $testUserIDs = $testToUserIDs = [];
+ $testUserIDs[] = $affectedUserIDs[0];
+ $testToUserIDs[$affectedUserIDs[0]] = $countToUserID[$affectedUserIDs[0]];
+
+ // send to scheduler
+ $data = [
+ 'bot' => $bot,
+ 'placeholders' => $placeholders,
+ 'affectedUserIDs' => !$bot->testMode ? $affectedUserIDs : $testUserIDs,
+ 'countToUserID' => !$bot->testMode ? $countToUserID : $testToUserIDs,
+ ];
+
+ $job = new NotifyScheduleBackgroundJob($data);
+ BackgroundQueueHandler::getInstance()->performJob($job);
+ }
+ }
}
diff --git a/files/lib/system/event/listener/UzbotWbbDeleteBotListener.class.php b/files/lib/system/event/listener/UzbotWbbDeleteBotListener.class.php
index bbbfc97..97b64d4 100644
--- a/files/lib/system/event/listener/UzbotWbbDeleteBotListener.class.php
+++ b/files/lib/system/event/listener/UzbotWbbDeleteBotListener.class.php
@@ -1,30 +1,54 @@
- * @package com.uz.wcf.bot3.wbb
*/
-class UzbotWbbDeleteBotListener implements IParameterizedEventListener {
- /**
- * @inheritDoc
- */
- public function execute($eventObj, $className, $eventName, array &$parameters) {
- // check module
- if (!MODULE_UZBOT) return;
-
- // only delete
- if ($eventObj->getActionName() != 'delete') return;
-
- $botIDs = $eventObj->getObjectIDs();
- if (!empty($botIDs)) {
- $oldConditions = ConditionHandler::getInstance()->deleteConditions('com.uz.wcf.bot.condition.wbb', $botIDs);
- }
- }
+class UzbotWbbDeleteBotListener implements IParameterizedEventListener
+{
+ /**
+ * @inheritDoc
+ */
+ public function execute($eventObj, $className, $eventName, array &$parameters)
+ {
+ // check module
+ if (!MODULE_UZBOT) {
+ return;
+ }
+
+ // only delete
+ if ($eventObj->getActionName() != 'delete') {
+ return;
+ }
+
+ $botIDs = $eventObj->getObjectIDs();
+ if (!empty($botIDs)) {
+ $oldConditions = ConditionHandler::getInstance()->deleteConditions('com.uz.wcf.bot.condition.wbb', $botIDs);
+ }
+ }
}
diff --git a/language/de.xml b/language/de.xml
index 94840bb..eb5620a 100644
--- a/language/de.xml
+++ b/language/de.xml
@@ -1,150 +1,150 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Dieser Bot überwacht die Änderung oder das Löschen von Beiträgen durch den Verfasser und erstellt eine Benachrichtigung, wenn ein Benutzer seinen Beitrag ändert oder löscht. Die Moderation von Beiträgen wird durch diesen Bot nicht erfasst.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Dieser Bot überwacht die Änderung oder das Löschen von Beiträgen durch den Verfasser und erstellt eine Benachrichtigung, wenn ein Benutzer seinen Beitrag ändert oder löscht. Die Moderation von Beiträgen wird durch diesen Bot nicht erfasst.
Der Verfasser des Beitrags ist der betroffene Benutzer und kann direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im Thema mit dem erkannten Beitrag erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Durch Konfiguration von Foren und der Allgemeinen Benutzer-Bedingungen kann die Überwachung auf bestimmte Foren bzw. Benutzer begrenzt werden.
Die folgenden Bot-spezifischen Platzhalter stehen zur Verfügung:
@@ -180,9 +180,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot überwacht die Veröffentlichung von Beiträgen und erstellt Benachrichtigungen, wenn ein Benutzer oder Gast einen neuen Beitrag verfasst hat und dieser veröffentlicht/freigeschaltet wird.
+
+
+ - Dieser Bot überwacht die Veröffentlichung von Beiträgen und erstellt Benachrichtigungen, wenn ein Benutzer oder Gast einen neuen Beitrag verfasst hat und dieser veröffentlicht/freigeschaltet wird.
Der Verfasser des Beitrags ist der betroffene Benutzer und kann direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im Thema mit dem erkannten Beitrag erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Bei „Gesamtzahl der Beiträge“ erfolgt die Benachrichtigung, wenn die Gesamtzahl einen der unter „Auslösewerte“ eingegebenen Wert erreicht hat.
Bei „x. Beitrag eines Benutzer“ erfolgt die Benachrichtigung, wenn der betroffenen Benutzer eine der unter „Auslösewerte“ eingegebene Anzahl an Beiträgen erreicht hat.
@@ -219,9 +219,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot überwacht die Moderation von Beiträgen und erstellt Benachrichtigungen, wenn ein Beitrag entsprechend der ausgewählten Aktion(en) geändert wurde.
+
+
+ - Dieser Bot überwacht die Moderation von Beiträgen und erstellt Benachrichtigungen, wenn ein Beitrag entsprechend der ausgewählten Aktion(en) geändert wurde.
Der Verfasser des Beitrags ist der betroffene Benutzer und kann direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im Thema mit dem moderierten Beitrag erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Durch Konfiguration von Foren und der Allgemeinen Benutzer-Bedingungen kann die Überwachung auf bestimmte Foren bzw. Benutzer begrenzt werden. Durch Wahl des Betroffenen Benutzers kann die Benachrichtigung entweder an den Moderator oder den Ersteller des Beitrags versendet werden.
Die folgenden Bot-spezifischen Platzhalter stehen zur Verfügung:
@@ -259,9 +259,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot überwacht die Moderation von Themen und erstellt Benachrichtigungen, wenn ein Thema entsprechend der ausgewählten Aktion(en) geändert wurde.
+
+
+ - Dieser Bot überwacht die Moderation von Themen und erstellt Benachrichtigungen, wenn ein Thema entsprechend der ausgewählten Aktion(en) geändert wurde.
Der Verfasser des Themas und, wenn nicht ausgeschlossen, die Verfasser von Beiträgen im Thema (Poster) sind die betroffenen Benutzer und können direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im moderierten Thema erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Durch Konfiguration von Foren und der Allgemeinen Benutzer-Bedingungen kann die Überwachung auf bestimmte Foren bzw. Benutzer begrenzt werden. Durch Wahl des Betroffenen Benutzers kann die Benachrichtigung entweder an den Moderator oder den Ersteller des Themas und die Poster versendet werden.
Hinweis: Es wird für jeden betroffenen Benutzer eine Benachrichtigung erstellt. Dies gilt auch für Benachrichtigungen ohne individuellen Empfänger wie Artikel, Themen oder Beiträge. Soll nur eine Benachrichtigung durch den Bot erstellt werden, so muss entweder bei Verfasser „nur den Verfasser des Themas als betroffenen Benutzer nutzen“ oder bei Betroffener Benutzer „Agierender Benutzer“ ausgewählt werden.
@@ -298,9 +298,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot modifiziert ausgewählte Themen und erstellt Benachrichtigungen, wenn eine Aktion auf die betroffenen Themen angewendet wurde. Die Anzahl der Themen je Bot-Durchlauf kann konfiguriert werden (Standard: 300).
+
+
+ - Dieser Bot modifiziert ausgewählte Themen und erstellt Benachrichtigungen, wenn eine Aktion auf die betroffenen Themen angewendet wurde. Die Anzahl der Themen je Bot-Durchlauf kann konfiguriert werden (Standard: 300).
Die Verfasser der Themen und, wenn nicht ausgeschlossen, die Verfasser von Beiträgen im Thema (Poster) sind die betroffenen Benutzer und können direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im modifizierten Thema erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Es kann mehr als eine Aktion gewählt werden. Die Aktionen werden in der Reihenfolge wie bei der Bot-Konfiguration abgearbeitet.
Hinweis: Es wird für jeden betroffenen Benutzer eine Benachrichtigung erstellt. Dies gilt auch für Benachrichtigungen ohne individuellen Empfänger wie Artikel, Themen oder Beiträge. Soll nur eine Benachrichtigung je Thema durch den Bot erstellt werden, so muss bei Verfasser „nur den Verfasser des Themas als betroffenen Benutzer nutzen“ ausgewählt werden. Abhängig von Konfiguration und Anzahl der modifizierten Themen können sehr viele Benachrichtigungen erstellt werden.
@@ -327,9 +327,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot überwacht die Veröffentlichung von Themen und versendet eine Benachrichtigung, wenn ein Benutzer oder Gast ein neues Thema verfasst hat und dieses veröffentlicht/freigeschaltet wird.
+
+
+ - Dieser Bot überwacht die Veröffentlichung von Themen und versendet eine Benachrichtigung, wenn ein Benutzer oder Gast ein neues Thema verfasst hat und dieses veröffentlicht/freigeschaltet wird.
Der Verfasser des Themas ist der betroffene Benutzer und kann direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im Thema erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Es können mehrere Foren überwacht werden oder nur eines. Durch Konfiguration der Allgemeinen Benutzer-Bedingungen lassen sich zudem gezielt einzelne Benutzer überwachen.
Die folgenden Bot-spezifischen Platzhalter stehen zur Verfügung:
@@ -361,9 +361,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot ermittelt die Top-Poster (Beiträge) in einem wählbaren Zeitraum und versendet eine Benachrichtigung, wenn dieser Zeitraum abgelaufen ist. Es werden bis auf gelöschte Beiträge alle Beiträge der Benutzer berücksichtigt.
+
+
+ - Dieser Bot ermittelt die Top-Poster (Beiträge) in einem wählbaren Zeitraum und versendet eine Benachrichtigung, wenn dieser Zeitraum abgelaufen ist. Es werden bis auf gelöschte Beiträge alle Beiträge der Benutzer berücksichtigt.
Die ermittelten Top-Poster sind die betroffenen Benutzer und können direkt adressiert werden.
Es können mehrere Foren überwacht werden oder nur eines. Durch Konfiguration der Allgemeinen Benutzer-Bedingungen lassen sich zudem gezielt einzelne Benutzer überwachen.
Hinweis: Es wird für jeden betroffenen Benutzer eine Benachrichtigung erstellt. Dies gilt auch für Benachrichtigungen ohne individuellen Empfänger wie Artikel, Themen oder Beiträge. Soll nur eine Benachrichtigung durch den Bot erstellt werden, so muss „Ergebnisse zusammenfassen“ aktiviert werden.
@@ -393,9 +393,9 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
- - Dieser Bot eine tägliche Statistik mit Forum-Daten wie z.B. Foren, Themen und Beiträge.
+
+
+ - Dieser Bot eine tägliche Statistik mit Forum-Daten wie z.B. Foren, Themen und Beiträge.
Es muss nur eine Benachrichtigung konfiguriert werden. Betroffene Benutzer gibt es bei diesem Bot nicht.
Die folgenden Bot-spezifischen Platzhalter stehen zur Verfügung:
]]>
-
- - Dieser Bot überwacht das Auswählen eines Beitrags als Hilfreichste Antwort und versendet eine Benachrichtigung, wenn die Hilfreichste Antwort in einem Thema festgelegt wird.
+
+ - Dieser Bot überwacht das Auswählen eines Beitrags als Hilfreichste Antwort und versendet eine Benachrichtigung, wenn die Hilfreichste Antwort in einem Thema festgelegt wird.
Der Autor des Beitrags ist der betroffene Benutzer und kann direkt adressiert werden. Bei Bedarf kann auch ein Beitrag direkt im Thema erstellt werden. Dazu muss unter Benachrichtigung 0 als Thema-ID bei „Thema“ eingegeben werden.
Die folgenden Bot-spezifischen Platzhalter stehen zur Verfügung:
@@ -451,42 +451,42 @@
[user-profile] Link zum Profil des Benutzers
[@user-profile] Link zum Profil des Benutzers mit Benachrichtungsfunktion (nur Beiträge)
]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Foren
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Foren
- Gesamt: {#$boardOld} -- {#$board} ({if $board > $boardOld}+{/if}{$board - $boardOld})
- Kategorien: {#$boardCategoryOld} -- {#$boardCategory} ({if $boardCategory > $boardCategoryOld}+{/if}{$boardCategory - $boardCategoryOld})
- Verweise: {#$boardLinkOld} -- {#$boardLink} ({if $boardLink > $boardLinkOld}+{/if}{$boardLink - $boardLinkOld})
@@ -508,5 +508,5 @@
- Gelöscht: {#$postDeletedOld} -- {#$postDeleted} ({if $postDeleted > $postDeletedOld}+{/if}{$postDeleted - $postDeletedOld})
- Bearbeitungen: {#$postEditOld} -- {#$postEdit} ({if $postEdit > $postEditOld}+{/if}{$postEdit - $postEditOld})
]]>
-
+
diff --git a/language/en.xml b/language/en.xml
index cf231e5..befdc10 100644
--- a/language/en.xml
+++ b/language/en.xml
@@ -1,150 +1,150 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - This Bot monitors the modification or deletion of posts by their authors and sends a notification when a user has edited or deleted a post of him. The moderation of posts is not accessed by this Bot.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - This Bot monitors the modification or deletion of posts by their authors and sends a notification when a user has edited or deleted a post of him. The moderation of posts is not accessed by this Bot.
The author of the post is affected user and can be directly addressed. If necessary, a post can be created directly in the thread with the recognized post. To do so, you must enter 0 as a thread ID under “Thread”.
By selection of monitored boards and / or configuration of general user conditions the monitoring can be limited to certain boards resp. users.
The following Bot-specific placeholders are available:
@@ -180,9 +180,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This Bot monitors the publication of posts and sends a notification when a user or guest has written a new post and the post is published / enabled.
+
+
+ - This Bot monitors the publication of posts and sends a notification when a user or guest has written a new post and the post is published / enabled.
The author of the post is affected user and can be directly addressed. If necessary, a post can be created directly in the thread with the recognized post. To do so, you must enter 0 as a thread ID under “Thread”.
“Total number of posts” will force a notification when the total number of posts reaches one of the values in “Trigger Values”.
Using “Xth post of a user” the notification will be sent when the affected user’s count for posts reaches one of the values in “Trigger Values”.
@@ -219,9 +219,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This Bot monitors the moderation of posts and sends a notification when a post was changed in accordance with the selected action(s).
+
+
+ - This Bot monitors the moderation of posts and sends a notification when a post was changed in accordance with the selected action(s).
The author of the post is the affected user and can be directly addressed. If necessary, a post can be created directly in the thread with the moderated post. To do so, you must enter 0 as a thread ID under “Thread”.
By selection of monitored boards and / or configuration of general user conditions the monitoring can be limited to certain boards resp. users. By selection of the affected user, the notifications will be send to either the moderator or the authors of the post.
The following Bot-specific placeholders are available:
@@ -259,9 +259,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This Bot monitors the moderation of threads and sends a notification when a thread was changed in accordance with the selected action(s).
+
+
+ - This Bot monitors the moderation of threads and sends a notification when a thread was changed in accordance with the selected action(s).
The author of the thread and, unless excluded, authors of the posts within the thread (poster) are the affected users and can be directly addressed. If necessary, a post can be created directly in the moderated thread. To do so, you must enter 0 as a thread ID under “Thread”.
By selection of monitored boards and / or configuration of general user conditions the monitoring can be limited to certain boards resp. users. By selection of the affected user, the notifications will be send to either the moderator or the authors of the thread / posts.
Notice: one notification will be created for each affected user. This is valid for notifications without individual receiver, like article, threads and posts, too. If you wish only one notification, you have to either select “only consider the author of the thread as affected user” (Author) or “Acting user” as affected user.
@@ -298,9 +298,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This Bot modifies selected threads and sends a notification when a modification action was applied to the threads. The number of threads per cronjob run can be configured (default: 300).
+
+
+ - This Bot modifies selected threads and sends a notification when a modification action was applied to the threads. The number of threads per cronjob run can be configured (default: 300).
The authors of the threads and, unless excluded, authors of the posts within the thread (poster) are the affected users and can be directly addressed. If necessary, a post can be created directly in the modified thread. To do so, you must enter 0 as a thread ID under “Thread”.
You may choose more than one action. Actions will be executed according to the sequence in the Bot configuration.
Notice: one notification will be created for each affected user. This is valid for notifications without individual receiver, like article, threads and posts, too. If you wish only one notification per thread, you have to select “only consider the author of the thread as affected user” under Author. Depending on configuration and number of modified threads, a lot of notifications may be created.
@@ -327,9 +327,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This bot monitors the publication of threads and sends a notification when a user or guest has written a new thread and the thread is published / enabled.
+
+
+ - This bot monitors the publication of threads and sends a notification when a user or guest has written a new thread and the thread is published / enabled.
The author of the topic is the affected user and can be directly addressed. If necessary, a post can be created directly in the thread. To do so, you must enter 0 as a thread ID under “Thread”.
Multiple forums can be monitored or only one. By configuring the general user conditions, specific users can be monitored.
The following Bot-specific placeholders are available:
@@ -361,9 +361,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This bot calculates the top posters for the given time period and sends a notification when the period has expired.
+
+
+ - This bot calculates the top posters for the given time period and sends a notification when the period has expired.
The top posters are the affected users and can be directly addressed.
Multiple forums can be monitored or only one. By configuring the general user conditions, specific users can be monitored.
Notice: one notification will be created for each affected user. This is valid for notifications without individual receiver, like article, threads and posts, too. If you wish only one notification, you have to activate “Condense Results”.
@@ -393,9 +393,9 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
- - This Bot creates a daily statistics with forum data like boards, threads and posts.
+
+
+ - This Bot creates a daily statistics with forum data like boards, threads and posts.
Only the notification must be configured. And there are no affected users.
The following Bot-specific placeholders are available:
]]>
-
- - This bot monitors the selection of a post as Best Answer and sends a notification when the Best Answer is set in a thread.
+
+ - This bot monitors the selection of a post as Best Answer and sends a notification when the Best Answer is set in a thread.
The author of the post is the affected user and can be directly addressed. If necessary, a post can be created directly in the thread. To do so, you must enter 0 as a thread ID under “Thread”.
The following Bot-specific placeholders are available:
@@ -451,42 +451,42 @@
[user-profile] Link to the user’s profile
[@user-profile] Link to the user’s profile with notification (posts only)
]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Boards
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Boards
- Total: {#$boardOld} -- {#$board} ({if $board > $boardOld}+{/if}{$board - $boardOld})
- Categories: {#$boardCategoryOld} -- {#$boardCategory} ({if $boardCategory > $boardCategoryOld}+{/if}{$boardCategory - $boardCategoryOld})
- Links: {#$boardLinkOld} -- {#$boardLink} ({if $boardLink > $boardLinkOld}+{/if}{$boardLink - $boardLinkOld})
@@ -508,5 +508,5 @@
- Deleted: {#$postDeletedOld} -- {#$postDeleted} ({if $postDeleted > $postDeletedOld}+{/if}{$postDeleted - $postDeletedOld})
- Edits: {#$postEditOld} -- {#$postEdit} ({if $postEdit > $postEditOld}+{/if}{$postEdit - $postEditOld})
]]>
-
+
diff --git a/objectType.xml b/objectType.xml
index 78460cc..76163ce 100644
--- a/objectType.xml
+++ b/objectType.xml
@@ -1,77 +1,77 @@
-
-
- com.uz.wcf.bot.condition.wbbPosts
- com.uz.wcf.bot.condition.user
- wcf\system\condition\UserIntegerPropertyCondition
- contents
- wbbPosts
- 0
-
-
-
-
- com.uz.wcf.bot.wbb.username
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\thread\ThreadUsernameCondition
- com.woltlab.wbb.thread
- general
-
-
-
- com.uz.wcf.bot.wbb.thread.time
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\uzbot\UzbotThreadIntegerPropertyCondition
- com.woltlab.wbb.thread
- general
-
-
- com.uz.wcf.bot.wbb.thread.lastPostTime
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\uzbot\UzbotThreadIntegerPropertyCondition
- com.woltlab.wbb.thread
- general
-
-
-
- com.uz.wcf.bot.wbb.replies
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\thread\ThreadIntegerPropertyCondition
- com.woltlab.wbb.thread
- general
- 0
-
-
- com.uz.wcf.bot.wbb.views
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\thread\ThreadIntegerPropertyCondition
- com.woltlab.wbb.thread
- general
- 0
-
-
- com.uz.wcf.bot.wbb.board
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\thread\ThreadBoardCondition
- com.woltlab.wbb.thread
- general
-
-
-
- com.uz.wcf.bot.wbb.state
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\thread\ThreadStateCondition
- com.woltlab.wbb.thread
- general
-
-
-
- com.uz.wcf.bot.wbb.state.label
- com.uz.wcf.bot.condition.wbb
- wbb\system\condition\uzbot\UzbotThreadLabelStateCondition
- com.woltlab.wbb.thread
- general
-
-
+
+
+ com.uz.wcf.bot.condition.wbbPosts
+ com.uz.wcf.bot.condition.user
+ wcf\system\condition\UserIntegerPropertyCondition
+ contents
+ wbbPosts
+ 0
+
+
+
+
+ com.uz.wcf.bot.wbb.username
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\thread\ThreadUsernameCondition
+ com.woltlab.wbb.thread
+ general
+
+
+
+ com.uz.wcf.bot.wbb.thread.time
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\uzbot\UzbotThreadIntegerPropertyCondition
+ com.woltlab.wbb.thread
+ general
+
+
+ com.uz.wcf.bot.wbb.thread.lastPostTime
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\uzbot\UzbotThreadIntegerPropertyCondition
+ com.woltlab.wbb.thread
+ general
+
+
+
+ com.uz.wcf.bot.wbb.replies
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\thread\ThreadIntegerPropertyCondition
+ com.woltlab.wbb.thread
+ general
+ 0
+
+
+ com.uz.wcf.bot.wbb.views
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\thread\ThreadIntegerPropertyCondition
+ com.woltlab.wbb.thread
+ general
+ 0
+
+
+ com.uz.wcf.bot.wbb.board
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\thread\ThreadBoardCondition
+ com.woltlab.wbb.thread
+ general
+
+
+
+ com.uz.wcf.bot.wbb.state
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\thread\ThreadStateCondition
+ com.woltlab.wbb.thread
+ general
+
+
+
+ com.uz.wcf.bot.wbb.state.label
+ com.uz.wcf.bot.condition.wbb
+ wbb\system\condition\uzbot\UzbotThreadLabelStateCondition
+ com.woltlab.wbb.thread
+ general
+
+
diff --git a/objectTypeDefinition.xml b/objectTypeDefinition.xml
index d95470d..2380537 100644
--- a/objectTypeDefinition.xml
+++ b/objectTypeDefinition.xml
@@ -1,9 +1,9 @@
-
-
- com.uz.wcf.bot.condition.wbb
- wcf\system\condition\IObjectListCondition
-
-
+
+
+ com.uz.wcf.bot.condition.wbb
+ wcf\system\condition\IObjectListCondition
+
+
diff --git a/option.xml b/option.xml
index f014abf..b7aa3e2 100644
--- a/option.xml
+++ b/option.xml
@@ -1,14 +1,14 @@
-
-
-
- uzbot.general.data
- integer
- 300
- 50
- 5000
-
-
-
+
+
+
+ uzbot.general.data
+ integer
+ 300
+ 50
+ 5000
+
+
+
diff --git a/package.xml b/package.xml
index d70bd97..be87aea 100644
--- a/package.xml
+++ b/package.xml
@@ -1,74 +1,90 @@
-
-
- Community Bot 3 - Forum Extension
-
- Community Bot 3 - Forum-Erweiterung
-
- 5.5.1
- 2022-07-10
-
-
-
- Zaydowicz
-
-
-
- com.uz.wcf.bot3
- com.woltlab.wbb
- com.woltlab.wcf
-
-
-
- com.woltlab.wcf
-
-
-
- eventListener.xml
- files.tar
- language/*.xml
- update_post.sql
- update_thread.sql
- update_uzbot.sql
- update_uzbot_top.sql
- update_stats.sql
- option.xml
- cronjob.xml
- objectTypeDefinition.xml
- objectType.xml
- templateListener.xml
- acptemplates.tar
- uzbotNotify.xml
- uzbotType.xml
- acp/install_com.uz.wcf.bot3.wbb.php
-
-
-
- update_uzbot_540.sql
- files.tar
- acptemplates.tar
- language/*.xml
-
-
-
- update_uzbot_540.sql
- files.tar
- acptemplates.tar
- language/*.xml
-
-
-
- update_uzbot_540.sql
- files.tar
- acptemplates.tar
- language/*.xml
-
-
-
- files.tar
-
-
-
- files.tar
-
+
+
+ Community Bot 3 - Forum Extension
+
+ Community Bot 3 - Forum-Erweiterung
+
+ 5.5.2
+ 2022-09-18
+
+
+
+
+
+
+
+
+ de.softcreatr.wcf.bot3
+ com.woltlab.wbb
+ com.woltlab.wcf
+
+
+
+ com.woltlab.wcf
+ com.uz.wcf.bot3.wbb
+
+
+
+
+
+
+ update_post.sql
+ update_thread.sql
+ update_uzbot.sql
+ update_uzbot_top.sql
+ update_stats.sql
+
+
+
+
+
+
+
+
+ acp/install_com.uz.wcf.bot3.wbb.php
+
+
+
+ update_uzbot_540.sql
+
+
+
+
+
+
+ update_uzbot_540.sql
+
+
+
+
+
+
+ update_uzbot_540.sql
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templateListener.xml b/templateListener.xml
index 4622c89..b2c6e3d 100644
--- a/templateListener.xml
+++ b/templateListener.xml
@@ -1,30 +1,30 @@
-
-
- admin
- uzbotAdd
- UzbotNotify
-
-
-
- admin
- uzbotAdd
- UzbotNotifyJS
-
-
-
-
- admin
- uzbotAdd
- UzbotType
-
-
-
- admin
- uzbotAdd
- UzbotTypeJS
-
-
-
+
+
+ admin
+ uzbotAdd
+ UzbotNotify
+
+
+
+ admin
+ uzbotAdd
+ UzbotNotifyJS
+
+
+
+
+ admin
+ uzbotAdd
+ UzbotType
+
+
+
+ admin
+ uzbotAdd
+ UzbotTypeJS
+
+
+
diff --git a/update_stats.sql b/update_stats.sql
index 633a825..ee244b4 100644
--- a/update_stats.sql
+++ b/update_stats.sql
@@ -16,4 +16,4 @@ ALTER TABLE wcf1_uzbot_stats ADD postDisabled INT(10) DEFAULT 0;
ALTER TABLE wcf1_uzbot_stats ADD postClosed INT(10) DEFAULT 0;
ALTER TABLE wcf1_uzbot_stats ADD postDeleted INT(10) DEFAULT 0;
ALTER TABLE wcf1_uzbot_stats ADD postEdit INT(10) DEFAULT 0;
-ALTER TABLE wcf1_uzbot_stats ADD timeWbb INT(10) DEFAULT 0;
\ No newline at end of file
+ALTER TABLE wcf1_uzbot_stats ADD timeWbb INT(10) DEFAULT 0;
diff --git a/update_uzbot.sql b/update_uzbot.sql
index 754c1ef..465fb0e 100644
--- a/update_uzbot.sql
+++ b/update_uzbot.sql
@@ -1,19 +1,19 @@
-ALTER TABLE wcf1_uzbot ADD wbbPostData TEXT;
-ALTER TABLE wcf1_uzbot ADD wbbPostModerationData TEXT;
-ALTER TABLE wcf1_uzbot ADD wbbThreadData TEXT;
-ALTER TABLE wcf1_uzbot ADD wbbThreadModerationData TEXT;
-ALTER TABLE wcf1_uzbot ADD wbbThreadModificationData TEXT;
+ALTER TABLE wcf1_uzbot ADD wbbPostData TEXT;
+ALTER TABLE wcf1_uzbot ADD wbbPostModerationData TEXT;
+ALTER TABLE wcf1_uzbot ADD wbbThreadData TEXT;
+ALTER TABLE wcf1_uzbot ADD wbbThreadModerationData TEXT;
+ALTER TABLE wcf1_uzbot ADD wbbThreadModificationData TEXT;
-ALTER TABLE wcf1_uzbot ADD postCountAction VARCHAR(15),
-ALTER TABLE wcf1_uzbot ADD threadID INT(10);
-ALTER TABLE wcf1_uzbot ADD topPosterCount INT(10) DEFAULT 1;
-ALTER TABLE wcf1_uzbot ADD topPosterInterval TINYINT(1) DEFAULT 1;
-ALTER TABLE wcf1_uzbot ADD topPosterNext INT(10) DEFAULT 0;
-ALTER TABLE wcf1_uzbot ADD threadNewBoardIDs TEXT;
-ALTER TABLE wcf1_uzbot ADD uzbotBoardIDs TEXT;
+ALTER TABLE wcf1_uzbot ADD postCountAction VARCHAR(15),
+ALTER TABLE wcf1_uzbot ADD threadID INT(10);
+ALTER TABLE wcf1_uzbot ADD topPosterCount INT(10) DEFAULT 1;
+ALTER TABLE wcf1_uzbot ADD topPosterInterval TINYINT(1) DEFAULT 1;
+ALTER TABLE wcf1_uzbot ADD topPosterNext INT(10) DEFAULT 0;
+ALTER TABLE wcf1_uzbot ADD threadNewBoardIDs TEXT;
+ALTER TABLE wcf1_uzbot ADD uzbotBoardIDs TEXT;
-ALTER TABLE wcf1_uzbot ADD postChangeUpdate TINYINT(1) DEFAULT 1;
-ALTER TABLE wcf1_uzbot ADD postChangeDelete TINYINT(1) DEFAULT 1;
+ALTER TABLE wcf1_uzbot ADD postChangeUpdate TINYINT(1) DEFAULT 1;
+ALTER TABLE wcf1_uzbot ADD postChangeDelete TINYINT(1) DEFAULT 1;
-ALTER TABLE wcf1_uzbot ADD postIsOfficial TINYINT(1) DEFAULT 0;
-ALTER TABLE wcf1_uzbot ADD threadIsOfficial TINYINT(1) DEFAULT 0;
\ No newline at end of file
+ALTER TABLE wcf1_uzbot ADD postIsOfficial TINYINT(1) DEFAULT 0;
+ALTER TABLE wcf1_uzbot ADD threadIsOfficial TINYINT(1) DEFAULT 0;
diff --git a/update_uzbot_540.sql b/update_uzbot_540.sql
index 35390ca..b471154 100644
--- a/update_uzbot_540.sql
+++ b/update_uzbot_540.sql
@@ -1,2 +1,2 @@
-ALTER TABLE wcf1_uzbot ADD postIsOfficial TINYINT(1) DEFAULT 0;
-ALTER TABLE wcf1_uzbot ADD threadIsOfficial TINYINT(1) DEFAULT 0;
\ No newline at end of file
+ALTER TABLE wcf1_uzbot ADD postIsOfficial TINYINT(1) DEFAULT 0;
+ALTER TABLE wcf1_uzbot ADD threadIsOfficial TINYINT(1) DEFAULT 0;
diff --git a/update_uzbot_top.sql b/update_uzbot_top.sql
index d9a8264..0411196 100644
--- a/update_uzbot_top.sql
+++ b/update_uzbot_top.sql
@@ -1,3 +1,3 @@
-ALTER TABLE wcf1_uzbot_top ADD post INT(10) DEFAULT NULL;
+ALTER TABLE wcf1_uzbot_top ADD post INT(10) DEFAULT NULL;
ALTER TABLE wcf1_uzbot_top ADD FOREIGN KEY (post) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
diff --git a/uzbotNotify.xml b/uzbotNotify.xml
index ce9e635..12117a3 100644
--- a/uzbotNotify.xml
+++ b/uzbotNotify.xml
@@ -1,32 +1,32 @@
-
-
- 10
- 1
- 1
- 1
- 1
- 0
- 1
- 0
-
- wbb\data\uzbot\notification\UzbotNotifyForumThread
- 10
-
-
-
- 11
- 1
- 0
- 1
- 0
- 0
- 0
- 0
-
- wbb\data\uzbot\notification\UzbotNotifyForumPost
- 11
-
-
+
+
+ 10
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 0
+
+ wbb\data\uzbot\notification\UzbotNotifyForumThread
+ 10
+
+
+
+ 11
+ 1
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+
+ wbb\data\uzbot\notification\UzbotNotifyForumPost
+ 11
+
+
diff --git a/uzbotType.xml b/uzbotType.xml
index 4c8f17f..912ff41 100644
--- a/uzbotType.xml
+++ b/uzbotType.xml
@@ -1,139 +1,139 @@
-
-
- 30
- WBB
- 0
- 1
- 1
- 0
- 0
-
-
-
- 1
- 30
-
-
-
- 31
- WBB
- 0
- 1
- 1
- 0
- 1
- postCountAction
- postTop
-
- 1
- 31
-
-
-
- 32
- WBB
- 0
- 1
- 0
- 1
- 0
-
-
-
- 1
- 32
-
-
-
- 40
- WBB
- 1
- 1
- 0
- 1
- 0
-
-
-
- 1
- 41
-
-
-
- 41
- WBB
- 0
- 1
- 1
- 0
- 0
-
-
-
- 0
- 42
-
-
-
- 42
- WBB
- 0
- 1
- 1
- 0
- 0
-
-
-
- 1
- 43
-
-
-
- 43
- WBB
- 1
- 1
- 0
- 0
- 0
-
-
-
- 1
- 45
-
-
-
- 44
- WBB
- 0
- 0
- 0
- 0
- 0
-
-
-
- 1
- 44
-
-
-
- 45
- WBB52
- 0
- 1
- 1
- 0
- 0
-
-
-
- 1
- 40
-
-
+
+
+ 30
+ WBB
+ 0
+ 1
+ 1
+ 0
+ 0
+
+
+
+ 1
+ 30
+
+
+
+ 31
+ WBB
+ 0
+ 1
+ 1
+ 0
+ 1
+ postCountAction
+ postTop
+
+ 1
+ 31
+
+
+
+ 32
+ WBB
+ 0
+ 1
+ 0
+ 1
+ 0
+
+
+
+ 1
+ 32
+
+
+
+ 40
+ WBB
+ 1
+ 1
+ 0
+ 1
+ 0
+
+
+
+ 1
+ 41
+
+
+
+ 41
+ WBB
+ 0
+ 1
+ 1
+ 0
+ 0
+
+
+
+ 0
+ 42
+
+
+
+ 42
+ WBB
+ 0
+ 1
+ 1
+ 0
+ 0
+
+
+
+ 1
+ 43
+
+
+
+ 43
+ WBB
+ 1
+ 1
+ 0
+ 0
+ 0
+
+
+
+ 1
+ 45
+
+
+
+ 44
+ WBB
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 1
+ 44
+
+
+
+ 45
+ WBB52
+ 0
+ 1
+ 1
+ 0
+ 0
+
+
+
+ 1
+ 40
+
+