Skip to content

Commit

Permalink
add flag 'summary_as_comment'
Browse files Browse the repository at this point in the history
When setting this flag to true, the description is used as the comment.
Existing comments are not replaced.

closes #34
  • Loading branch information
tessus committed Feb 24, 2019
1 parent 08a0e4f commit dd1a29f
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions Mantis.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'url' => 'https://www.mediawiki.org/wiki/Extension:Mantis',
'description' => 'Mantis Bug Tracker integration',
'license-name' => 'GPL-2.0+',
'version' => '2.0.3'
'version' => '2.1.0'
);

// Configuration variables
Expand Down Expand Up @@ -191,33 +191,34 @@ function renderMantis( $input, $args, $mwParser )

$columnNames = 'id:b.id,project:p.name,category:c.name,severity:b.severity,priority:b.priority,status:b.status,username:u.username,created:b.date_submitted,updated:b.last_updated,summary:b.summary,fixed_in_version:b.fixed_in_version,version:b.version,target_version:b.target_version,resolution:b.resolution';

$conf['bugid'] = NULL;
$conf['table'] = 'sortable';
$conf['header'] = true;
$conf['color'] = true;
$conf['status'] = ['open'];
$conf['severity'] = NULL;
$conf['count'] = NULL;
$conf['orderby'] = 'b.last_updated';
$conf['order'] = 'desc';
$conf['dateformat'] = 'Y-m-d';
$conf['suppresserrors'] = false;
$conf['suppressinfo'] = false;
$conf['summarylength'] = NULL;
$conf['project'] = NULL;
$conf['category'] = NULL;
$conf['show'] = ['id','category','severity','status','updated','summary'];
$conf['comment'] = NULL;
$conf['fixed_in_version'] = NULL;
$conf['fixed_in_versionR'] = NULL;
$conf['version'] = NULL;
$conf['versionR'] = NULL;
$conf['target_version'] = NULL;
$conf['target_versionR'] = NULL;
$conf['username'] = NULL;
$conf['resolution'] = NULL;
$conf['headername'] = NULL;
$conf['align'] = NULL;
$conf['bugid'] = NULL;
$conf['table'] = 'sortable';
$conf['header'] = true;
$conf['color'] = true;
$conf['status'] = ['open'];
$conf['severity'] = NULL;
$conf['count'] = NULL;
$conf['orderby'] = 'b.last_updated';
$conf['order'] = 'desc';
$conf['dateformat'] = 'Y-m-d';
$conf['suppresserrors'] = false;
$conf['suppressinfo'] = false;
$conf['summarylength'] = NULL;
$conf['project'] = NULL;
$conf['category'] = NULL;
$conf['show'] = ['id','category','severity','status','updated','summary'];
$conf['comment'] = NULL;
$conf['fixed_in_version'] = NULL;
$conf['fixed_in_versionR'] = NULL;
$conf['version'] = NULL;
$conf['versionR'] = NULL;
$conf['target_version'] = NULL;
$conf['target_versionR'] = NULL;
$conf['username'] = NULL;
$conf['resolution'] = NULL;
$conf['headername'] = NULL;
$conf['align'] = NULL;
$conf['summary_as_comment'] = false;

$tableOptions = ['sortable', 'standard', 'noborder'];
$orderbyOptions = createArray($columnNames);
Expand Down Expand Up @@ -356,6 +357,7 @@ function renderMantis( $input, $args, $mwParser )
case 'suppressinfo':
case 'color':
case 'header':
case 'summary_as_comment':
if ($arg == 'true' || $arg == 'yes' || $arg == 'on')
{
$conf["$type"] = true;
Expand Down Expand Up @@ -928,7 +930,7 @@ function renderMantis( $input, $args, $mwParser )
$header = ($conf['headername'][$colname] ? $conf['headername'][$colname] : ucfirst($colname));
$output .= "!".ucfirst($header)."\n";
}
if (!empty($conf['comment']))
if (!empty($conf['comment']) || $conf['summary_as_comment'])
{
$output .= "!Comment\n";
}
Expand Down Expand Up @@ -1006,18 +1008,24 @@ function renderMantis( $input, $args, $mwParser )
break;
}
}
if (!empty($conf['comment']))
if (!empty($conf['comment']) || $conf['summary_as_comment'])
{
$comment = '';
$output .= sprintf($format, $color, 'left');

if (array_key_exists($row['id'], $conf['comment']))
if ($conf['summary_as_comment'])
{
$output .= $conf['comment'][$row['id']]."\n";
$comment = $row['summary'];
if ($conf['summarylength'] && (strlen($comment) > $conf['summarylength']))
{
$comment = trim(substr($row['summary'], 0, $conf['summarylength']))."...";
}
}
else
if (array_key_exists($row['id'], $conf['comment']))
{
$output .= "\n";
$comment = $conf['comment'][$row['id']];
}
$output .= $comment."\n";
}
}
// create table end
Expand Down

0 comments on commit dd1a29f

Please sign in to comment.