Skip to content

Commit

Permalink
cleanup and rewrite of error message code
Browse files Browse the repository at this point in the history
  • Loading branch information
tessus committed Jan 11, 2015
1 parent bc23e73 commit 4e0241f
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions Mantis.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* https://www.mediawiki.org/wiki/Extension:Mantis
* https://github.com/tessus/mwExtensionMantis
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
Expand Down Expand Up @@ -460,24 +460,50 @@ function renderMantis( $input, $args, $mwParser )
}
else
{
// status set
$useAnd = false;
$errmsg = "No MANTIS entries with ";

if ($conf['status'])
{
$errmsg = sprintf("No MANTIS entries with status '%s' found.\n", $conf['status']);
// status and severity set
if ($conf['severity'])
$errmsg .= sprintf("status '%s'", $conf['status']);
$useAnd = true;
}

if ($conf['severity'])
{
if ($useAnd)
{
$errmsg = sprintf("No MANTIS entries with status '%s' and severity '%s' found.\n", $conf['status'], $conf['severity']);
$errmsg .= " and ";
}
$errmsg .= sprintf("severity '%s'", $conf['severity']);
$useAnd = true;
}
else

if ($conf['category'])
{
$errmsg = sprintf("No MANTIS entries found.\n");
// severity set
if ($conf['severity'])
if ($useAnd)
{
$errmsg = sprintf("No MANTIS entries with severity '%s' found.\n", $conf['severity']);
$errmsg .= " and ";
}
$errmsg .= sprintf("category '%s'", implode("'", $conf['category']));
$useAnd = true;
}

if ($conf['project'])
{
if ($useAnd)
{
$errmsg .= " and ";
}
$errmsg .= sprintf("project '%s'", implode("'", $conf['project']));
$useAnd = true;
}

$errmsg .= " found.\n";

if (!$useAnd)
{
$errmsg = sprintf("No MANTIS entries found.\n");
}
}
$result->free();
Expand Down

0 comments on commit 4e0241f

Please sign in to comment.