2 # Copyright 2002 Katipo Communications
4 # This file is part of Koha.
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
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.
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
20 use vars qw($VERSION $AUTOLOAD $context @context_stack);
23 if ($ENV{'HTTP_USER_AGENT'}) {
25 import CGI::Carp qw(fatalsToBrowser);
28 my $debug_level = C4::Context->preference("DebugLevel");
30 if ($debug_level eq "2"){
31 # debug 2 , print extra info too.
32 my %versions = get_versions();
34 # a little example table with various version info";
36 <h1>debug level $debug_level </h1>
37 <p>Got an error: $msg</p>
39 <tr><th>Apache<td> $versions{apacheVersion}</tr>
40 <tr><th>Koha<td> $versions{kohaVersion}</tr>
41 <tr><th>MySQL<td> $versions{mysqlVersion}</tr>
42 <tr><th>OS<td> $versions{osVersion}</tr>
43 <tr><th>Perl<td> $versions{perlVersion}</tr>
46 } elsif ($debug_level eq "1"){
47 print "<h1>debug level $debug_level </h1>";
48 print "<p>Got an error: $msg</p>";
50 print "production mode - trapped fatal";
53 CGI::Carp->set_message(\&handle_errors);
54 } # else there is no browser to send fatals to!
55 $VERSION = '3.00.00.036';
65 C4::Context - Maintain and manipulate the context of a Koha script
71 use C4::Context("/path/to/koha-conf.xml");
73 $config_value = C4::Context->config("config_variable");
75 $koha_preference = C4::Context->preference("preference");
77 $db_handle = C4::Context->dbh;
79 $Zconn = C4::Context->Zconn;
81 $stopwordhash = C4::Context->stopwords;
85 When a Koha script runs, it makes use of a certain number of things:
86 configuration settings in F</etc/koha/koha-conf.xml>, a connection to the Koha
87 databases, and so forth. These things make up the I<context> in which
90 This module takes care of setting up the context for a script:
91 figuring out which configuration file to load, and loading it, opening
92 a connection to the right database, and so forth.
94 Most scripts will only use one context. They can simply have
100 Other scripts may need to use several contexts. For instance, if a
101 library has two databases, one for a certain collection, and the other
102 for everything else, it might be necessary for a script to use two
103 different contexts to search both databases. Such scripts should use
104 the C<&set_context> and C<&restore_context> functions, below.
106 By default, C4::Context reads the configuration from
107 F</etc/koha/koha-conf.xml>. This may be overridden by setting the C<$KOHA_CONF>
108 environment variable to the pathname of a configuration file to use.
117 # In addition to what is said in the POD above, a Context object is a
118 # reference-to-hash with the following fields:
121 # A reference-to-hash whose keys and values are the
122 # configuration variables and values specified in the config
123 # file (/etc/koha/koha-conf.xml).
125 # A handle to the appropriate database for this context.
127 # Used by &set_dbh and &restore_dbh to hold other database
128 # handles for this context.
130 # A connection object for the Zebra server
132 # Koha's main configuration file koha-conf.xml
133 # is searched for according to this priority list:
135 # 1. Path supplied via use C4::Context '/path/to/koha-conf.xml'
136 # 2. Path supplied in KOHA_CONF environment variable.
137 # 3. Path supplied in INSTALLED_CONFIG_FNAME, as long
138 # as value has changed from its default of
139 # '__KOHA_CONF_DIR__/koha-conf.xml', as happens
140 # when Koha is installed in 'standard' or 'single'
142 # 4. Path supplied in CONFIG_FNAME.
144 # The first entry that refers to a readable file is used.
146 use constant CONFIG_FNAME => "/etc/koha/koha-conf.xml";
147 # Default config file, if none is specified
149 my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
150 # path to config file set by installer
151 # __KOHA_CONF_DIR__ is set by rewrite-confg.PL
152 # when Koha is installed in 'standard' or 'single'
153 # mode. If Koha was installed in 'dev' mode,
154 # __KOHA_CONF_DIR__ is *not* rewritten; instead
155 # developers should set the KOHA_CONF environment variable
157 $context = undef; # Initially, no context is set
158 @context_stack = (); # Initially, no saved contexts
162 returns the kohaversion stored in kohaversion.pl file
167 my $cgidir = C4::Context->intranetdir ."/cgi-bin";
169 # 2 cases here : on CVS install, $cgidir does not need a /cgi-bin
170 # on a standard install, /cgi-bin need to be added.
171 # test one, then the other
172 # FIXME - is this all really necessary?
173 unless (opendir(DIR, "$cgidir/cataloguing/value_builder")) {
174 $cgidir = C4::Context->intranetdir;
178 do $cgidir."/kohaversion.pl" || die "NO $cgidir/kohaversion.pl";
179 return kohaversion();
181 =item read_config_file
185 Reads the specified Koha config file.
187 Returns an object containing the configuration variables. The object's
188 structure is a bit complex to the uninitiated ... take a look at the
189 koha-conf.xml file as well as the XML::Simple documentation for details. Or,
190 here are a few examples that may give you what you need:
192 The simple elements nested within the <config> element:
194 my $pass = $koha->{'config'}->{'pass'};
196 The <listen> elements:
198 my $listen = $koha->{'listen'}->{'biblioserver'}->{'content'};
200 The elements nested within the <server> element:
202 my $ccl2rpn = $koha->{'server'}->{'biblioserver'}->{'cql2rpn'};
204 Returns undef in case of error.
210 sub read_config_file { # Pass argument naming config file to read
211 my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
212 return $koha; # Return value: ref-to-hash holding the configuration
216 # Translates the full text name of a database into de appropiate dbi name
222 # FIXME - Should have other databases.
223 if (/mysql/i) { return("mysql"); }
224 if (/Postgres|Pg|PostgresSQL/) { return("Pg"); }
225 if (/oracle/i) { return("Oracle"); }
227 return undef; # Just in case
232 my $conf_fname = shift; # Config file name
235 # Create a new context from the given config file name, if
236 # any, then set it as the current context.
237 $context = new C4::Context($conf_fname);
238 return undef if !defined($context);
239 $context->set_context;
244 $context = new C4::Context;
245 $context = new C4::Context("/path/to/koha-conf.xml");
247 Allocates a new context. Initializes the context from the specified
248 file, which defaults to either the file given by the C<$KOHA_CONF>
249 environment variable, or F</etc/koha/koha-conf.xml>.
251 C<&new> does not set this context as the new default context; for
252 that, use C<&set_context>.
258 # 2004-08-10 A. Tarallo: Added check if the conf file is not empty
261 my $conf_fname = shift; # Config file to load
264 # check that the specified config file exists and is not empty
265 undef $conf_fname unless
266 (defined $conf_fname && -e $conf_fname && -s $conf_fname);
267 # Figure out a good config file to load if none was specified.
268 if (!defined($conf_fname))
270 # If the $KOHA_CONF environment variable is set, use
271 # that. Otherwise, use the built-in default.
272 if (exists $ENV{"KOHA_CONF"} and $ENV{'KOHA_CONF'} and -e $ENV{"KOHA_CONF"} and -s $ENV{"KOHA_CONF"}) {
273 $conf_fname = $ENV{"KOHA_CONF"};
274 } elsif ($INSTALLED_CONFIG_FNAME !~ /__KOHA_CONF_DIR/ and -e $INSTALLED_CONFIG_FNAME and -s $INSTALLED_CONFIG_FNAME) {
275 # NOTE: be careful -- don't change __KOHA_CONF_DIR in the above
276 # regex to anything else -- don't want installer to rewrite it
277 $conf_fname = $INSTALLED_CONFIG_FNAME;
278 } elsif (-e CONFIG_FNAME and -s CONFIG_FNAME) {
279 $conf_fname = CONFIG_FNAME;
281 warn "unable to locate Koha configuration file koha-conf.xml";
285 # Load the desired config file.
286 $self = read_config_file($conf_fname);
287 $self->{"config_file"} = $conf_fname;
289 warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
290 return undef if !defined($self->{"config"});
292 $self->{"dbh"} = undef; # Database handle
293 $self->{"Zconn"} = undef; # Zebra Connections
294 $self->{"stopwords"} = undef; # stopwords list
295 $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
296 $self->{"userenv"} = undef; # User env
297 $self->{"activeuser"} = undef; # current active user
305 $context = new C4::Context;
306 $context->set_context();
308 set_context C4::Context $context;
311 restore_context C4::Context;
313 In some cases, it might be necessary for a script to use multiple
314 contexts. C<&set_context> saves the current context on a stack, then
315 sets the context to C<$context>, which will be used in future
316 operations. To restore the previous context, use C<&restore_context>.
324 my $new_context; # The context to set
326 # Figure out whether this is a class or instance method call.
328 # We're going to make the assumption that control got here
329 # through valid means, i.e., that the caller used an instance
330 # or class method call, and that control got here through the
331 # usual inheritance mechanisms. The caller can, of course,
332 # break this assumption by playing silly buggers, but that's
333 # harder to do than doing it properly, and harder to check
335 if (ref($self) eq "")
337 # Class method. The new context is the next argument.
338 $new_context = shift;
340 # Instance method. The new context is $self.
341 $new_context = $self;
344 # Save the old context, if any, on the stack
345 push @context_stack, $context if defined($context);
347 # Set the new context
348 $context = $new_context;
351 =item restore_context
355 Restores the context set by C<&set_context>.
364 if ($#context_stack < 0)
367 die "Context stack underflow";
370 # Pop the old context and set it.
371 $context = pop @context_stack;
373 # FIXME - Should this return something, like maybe the context
374 # that was current when this was called?
379 $value = C4::Context->config("config_variable");
381 $value = C4::Context->config_variable;
383 Returns the value of a variable specified in the configuration file
384 from which the current context was created.
386 The second form is more compact, but of course may conflict with
387 method names. If there is a configuration variable called "new", then
388 C<C4::Config-E<gt>new> will not return it.
392 sub _common_config ($$) {
395 return undef if !defined($context->{$term});
396 # Presumably $self->{$term} might be
397 # undefined if the config file given to &new
398 # didn't exist, and the caller didn't bother
399 # to check the return value.
401 # Return the value of the requested config variable
402 return $context->{$term}->{$var};
406 return _common_config($_[1],'config');
409 return _common_config($_[1],'server');
412 return _common_config($_[1],'serverinfo');
417 $sys_preference = C4::Context->preference("some_variable");
419 Looks up the value of the given system preference in the
420 systempreferences table of the Koha database, and returns it. If the
421 variable is not set, or in case of error, returns the undefined value.
426 # FIXME - The preferences aren't likely to change over the lifetime of
427 # the script (and things might break if they did change), so perhaps
428 # this function should cache the results it finds.
432 my $var = shift; # The system preference to return
433 my $retval; # Return value
434 my $dbh = C4::Context->dbh or return 0;
435 # Look up systempreferences.variable==$var
436 $retval = $dbh->selectrow_array(<<EOT);
438 FROM systempreferences
439 WHERE variable='$var'
445 sub boolean_preference ($) {
447 my $var = shift; # The system preference to return
448 my $it = preference($self, $var);
449 return defined($it)? C4::Boolean::true_p($it): undef;
453 # This implements C4::Config->foo, and simply returns
454 # C4::Context->config("foo"), as described in the documentation for
457 # FIXME - Perhaps this should be extended to check &config first, and
458 # then &preference if that fails. OTOH, AUTOLOAD could lead to crappy
459 # code, so it'd probably be best to delete it altogether so as not to
460 # encourage people to use it.
465 $AUTOLOAD =~ s/.*:://; # Chop off the package name,
466 # leaving only the function name.
467 return $self->config($AUTOLOAD);
472 $Zconn = C4::Context->Zconn
474 Returns a connection to the Zebra database for the current
475 context. If no connection has yet been made, this method
476 creates one and connects.
480 C<$server> one of the servers defined in the koha-conf.xml file
482 C<$async> whether this is a asynchronous connection
484 C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
496 if ( defined($context->{"Zconn"}->{$server}) ) {
497 return $context->{"Zconn"}->{$server};
498 # No connection object or it died. Create one.
500 $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
501 return $context->{"Zconn"}->{$server};
507 $context->{"Zconn"} = &_new_Zconn($server,$async);
509 Internal function. Creates a new database connection from the data given in the current context and returns it.
511 C<$server> one of the servers defined in the koha-conf.xml file
513 C<$async> whether this is a asynchronous connection
515 C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
520 my ($server,$async,$auth,$piggyback,$syntax) = @_;
522 my $tried=0; # first attempt
523 my $Zconn; # connection object
524 $server = "biblioserver" unless $server;
525 $syntax = "usmarc" unless $syntax;
527 my $host = $context->{'listen'}->{$server}->{'content'};
528 my $servername = $context->{"config"}->{$server};
529 my $user = $context->{"serverinfo"}->{$server}->{"user"};
530 my $password = $context->{"serverinfo"}->{$server}->{"password"};
531 $auth = 1 if($user && $password);
535 my $o = new ZOOM::Options();
536 $o->option(user=>$user) if $auth;
537 $o->option(password=>$password) if $auth;
538 $o->option(async => 1) if $async;
539 $o->option(count => $piggyback) if $piggyback;
540 $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
541 $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
542 $o->option(preferredRecordSyntax => $syntax);
543 $o->option(elementSetName => "F"); # F for 'full' as opposed to B for 'brief'
544 $o->option(databaseName => ($servername?$servername:"biblios"));
546 # create a new connection object
547 $Zconn= create ZOOM::Connection($o);
550 $Zconn->connect($host, 0);
552 # check for errors and warn
553 if ($Zconn->errcode() !=0) {
554 warn "something wrong with the connection: ". $Zconn->errmsg();
559 # # Koha manages the Zebra server -- this doesn't work currently for me because of permissions issues
560 # # Also, I'm skeptical about whether it's the best approach
561 # warn "problem with Zebra";
562 # if ( C4::Context->preference("ManageZebra") ) {
563 # if ($@->code==10000 && $tried==0) { ##No connection try restarting Zebra
565 # warn "trying to restart Zebra";
566 # my $res=system("zebrasrv -f $ENV{'KOHA_CONF'} >/koha/log/zebra-error.log");
569 # warn "Error ", $@->code(), ": ", $@->message(), "\n";
579 # Internal helper function (not a method!). This creates a new
580 # database connection from the data given in the current context, and
586 ##correct name for db_schme
588 if ($context->config("db_scheme")){
589 $db_driver=db_scheme2dbi($context->config("db_scheme"));
594 my $db_name = $context->config("database");
595 my $db_host = $context->config("hostname");
596 my $db_port = $context->config("port");
597 $db_port = "" unless defined $db_port;
598 my $db_user = $context->config("user");
599 my $db_passwd = $context->config("pass");
600 # MJR added or die here, as we can't work without dbh
601 my $dbh= DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
602 $db_user, $db_passwd) or die $DBI::errstr;
604 if ( $db_driver eq 'mysql' ) {
605 # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
606 # this is better than modifying my.cnf (and forcing all communications to be in utf8)
607 $dbh->{'mysql_enable_utf8'}=1; #enable
608 $dbh->do("set NAMES 'utf8'");
610 elsif ( $db_driver eq 'Pg' ) {
611 $dbh->do( "set client_encoding = 'UTF8';" );
618 $dbh = C4::Context->dbh;
620 Returns a database handle connected to the Koha database for the
621 current context. If no connection has yet been made, this method
622 creates one, and connects to the database.
624 This database handle is cached for future use: if you call
625 C<C4::Context-E<gt>dbh> twice, you will get the same handle both
626 times. If you need a second database handle, use C<&new_dbh> and
627 possibly C<&set_dbh>.
637 if (defined($context->{"dbh"})) {
638 $sth=$context->{"dbh"}->prepare("select 1");
639 return $context->{"dbh"} if (defined($sth->execute));
642 # No database handle or it died . Create one.
643 $context->{"dbh"} = &_new_dbh();
645 return $context->{"dbh"};
650 $dbh = C4::Context->new_dbh;
652 Creates a new connection to the Koha database for the current context,
653 and returns the database handle (a C<DBI::db> object).
655 The handle is not saved anywhere: this method is strictly a
656 convenience function; the point is that it knows which database to
657 connect to so that the caller doesn't have to know.
671 $my_dbh = C4::Connect->new_dbh;
672 C4::Connect->set_dbh($my_dbh);
674 C4::Connect->restore_dbh;
676 C<&set_dbh> and C<&restore_dbh> work in a manner analogous to
677 C<&set_context> and C<&restore_context>.
679 C<&set_dbh> saves the current database handle on a stack, then sets
680 the current database handle to C<$my_dbh>.
682 C<$my_dbh> is assumed to be a good database handle.
692 # Save the current database handle on the handle stack.
693 # We assume that $new_dbh is all good: if the caller wants to
694 # screw himself by passing an invalid handle, that's fine by
696 push @{$context->{"dbh_stack"}}, $context->{"dbh"};
697 $context->{"dbh"} = $new_dbh;
702 C4::Context->restore_dbh;
704 Restores the database handle saved by an earlier call to
705 C<C4::Context-E<gt>set_dbh>.
714 if ($#{$context->{"dbh_stack"}} < 0)
717 die "DBH stack underflow";
720 # Pop the old database handle and set it.
721 $context->{"dbh"} = pop @{$context->{"dbh_stack"}};
723 # FIXME - If it is determined that restore_context should
724 # return something, then this function should, too.
727 =item marcfromkohafield
729 $dbh = C4::Context->marcfromkohafield;
731 Returns a hash with marcfromkohafield.
733 This hash is cached for future use: if you call
734 C<C4::Context-E<gt>marcfromkohafield> twice, you will get the same hash without real DB access
739 sub marcfromkohafield
743 # If the hash already exists, return it.
744 return $context->{"marcfromkohafield"} if defined($context->{"marcfromkohafield"});
746 # No hash. Create one.
747 $context->{"marcfromkohafield"} = &_new_marcfromkohafield();
749 return $context->{"marcfromkohafield"};
752 # _new_marcfromkohafield
753 # Internal helper function (not a method!). This creates a new
754 # hash with stopwords
755 sub _new_marcfromkohafield
757 my $dbh = C4::Context->dbh;
758 my $marcfromkohafield;
759 my $sth = $dbh->prepare("select frameworkcode,kohafield,tagfield,tagsubfield from marc_subfield_structure where kohafield > ''");
761 while (my ($frameworkcode,$kohafield,$tagfield,$tagsubfield) = $sth->fetchrow) {
763 $marcfromkohafield->{$frameworkcode}->{$kohafield} = [$tagfield,$tagsubfield];
765 return $marcfromkohafield;
770 $dbh = C4::Context->stopwords;
772 Returns a hash with stopwords.
774 This hash is cached for future use: if you call
775 C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real DB access
784 # If the hash already exists, return it.
785 return $context->{"stopwords"} if defined($context->{"stopwords"});
787 # No hash. Create one.
788 $context->{"stopwords"} = &_new_stopwords();
790 return $context->{"stopwords"};
794 # Internal helper function (not a method!). This creates a new
795 # hash with stopwords
798 my $dbh = C4::Context->dbh;
800 my $sth = $dbh->prepare("select word from stopwords");
802 while (my $stopword = $sth->fetchrow_array) {
804 $stopwordlist->{$stopword} = uc($stopword);
806 $stopwordlist->{A} = "A" unless $stopwordlist;
807 return $stopwordlist;
812 C4::Context->userenv;
814 Builds a hash for user environment variables.
816 This hash shall be cached for future use: if you call
817 C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
819 set_userenv is called in Auth.pm
826 my $var = $context->{"activeuser"};
827 return $context->{"userenv"}->{$var} if (defined $context->{"userenv"}->{$var});
828 # insecure=1 management
829 if ($context->{"dbh"} && $context->preference('insecure')) {
831 $insecure{flags} = '16382';
832 $insecure{branchname} ='Insecure';
833 $insecure{number} ='0';
834 $insecure{cardnumber} ='0';
835 $insecure{id} = 'insecure';
836 $insecure{branch} = 'INS';
837 $insecure{emailaddress} = 'test@mode.insecure.com';
846 C4::Context->set_userenv($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags, $emailaddress);
848 Informs a hash for user environment variables.
850 This hash shall be cached for future use: if you call
851 C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
853 set_userenv is called in Auth.pm
859 my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
860 my $var=$context->{"activeuser"};
862 "number" => $usernum,
864 "cardnumber" => $usercnum,
865 "firstname" => $userfirstname,
866 "surname" => $usersurname,
867 #possibly a law problem
868 "branch" => $userbranch,
869 "branchname" => $branchname,
870 "flags" => $userflags,
871 "emailaddress" => $emailaddress,
872 "branchprinter" => $branchprinter
874 $context->{userenv}->{$var} = $cell;
880 C4::Context->_new_userenv($session);
882 Builds a hash for user environment variables.
884 This hash shall be cached for future use: if you call
885 C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
887 _new_userenv is called in Auth.pm
896 $context->{"activeuser"}=$sessionID;
901 C4::Context->_unset_userenv;
903 Destroys the hash for activeuser user environment variables.
912 undef $context->{"activeuser"} if ($context->{"activeuser"} eq $sessionID);
918 C4::Context->get_versions
920 Gets 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'.
926 # A little example sub to show more debugging info for CGI::Carp
929 $versions{kohaVersion} = C4::Context->config("kohaversion");
930 $versions{osVersion} = `uname -a`;
931 $versions{perlVersion} = $];
932 $versions{mysqlVersion} = `mysql -V`;
933 $versions{apacheVersion} = `httpd -v`;
934 $versions{apacheVersion} = `httpd2 -v` unless $versions{apacheVersion} ;
935 $versions{apacheVersion} = `apache2 -v` unless $versions{apacheVersion} ;
936 $versions{apacheVersion} = `/usr/sbin/apache2 -v` unless $versions{apacheVersion} ;
952 Specifies the configuration file to read.
962 Andrew Arensburger <arensb at ooblick dot com>
964 Joshua Ferraro <jmf at liblime dot com>
968 # Revision 1.57 2007/05/22 09:13:55 tipaul
969 # Bugfixes & improvements (various and minor) :
970 # - updating templates to have tmpl_process3.pl running without any errors
971 # - adding a drupal-like css for prog templates (with 3 small images)
972 # - fixing some bugs in circulation & other scripts
973 # - updating french translation
974 # - fixing some typos in templates
976 # Revision 1.56 2007/04/23 15:21:17 tipaul
977 # renaming currenttransfers to transferstoreceive
979 # Revision 1.55 2007/04/17 08:48:00 tipaul
980 # circulation cleaning continued: bufixing
982 # Revision 1.54 2007/03/29 16:45:53 tipaul
983 # Code cleaning of Biblio.pm (continued)
985 # All subs have be cleaned :
988 # - reordering Biblio.pm completly
989 # - using only naming conventions
991 # Seems to have broken nothing, but it still has to be heavily tested.
992 # Note that Biblio.pm is now much more efficient than previously & probably more reliable as well.
994 # Revision 1.53 2007/03/29 13:30:31 tipaul
996 # == Biblio.pm cleaning (useless) ==
997 # * some sub declaration dropped
998 # * removed modbiblio sub
999 # * removed moditem sub
1000 # * removed newitems. It was used only in finishrecieve. Replaced by a TransformKohaToMarc+AddItem, that is better.
1001 # * removed MARCkoha2marcItem
1002 # * removed MARCdelsubfield declaration
1003 # * removed MARCkoha2marcBiblio
1005 # == Biblio.pm cleaning (naming conventions) ==
1006 # * MARCgettagslib renamed to GetMarcStructure
1007 # * MARCgetitems renamed to GetMarcItem
1008 # * MARCfind_frameworkcode renamed to GetFrameworkCode
1009 # * MARCmarc2koha renamed to TransformMarcToKoha
1010 # * MARChtml2marc renamed to TransformHtmlToMarc
1011 # * MARChtml2xml renamed to TranformeHtmlToXml
1012 # * zebraop renamed to ModZebra
1015 # * removing MARC=OFF related scripts (in cataloguing directory)
1016 # * removed checkitems (function related to MARC=off feature, that is completly broken in head. If someone want to reintroduce it, hard work coming...)
1017 # * removed getitemsbybiblioitem (used only by MARC=OFF scripts, that is removed as well)
1019 # Revision 1.52 2007/03/16 01:25:08 kados
1020 # Using my precrash CVS copy I did the following:
1022 # cvs -z3 -d:ext:kados@cvs.savannah.nongnu.org:/sources/koha co -P koha
1023 # find koha.precrash -type d -name "CVS" -exec rm -v {} \;
1024 # cp -r koha.precrash/* koha/
1028 # This should in theory put us right back where we were before the crash
1030 # Revision 1.52 2007/03/12 21:17:05 rych
1031 # add server, serverinfo as arrays from config
1033 # Revision 1.51 2007/03/09 14:31:47 tipaul
1034 # rel_3_0 moved to HEAD
1036 # Revision 1.43.2.10 2007/02/09 17:17:56 hdl
1037 # Managing a little better database absence.
1038 # (preventing from BIG 550)
1040 # Revision 1.43.2.9 2006/12/20 16:50:48 tipaul
1041 # improving "insecure" management
1044 # you told me that you had some libraries with insecure=ON (behind a firewall).
1045 # 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.
1047 # Revision 1.43.2.8 2006/12/19 16:48:16 alaurin
1048 # reident programs, and adding branchcode value in reserves
1050 # Revision 1.43.2.7 2006/12/06 21:55:38 hdl
1051 # Adding ModZebrations for servers to get serverinfos in Context.pm
1052 # Using this function in rebuild_zebra.pl
1054 # Revision 1.43.2.6 2006/11/24 21:18:31 kados
1055 # very minor changes, no functional ones, just comments, etc.
1057 # Revision 1.43.2.5 2006/10/30 13:24:16 toins
1058 # fix some minor POD error.
1060 # Revision 1.43.2.4 2006/10/12 21:42:49 hdl
1061 # Managing multiple zebra connections
1063 # Revision 1.43.2.3 2006/10/11 14:27:26 tipaul
1064 # removing a warning
1066 # Revision 1.43.2.2 2006/10/10 15:28:16 hdl
1067 # BUG FIXING : using database name in Zconn if defined and not hard coded value
1069 # Revision 1.43.2.1 2006/10/06 13:47:28 toins
1070 # Synch with dev_week.
1071 # /!\ WARNING :: Please now use the new version of koha.xml.
1073 # Revision 1.18.2.5.2.14 2006/09/24 15:24:06 kados
1074 # remove Zebraauth routine, fold the functionality into Zconn
1075 # Zconn can now take several arguments ... this will probably
1076 # change soon as I'm not completely happy with the readability
1077 # of the current format ... see the POD for details.
1079 # cleaning up Biblio.pm, removing unnecessary routines.
1081 # DeleteBiblio - used to delete a biblio from zebra and koha tables
1082 # -- checks to make sure there are no existing issues
1083 # -- saves backups of biblio,biblioitems,items in deleted* tables
1084 # -- does commit operation
1086 # getRecord - used to retrieve one record from zebra in piggyback mode using biblionumber
1087 # brought back z3950_extended_services routine
1089 # Lots of modifications to Context.pm, you can now store user and pass info for
1090 # multiple servers (for federated searching) using the <serverinfo> element.
1091 # I'll commit my koha.xml to demonstrate this or you can refer to the POD in
1092 # Context.pm (which I also expanded on).
1094 # Revision 1.18.2.5.2.13 2006/08/10 02:10:21 kados
1095 # Turned warnings on, and running a search turned up lots of warnings.
1096 # Cleaned up those ...
1098 # removed getitemtypes from Koha.pm (one in Search.pm looks newer)
1099 # removed itemcount from Biblio.pm
1101 # made some local subs local with a _ prefix (as they were redefined
1104 # Add two new search subs to Search.pm the start of a new search API
1105 # that's a bit more scalable
1107 # Revision 1.18.2.5.2.10 2006/07/21 17:50:51 kados
1108 # moving the *.properties files to intranetdir/etc dir
1110 # Revision 1.18.2.5.2.9 2006/07/17 08:05:20 tipaul
1111 # there was a hardcoded link to /koha/etc/ I replaced it with intranetdir config value
1113 # Revision 1.18.2.5.2.8 2006/07/11 12:20:37 kados
1114 # adding ccl and cql files ... Tumer, if you want to fit these into the
1115 # config file by all means do.
1117 # Revision 1.18.2.5.2.7 2006/06/04 22:50:33 tgarip1957
1118 # We do not hard code cql2rpn conversion file in context.pm our koha.xml configuration file already describes the path for this file.
1119 # At cql searching we use method CQL not CQL2RPN as the cql2rpn conversion file is defined at server level
1121 # Revision 1.18.2.5.2.6 2006/06/02 23:11:24 kados
1122 # Committing my working dev_week. It's been tested only with
1123 # searching, and there's quite a lot of config stuff to set up
1124 # beforehand. As things get closer to a release, we'll be making
1125 # some scripts to do it for us
1127 # Revision 1.18.2.5.2.5 2006/05/28 18:49:12 tgarip1957
1128 # This is an unusual commit. The main purpose is a working model of Zebra on a modified rel2_2.
1129 # Any questions regarding these commits should be asked to Joshua Ferraro unless you are Joshua whom I'll report to
1131 # Revision 1.36 2006/05/09 13:28:08 tipaul
1132 # adding the branchname and the librarian name in every page :
1133 # - modified userenv to add branchname
1134 # - modifier menus.inc to have the librarian name & userenv displayed on every page. they are in a librarian_information div.
1136 # Revision 1.35 2006/04/13 08:40:11 plg
1137 # bug fixed: typo on Zconnauth name
1139 # Revision 1.34 2006/04/10 21:40:23 tgarip1957
1140 # 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:
1142 # zebraport=<your port>
1143 # zebrauser=<username>
1144 # zebrapass=<password>
1146 # The zebra.cfg file should read:
1149 # passw.c:<yourpasswordfile>
1151 # Password file should be prepared with Apaches htpasswd utility in encrypted mode and should exist in a folder zebra.cfg can read
1153 # Revision 1.33 2006/03/15 11:21:56 plg
1154 # bug fixed: utf-8 data where not displayed correctly in screens. Supposing
1155 # your data are truely utf-8 encoded in your database, they should be
1156 # correctly displayed. "set names 'UTF8'" on mysql connection (C4/Context.pm)
1157 # is mandatory and "binmode" to utf8 (C4/Interface/CGI/Output.pm) seemed to
1158 # converted data twice, so it was removed.
1160 # Revision 1.32 2006/03/03 17:25:01 hdl
1161 # Bug fixing : a line missed a comment sign.
1163 # Revision 1.31 2006/03/03 16:45:36 kados
1164 # Remove the search that tests the Zconn -- warning, still no fault
1167 # Revision 1.30 2006/02/22 00:56:59 kados
1168 # First go at a connection object for Zebra. You can now get a
1169 # connection object by doing:
1171 # my $Zconn = C4::Context->Zconn;
1173 # My initial tests indicate that as soon as your funcion ends
1174 # (ie, when you're done doing something) the connection will be
1175 # closed automatically. There may be some other way to make the
1176 # connection more stateful, I'm not sure...