Move the rest of CustIS hooks to custishacks, remove "custis" extension

hinted-selects
Vitaliy Filippov 2014-08-18 18:16:36 +04:00
parent d235711747
commit 8ac317050d
3 changed files with 0 additions and 113 deletions

View File

@ -195,13 +195,11 @@ $Bugzilla::messages->{en} = {
'remind_me_about_worktime' => 'Remind me to track worktime for each comment',
'remind_me_about_worktime_newbug' => 'Remind me to track worktime for new bugs',
'remind_me_about_flags' => 'Remind me about flag requests',
'redirect_me_to_my_bugzilla' => 'Redirect me to my bugzilla',
'saved_searches_position' => 'Position of Saved Searches bar',
'footer' => 'Page footer',
'header' => 'Page header',
'both' => 'Both',
'csv_charset' => 'Character set for CSV import and export',
'email_weekly_worktime' => 'Email me weekly worktime report',
'silent_affects_flags' => 'Do not send flag email under Silent mode',
'send' => 'Send',
'do_not_send' => 'Don\'t send',

View File

@ -1,28 +0,0 @@
#!/usr/bin/perl
# Not really an extension -- can't be disabled, because many core files in our version
# depend on features implemented here.
# License: Dual-license GPL 3.0+ or MPL 1.1+
# Author: Vitaliy Filippov <vitalif@mail.ru>
# FIXME: Most of these 'non-disableable' features should be moved into core.
use strict;
use Bugzilla;
use Bugzilla::Hook;
use Bugzilla::Extension;
my $REQUIRED_MODULES = [];
my $OPTIONAL_MODULES = [];
required_modules('custis', $REQUIRED_MODULES);
optional_modules('custis', $OPTIONAL_MODULES);
clear_hooks('custis');
# Other hooks
set_hook('custis', 'flag_check_requestee_list', 'CustisMiscHooks::flag_check_requestee_list');
set_hook('custis', 'enter_bug_cloned_bug', 'CustisMiscHooks::enter_bug_cloned_bug');
set_hook('custis', 'post_bug_cloned_bug', 'CustisMiscHooks::post_bug_cloned_bug');
set_hook('custis', 'emailin_filter_body', 'CustisMiscHooks::emailin_filter_body');
1;
__END__

View File

@ -1,83 +0,0 @@
#!/usr/bin/perl
# Misc hooks:
# - Expand "group" users in flag requestee
# - Set cf_extbug automatically during bug cloning
# - Filter text body of input messages to remove Outlook link URLs
package CustisMiscHooks;
use strict;
use utf8;
use Bugzilla::User;
use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::Error;
# Expand CUSTIS-specific "group" users in flag requestee
sub flag_check_requestee_list
{
my ($args) = @_;
my $requestees = $args->{requestees};
if (@$requestees)
{
my $group_users = Bugzilla->dbh->selectall_arrayref(
'SELECT watcher.*, watched.login_name group_user FROM profiles watcher, watch, profiles watched WHERE watcher.userid=watch.watcher AND watched.userid=watch.watched AND watched.login_name IN ('.
join(',', ('?') x @$requestees).') AND watched.disable_mail>0 AND watched.realname LIKE \'Группа%\'', {Slice=>{}}, @$requestees
);
my %del = map { ($_->{group_user} => 1) } @$group_users;
@$requestees = ((grep { !$del{$_} } @$requestees), (map { $_->{login_name} } @$group_users));
}
return 1;
}
# Bug 69514 - Automatic setting of cf_extbug during clone to internal/external product
sub enter_bug_cloned_bug
{
my ($args) = @_;
if (($args->{product}->extproduct || 0) == $args->{cloned_bug}->product_id)
{
$args->{default}->{cf_extbug} = $args->{cloned_bug}->id;
}
elsif (($args->{cloned_bug}->product_obj->extproduct || 0) == $args->{product}->id)
{
$args->{default}->{dependson} = $args->{cloned_bug}->id;
$args->{default}->{blocked} = '';
}
return 1;
}
# Bug 69514 - Automatic setting of cf_extbug during clone to external product
sub post_bug_cloned_bug
{
my ($args) = @_;
if (($args->{cloned_bug}->product_obj->extproduct || 0) == $args->{bug}->product_id &&
!$args->{cloned_bug}->{cf_extbug})
{
$args->{cloned_bug}->{cf_extbug} = $args->{bug}->id;
}
return 1;
}
# Filter text body of input messages to remove Outlook link URLs.
sub emailin_filter_body
{
my ($args) = @_;
for (${$args->{body}})
{
if (/From:\s+bugzilla-daemon(\s*[a-z0-9_\-]+\s*:.*?\n)*\s*Bug\s*\d+<[^>]*>\s*\([^\)]*\)\s*/iso)
{
my ($pr, $ps) = ($`, $');
$ps =~ s/\n+(\r*\n+)+/\n/giso;
$_ = $pr . $ps;
s!from\s+.*?<http://plantime[^>]*search=([^>]*)>!from $1!giso;
s!((Comment|Bug)\s+\#?\d+)<[^<>]*>!$1!giso;
s!\n[^\n]*<http://plantime[^>]*search=[^>]*>\s+changed:[ \t\r]*\n.*?$!!iso;
s/\s*\n--\s*Configure\s*bugmail<[^>]*>(([ \t\r]*\n[^\n]*)*)//iso;
}
}
return 1;
}
1;
__END__