Skip to content

Commit

Permalink
Update SlackNotificationsCore.php
Browse files Browse the repository at this point in the history
  • Loading branch information
paladox authored May 12, 2020
1 parent bfd2a9a commit 19cbf18
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions SlackNotificationsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ class SlackNotifications
*/
static function getSlackUserText($user)
{
global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingUserPage,
$wgWikiUrlEndingBlockUser, $wgWikiUrlEndingUserRights,
$wgWikiUrlEndingUserTalkPage, $wgWikiUrlEndingUserContributions,
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgSlackNotificationWikiUrlEndingUserPage,
$wgSlackNotificationWikiUrlEndingBlockUser, $wgSlackNotificationWikiUrlEndingUserRights,
$wgSlackNotificationWikiUrlEndingUserTalkPage, $wgSlackNotificationWikiUrlEndingUserContributions,
$wgSlackIncludeUserUrls;

if ($wgSlackIncludeUserUrls)
{
return sprintf(
"%s (%s | %s | %s | %s)",
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingUserPage.$user."|$user>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingBlockUser.$user."|block>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingUserRights.$user."|groups>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingUserTalkPage.$user."|talk>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingUserContributions.$user."|contribs>");
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingUserPage.$user."|$user>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingBlockUser.$user."|block>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingUserRights.$user."|groups>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingUserTalkPage.$user."|talk>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingUserContributions.$user."|contribs>");
}
else
{
return "<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingUserPage.$user."|$user>";
return "<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingUserPage.$user."|$user>";
}
}

Expand All @@ -34,25 +34,25 @@ static function getSlackUserText($user)
*/
static function getSlackArticleText(WikiPage $article, $diff = false)
{
global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingEditArticle,
$wgWikiUrlEndingDeleteArticle, $wgWikiUrlEndingHistory,
$wgWikiUrlEndingDiff, $wgSlackIncludePageUrls;
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgSlackNotificationWikiUrlEndingEditArticle,
$wgSlackNotificationWikiUrlEndingDeleteArticle, $wgSlackNotificationWikiUrlEndingHistory,
$wgSlackNotificationWikiUrlEndingDiff, $wgSlackIncludePageUrls;

$prefix = "<".$wgWikiUrl.$wgWikiUrlEnding.str_replace(" ", "_", $article->getTitle()->getFullText());
$prefix = "<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.str_replace(" ", "_", $article->getTitle()->getFullText());
if ($wgSlackIncludePageUrls)
{
$out = sprintf(
"%s (%s | %s | %s",
$prefix."|".$article->getTitle()->getFullText().">",
$prefix."&".$wgWikiUrlEndingEditArticle."|edit>",
$prefix."&".$wgWikiUrlEndingDeleteArticle."|delete>",
$prefix."&".$wgWikiUrlEndingHistory."|history>"/*,
$prefix."&".$wgSlackNotificationWikiUrlEndingEditArticle."|edit>",
$prefix."&".$wgSlackNotificationWikiUrlEndingDeleteArticle."|delete>",
$prefix."&".$wgSlackNotificationWikiUrlEndingHistory."|history>"/*,
"move",
"protect",
"watch"*/);
if ($diff)
{
$out .= " | ".$prefix."&".$wgWikiUrlEndingDiff.$article->getRevision()->getID()."|diff>)";
$out .= " | ".$prefix."&".$wgSlackNotificationWikiUrlEndingDiff.$article->getRevision()->getID()."|diff>)";
}
else
{
Expand All @@ -72,26 +72,26 @@ static function getSlackArticleText(WikiPage $article, $diff = false)
*/
static function getSlackTitleText(Title $title)
{
global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingEditArticle,
$wgWikiUrlEndingDeleteArticle, $wgWikiUrlEndingHistory,
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgSlackNotificationWikiUrlEndingEditArticle,
$wgSlackNotificationWikiUrlEndingDeleteArticle, $wgSlackNotificationWikiUrlEndingHistory,
$wgSlackIncludePageUrls;

$titleName = $title->getFullText();
if ($wgSlackIncludePageUrls)
{
return sprintf(
"%s (%s | %s | %s)",
"<".$wgWikiUrl.$wgWikiUrlEnding.$titleName."|".$titleName.">",
"<".$wgWikiUrl.$wgWikiUrlEnding.$titleName."&".$wgWikiUrlEndingEditArticle."|edit>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$titleName."&".$wgWikiUrlEndingDeleteArticle."|delete>",
"<".$wgWikiUrl.$wgWikiUrlEnding.$titleName."&".$wgWikiUrlEndingHistory."|history>"/*,
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$titleName."|".$titleName.">",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$titleName."&".$wgSlackNotificationWikiUrlEndingEditArticle."|edit>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$titleName."&".$wgSlackNotificationWikiUrlEndingDeleteArticle."|delete>",
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$titleName."&".$wgSlackNotificationWikiUrlEndingHistory."|history>"/*,
"move",
"protect",
"watch"*/);
}
else
{
return "<".$wgWikiUrl.$wgWikiUrlEnding.$titleName."|".$titleName.">";
return "<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$titleName."|".$titleName.">";
}
}

Expand Down Expand Up @@ -324,11 +324,11 @@ static function slack_file_uploaded($image)
global $wgSlackNotificationFileUpload;
if (!$wgSlackNotificationFileUpload) return;

global $wgWikiUrl, $wgWikiUrlEnding, $wgUser;
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgUser;
$message = sprintf(
"%s has uploaded file <%s|%s> (format: %s, size: %s MB, summary: %s)",
self::getSlackUserText($wgUser->mName),
$wgWikiUrl . $wgWikiUrlEnding . $image->getLocalFile()->getTitle(),
$wgSlackNotificationWikiUrl . $wgSlackNotificationWikiUrlEnding . $image->getLocalFile()->getTitle(),
$image->getLocalFile()->getTitle(),
$image->getLocalFile()->getMimeType(),
round($image->getLocalFile()->size / 1024 / 1024, 3),
Expand All @@ -347,14 +347,14 @@ static function slack_user_blocked(Block $block, $user)
global $wgSlackNotificationBlockedUser;
if (!$wgSlackNotificationBlockedUser) return;

global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingBlockList;
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgSlackNotificationWikiUrlEndingBlockList;
$message = sprintf(
"%s has blocked %s %s Block expiration: %s. %s",
self::getSlackUserText($user),
self::getSlackUserText($block->getTarget()),
$block->mReason == "" ? "" : "with reason '".$block->mReason."'.",
$block->mExpiry,
"<".$wgWikiUrl.$wgWikiUrlEnding.$wgWikiUrlEndingBlockList."|List of all blocks>.");
"<".$wgSlackNotificationWikiUrl.$wgSlackNotificationWikiUrlEnding.$wgSlackNotificationWikiUrlEndingBlockList."|List of all blocks>.");
self::push_slack_notify($message, "red", $user);
return true;
}
Expand All @@ -368,7 +368,7 @@ static function slack_user_groups_changed(User $user, array $added, array $remov
global $wgSlackNotificationUserGroupsChanged;
if (!$wgSlackNotificationUserGroupsChanged) return;

global $wgWikiUrl, $wgWikiUrlEnding, $wgWikiUrlEndingUserRights;
global $wgSlackNotificationWikiUrl, $wgSlackNotificationWikiUrlEnding, $wgSlackNotificationWikiUrlEndingUserRights;
$message = sprintf(
"%s has changed user groups for %s. New groups: %s",
self::getSlackUserText($performer),
Expand Down

0 comments on commit 19cbf18

Please sign in to comment.