Skip to content

Commit

Permalink
php8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Takika committed Dec 29, 2022
1 parent 7e89e4a commit c1d7f0f
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions rc_bugheader.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
* Show additional informations from bugtracker mails
*
* @version 0.2
Expand All @@ -11,11 +11,11 @@ class rc_bugheader extends rcube_plugin
{
public $task = 'mail';

private $_bugMailHeaders = array(
private $_bugMailHeaders = [
'X-Trac-Ticket-URL',
'X-Trac-Ticket-ID',
'X-SourceForge-Tracker-itemid'
);
];

function init()
{
Expand All @@ -42,59 +42,64 @@ function message_headers_output($p)
$title = '';
$value = '';

$tracTicketId = $p['headers']->others['x-trac-ticket-id'];
if (!empty($tracTicketId)) {
if (isset($p['headers']->others['x-trac-ticket-id']) && !empty($p['headers']->others['x-trac-ticket-id'])) {
$tracTicketId = $p['headers']->others['x-trac-ticket-id'];
// If Trac Ticket
$title = 'Trac Ticket';
$tracTicketId = '#' . $tracTicketId;
$tracTicketUrl = $p['headers']->others['x-trac-ticket-url'];
if (!empty($tracTicketUrl)) {
// If has a Trac Ticket URL
$value = '<a href="' . rcube::Q($tracTicketUrl) . '" target="_blank">' . rcube::Q($tracTicketId) . '</a>';
} else {
//If NOT has ticket URL
$value = rcube::Q($tracTicketId);
if (isset($p['headers']->others['x-trac-ticket-url'])) {
$tracTicketUrl = $p['headers']->others['x-trac-ticket-url'];
if (!empty($tracTicketUrl)) {
// If has a Trac Ticket URL
$value = '<a href="' . rcube::Q($tracTicketUrl) . '" target="_blank">' . rcube::Q($tracTicketId) . '</a>';
} else {
//If NOT has ticket URL
$value = rcube::Q($tracTicketId);
}
}
}

$sfTrackerItemId = $p['headers']->others['x-sourceforge-tracker-itemid'];
if (!empty($sfTrackerItemId)) {
if (isset($p['headers']->others['x-sourceforge-tracker-itemid']) && !empty($p['headers']->others['x-sourceforge-tracker-itemid'])) {
$sfTrackerItemId = $p['headers']->others['x-sourceforge-tracker-itemid'];
// If SourceForge tracker item
$title = 'Tracker ID';
$value = '<a href="http://sourceforge.net/support/tracker.php?aid=' . rcube::Q($sfTrackerItemId) . '" target="_blank">' . rcube::Q($sfTrackerItemId) . '</a>';
}

$references = $p['headers']->references;
if (preg_match('#<(\w+)/(\w+)/commit/(\w+)@github\.com>#i', $references, $matches)) {
// If GitHub Commit
$title = 'GitHub Commit';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/commit/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
}
if (isset($p['headers']->references)) {
$references = $p['headers']->references;
if (preg_match('#<(\w+)/(\w+)/commit/(\w+)@github\.com>#i', $references, $matches)) {
// If GitHub Commit
$title = 'GitHub Commit';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/commit/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
}

if (preg_match('#<(\w+)/(\w+)/issues/(\w+)@github\.com>#i', $references, $matches)) {
// If GitHub Issue
$title = 'GitHub Issue';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/issues/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
if (preg_match('#<(\w+)/(\w+)/issues/(\w+)@github\.com>#i', $references, $matches)) {
// If GitHub Issue
$title = 'GitHub Issue';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/issues/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
}
}

$message_id = $p['headers']->messageID;
if (preg_match('#<(\w+)/(\w+)/pull/(\w+)@github\.com>#i', $message_id, $matches)) {
// If GitHub Pull request
$title = 'GitHub Pull';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/pull/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
if (isset($p['headers']->messageID)) {
$message_id = $p['headers']->messageID;
if (preg_match('#<(\w+)/(\w+)/pull/(\w+)@github\.com>#i', $message_id, $matches)) {
// If GitHub Pull request
$title = 'GitHub Pull';
$value = '<a href="https://github.com/' . rcube::Q($matches[1]) . '/' . rcube::Q($matches[2]) . '/pull/' . rcube::Q($matches[3]) . '" target="_blank">' . rcube::Q($matches[3]) . '</a>';
}
}

if (!empty($title) && !empty($value)) {
//if bug header found...
$p['output'][$key] = array(
$p['output'][$key] = [
'title' => $title,
'value' => $value,
'html' => true
);
];
}

return $p;
}

}
?>

0 comments on commit c1d7f0f

Please sign in to comment.