Aklapper has uploaded a new change for review. https://gerrit.wikimedia.org/r/106713
Change subject: [4.4] Apply custom changes to attachment.cgi ...................................................................... [4.4] Apply custom changes to attachment.cgi DO NOT COMMIT until Bugzilla has been upgraded to 4.4. This file is an upstream copy of Bugzilla 4.4 code in http://bzr.mozilla.org/bugzilla/4.4/view/head:/attachment.cgi with our custom changes applied for https://bugzilla.wikimedia.org/show_bug.cgi?id=54181 Change-Id: I9c609492b5d294eca6fcca61477f55e1de8e8b1b --- M attachment.cgi 1 file changed, 52 insertions(+), 69 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/bugzilla/modifications refs/changes/13/106713/1 diff --git a/attachment.cgi b/attachment.cgi index e271d50..769c47f 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -1,33 +1,10 @@ #!/usr/bin/perl -wT -# -*- Mode: perl; indent-tabs-mode: nil -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.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): Terry Weissman <te...@mozilla.org> -# Myk Melez <m...@mozilla.org> -# Daniel Raichle <draic...@gmx.net> -# Dave Miller <justd...@syndicomm.com> -# Alexander J. Vincent <ajvinc...@juno.com> -# Max Kanat-Alexander <mka...@bugzilla.org> -# Greg Hendricks <ghendri...@novell.com> -# Frédéric Buclin <lpso...@gmail.com> -# Marc Schumann <wurbl...@gmail.com> -# Byron Jones <bugzi...@glob.com.au> +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. ################################################################################ # Script Initialization @@ -459,9 +436,8 @@ sub viewall { # Retrieve and validate parameters my $bug = Bugzilla::Bug->check(scalar $cgi->param('bugid')); - my $bugid = $bug->id; - my $attachments = Bugzilla::Attachment->get_attachments_by_bug($bugid); + my $attachments = Bugzilla::Attachment->get_attachments_by_bug($bug); # Ignore deleted attachments. @$attachments = grep { $_->datasize } @$attachments; @@ -483,40 +459,51 @@ # Display a form for entering a new attachment. sub enter { - # Retrieve and validate parameters - my $bug = Bugzilla::Bug->check(scalar $cgi->param('bugid')); - my $bugid = $bug->id; - Bugzilla::Attachment->_check_bug($bug); - my $dbh = Bugzilla->dbh; - my $user = Bugzilla->user; + # Retrieve and validate parameters + my $bug = Bugzilla::Bug->check(scalar $cgi->param('bugid')); + my $bugid = $bug->id; + Bugzilla::Attachment->_check_bug($bug); + my $dbh = Bugzilla->dbh; + my $user = Bugzilla->user; - # Retrieve the attachments the user can edit from the database and write - # them into an array of hashes where each hash represents one attachment. - my $canEdit = ""; - if (!$user->in_group('editbugs', $bug->product_id)) { - $canEdit = "AND submitter_id = " . $user->id; - } - my $attach_ids = $dbh->selectcol_arrayref("SELECT attach_id FROM attachments - WHERE bug_id = ? AND isobsolete = 0 $canEdit - ORDER BY attach_id", undef, $bugid); + # Retrieve the attachments the user can edit from the database and write + # them into an array of hashes where each hash represents one attachment. + + my ($can_edit, $not_private) = ('', ''); + if (!$user->in_group('editbugs', $bug->product_id)) { + $can_edit = "AND submitter_id = " . $user->id; + } + if (!$user->is_insider) { + $not_private = "AND isprivate = 0"; + } + my $attach_ids = $dbh->selectcol_arrayref( + "SELECT attach_id + FROM attachments + WHERE bug_id = ? + AND isobsolete = 0 + $can_edit $not_private + ORDER BY attach_id", + undef, $bugid); - # Define the variables and functions that will be passed to the UI template. - $vars->{'bug'} = $bug; - $vars->{'attachments'} = Bugzilla::Attachment->new_from_list($attach_ids); + # Define the variables and functions that will be passed to the UI template. + $vars->{'bug'} = $bug; + $vars->{'attachments'} = Bugzilla::Attachment->new_from_list($attach_ids); - my $flag_types = Bugzilla::FlagType::match({'target_type' => 'attachment', - 'product_id' => $bug->product_id, - 'component_id' => $bug->component_id}); - $vars->{'flag_types'} = $flag_types; - $vars->{'any_flags_requesteeble'} = - grep { $_->is_requestable && $_->is_requesteeble } @$flag_types; - $vars->{'token'} = issue_session_token('create_attachment'); + my $flag_types = Bugzilla::FlagType::match({ + 'target_type' => 'attachment', + 'product_id' => $bug->product_id, + 'component_id' => $bug->component_id + }); + $vars->{'flag_types'} = $flag_types; + $vars->{'any_flags_requesteeble'} = + grep { $_->is_requestable && $_->is_requesteeble } @$flag_types; + $vars->{'token'} = issue_session_token('create_attachment'); - print $cgi->header(); + print $cgi->header(); - # Generate and return the UI (HTML page) from the appropriate template. - $template->process("attachment/create.html.tmpl", $vars) - || ThrowTemplateError($template->error()); + # Generate and return the UI (HTML page) from the appropriate template. + $template->process("attachment/create.html.tmpl", $vars) + || ThrowTemplateError($template->error()); } # Insert a new attachment into the database. @@ -597,6 +584,8 @@ $owner = $bug->assigned_to->login; $bug->set_assigned_to($user); } + + $bug->add_cc($user) if $cgi->param('addselfcc'); $bug->update($timestamp); $dbh->bz_commit_transaction; @@ -626,9 +615,7 @@ my $attachment = validateID(); my $bugattachments = - Bugzilla::Attachment->get_attachments_by_bug($attachment->bug_id); - # We only want attachment IDs. - @$bugattachments = map { $_->id } @$bugattachments; + Bugzilla::Attachment->get_attachments_by_bug($attachment->bug); my $any_flags_requesteeble = grep { $_->is_requestable && $_->is_requesteeble } @{$attachment->flag_types}; @@ -677,8 +664,7 @@ if ($delta_ts && $delta_ts ne $modification_time) { datetime_from($delta_ts) or ThrowCodeError('invalid_timestamp', { timestamp => $delta_ts }); - ($vars->{'operations'}) = - Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $delta_ts); + ($vars->{'operations'}) = $bug->get_activity($attachment->id, $delta_ts); # If the modification date changed but there is no entry in # the activity table, this means someone commented only. @@ -712,6 +698,8 @@ type => CMT_ATTACHMENT_UPDATED, extra_data => $attachment->id }); } + + $bug->add_cc($user) if $cgi->param('addselfcc'); if ($can_edit) { my ($flags, $new_flags) = @@ -787,7 +775,6 @@ # The token is valid. Delete the content of the attachment. my $msg; $vars->{'attachment'} = $attachment; - $vars->{'date'} = $date; $vars->{'reason'} = clean_text($cgi->param('reason') || ''); $template->process("attachment/delete_reason.txt.tmpl", $vars, \$msg) @@ -796,10 +783,6 @@ # Paste the reason provided by the admin into a comment. $bug->add_comment($msg); - # If the attachment is stored locally, remove it. - if (-e $attachment->_get_local_filename) { - unlink $attachment->_get_local_filename; - } $attachment->remove_from_db(); # Now delete the token. -- To view, visit https://gerrit.wikimedia.org/r/106713 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9c609492b5d294eca6fcca61477f55e1de8e8b1b Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/bugzilla/modifications Gerrit-Branch: master Gerrit-Owner: Aklapper <aklap...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits