← Index
Performance Profile   « block view • line view • sub view »
For opac/opac-main.pl
  Run on Mon Aug 24 11:28:47 2009
Reported on Mon Aug 24 11:29:06 2009

File /home/chris/git/koha.git/C4/Context.pm
Statements Executed 993
Total Time 0.0164052 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.00ms85.1msC4::Context::::newC4::Context::new
258971.86ms48.6msC4::Context::::dbhC4::Context::dbh
111318µs896µsC4::Context::::KOHAVERSIONC4::Context::KOHAVERSION
303030238µs85.4msC4::Context::::importC4::Context::import
11169µs15.1msC4::Context::::db_scheme2dbiC4::Context::db_scheme2dbi
11159µs37.8msC4::Context::::_new_dbhC4::Context::_new_dbh
71155µs55µsC4::Context::::_common_configC4::Context::_common_config
82152µs52µsC4::Context::::userenvC4::Context::userenv
72142µs97µsC4::Context::::configC4::Context::config
22127µs27µsC4::Context::::set_shelves_userenvC4::Context::set_shelves_userenv
11122µs556µsC4::Context::::AUTOLOADC4::Context::AUTOLOAD
11114µs14µsC4::Context::::get_shelves_userenvC4::Context::get_shelves_userenv
11114µs78.8msC4::Context::::read_config_fileC4::Context::read_config_file
11113µs761µsC4::Context::::boolean_preferenceC4::Context::boolean_preference
11111µs11µsC4::Context::::_new_userenvC4::Context::_new_userenv
11110µs10µsC4::Context::::set_contextC4::Context::set_context
0000s0sC4::Context::::ModZebrationsC4::Context::ModZebrations
0000s0sC4::Context::::ZconnC4::Context::Zconn
0000s0sC4::Context::::_new_ZconnC4::Context::_new_Zconn
0000s0sC4::Context::::_new_marcfromkohafieldC4::Context::_new_marcfromkohafield
0000s0sC4::Context::::_new_stopwordsC4::Context::_new_stopwords
0000s0sC4::Context::::_unset_userenvC4::Context::_unset_userenv
0000s0sC4::Context::::cacheC4::Context::cache
0000s0sC4::Context::::clear_syspref_cacheC4::Context::clear_syspref_cache
0000s0sC4::Context::::get_versionsC4::Context::get_versions
0000s0sC4::Context::::handle_errorsC4::Context::handle_errors
0000s0sC4::Context::::marcfromkohafieldC4::Context::marcfromkohafield
0000s0sC4::Context::::new_dbhC4::Context::new_dbh
0000s0sC4::Context::::preferenceC4::Context::preference
0000s0sC4::Context::::restore_contextC4::Context::restore_context
0000s0sC4::Context::::restore_dbhC4::Context::restore_dbh
0000s0sC4::Context::::set_dbhC4::Context::set_dbh
0000s0sC4::Context::::set_userenvC4::Context::set_userenv
0000s0sC4::Context::::stopwordsC4::Context::stopwords
0000s0sC4::Context::::zebraconfigC4::Context::zebraconfig
0000s0sXML::Simple::::BEGINXML::Simple::BEGIN
LineStmts.Exclusive
Time
Avg.Code
1package C4::Context;
2# Copyright 2002 Katipo Communications
3#
4# This file is part of Koha.
5#
6# Koha is free software; you can redistribute it and/or modify it under the
7# terms of the GNU General Public License as published by the Free Software
8# Foundation; either version 2 of the License, or (at your option) any later
9# version.
10#
11# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17# Suite 330, Boston, MA 02111-1307 USA
18
19336µs12µsuse strict;
# spent 10µs making 1 call to strict::import
20329µs10µsuse vars qw($VERSION $AUTOLOAD $context @context_stack $usecache $cache);
# spent 77µs making 1 call to vars::import
213279µs93µsuse warnings;
# spent 24µs making 1 call to warnings::import
22
23BEGIN {
2423µs1µs if ($ENV{'HTTP_USER_AGENT'}) {
25122µs22µs require CGI::Carp;
26 # FIXME for future reference, CGI::Carp doc says
27 # "Note that fatalsToBrowser does not work with mod_perl version 2.0 and higher."
28 import CGI::Carp qw(fatalsToBrowser);
29 sub handle_errors {
30 my $msg = shift;
31 my $debug_level;
32 eval {C4::Context->dbh();};
33 if ($@){
34 $debug_level = 1;
35 }
36 else {
37 $debug_level = C4::Context->preference("DebugLevel");
38 }
39
40 print q(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
41 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
42 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
43 <head><title>Koha Error</title></head>
44 <body>
45 );
46 if ($debug_level eq "2"){
47 # debug 2 , print extra info too.
48 my %versions = get_versions();
49
50 # a little example table with various version info";
51 print "
52 <h1>Koha error</h1>
53 <p>The following fatal error has occurred:</p>
54 <pre><code>$msg</code></pre>
55 <table>
56 <tr><th>Apache</th><td> $versions{apacheVersion}</td></tr>
57 <tr><th>Koha</th><td> $versions{kohaVersion}</td></tr>
58 <tr><th>Koha DB</th><td> $versions{kohaDbVersion}</td></tr>
59 <tr><th>MySQL</th><td> $versions{mysqlVersion}</td></tr>
60 <tr><th>OS</th><td> $versions{osVersion}</td></tr>
61 <tr><th>Perl</th><td> $versions{perlVersion}</td></tr>
62 </table>";
63
64 } elsif ($debug_level eq "1"){
65 print "
66 <h1>Koha error</h1>
67 <p>The following fatal error has occurred:</p>
68 <pre><code>$msg</code></pre>";
69 } else {
70 print "<p>production mode - trapped fatal error</p>";
71 }
72 print "</body></html>";
73 }
74 CGI::Carp::set_message(\&handle_errors);
75 ## give a stack backtrace if KOHA_BACKTRACES is set
76 ## can't rely on DebugLevel for this, as we're not yet connected
77 if ($ENV{KOHA_BACKTRACES}) {
78 $main::SIG{__DIE__} = \&CGI::Carp::confess;
79 }
80
81
82 } # else there is no browser to send fatals to!
83$VERSION = '3.00.00.036';
84118µs18µs}
85
863224µs75µsuse DBI;
# spent 40µs making 1 call to Exporter::import
873163µs54µsuse ZOOM;
# spent 5µs making 1 call to import
883182µs61µsuse XML::Simple;
# spent 19µs making 1 call to XML::Simple::import
893257µs86µsuse C4::Boolean;
# spent 95µs making 1 call to Exporter::import
903214µs71µsuse C4::Debug;
# spent 90µs making 1 call to Exporter::import
91329µs10µsuse POSIX ();
92
93use Memoize::Memcached
94 memcached => {
# spent 159µs making 1 call to Memoize::Memcached::import
95 servers => [ '127.0.0.1:11211' ],
963241µs80µs };
97
98110µs10µsmemoize_memcached('preference');
# spent 2.75ms making 1 call to Memoize::Memcached::memoize_memcached
9917µs7µsmemoize_memcached('config');
# spent 534µs making 1 call to Memoize::Memcached::memoize_memcached
100
101=head1 NAME
102
103C4::Context - Maintain and manipulate the context of a Koha script
104
105=head1 SYNOPSIS
106
107 use C4::Context;
108
109 use C4::Context("/path/to/koha-conf.xml");
110
111 $config_value = C4::Context->config("config_variable");
112
113 $koha_preference = C4::Context->preference("preference");
114
115 $db_handle = C4::Context->dbh;
116
117 $Zconn = C4::Context->Zconn;
118
119 $stopwordhash = C4::Context->stopwords;
120
121=head1 DESCRIPTION
122
123When a Koha script runs, it makes use of a certain number of things:
124configuration settings in F</etc/koha/koha-conf.xml>, a connection to the Koha
125databases, and so forth. These things make up the I<context> in which
126the script runs.
127
128This module takes care of setting up the context for a script:
129figuring out which configuration file to load, and loading it, opening
130a connection to the right database, and so forth.
131
132Most scripts will only use one context. They can simply have
133
134 use C4::Context;
135
136at the top.
137
138Other scripts may need to use several contexts. For instance, if a
139library has two databases, one for a certain collection, and the other
140for everything else, it might be necessary for a script to use two
141different contexts to search both databases. Such scripts should use
142the C<&set_context> and C<&restore_context> functions, below.
143
144By default, C4::Context reads the configuration from
145F</etc/koha/koha-conf.xml>. This may be overridden by setting the C<$KOHA_CONF>
146environment variable to the pathname of a configuration file to use.
147
148=head1 METHODS
149
150=over 2
151
152=cut
153
154#'
155# In addition to what is said in the POD above, a Context object is a
156# reference-to-hash with the following fields:
157#
158# config
159# A reference-to-hash whose keys and values are the
160# configuration variables and values specified in the config
161# file (/etc/koha/koha-conf.xml).
162# dbh
163# A handle to the appropriate database for this context.
164# dbh_stack
165# Used by &set_dbh and &restore_dbh to hold other database
166# handles for this context.
167# Zconn
168# A connection object for the Zebra server
169
170# Koha's main configuration file koha-conf.xml
171# is searched for according to this priority list:
172#
173# 1. Path supplied via use C4::Context '/path/to/koha-conf.xml'
174# 2. Path supplied in KOHA_CONF environment variable.
175# 3. Path supplied in INSTALLED_CONFIG_FNAME, as long
176# as value has changed from its default of
177# '__KOHA_CONF_DIR__/koha-conf.xml', as happens
178# when Koha is installed in 'standard' or 'single'
179# mode.
180# 4. Path supplied in CONFIG_FNAME.
181#
182# The first entry that refers to a readable file is used.
183
18433.21ms1.07msuse constant CONFIG_FNAME => "/etc/koha/koha-conf.xml";
# spent 55µs making 1 call to constant::import
185 # Default config file, if none is specified
186
1871700ns700nsmy $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
188 # path to config file set by installer
189 # __KOHA_CONF_DIR__ is set by rewrite-confg.PL
190 # when Koha is installed in 'standard' or 'single'
191 # mode. If Koha was installed in 'dev' mode,
192 # __KOHA_CONF_DIR__ is *not* rewritten; instead
193 # developers should set the KOHA_CONF environment variable
194
1951300ns300ns$context = undef; # Initially, no context is set
1961900ns900ns@context_stack = (); # Initially, no saved contexts
197
198
199=item KOHAVERSION
200 returns the kohaversion stored in kohaversion.pl file
201
202=cut
203
204
# spent 896µs (318+577) within C4::Context::KOHAVERSION which was called # once (318µs+577µs) by C4::Auth::_version_check at line 485 of /home/chris/git/koha.git/C4/Auth.pm
sub KOHAVERSION {
2054230µs58µs my $cgidir = C4::Context->intranetdir;
# spent 556µs making 1 call to C4::Context::AUTOLOAD
206
207 # Apparently the GIT code does not run out of a CGI-BIN subdirectory
208 # but distribution code does? (Stan, 1jan08)
209 if(-d $cgidir . "/cgi-bin"){
210 my $cgidir .= "/cgi-bin";
211 }
212
213 do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
214 return kohaversion();
# spent 9µs making 1 call to C4::Context::kohaversion
215}
216=item read_config_file
217
218=over 4
219
220Reads the specified Koha config file.
221
222Returns an object containing the configuration variables. The object's
223structure is a bit complex to the uninitiated ... take a look at the
224koha-conf.xml file as well as the XML::Simple documentation for details. Or,
225here are a few examples that may give you what you need:
226
227The simple elements nested within the <config> element:
228
229 my $pass = $koha->{'config'}->{'pass'};
230
231The <listen> elements:
232
233 my $listen = $koha->{'listen'}->{'biblioserver'}->{'content'};
234
235The elements nested within the <server> element:
236
237 my $ccl2rpn = $koha->{'server'}->{'biblioserver'}->{'cql2rpn'};
238
239Returns undef in case of error.
240
241=back
242
243=cut
244
245
# spent 78.8ms (14µs+78.8) within C4::Context::read_config_file which was called # once (14µs+78.8ms) by C4::Context::new at line 336
sub read_config_file { # Pass argument naming config file to read
246414µs3µs my $koha;
247 if ($usecache){
248 $koha = $cache->get_from_cache("Koha:context:config");
249 if (! $koha){
250 $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
251 $cache->set_in_cache("Koha:context:config",$koha);
252 }
253 return $koha;
254 }
255 $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
# spent 78.8ms making 1 call to XML::Simple::XMLin
256 return $koha; # Return value: ref-to-hash holding the configuration
257}
258
259# db_scheme2dbi
260# Translates the full text name of a database into de appropiate dbi name
261#
262
# spent 15.1ms (69µs+15.0) within C4::Context::db_scheme2dbi which was called # once (69µs+15.0ms) by C4::Context::_new_dbh at line 682
sub db_scheme2dbi {
263330µs10µs my $name = shift;
264
265 for ($name) {
266# FIXME - Should have other databases.
267138µs38µs if (/mysql/i) { return("mysql"); }
# spent 15.0ms making 1 call to utf8::SWASHNEW
268 if (/Postgres|Pg|PostgresSQL/) { return("Pg"); }
269 if (/oracle/i) { return("Oracle"); }
270 }
271 return undef; # Just in case
272}
273
274
# spent 85.4ms (238µs+85.1) within C4::Context::import which was called 30 times, avg 2.85ms/call: # once (15µs+85.1ms) at line 25 of /home/chris/git/koha.git/C4/Auth.pm # once (11µs+0s) at line 4 of /home/chris/git/koha.git/C4/Message.pm # once (11µs+0s) at line 22 of /home/chris/git/koha.git/C4/Items.pm # once (9µs+0s) at line 23 of /home/chris/git/koha.git/C4/NewsChannels.pm # once (9µs+0s) at line 25 of /home/chris/git/koha.git/C4/Suggestions.pm # once (9µs+0s) at line 23 of /home/chris/git/koha.git/C4/Heading.pm # once (9µs+0s) at line 23 of /home/chris/git/koha.git/C4/Circulation.pm # once (9µs+0s) at line 25 of /home/chris/git/koha.git/C4/Overdues.pm # once (8µs+0s) at line 28 of /home/chris/git/koha.git/C4/VirtualShelves.pm # once (8µs+0s) at line 22 of /home/chris/git/koha.git/C4/Koha.pm # once (8µs+0s) at line 26 of /home/chris/git/koha.git/C4/Log.pm # once (8µs+0s) at line 22 of /home/chris/git/koha.git/C4/Accounts.pm # once (8µs+0s) at line 25 of /home/chris/git/koha.git/C4/Calendar.pm # once (8µs+0s) at line 23 of /home/chris/git/koha.git/C4/XSLT.pm # once (8µs+0s) at line 36 of /home/chris/git/koha.git/C4/SMS.pm # once (8µs+0s) at line 22 of /home/chris/git/koha.git/C4/Members.pm # once (7µs+0s) at line 20 of /home/chris/git/koha.git/C4/ItemCirculationAlertPreference.pm # once (7µs+0s) at line 24 of /home/chris/git/koha.git/C4/ClassSource.pm # once (7µs+0s) at line 24 of /home/chris/git/koha.git/C4/Stats.pm # once (7µs+0s) at line 21 of /home/chris/git/koha.git/C4/Search.pm # once (7µs+0s) at line 22 of /home/chris/git/koha.git/C4/Members/Messaging.pm # once (7µs+0s) at line 31 of /home/chris/git/koha.git/C4/Output.pm # once (7µs+0s) at line 25 of /home/chris/git/koha.git/C4/ClassSortRoutine.pm # once (6µs+0s) by C4::ItemType::BEGIN at line 20 of /home/chris/git/koha.git/C4/ItemType.pm # once (6µs+0s) at line 22 of /home/chris/git/koha.git/C4/Acquisition.pm # once (6µs+0s) at line 25 of /home/chris/git/koha.git/C4/Reserves.pm # once (6µs+0s) at line 20 of /home/chris/git/koha.git/C4/Dates.pm # once (6µs+0s) at line 33 of /home/chris/git/koha.git/C4/Languages.pm # once (6µs+0s) by C4::Category::BEGIN at line 20 of /home/chris/git/koha.git/C4/Category.pm # once (6µs+0s) at line 21 of /home/chris/git/koha.git/C4/Branch.pm
sub import {
275 # Create the default context ($C4::Context::Context)
276 # the first time the module is called
277 # (a config file can be optionaly passed)
278
279 # default context allready exists?
2803565µs2µs return if $context;
281
282 # no ? so load it!
283 my ($pkg,$config_file) = @_ ;
284 my $new_ctx = __PACKAGE__->new($config_file);
# spent 85.1ms making 1 call to C4::Context::new
285 return unless $new_ctx;
286
287 # if successfully loaded, use it by default
288 $new_ctx->set_context;
# spent 10µs making 1 call to C4::Context::set_context
289 1;
290}
291
292=item new
293
294 $context = new C4::Context;
295 $context = new C4::Context("/path/to/koha-conf.xml");
296
297Allocates a new context. Initializes the context from the specified
298file, which defaults to either the file given by the C<$KOHA_CONF>
299environment variable, or F</etc/koha/koha-conf.xml>.
300
301C<&new> does not set this context as the new default context; for
302that, use C<&set_context>.
303
304=cut
305
306#'
307# Revision History:
308# 2004-08-10 A. Tarallo: Added check if the conf file is not empty
309
# spent 85.1ms (3.00+82.1) within C4::Context::new which was called # once (3.00ms+82.1ms) by C4::Context::import at line 284
sub new {
31025333µs13µs my $class = shift;
311 my $conf_fname = shift; # Config file to load
312 my $self = {};
313
314 # check that the specified config file exists and is not empty
315 undef $conf_fname unless
316 (defined $conf_fname && -s $conf_fname);
317 # Figure out a good config file to load if none was specified.
318 if (!defined($conf_fname))
319 {
320 # If the $KOHA_CONF environment variable is set, use
321 # that. Otherwise, use the built-in default.
322 if (exists $ENV{"KOHA_CONF"} and $ENV{'KOHA_CONF'} and -s $ENV{"KOHA_CONF"}) {
323 $conf_fname = $ENV{"KOHA_CONF"};
324 } elsif ($INSTALLED_CONFIG_FNAME !~ /__KOHA_CONF_DIR/ and -s $INSTALLED_CONFIG_FNAME) {
325 # NOTE: be careful -- don't change __KOHA_CONF_DIR in the above
326 # regex to anything else -- don't want installer to rewrite it
327 $conf_fname = $INSTALLED_CONFIG_FNAME;
328 } elsif (-s CONFIG_FNAME) {
329 $conf_fname = CONFIG_FNAME;
330 } else {
331 warn "unable to locate Koha configuration file koha-conf.xml";
332 return undef;
333 }
334 }
335 # Load the desired config file.
336 $self = read_config_file($conf_fname);
# spent 78.8ms making 1 call to C4::Context::read_config_file
337 $self->{"config_file"} = $conf_fname;
338
339 warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
340 return undef if !defined($self->{"config"});
341
342 $self->{"dbh"} = undef; # Database handle
343 $self->{"Zconn"} = undef; # Zebra Connections
344 $self->{"stopwords"} = undef; # stopwords list
345 $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
346 $self->{"userenv"} = undef; # User env
347 $self->{"activeuser"} = undef; # current active user
348 $self->{"shelves"} = undef;
349my $usecache=1;
350if ($usecache){
351 # if (preference('usecache')){
352 require C4::Cache;
353 C4::Cache->import();
# spent 6µs making 1 call to UNIVERSAL::import
354 $cache = C4::Cache->new ( {'cache_type' => 'FastMemcached', ## fix me these need to come from a syspref
# spent 614µs making 1 call to C4::Cache::new
355 'cache_servers' => '127.0.0.1:11211'
356 }
357 );
358 $self->{"cache"} = $cache;
359 }
360 bless $self, $class;
361 return $self;
362}
363
364=item set_context
365
366 $context = new C4::Context;
367 $context->set_context();
368or
369 set_context C4::Context $context;
370
371 ...
372 restore_context C4::Context;
373
374In some cases, it might be necessary for a script to use multiple
375contexts. C<&set_context> saves the current context on a stack, then
376sets the context to C<$context>, which will be used in future
377operations. To restore the previous context, use C<&restore_context>.
378
379=cut
380
381#'
382sub set_context
383
# spent 10µs within C4::Context::set_context which was called # once (10µs+0s) by C4::Context::import at line 288
{
38465µs800ns my $self = shift;
385 my $new_context; # The context to set
386
387 # Figure out whether this is a class or instance method call.
388 #
389 # We're going to make the assumption that control got here
390 # through valid means, i.e., that the caller used an instance
391 # or class method call, and that control got here through the
392 # usual inheritance mechanisms. The caller can, of course,
393 # break this assumption by playing silly buggers, but that's
394 # harder to do than doing it properly, and harder to check
395 # for.
396 if (ref($self) eq "")
397 {
398 # Class method. The new context is the next argument.
399 $new_context = shift;
400 } else {
401 # Instance method. The new context is $self.
402 $new_context = $self;
403 }
404
405 # Save the old context, if any, on the stack
406 push @context_stack, $context if defined($context);
407
408 # Set the new context
409 $context = $new_context;
410}
411
412=item restore_context
413
414 &restore_context;
415
416Restores the context set by C<&set_context>.
417
418=cut
419
420#'
421sub restore_context
422{
423 my $self = shift;
424
425 if ($#context_stack < 0)
426 {
427 # Stack underflow.
428 die "Context stack underflow";
429 }
430
431 # Pop the old context and set it.
432 $context = pop @context_stack;
433
434 # FIXME - Should this return something, like maybe the context
435 # that was current when this was called?
436}
437
438=item config
439
440 $value = C4::Context->config("config_variable");
441
442 $value = C4::Context->config_variable;
443
444Returns the value of a variable specified in the configuration file
445from which the current context was created.
446
447The second form is more compact, but of course may conflict with
448method names. If there is a configuration variable called "new", then
449C<C4::Config-E<gt>new> will not return it.
450
451=cut
452
453
# spent 55µs within C4::Context::_common_config which was called 7 times, avg 8µs/call: # 7 times (55µs+0s) by C4::Context::config at line 467, avg 8µs/call
sub _common_config ($$) {
4542836µs1µs my $var = shift;
455 my $term = shift;
456 return undef if !defined($context->{$term});
457 # Presumably $self->{$term} might be
458 # undefined if the config file given to &new
459 # didn't exist, and the caller didn't bother
460 # to check the return value.
461
462 # Return the value of the requested config variable
463 return $context->{$term}->{$var};
464}
465
466
# spent 97µs (42+55) within C4::Context::config which was called 7 times, avg 14µs/call: # 6 times (36µs+48µs) by Memoize::_memoizer at line 247 of /usr/share/perl/5.10/Memoize.pm, avg 14µs/call # once (7µs+7µs) by Memoize::_memoizer at line 269 of /usr/share/perl/5.10/Memoize.pm
sub config {
467732µs5µs return _common_config($_[1],'config');
# spent 55µs making 7 calls to C4::Context::_common_config, avg 8µs/call
468}
469sub zebraconfig {
470 return _common_config($_[1],'server');
471}
472sub ModZebrations {
473 return _common_config($_[1],'serverinfo');
474}
475
476=item preference
477
478 $sys_preference = C4::Context->preference('some_variable');
479
480Looks up the value of the given system preference in the
481systempreferences table of the Koha database, and returns it. If the
482variable is not set or does not exist, undef is returned.
483
484In case of an error, this may return 0.
485
486Note: It is impossible to tell the difference between system
487preferences which do not exist, and those whose values are set to NULL
488with this method.
489
490=cut
491
492# FIXME: running this under mod_perl will require a means of
493# flushing the caching mechanism.
494
4951300ns300nsmy %sysprefs;
496
497sub preference {
498 my $self = shift;
499 my $var = shift; # The system preference to return
500 my $retval; # Return value
501
502 if (exists $sysprefs{$var}) {
503 return $sysprefs{$var};
504 }
505 my $dbh = C4::Context->dbh or return 0;
506 my $sql = <<'END_SQL';
507 SELECT value
508 FROM systempreferences
509 WHERE variable=?
510 LIMIT 1
511END_SQL
512 $sysprefs{$var} = $dbh->selectrow_array( $sql, {}, $var );
513 return $sysprefs{$var};
514}
515
516
# spent 761µs (13+748) within C4::Context::boolean_preference which was called # once (13µs+748µs) by C4::Auth::checkauth at line 782 of /home/chris/git/koha.git/C4/Auth.pm
sub boolean_preference ($) {
517422µs6µs my $self = shift;
518 my $var = shift; # The system preference to return
519 my $it = preference($self, $var);
520 return defined($it)? C4::Boolean::true_p($it): undef;
# spent 20µs making 1 call to C4::Boolean::true_p
521}
522
523=item clear_syspref_cache
524
525 C4::Context->clear_syspref_cache();
526
527 cleans the internal cache of sysprefs. Please call this method if
528 you update the systempreferences table. Otherwise, your new changes
529 will not be seen by this process.
530
531=cut
532
533sub clear_syspref_cache {
534 %sysprefs = ();
535}
536
537# AUTOLOAD
538# This implements C4::Config->foo, and simply returns
539# C4::Context->config("foo"), as described in the documentation for
540# &config, above.
541
542# FIXME - Perhaps this should be extended to check &config first, and
543# then &preference if that fails. OTOH, AUTOLOAD could lead to crappy
544# code, so it'd probably be best to delete it altogether so as not to
545# encourage people to use it.
546sub AUTOLOAD
547
# spent 556µs (22+533) within C4::Context::AUTOLOAD which was called # once (22µs+533µs) by C4::Context::KOHAVERSION at line 205
{
548316µs5µs my $self = shift;
549
550 $AUTOLOAD =~ s/.*:://; # Chop off the package name,
551 # leaving only the function name.
552 return $self->config($AUTOLOAD);
553}
554
555=item Zconn
556
557$Zconn = C4::Context->Zconn
558
559Returns a connection to the Zebra database for the current
560context. If no connection has yet been made, this method
561creates one and connects.
562
563C<$self>
564
565C<$server> one of the servers defined in the koha-conf.xml file
566
567C<$async> whether this is a asynchronous connection
568
569C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
570
571
572=cut
573
574sub Zconn {
575 my $self=shift;
576 my $server=shift;
577 my $async=shift;
578 my $auth=shift;
579 my $piggyback=shift;
580 my $syntax=shift;
581 if ( defined($context->{"Zconn"}->{$server}) && (0 == $context->{"Zconn"}->{$server}->errcode()) ) {
582 return $context->{"Zconn"}->{$server};
583 # No connection object or it died. Create one.
584 }else {
585 # release resources if we're closing a connection and making a new one
586 # FIXME: this needs to be smarter -- an error due to a malformed query or
587 # a missing index does not necessarily require us to close the connection
588 # and make a new one, particularly for a batch job. However, at
589 # first glance it does not look like there's a way to easily check
590 # the basic health of a ZOOM::Connection
591 $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
592
593 $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
594 return $context->{"Zconn"}->{$server};
595 }
596}
597
598=item _new_Zconn
599
600$context->{"Zconn"} = &_new_Zconn($server,$async);
601
602Internal function. Creates a new database connection from the data given in the current context and returns it.
603
604C<$server> one of the servers defined in the koha-conf.xml file
605
606C<$async> whether this is a asynchronous connection
607
608C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
609
610=cut
611
612sub _new_Zconn {
613 my ($server,$async,$auth,$piggyback,$syntax) = @_;
614
615 my $tried=0; # first attempt
616 my $Zconn; # connection object
617 $server = "biblioserver" unless $server;
618 $syntax = "usmarc" unless $syntax;
619
620 my $host = $context->{'listen'}->{$server}->{'content'};
621 my $servername = $context->{"config"}->{$server};
622 my $user = $context->{"serverinfo"}->{$server}->{"user"};
623 my $password = $context->{"serverinfo"}->{$server}->{"password"};
624 $auth = 1 if($user && $password);
625 retry:
626 eval {
627 # set options
628 my $o = new ZOOM::Options();
629 $o->option(user=>$user) if $auth;
630 $o->option(password=>$password) if $auth;
631 $o->option(async => 1) if $async;
632 $o->option(count => $piggyback) if $piggyback;
633 $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
634 $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
635 $o->option(preferredRecordSyntax => $syntax);
636 $o->option(elementSetName => "F"); # F for 'full' as opposed to B for 'brief'
637 $o->option(databaseName => ($servername?$servername:"biblios"));
638
639 # create a new connection object
640 $Zconn= create ZOOM::Connection($o);
641
642 # forge to server
643 $Zconn->connect($host, 0);
644
645 # check for errors and warn
646 if ($Zconn->errcode() !=0) {
647 warn "something wrong with the connection: ". $Zconn->errmsg();
648 }
649
650 };
651# if ($@) {
652# # Koha manages the Zebra server -- this doesn't work currently for me because of permissions issues
653# # Also, I'm skeptical about whether it's the best approach
654# warn "problem with Zebra";
655# if ( C4::Context->preference("ManageZebra") ) {
656# if ($@->code==10000 && $tried==0) { ##No connection try restarting Zebra
657# $tried=1;
658# warn "trying to restart Zebra";
659# my $res=system("zebrasrv -f $ENV{'KOHA_CONF'} >/koha/log/zebra-error.log");
660# goto "retry";
661# } else {
662# warn "Error ", $@->code(), ": ", $@->message(), "\n";
663# $Zconn="error";
664# return $Zconn;
665# }
666# }
667# }
668 return $Zconn;
669}
670
671# _new_dbh
672# Internal helper function (not a method!). This creates a new
673# database connection from the data given in the current context, and
674# returns it.
675sub _new_dbh
676
# spent 37.8ms (59µs+37.8) within C4::Context::_new_dbh which was called # once (59µs+37.8ms) by C4::Context::dbh at line 736
{
677
678 ## $context
679 ## correct name for db_schme
68015202µs13µs my $db_driver;
681 if ($context->config("db_scheme")){
682 $db_driver=db_scheme2dbi($context->config("db_scheme"));
# spent 15.1ms making 1 call to C4::Context::db_scheme2dbi # spent 1.07ms making 1 call to Memoize::__ANON__[(eval 0)[/usr/share/perl/5.10/Memoize.pm:73]:1]
683 }else{
684 $db_driver="mysql";
685 }
686
687 my $db_name = $context->config("database");
688 my $db_host = $context->config("hostname");
689 my $db_port = $context->config("port") || '';
690 my $db_user = $context->config("user");
691 my $db_passwd = $context->config("pass");
692 # MJR added or die here, as we can't work without dbh
693 my $dbh= DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
# spent 18.7ms making 1 call to DBI::connect
694 $db_user, $db_passwd) or die $DBI::errstr;
695 my $tz = $ENV{TZ};
696 if ( $db_driver eq 'mysql' ) {
697 # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
698 # this is better than modifying my.cnf (and forcing all communications to be in utf8)
699 $dbh->{'mysql_enable_utf8'}=1; #enable
# spent 8µs making 1 call to DBI::common::STORE
700 $dbh->do("set NAMES 'utf8'");
# spent 71µs making 1 call to DBI::db::do
701 ($tz) and $dbh->do(qq(SET time_zone = "$tz"));
702 }
703 elsif ( $db_driver eq 'Pg' ) {
704 $dbh->do( "set client_encoding = 'UTF8';" );
705 ($tz) and $dbh->do(qq(SET TIME ZONE = "$tz"));
706 }
707 return $dbh;
708}
709
710=item dbh
711
712 $dbh = C4::Context->dbh;
713
714Returns a database handle connected to the Koha database for the
715current context. If no connection has yet been made, this method
716creates one, and connects to the database.
717
718This database handle is cached for future use: if you call
719C<C4::Context-E<gt>dbh> twice, you will get the same handle both
720times. If you need a second database handle, use C<&new_dbh> and
721possibly C<&set_dbh>.
722
723=cut
724
725#'
726sub dbh
727
# spent 48.6ms (1.86+46.7) within C4::Context::dbh which was called 258 times, avg 188µs/call: # 250 times (1.75ms+8.48ms) by C4::Languages::language_get_description at line 331 of /home/chris/git/koha.git/C4/Languages.pm, avg 41µs/call # once (20µs+37.8ms) at line 55 of /home/chris/git/koha.git/C4/VirtualShelves.pm # once (15µs+96µs) by C4::Output::themelanguage at line 158 of /home/chris/git/koha.git/C4/Output.pm # once (14µs+78µs) at line 60 of /home/chris/git/koha.git/opac/opac-main.pl # once (13µs+65µs) by C4::Languages::getAllLanguages at line 179 of /home/chris/git/koha.git/C4/Languages.pm # once (14µs+60µs) by C4::Auth::get_session at line 1224 of /home/chris/git/koha.git/C4/Auth.pm # once (9µs+35µs) by C4::Auth::checkauth at line 518 of /home/chris/git/koha.git/C4/Auth.pm # once (9µs+35µs) by C4::NewsChannels::GetNewsToDisplay at line 138 of /home/chris/git/koha.git/C4/NewsChannels.pm # once (10µs+31µs) by C4::Members::GetMember at line 485 of /home/chris/git/koha.git/C4/Members.pm
{
72877610.2ms13µs my $self = shift;
729 my $sth;
730
731 if (defined($context->{"dbh"}) && $context->{"dbh"}->ping()) {
# spent 8.88ms making 257 calls to DBI::db::ping, avg 35µs/call
732 return $context->{"dbh"};
733 }
734
735 # No database handle or it died . Create one.
736 $context->{"dbh"} = &_new_dbh();
# spent 37.8ms making 1 call to C4::Context::_new_dbh
737
738 return $context->{"dbh"};
739}
740
741=item new_dbh
742
743 $dbh = C4::Context->new_dbh;
744
745Creates a new connection to the Koha database for the current context,
746and returns the database handle (a C<DBI::db> object).
747
748The handle is not saved anywhere: this method is strictly a
749convenience function; the point is that it knows which database to
750connect to so that the caller doesn't have to know.
751
752=cut
753
754#'
755sub new_dbh
756{
757 my $self = shift;
758
759 return &_new_dbh();
760}
761
762=item set_dbh
763
764 $my_dbh = C4::Connect->new_dbh;
765 C4::Connect->set_dbh($my_dbh);
766 ...
767 C4::Connect->restore_dbh;
768
769C<&set_dbh> and C<&restore_dbh> work in a manner analogous to
770C<&set_context> and C<&restore_context>.
771
772C<&set_dbh> saves the current database handle on a stack, then sets
773the current database handle to C<$my_dbh>.
774
775C<$my_dbh> is assumed to be a good database handle.
776
777=cut
778
779#'
780sub set_dbh
781{
782 my $self = shift;
783 my $new_dbh = shift;
784
785 # Save the current database handle on the handle stack.
786 # We assume that $new_dbh is all good: if the caller wants to
787 # screw himself by passing an invalid handle, that's fine by
788 # us.
789 push @{$context->{"dbh_stack"}}, $context->{"dbh"};
790 $context->{"dbh"} = $new_dbh;
791}
792
793=item restore_dbh
794
795 C4::Context->restore_dbh;
796
797Restores the database handle saved by an earlier call to
798C<C4::Context-E<gt>set_dbh>.
799
800=cut
801
802#'
803sub restore_dbh
804{
805 my $self = shift;
806
807 if ($#{$context->{"dbh_stack"}} < 0)
808 {
809 # Stack underflow
810 die "DBH stack underflow";
811 }
812
813 # Pop the old database handle and set it.
814 $context->{"dbh"} = pop @{$context->{"dbh_stack"}};
815
816 # FIXME - If it is determined that restore_context should
817 # return something, then this function should, too.
818}
819
820=item marcfromkohafield
821
822 $dbh = C4::Context->marcfromkohafield;
823
824Returns a hash with marcfromkohafield.
825
826This hash is cached for future use: if you call
827C<C4::Context-E<gt>marcfromkohafield> twice, you will get the same hash without real DB access
828
829=cut
830
831#'
832sub marcfromkohafield
833{
834 my $retval = {};
835
836 # If the hash already exists, return it.
837 return $context->{"marcfromkohafield"} if defined($context->{"marcfromkohafield"});
838
839 # No hash. Create one.
840 $context->{"marcfromkohafield"} = &_new_marcfromkohafield();
841
842 return $context->{"marcfromkohafield"};
843}
844
845# _new_marcfromkohafield
846# Internal helper function (not a method!). This creates a new
847# hash with stopwords
848sub _new_marcfromkohafield
849{
850 my $dbh = C4::Context->dbh;
851 my $marcfromkohafield;
852 my $sth = $dbh->prepare("select frameworkcode,kohafield,tagfield,tagsubfield from marc_subfield_structure where kohafield > ''");
853 $sth->execute;
854 while (my ($frameworkcode,$kohafield,$tagfield,$tagsubfield) = $sth->fetchrow) {
855 my $retval = {};
856 $marcfromkohafield->{$frameworkcode}->{$kohafield} = [$tagfield,$tagsubfield];
857 }
858 return $marcfromkohafield;
859}
860
861=item stopwords
862
863 $dbh = C4::Context->stopwords;
864
865Returns a hash with stopwords.
866
867This hash is cached for future use: if you call
868C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real DB access
869
870=cut
871
872#'
873sub stopwords
874{
875 my $retval = {};
876
877 # If the hash already exists, return it.
878 return $context->{"stopwords"} if defined($context->{"stopwords"});
879
880 # No hash. Create one.
881 $context->{"stopwords"} = &_new_stopwords();
882
883 return $context->{"stopwords"};
884}
885
886# _new_stopwords
887# Internal helper function (not a method!). This creates a new
888# hash with stopwords
889sub _new_stopwords
890{
891 my $dbh = C4::Context->dbh;
892 my $stopwordlist;
893 my $sth = $dbh->prepare("select word from stopwords");
894 $sth->execute;
895 while (my $stopword = $sth->fetchrow_array) {
896 $stopwordlist->{$stopword} = uc($stopword);
897 }
898 $stopwordlist->{A} = "A" unless $stopwordlist;
899 return $stopwordlist;
900}
901
902=item userenv
903
904 C4::Context->userenv;
905
906Retrieves a hash for user environment variables.
907
908This hash shall be cached for future use: if you call
909C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
910
911=cut
912
913#'
914
# spent 52µs within C4::Context::userenv which was called 8 times, avg 7µs/call: # 6 times (36µs+0s) by C4::Auth::get_template_and_user at line 255 of /home/chris/git/koha.git/C4/Auth.pm, avg 6µs/call # 2 times (17µs+0s) by C4::Auth::get_template_and_user at line 327 of /home/chris/git/koha.git/C4/Auth.pm, avg 8µs/call
sub userenv {
9151628µs2µs my $var = $context->{"activeuser"};
916 return $context->{"userenv"}->{$var} if (defined $var and defined $context->{"userenv"}->{$var});
917 # insecure=1 management
918 if ($context->{"dbh"} && $context->preference('insecure')) {
919 my %insecure;
920 $insecure{flags} = '16382';
921 $insecure{branchname} ='Insecure';
922 $insecure{number} ='0';
923 $insecure{cardnumber} ='0';
924 $insecure{id} = 'insecure';
925 $insecure{branch} = 'INS';
926 $insecure{emailaddress} = 'test@mode.insecure.com';
927 return \%insecure;
928 } else {
929 return;
930 }
931}
932
933=item set_userenv
934
935 C4::Context->set_userenv($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags, $emailaddress);
936
937Establish a hash of user environment variables.
938
939set_userenv is called in Auth.pm
940
941=cut
942
943#'
944sub set_userenv {
945 my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
946 my $var=$context->{"activeuser"};
947 my $cell = {
948 "number" => $usernum,
949 "id" => $userid,
950 "cardnumber" => $usercnum,
951 "firstname" => $userfirstname,
952 "surname" => $usersurname,
953 #possibly a law problem
954 "branch" => $userbranch,
955 "branchname" => $branchname,
956 "flags" => $userflags,
957 "emailaddress" => $emailaddress,
958 "branchprinter" => $branchprinter
959 };
960 $context->{userenv}->{$var} = $cell;
961 return $cell;
962}
963
964
# spent 27µs within C4::Context::set_shelves_userenv which was called 2 times, avg 14µs/call: # once (18µs+0s) by C4::Auth::checkauth at line 773 of /home/chris/git/koha.git/C4/Auth.pm # once (9µs+0s) by C4::Auth::checkauth at line 774 of /home/chris/git/koha.git/C4/Auth.pm
sub set_shelves_userenv ($$) {
9651015µs2µs my ($type, $shelves) = @_ or return undef;
966 my $activeuser = $context->{activeuser} or return undef;
967 $context->{userenv}->{$activeuser}->{barshelves} = $shelves if $type eq 'bar';
968 $context->{userenv}->{$activeuser}->{pubshelves} = $shelves if $type eq 'pub';
969 $context->{userenv}->{$activeuser}->{totshelves} = $shelves if $type eq 'tot';
970}
971
972
# spent 14µs within C4::Context::get_shelves_userenv which was called # once (14µs+0s) by C4::Auth::get_template_and_user at line 244 of /home/chris/git/koha.git/C4/Auth.pm
sub get_shelves_userenv () {
97368µs1µs my $active;
974 unless ($active = $context->{userenv}->{$context->{activeuser}}) {
975 $debug and warn "get_shelves_userenv cannot retrieve context->{userenv}->{context->{activeuser}}";
976 return undef;
977 }
978 my $totshelves = $active->{totshelves} or undef;
979 my $pubshelves = $active->{pubshelves} or undef;
980 my $barshelves = $active->{barshelves} or undef;
981 return ($totshelves, $pubshelves, $barshelves);
982}
983
984=item _new_userenv
985
986 C4::Context->_new_userenv($session); # FIXME: This calling style is wrong for what looks like an _internal function
987
988Builds a hash for user environment variables.
989
990This hash shall be cached for future use: if you call
991C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
992
993_new_userenv is called in Auth.pm
994
995=cut
996
997#'
998sub _new_userenv
999
# spent 11µs within C4::Context::_new_userenv which was called # once (11µs+0s) by C4::Auth::checkauth at line 620 of /home/chris/git/koha.git/C4/Auth.pm
{
100035µs2µs shift; # Useless except it compensates for bad calling style
1001 my ($sessionID)= @_;
1002 $context->{"activeuser"}=$sessionID;
1003}
1004
1005=item _unset_userenv
1006
1007 C4::Context->_unset_userenv;
1008
1009Destroys the hash for activeuser user environment variables.
1010
1011=cut
1012
1013#'
1014
1015sub _unset_userenv
1016{
1017 my ($sessionID)= @_;
1018 undef $context->{"activeuser"} if ($context->{"activeuser"} eq $sessionID);
1019}
1020
1021
1022=item get_versions
1023
1024 C4::Context->get_versions
1025
1026Gets various version info, for core Koha packages, Currently called from carp handle_errors() sub, to send to browser if 'DebugLevel' syspref is set to '2'.
1027
1028=cut
1029
1030#'
1031
1032# A little example sub to show more debugging info for CGI::Carp
1033sub get_versions {
1034 my %versions;
1035 $versions{kohaVersion} = KOHAVERSION();
1036 $versions{kohaDbVersion} = C4::Context->preference('version');
1037 $versions{osVersion} = join(" ", POSIX::uname());
1038 $versions{perlVersion} = $];
1039 {
10403197µs66µs no warnings qw(exec); # suppress warnings if unable to find a program in $PATH
# spent 38µs making 1 call to warnings::unimport
1041 $versions{mysqlVersion} = `mysql -V`;
1042 $versions{apacheVersion} = `httpd -v`;
1043 $versions{apacheVersion} = `httpd2 -v` unless $versions{apacheVersion} ;
1044 $versions{apacheVersion} = `apache2 -v` unless $versions{apacheVersion} ;
1045 $versions{apacheVersion} = `/usr/sbin/apache2 -v` unless $versions{apacheVersion} ;
1046 }
1047 return %versions;
1048}
1049
1050sub cache {
1051 my $self = shift;
1052 return $cache;
1053}
1054
105519µs9µs1;
1056__END__
1057
1058=back
1059
1060=head1 ENVIRONMENT
1061
1062=over 4
1063
1064=item C<KOHA_CONF>
1065
1066Specifies the configuration file to read.
1067
1068=back
1069
1070=head1 SEE ALSO
1071
1072XML::Simple
1073
1074=head1 AUTHORS
1075
1076Andrew Arensburger <arensb at ooblick dot com>
1077
1078Joshua Ferraro <jmf at liblime dot com>
1079
1080=cut
1081
1082# Revision 1.57 2007/05/22 09:13:55 tipaul
1083# Bugfixes & improvements (various and minor) :
1084# - updating templates to have tmpl_process3.pl running without any errors
1085# - adding a drupal-like css for prog templates (with 3 small images)
1086# - fixing some bugs in circulation & other scripts
1087# - updating french translation
1088# - fixing some typos in templates
1089#
1090# Revision 1.56 2007/04/23 15:21:17 tipaul
1091# renaming currenttransfers to transferstoreceive
1092#
1093# Revision 1.55 2007/04/17 08:48:00 tipaul
1094# circulation cleaning continued: bufixing
1095#
1096# Revision 1.54 2007/03/29 16:45:53 tipaul
1097# Code cleaning of Biblio.pm (continued)
1098#
1099# All subs have be cleaned :
1100# - removed useless
1101# - merged some
1102# - reordering Biblio.pm completly
1103# - using only naming conventions
1104#
1105# Seems to have broken nothing, but it still has to be heavily tested.
1106# Note that Biblio.pm is now much more efficient than previously & probably more reliable as well.
1107#
1108# Revision 1.53 2007/03/29 13:30:31 tipaul
1109# Code cleaning :
1110# == Biblio.pm cleaning (useless) ==
1111# * some sub declaration dropped
1112# * removed modbiblio sub
1113# * removed moditem sub
1114# * removed newitems. It was used only in finishrecieve. Replaced by a TransformKohaToMarc+AddItem, that is better.
1115# * removed MARCkoha2marcItem
1116# * removed MARCdelsubfield declaration
1117# * removed MARCkoha2marcBiblio
1118#
1119# == Biblio.pm cleaning (naming conventions) ==
1120# * MARCgettagslib renamed to GetMarcStructure
1121# * MARCgetitems renamed to GetMarcItem
1122# * MARCfind_frameworkcode renamed to GetFrameworkCode
1123# * MARCmarc2koha renamed to TransformMarcToKoha
1124# * MARChtml2marc renamed to TransformHtmlToMarc
1125# * MARChtml2xml renamed to TranformeHtmlToXml
1126# * zebraop renamed to ModZebra
1127#
1128# == MARC=OFF ==
1129# * removing MARC=OFF related scripts (in cataloguing directory)
1130# * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
1131# * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
1132#
1133# Revision 1.52 2007/03/16 01:25:08 kados
1134# Using my precrash CVS copy I did the following:
1135#
1136# cvs -z3 -d:ext:kados@cvs.savannah.nongnu.org:/sources/koha co -P koha
1137# find koha.precrash -type d -name "CVS" -exec rm -v {} \;
1138# cp -r koha.precrash/* koha/
1139# cd koha/
1140# cvs commit
1141#
1142# This should in theory put us right back where we were before the crash
1143#
1144# Revision 1.52 2007/03/12 21:17:05 rych
1145# add server, serverinfo as arrays from config
1146#
1147# Revision 1.51 2007/03/09 14:31:47 tipaul
1148# rel_3_0 moved to HEAD
1149#
1150# Revision 1.43.2.10 2007/02/09 17:17:56 hdl
1151# Managing a little better database absence.
1152# (preventing from BIG 550)
1153#
1154# Revision 1.43.2.9 2006/12/20 16:50:48 tipaul
1155# improving "insecure" management
1156#
1157# WARNING KADOS :
1158# you told me that you had some libraries with insecure=ON (behind a firewall).
1159# In this commit, I created a "fake" user when insecure=ON. It has a fake branch. You may find better to have the 1st branch in branch table instead of a fake one.
1160#
1161# Revision 1.43.2.8 2006/12/19 16:48:16 alaurin
1162# reident programs, and adding branchcode value in reserves
1163#
1164# Revision 1.43.2.7 2006/12/06 21:55:38 hdl
1165# Adding ModZebrations for servers to get serverinfos in Context.pm
1166# Using this function in rebuild_zebra.pl
1167#
1168# Revision 1.43.2.6 2006/11/24 21:18:31 kados
1169# very minor changes, no functional ones, just comments, etc.
1170#
1171# Revision 1.43.2.5 2006/10/30 13:24:16 toins
1172# fix some minor POD error.
1173#
1174# Revision 1.43.2.4 2006/10/12 21:42:49 hdl
1175# Managing multiple zebra connections
1176#
1177# Revision 1.43.2.3 2006/10/11 14:27:26 tipaul
1178# removing a warning
1179#
1180# Revision 1.43.2.2 2006/10/10 15:28:16 hdl
1181# BUG FIXING : using database name in Zconn if defined and not hard coded value
1182#
1183# Revision 1.43.2.1 2006/10/06 13:47:28 toins
1184# Synch with dev_week.
1185# /!\ WARNING :: Please now use the new version of koha.xml.
1186#
1187# Revision 1.18.2.5.2.14 2006/09/24 15:24:06 kados
1188# remove Zebraauth routine, fold the functionality into Zconn
1189# Zconn can now take several arguments ... this will probably
1190# change soon as I'm not completely happy with the readability
1191# of the current format ... see the POD for details.
1192#
1193# cleaning up Biblio.pm, removing unnecessary routines.
1194#
1195# DeleteBiblio - used to delete a biblio from zebra and koha tables
1196# -- checks to make sure there are no existing issues
1197# -- saves backups of biblio,biblioitems,items in deleted* tables
1198# -- does commit operation
1199#
1200# getRecord - used to retrieve one record from zebra in piggyback mode using biblionumber
1201# brought back z3950_extended_services routine
1202#
1203# Lots of modifications to Context.pm, you can now store user and pass info for
1204# multiple servers (for federated searching) using the <serverinfo> element.
1205# I'll commit my koha.xml to demonstrate this or you can refer to the POD in
1206# Context.pm (which I also expanded on).
1207#
1208# Revision 1.18.2.5.2.13 2006/08/10 02:10:21 kados
1209# Turned warnings on, and running a search turned up lots of warnings.
1210# Cleaned up those ...
1211#
1212# removed getitemtypes from Koha.pm (one in Search.pm looks newer)
1213# removed itemcount from Biblio.pm
1214#
1215# made some local subs local with a _ prefix (as they were redefined
1216# elsewhere)
1217#
1218# Add two new search subs to Search.pm the start of a new search API
1219# that's a bit more scalable
1220#
1221# Revision 1.18.2.5.2.10 2006/07/21 17:50:51 kados
1222# moving the *.properties files to intranetdir/etc dir
1223#
1224# Revision 1.18.2.5.2.9 2006/07/17 08:05:20 tipaul
1225# there was a hardcoded link to /koha/etc/ I replaced it with intranetdir config value
1226#
1227# Revision 1.18.2.5.2.8 2006/07/11 12:20:37 kados
1228# adding ccl and cql files ... Tumer, if you want to fit these into the
1229# config file by all means do.
1230#
1231# Revision 1.18.2.5.2.7 2006/06/04 22:50:33 tgarip1957
1232# We do not hard code cql2rpn conversion file in context.pm our koha.xml configuration file already describes the path for this file.
1233# At cql searching we use method CQL not CQL2RPN as the cql2rpn conversion file is defined at server level
1234#
1235# Revision 1.18.2.5.2.6 2006/06/02 23:11:24 kados
1236# Committing my working dev_week. It's been tested only with
1237# searching, and there's quite a lot of config stuff to set up
1238# beforehand. As things get closer to a release, we'll be making
1239# some scripts to do it for us
1240#
1241# Revision 1.18.2.5.2.5 2006/05/28 18:49:12 tgarip1957
1242# This is an unusual commit. The main purpose is a working model of Zebra on a modified rel2_2.
1243# Any questions regarding these commits should be asked to Joshua Ferraro unless you are Joshua whom I'll report to
1244#
1245# Revision 1.36 2006/05/09 13:28:08 tipaul
1246# adding the branchname and the librarian name in every page :
1247# - modified userenv to add branchname
1248# - modifier menus.inc to have the librarian name & userenv displayed on every page. they are in a librarian_information div.
1249#
1250# Revision 1.35 2006/04/13 08:40:11 plg
1251# bug fixed: typo on Zconnauth name
1252#
1253# Revision 1.34 2006/04/10 21:40:23 tgarip1957
1254# A new handler defined for zebra Zconnauth with read/write permission. Zconnauth should only be called in biblio.pm where write operations are. Use of this handler will break things unless koha.conf contains new variables:
1255# zebradb=localhost
1256# zebraport=<your port>
1257# zebrauser=<username>
1258# zebrapass=<password>
1259#
1260# The zebra.cfg file should read:
1261# perm.anonymous:r
1262# perm.username:rw
1263# passw.c:<yourpasswordfile>
1264#
1265# Password file should be prepared with Apaches htpasswd utility in encrypted mode and should exist in a folder zebra.cfg can read
1266#
1267# Revision 1.33 2006/03/15 11:21:56 plg
1268# bug fixed: utf-8 data where not displayed correctly in screens. Supposing
1269# your data are truely utf-8 encoded in your database, they should be
1270# correctly displayed. "set names 'UTF8'" on mysql connection (C4/Context.pm)
1271# is mandatory and "binmode" to utf8 (C4/Interface/CGI/Output.pm) seemed to
1272# converted data twice, so it was removed.
1273#
1274# Revision 1.32 2006/03/03 17:25:01 hdl
1275# Bug fixing : a line missed a comment sign.
1276#
1277# Revision 1.31 2006/03/03 16:45:36 kados
1278# Remove the search that tests the Zconn -- warning, still no fault
1279# tollerance
1280#
1281# Revision 1.30 2006/02/22 00:56:59 kados
1282# First go at a connection object for Zebra. You can now get a
1283# connection object by doing:
1284#
1285# my $Zconn = C4::Context->Zconn;
1286#
1287# My initial tests indicate that as soon as your funcion ends
1288# (ie, when you're done doing something) the connection will be
1289# closed automatically. There may be some other way to make the
1290# connection more stateful, I'm not sure...
1291#
1292# Local Variables:
1293# tab-width: 4
1294# End: