bugzilla-4intranet/docs/en/html/api/Bugzilla/Attachment.html

295 lines
8.0 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Bugzilla::Attachment</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" title="style" type="text/css" href=".././../../../style.css" media="all" >
</head>
<body id="pod">
<p class="backlinktop"><b><a name="___top" href="../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
<h1>Bugzilla::Attachment</h1>
<div class='indexgroup'>
<ul class='indexList indexList1'>
<li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
<li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
<li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
<ul class='indexList indexList2'>
<li class='indexItem indexItem2'><a href='#Instance_Properties'>Instance Properties</a>
<li class='indexItem indexItem2'><a href='#Class_Methods'>Class Methods</a>
</ul>
</ul>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>
<p>Bugzilla::Attachment - Bugzilla attachment class.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre class="code"> use Bugzilla::Attachment;
# Get the attachment with the given ID.
my $attachment = new Bugzilla::Attachment($attach_id);
# Get the attachments with the given IDs.
my $attachments = Bugzilla::Attachment-&#62;new_from_list($attach_ids);</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>Attachment.pm represents an attachment object. It is an implementation of <a href="../Bugzilla/Object.html" class="podlinkpod"
>Bugzilla::Object</a>, and thus provides all methods that <a href="../Bugzilla/Object.html" class="podlinkpod"
>Bugzilla::Object</a> provides.</p>
<p>The methods that are specific to <code class="code">Bugzilla::Attachment</code> are listed below.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="Instance_Properties"
>Instance Properties</a></h2>
<dl>
<dt><a name="bug_id"
><code class="code">bug_id</code></a></dt>
<dd>
<p>the ID of the bug to which the attachment is attached</p>
</dd>
</dl>
<dl>
<dt><a name="bug"
><code class="code">bug</code></a></dt>
<dd>
<p>the bug object to which the attachment is attached</p>
</dd>
</dl>
<dl>
<dt><a name="description"
><code class="code">description</code></a></dt>
<dd>
<p>user-provided text describing the attachment</p>
</dd>
</dl>
<dl>
<dt><a name="contenttype"
><code class="code">contenttype</code></a></dt>
<dd>
<p>the attachment&#39;s MIME media type</p>
</dd>
</dl>
<dl>
<dt><a name="attacher"
><code class="code">attacher</code></a></dt>
<dd>
<p>the user who attached the attachment</p>
</dd>
</dl>
<dl>
<dt><a name="attached"
><code class="code">attached</code></a></dt>
<dd>
<p>the date and time on which the attacher attached the attachment</p>
</dd>
</dl>
<dl>
<dt><a name="modification_time"
><code class="code">modification_time</code></a></dt>
<dd>
<p>the date and time on which the attachment was last modified.</p>
</dd>
</dl>
<dl>
<dt><a name="filename"
><code class="code">filename</code></a></dt>
<dd>
<p>the name of the file the attacher attached</p>
</dd>
</dl>
<dl>
<dt><a name="ispatch"
><code class="code">ispatch</code></a></dt>
<dd>
<p>whether or not the attachment is a patch</p>
</dd>
</dl>
<dl>
<dt><a name="isurl"
><code class="code">isurl</code></a></dt>
<dd>
<p>whether or not the attachment is a URL</p>
</dd>
</dl>
<dl>
<dt><a name="isobsolete"
><code class="code">isobsolete</code></a></dt>
<dd>
<p>whether or not the attachment is obsolete</p>
</dd>
</dl>
<dl>
<dt><a name="isprivate"
><code class="code">isprivate</code></a></dt>
<dd>
<p>whether or not the attachment is private</p>
</dd>
</dl>
<dl>
<dt><a name="is_viewable"
><code class="code">is_viewable</code></a></dt>
<dd>
<p>Returns 1 if the attachment has a content-type viewable in this browser. Note that we don&#39;t use $cgi-&#62;Accept()&#39;s ability to check if a content-type matches, because this will return a value even if it&#39;s matched by the generic */* which most browsers add to the end of their Accept: headers.</p>
</dd>
</dl>
<dl>
<dt><a name="data"
><code class="code">data</code></a></dt>
<dd>
<p>the content of the attachment</p>
</dd>
</dl>
<dl>
<dt><a name="datasize"
><code class="code">datasize</code></a></dt>
<dd>
<p>the length (in characters) of the attachment content</p>
</dd>
</dl>
<dl>
<dt><a name="flags"
><code class="code">flags</code></a></dt>
<dd>
<p>flags that have been set on the attachment</p>
</dd>
</dl>
<dl>
<dt><a name="flag_types"
><code class="code">flag_types</code></a></dt>
<dd>
<p>Return all flag types available for this attachment as well as flags already set, grouped by flag type.</p>
</dd>
</dl>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="Class_Methods"
>Class Methods</a></h2>
<dl>
<dt><a name="get_attachments_by_bug($bug_id)"
><code class="code">get_attachments_by_bug($bug_id)</code></a></dt>
<dd>
<p>Description: retrieves and returns the attachments the currently logged in user can view for the given bug.</p>
<p>Params: <code class="code">$bug_id</code> - integer - the ID of the bug for which to retrieve and return attachments.</p>
<p>Returns: a reference to an array of attachment objects.</p>
<dt><a name="validate_is_patch()"
><code class="code">validate_is_patch()</code></a></dt>
<dd>
<p>Description: validates the &#34;patch&#34; flag passed in by CGI.</p>
<p>Returns: 1 on success.</p>
<dt><a name="validate_description()"
><code class="code">validate_description()</code></a></dt>
<dd>
<p>Description: validates the description passed in by CGI.</p>
<p>Returns: 1 on success.</p>
<dt><a name="validate_content_type()"
><code class="code">validate_content_type()</code></a></dt>
<dd>
<p>Description: validates the content type passed in by CGI.</p>
<p>Returns: 1 on success.</p>
<dt><a name="validate_can_edit($attachment,_$product_id)"
><code class="code">validate_can_edit($attachment, $product_id)</code></a></dt>
<dd>
<p>Description: validates if the user is allowed to view and edit the attachment. Only the submitter or someone with editbugs privs can edit it. Only the submitter and users in the insider group can view private attachments.</p>
<p>Params: $attachment - the attachment object being edited. $product_id - the product ID the attachment belongs to.</p>
<p>Returns: 1 on success. Else an error is thrown.</p>
<dt><a name="validate_obsolete($bug)"
><code class="code">validate_obsolete($bug)</code></a></dt>
<dd>
<p>Description: validates if attachments the user wants to mark as obsolete really belong to the given bug and are not already obsolete. Moreover, a user cannot mark an attachment as obsolete if he cannot view it (due to restrictions on it).</p>
<p>Params: $bug - The bug object obsolete attachments should belong to.</p>
<p>Returns: 1 on success. Else an error is thrown.</p>
<dt><a name="create($throw_error,_$bug,_$user,_$timestamp,_$hr_vars)"
><code class="code">create($throw_error, $bug, $user, $timestamp, $hr_vars)</code></a></dt>
<dd>
<p>Description: inserts an attachment from CGI input for the given bug.</p>
<p>Params: <code class="code">$bug</code> - Bugzilla::Bug object - the bug for which to insert the attachment. <code class="code">$user</code> - Bugzilla::User object - the user we&#39;re inserting an attachment for. <code class="code">$timestamp</code> - scalar - timestamp of the insert as returned by SELECT NOW(). <code class="code">$hr_vars</code> - hash reference - reference to a hash of template variables.</p>
<p>Returns: the ID of the new attachment.</p>
<dt><a name="remove_from_db()"
><code class="code">remove_from_db()</code></a></dt>
<dd>
<p>Description: removes an attachment from the DB.</p>
<p>Params: none</p>
<p>Returns: nothing</p>
</dd>
</dl>
<p class="backlinkbottom"><b><a name="___bottom" href="../index.html" title="All Documents">&lt;&lt;</a></b></p>
<!-- end doc -->
</body></html>