UltrasonicNXT has uploaded a new change for review.
https://gerrit.wikimedia.org/r/103097
Change subject: Add logging
......................................................................
Add logging
Log events (category, forum, thread, and reply creations) to
Special:Log/forum, and optionally to the recent changes via
$wgWikiForumLogInRC
Change-Id: Idfca0a8f1898b1238ade6a031e08d0e923ecb9ed
---
M WikiForum.i18n.php
M WikiForum.php
M WikiForumClass.php
3 files changed, 79 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiForum
refs/changes/97/103097/1
diff --git a/WikiForum.i18n.php b/WikiForum.i18n.php
index 77ad9b2..270e0c3 100644
--- a/WikiForum.i18n.php
+++ b/WikiForum.i18n.php
@@ -116,6 +116,15 @@
'group-forumadmin.css' => '/* CSS placed here will affect forum
administrators only */', # only translate this message to other languages if
you have to change it
'group-forumadmin.js' => '/* JS placed here will affect forum
administrators only */', # only translate this message to other languages if
you have to change it
+
+ // Logging messages
+ 'log-name-forum' => 'Forum log',
+ 'log-description-forum' => 'Logs [[Special:WikiForum|WikiForum]]
events',
+
+ 'logentry-forum-add-category' => '$1 {{GENDER:$1|created}} a new
category, $4',
+ 'logentry-forum-add-forum' => '$1 {{GENDER:$1|created}} a new forum,
$4',
+ 'logentry-forum-add-thread' => '$1 {{GENDER:$1|created}} a new thread,
$4',
+ 'logentry-forum-add-reply' => '$1 {{GENDER:$1|replied}} on the thread
$4',
);
/** Message documentation (Message documentation)
@@ -281,6 +290,14 @@
'grouppage-forumadmin' => '{{doc-group|forumadmin|page}}',
'group-forumadmin.css' => '{{doc-group|forumadmin|css}}',
'group-forumadmin.js' => '{{doc-group|forumadmin|js}}',
+
+ 'log-name-forum' => 'Title for the forum log',
+ 'log-description-forum' => 'Description of the forum log to be shown on
Special:Log/forum',
+
+ 'logentry-forum-add-category' => 'Shown when the user $1 created a new
category, $4',
+ 'logentry-forum-add-forum' => 'Shown when the user $1 created a new
forum, $4',
+ 'logentry-forum-add-thread' => 'Shown when the user $1 created a new
thread, $4',
+ 'logentry-forum-add-reply' => 'Shown when the user $1 replied on the
thread $4',
);
/** Afrikaans (Afrikaans)
@@ -2593,7 +2610,7 @@
'wikiforum-announcement-only-description' => 'Aankondigingenforum
(alleen forummoderatoren kunnen nieuwe berichten plaatsen)',
'wikiforum-by' => '$1<br />door {{GENDER:$3|$2}}',
'wikiforum-description' => 'Beschrijving:',
- 'wikiforum-forum-is-empty' => 'Dit forum is op het moment leeg.
+ 'wikiforum-forum-is-empty' => 'Dit forum is op het moment leeg.
Neem contact op met een forumbeheerder om categorieën en forums toe te
voegen.',
'wikiforum-forum-name' => 'Forum $1',
'wikiforum-name' => 'Naam:',
diff --git a/WikiForum.php b/WikiForum.php
index 173e33a..e1331c8 100644
--- a/WikiForum.php
+++ b/WikiForum.php
@@ -81,6 +81,9 @@
*/
);
+// Show the forum log in RecentChanges?
+$wgWikiForumLogInRC = true;
+
// ResourceLoader support for MediaWiki 1.17+
$wgResourceModules['ext.wikiForum'] = array(
'styles' => 'styles.css',
@@ -93,4 +96,8 @@
$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] =
'WikiForumHooks::addNavigationLink';
$wgHooks['SkinTemplateToolboxEnd'][] =
'WikiForumHooks::addNavigationLinkToToolbox';
$wgHooks['BeforePageDisplay'][] = 'WikiForumHooks::addStyles';
-$wgHooks['LoadExtensionSchemaUpdates'][] = 'WikiForumHooks::addTables';
\ No newline at end of file
+$wgHooks['LoadExtensionSchemaUpdates'][] = 'WikiForumHooks::addTables';
+
+// Logging
+$wgLogTypes[] = 'forum';
+$wgLogActionsHandlers['forum/*'] = 'LogFormatter';
\ No newline at end of file
diff --git a/WikiForumClass.php b/WikiForumClass.php
index 6cdad4c..72c4a8e 100644
--- a/WikiForumClass.php
+++ b/WikiForumClass.php
@@ -532,7 +532,7 @@
}
function addThread( $forumId, $title, $text ) {
- global $wgRequest, $wgUser, $wgWikiForumAllowAnonymous;
+ global $wgRequest, $wgUser, $wgWikiForumAllowAnonymous,
$wgWikiForumLogInRC, $wgLang;
if ( $wgWikiForumAllowAnonymous || $wgUser->isLoggedIn() ) {
if (
@@ -604,6 +604,18 @@
array(
'wff_forum' => $forumId ),
__METHOD__
);
+ $logEntry = new
ManualLogEntry( 'forum', 'add-thread' );
+
$logEntry->setPerformer( $wgUser );
+
$logEntry->setTarget( SpeciaLPage::getTitleFor( 'wikiforum' ) );
+ $shortText =
$wgLang->truncate( $text, 50 );
+
$logEntry->setComment( $shortText );
+
$logEntry->setParameters( array(
+
'4::thread-name' => $title,
+ ) );
+ $logid =
$logEntry->insert();
+ if (
$wgWikiForumLogInRC ) {
+
$logEntry->publish( $logid );
+ }
$this->result =
true;
} else {
$this->result =
false;
@@ -723,7 +735,7 @@
* @param $text String: reply text
*/
function addReply( $threadId, $text ) {
- global $wgRequest, $wgUser, $wgWikiForumAllowAnonymous;
+ global $wgRequest, $wgUser, $wgWikiForumAllowAnonymous,
$wgWikiForumLogInRC, $wgLang;
$timestamp = wfTimestampNow();
@@ -788,7 +800,7 @@
$pkForum =
$dbr->selectRow(
'wikiforum_threads',
-
'wft_forum',
+ array(
'wft_forum, wft_thread_name' ),
array(
'wft_thread' => $threadId ),
__METHOD__
);
@@ -798,6 +810,19 @@
array(
'wff_forum' => $pkForum->wft_forum ),
__METHOD__
);
+
+ $logEntry = new
ManualLogEntry( 'forum', 'add-reply' );
+
$logEntry->setPerformer( $wgUser );
+
$logEntry->setTarget( SpeciaLPage::getTitleFor( 'wikiforum' ) );
+ $shortText =
$wgLang->truncate( $text, 50 );
+
$logEntry->setComment( $shortText );
+
$logEntry->setParameters( array(
+
'4::thread-name' => $pkForum->wft_thread_name,
+ ) );
+ $logid =
$logEntry->insert();
+ if (
$wgWikiForumLogInRC ) {
+
$logEntry->publish( $logid );
+ }
$this->result =
true;
} else {
@@ -834,7 +859,7 @@
}
function addCategory( $categoryName ) {
- global $wgRequest, $wgUser;
+ global $wgRequest, $wgUser, $wgWikiForumLogInRC, $wgLang;
if (
$wgUser->isAllowed( 'wikiforum-admin' ) &&
@@ -863,6 +888,16 @@
),
__METHOD__
);
+ $logEntry = new ManualLogEntry( 'forum',
'add-category' );
+ $logEntry->setPerformer( $wgUser );
+ $logEntry->setTarget( SpeciaLPage::getTitleFor(
'wikiforum' ) );
+ $logEntry->setParameters( array(
+ '4::category-name' =>
$categoryName,
+ ) );
+ $logid = $logEntry->insert();
+ if ( $wgWikiForumLogInRC ) {
+ $logEntry->publish( $logid );
+ }
} else {
$this->errorMessage = wfMessage(
'wikiforum-no-text-or-title' )->text();
$this->result = false;
@@ -934,7 +969,7 @@
}
function addForum( $categoryId, $forumName, $description, $announcement
) {
- global $wgRequest, $wgUser;
+ global $wgRequest, $wgUser, $wgWikiForumLogInRC, $wgLang;
if ( strlen( $forumName ) < 0 ) {
$this->errorMessage = wfMessage(
'wikiforum-no-text-or-title' )->text();
@@ -983,6 +1018,19 @@
),
__METHOD__
);
+
+ $logEntry = new ManualLogEntry( 'forum',
'add-forum' );
+ $logEntry->setPerformer( $wgUser );
+ $logEntry->setTarget( SpeciaLPage::getTitleFor(
'wikiforum' ) );
+ $shortText = $wgLang->truncate( $description,
50 );
+ $logEntry->setComment( $shortText );
+ $logEntry->setParameters( array(
+ '4::forum-name' => $forumName,
+ ) );
+ $logid = $logEntry->insert();
+ if ( $wgWikiForumLogInRC ) {
+ $logEntry->publish( $logid );
+ }
} else {
$this->errorMessage = wfMessage(
'wikiforum-error-not-found' )->text();
$this->result = false;
--
To view, visit https://gerrit.wikimedia.org/r/103097
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfca0a8f1898b1238ade6a031e08d0e923ecb9ed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiForum
Gerrit-Branch: master
Gerrit-Owner: UltrasonicNXT <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits