From 024a5ddabaddd05a11ec7f93abebb9e273670d91 Mon Sep 17 00:00:00 2001 From: vfilippov Date: Fri, 11 Dec 2009 15:09:49 +0000 Subject: [PATCH] Bug 48299 git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@580 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- informer.cgi | 106 ++++++++++++++++++ .../en/custom/bug/show-informer.html.tmpl | 51 --------- 2 files changed, 106 insertions(+), 51 deletions(-) create mode 100755 informer.cgi delete mode 100644 template/en/custom/bug/show-informer.html.tmpl diff --git a/informer.cgi b/informer.cgi new file mode 100755 index 000000000..81f1f803e --- /dev/null +++ b/informer.cgi @@ -0,0 +1,106 @@ +#!/usr/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Contributor(s): Vitaliy Filippov + +use utf8; +use strict; + +use lib qw(. lib); +use GD; +use GD::Text; +use GD::Text::Align; + +use Bugzilla; +use Bugzilla::Bug; +use Bugzilla::Status; +use Bugzilla::Util; +use Bugzilla::Constants; + +my $cgi = Bugzilla->cgi; +my $id = $cgi->param('id'); +my $user = Bugzilla->login(); +my $bug = Bugzilla::Bug->new($id); +my $str; +my $format = lc $cgi->param('format') || 'short'; +if (!$user || !$bug->{error} && !$user->can_see_bug($bug->bug_id)) +{ + # Access denied + $str = "#$id нет доступа"; + $bug = undef; +} +else +{ + # Bug description + my $as = $bug->assigned_to; + $as = $as && $as->login; + $as =~ s/\@.*$// if $as; + my $st = $bug->bug_status; + $st .= '/' . $bug->resolution if $bug->resolution; + if ($format eq 'long') + { + $str = '#' . $bug->bug_id . " [$as] $st " . $bug->bug_severity . ' ' . $bug->product . '/' . $bug->component . " " . $bug->short_desc; + } + else + { + $str = '#' . $bug->bug_id . " [$as] " . $st; + } + $str =~ s/\s{2,}/ /gso; +} + +# GD-говнокод +my $size = $cgi->param('fontsize'); +my $qual = 1; +$size = Bugzilla->params->{graph_font_size} || 9 if !$size || $size > 25; +$size *= 2 if $qual; +my $font = Bugzilla->params->{graph_font} || gdSmallFont; +my $gdt = GD::Text->new(text => $str, font => $font, ptsize => $size) || die GD::Text::error(); +my ($w, $h) = $gdt->get('width', 'height'); +$w++; +$h++; +my $gdi = GD::Image->new($w, $h); +my $white = $gdi->colorAllocate(255,255,255); +my $black = $gdi->colorAllocate(0,0,0); +my $fore = $black; +$fore = $gdi->colorAllocate(255,0,0) if !$bug || $bug->bug_severity eq 'critical' || $bug->bug_severity eq 'blocker'; +my $border = $fore; +$gdi->trueColor(1); +$gdi->alphaBlending(1); +$gdi->filledRectangle(0,0,$w-1,$h-1,$white); +$gdt = GD::Text::Align->new($gdi, valign => 'top', halign => 'left', text => $str, font => $font, ptsize => $size, color => $fore); +$gdt->draw(1, 1, 0); +if ($bug && $bug->bug_status eq 'VERIFIED') +{ + $border = $gdi->colorAllocate(0x2f/2,0x6f/2,0xab/2); + $gdi->setStyle(($border) x (3*($qual+1)), (gdTransparent) x (3*($qual+1))); + $gdi->rectangle(0,0,$w-1,$h-1,gdStyled); +} +elsif ($bug && $bug->bug_status eq 'CLOSED') +{ + $border = $gdi->colorAllocate(0x60,0x60,0x60); + $gdi->rectangle(0,0,$w-1,$h-1,$border); +} +if ($bug && !is_open_state($bug->bug_status)) +{ + $gdi->line(0, $h/2, $w-1, $h/2, $border); +} +if ($qual) +{ + my $i2 = GD::Image->new($w/2, $h/2); + $i2->copyResampled($gdi, 0, 0, 0, 0, $w/2, $h/2, $w, $h); + $gdi = $i2; +} + +$cgi->header('image/png'); +binmode STDOUT; +print $gdi->png; diff --git a/template/en/custom/bug/show-informer.html.tmpl b/template/en/custom/bug/show-informer.html.tmpl deleted file mode 100644 index 99849bd38..000000000 --- a/template/en/custom/bug/show-informer.html.tmpl +++ /dev/null @@ -1,51 +0,0 @@ -[%# The contents of this file are subject to the Mozilla Public - # License Version 1.1 (the "License"); you may not use this file - # except in compliance with the License. You may obtain a copy of - # the License at http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS - # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - # implied. See the License for the specific language governing - # rights and limitations under the License. - # - # The Original Code is the Bugzilla Bug Tracking System. - # - # The Initial Developer of the Original Code is Netscape Communications - # Corporation. Portions created by Netscape are - # Copyright (C) 1998 Netscape Communications Corporation. All - # Rights Reserved. - # - # Contributor(s): Gervase Markham - # Vaskin Kissoyan - # Bradley Baetz - # Max Kanat-Alexander - #%] - -[% PROCESS global/variables.none.tmpl %] -[%# This script/template only handles one bug #%] -[% bug = bugs.0 %] -[% IF !bug.error %] -[% filtered_desc = bug.short_desc FILTER html %] -[% filtered_timestamp = bug.delta_ts FILTER time %] - -[% "$terms.Bug $bug.bug_id – $filtered_desc" %] - -
-[% IF bug.bug_status == "RESOLVED" OR bug.bug_status == "CLOSED" OR bug.bug_status == "VERIFIED" %] - -[% END %] - [% terms.Bug %] [% bug.bug_id %]  - [% bug.product %]/[% bug.component %]  - [% IF bug.assigned_to %][[% bug.assigned_to.login %]][% END %] -[% IF bug.bug_status == "RESOLVED" OR bug.bug_status == "CLOSED" OR bug.bug_status == "VERIFIED" %] - -[% END %] -
- - -[% ELSE %] - -Unauthorized -Unauthorized to see Bug [% bug.bug_id %]. - -[% END %]