~ubuntu-branches/ubuntu/intrepid/bugzilla/intrepid

« back to all changes in this revision

Viewing changes to docs/html/api/Bugzilla/Hook.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Bossek
  • Date: 2008-06-27 22:34:34 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080627223434-0ib57vstn43bb4a3
Tags: 3.0.4.1-1
* Update of French, Russian and German translations. (closes: #488251)
* Added Bulgarian and Belarusian translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
 
<html>
3
 
  <head>
4
 
    <title>
5
 
Bugzilla::Hook</title>
6
 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
 
  <link rel="stylesheet" title="style" type="text/css" href="../style.css" media="all" >
8
 
 
9
 
</head>
10
 
  <body id="pod">
11
 
<p class="backlinktop"><b><a name="___top" href="../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
12
 
<h1>Bugzilla::Hook</h1>
13
 
<div class='indexgroup'>
14
 
<ul   class='indexList indexList1'>
15
 
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
16
 
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
17
 
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
18
 
  <ul   class='indexList indexList2'>
19
 
    <li class='indexItem indexItem2'><a href='#How_Hooks_Work'>How Hooks Work</a>
20
 
    <li class='indexItem indexItem2'><a href='#Arguments_Passed_to_Hooks'>Arguments Passed to Hooks</a>
21
 
  </ul>
22
 
  <li class='indexItem indexItem1'><a href='#SUBROUTINES'>SUBROUTINES</a>
23
 
  <li class='indexItem indexItem1'><a href='#HOOKS'>HOOKS</a>
24
 
  <ul   class='indexList indexList2'>
25
 
    <li class='indexItem indexItem2'><a href='#enter_bug-entrydefaultvars'>enter_bug-entrydefaultvars</a>
26
 
    <li class='indexItem indexItem2'><a href='#install-requirements'>install-requirements</a>
27
 
    <li class='indexItem indexItem2'><a href='#install-update_db'>install-update_db</a>
28
 
    <li class='indexItem indexItem2'><a href='#db_schema-abstract_schema'>db_schema-abstract_schema</a>
29
 
  </ul>
30
 
</ul>
31
 
</div>
32
 
 
33
 
<h1><a class='u' href='#___top' title='click to go to top of document'
34
 
name="NAME"
35
 
>NAME</a></h1>
36
 
 
37
 
<p>Bugzilla::Hook - Extendible extension hooks for Bugzilla code</p>
38
 
 
39
 
<h1><a class='u' href='#___top' title='click to go to top of document'
40
 
name="SYNOPSIS"
41
 
>SYNOPSIS</a></h1>
42
 
 
43
 
<pre  class="code"> use Bugzilla::Hook;
44
 
 
45
 
 Bugzilla::Hook::process(&#34;hookname&#34;, { arg =&#62; $value, arg2 =&#62; $value2 });</pre>
46
 
 
47
 
<h1><a class='u' href='#___top' title='click to go to top of document'
48
 
name="DESCRIPTION"
49
 
>DESCRIPTION</a></h1>
50
 
 
51
 
<p>Bugzilla allows extension modules to drop in and add routines at arbitrary points in Bugzilla code. These points are refered to as hooks. When a piece of standard Bugzilla code wants to allow an extension to perform additional functions, it uses Bugzilla::Hook&#39;s <a href="#process" class="podlinkpod"
52
 
>&#34;process&#34;</a> subroutine to invoke any extension code if installed.</p>
53
 
 
54
 
<h2><a class='u' href='#___top' title='click to go to top of document'
55
 
name="How_Hooks_Work"
56
 
>How Hooks Work</a></h2>
57
 
 
58
 
<p>When a hook named <code  class="code">HOOK_NAME</code> is run, Bugzilla will attempt to invoke any source files named <em  class="code">extensions/*/code/HOOK_NAME.pl</em>.</p>
59
 
 
60
 
<p>So, for example, if your extension is called &#34;testopia&#34;, and you want to have code run during the <a href="#install-update_db" class="podlinkpod"
61
 
>&#34;install-update_db&#34;</a> hook, you would have a file called <em  class="code">extensions/testopia/code/install-update_db.pl</em> that contained perl code to run during that hook.</p>
62
 
 
63
 
<h2><a class='u' href='#___top' title='click to go to top of document'
64
 
name="Arguments_Passed_to_Hooks"
65
 
>Arguments Passed to Hooks</a></h2>
66
 
 
67
 
<p>Some <a href="#HOOKS" class="podlinkpod"
68
 
>hooks</a> have params that are passed to them.</p>
69
 
 
70
 
<p>These params are accessible through <a href="../Bugzilla.html#hook_args" class="podlinkpod"
71
 
>&#34;hook_args&#34; in Bugzilla</a>. That returns a hashref. Very frequently, if you want your hook to do anything, you have to modify these variables.</p>
72
 
 
73
 
<h1><a class='u' href='#___top' title='click to go to top of document'
74
 
name="SUBROUTINES"
75
 
>SUBROUTINES</a></h1>
76
 
 
77
 
<dl>
78
 
<dt><a name="process"
79
 
><code  class="code">process</code></a></dt>
80
 
 
81
 
<dd>
82
 
<dl>
83
 
<dt><a name="Description"
84
 
><b>Description</b></a></dt>
85
 
 
86
 
<dd>
87
 
<p>Invoke any code hooks with a matching name from any installed extensions.</p>
88
 
 
89
 
<p>See <code  class="code">customization.xml</code> in the Bugzilla Guide for more information on Bugzilla&#39;s extension mechanism.</p>
90
 
 
91
 
<dt><a name="Params"
92
 
><b>Params</b></a></dt>
93
 
 
94
 
<dd>
95
 
<dl>
96
 
<dt><a name="$name_-_The_name_of_the_hook_to_invoke."
97
 
><code  class="code">$name</code> - The name of the hook to invoke.
98
 
<dt><a name="$args_-_A_hashref._The_named_args_to_pass_to_the_hook._They_will_be_accessible_to_the_hook_via_&#34;hook_args&#34;_in_Bugzilla."
99
 
><code  class="code">$args</code> - A hashref. The named args to pass to the hook. They will be accessible to the hook via <a href="../Bugzilla.html#hook_args" class="podlinkpod"
100
 
>&#34;hook_args&#34; in Bugzilla</a>.</a></dt>
101
 
</dl>
102
 
 
103
 
<dt><a name="Returns_(nothing)"
104
 
><b>Returns</b> (nothing)</a></dt>
105
 
</dl>
106
 
</dd>
107
 
</dl>
108
 
 
109
 
<h1><a class='u' href='#___top' title='click to go to top of document'
110
 
name="HOOKS"
111
 
>HOOKS</a></h1>
112
 
 
113
 
<p>This describes what hooks exist in Bugzilla currently.</p>
114
 
 
115
 
<h2><a class='u' href='#___top' title='click to go to top of document'
116
 
name="enter_bug-entrydefaultvars"
117
 
>enter_bug-entrydefaultvars</a></h2>
118
 
 
119
 
<p>This happens right before the template is loaded on enter_bug.cgi.</p>
120
 
 
121
 
<p>Params:</p>
122
 
 
123
 
<dl>
124
 
<dt><a name="vars_-_A_hashref._The_variables_that_will_be_passed_into_the_template."
125
 
><code  class="code">vars</code> - A hashref. The variables that will be passed into the template.</a></dt>
126
 
</dl>
127
 
 
128
 
<h2><a class='u' href='#___top' title='click to go to top of document'
129
 
name="install-requirements"
130
 
>install-requirements</a></h2>
131
 
 
132
 
<p>Because of the way Bugzilla installation works, there can&#39;t be a normal hook during the time that <em  class="code">checksetup.pl</em> checks what modules are installed. (<code  class="code">Bugzilla::Hook</code> needs to have those modules installed--it&#39;s a chicken-and-egg problem.)</p>
133
 
 
134
 
<p>So instead of the way hooks normally work, this hook just looks for two subroutines (or constants, since all constants are just subroutines) in your file, called <code  class="code">OPTIONAL_MODULES</code> and <code  class="code">REQUIRED_MODULES</code>, which should return arrayrefs in the same format as <code  class="code">OPTIONAL_MODULES</code> and <code  class="code">REQUIRED_MODULES</code> in <a href="../Bugzilla/Install/Requirements.html" class="podlinkpod"
135
 
>Bugzilla::Install::Requirements</a>.</p>
136
 
 
137
 
<p>These subroutines will be passed an arrayref that contains the current Bugzilla requirements of the same type, in case you want to modify Bugzilla&#39;s requirements somehow. (Probably the most common would be to alter a version number or the &#34;feature&#34; element of <code  class="code">OPTIONAL_MODULES</code>.)</p>
138
 
 
139
 
<p><em  class="code">checksetup.pl</em> will add these requirements to its own.</p>
140
 
 
141
 
<p>Please remember--if you put something in <code  class="code">REQUIRED_MODULES</code>, then <em  class="code">checksetup.pl</em> <b>cannot complete</b> unless the user has that module installed! So use <code  class="code">OPTIONAL_MODULES</code> whenever you can.</p>
142
 
 
143
 
<h2><a class='u' href='#___top' title='click to go to top of document'
144
 
name="install-update_db"
145
 
>install-update_db</a></h2>
146
 
 
147
 
<p>This happens at the very end of all the tables being updated during an installation or upgrade. If you need to modify your custom schema, do it here. No params are passed.</p>
148
 
 
149
 
<h2><a class='u' href='#___top' title='click to go to top of document'
150
 
name="db_schema-abstract_schema"
151
 
>db_schema-abstract_schema</a></h2>
152
 
 
153
 
<p>This allows you to add tables to Bugzilla. Note that we recommend that you prefix the names of your tables with some word, so that they don&#39;t conflict with any future Bugzilla tables.</p>
154
 
 
155
 
<p>If you wish to add new <i>columns</i> to existing Bugzilla tables, do that in <a href="#install-update_db" class="podlinkpod"
156
 
>&#34;install-update_db&#34;</a>.</p>
157
 
 
158
 
<p>Params:</p>
159
 
 
160
 
<dl>
161
 
<dt><a 
162
 
><code  class="code">schema</code> - A hashref, in the format of <a href="../Bugzilla/DB/Schema.html#ABSTRACT_SCHEMA" class="podlinkpod"
163
 
>&#34;ABSTRACT_SCHEMA&#34; in Bugzilla::DB::Schema</a>. Add new hash keys to make new table definitions. <em  class="code">checksetup.pl</em> will automatically add these tables to the database when run.</a></dt>
164
 
</dl>
165
 
<p class="backlinkbottom"><b><a name="___bottom" href="../index.html" title="All Documents">&lt;&lt;</a></b></p>
166
 
 
167
 
<!-- end doc -->
168
 
 
169
 
</body></html>