Commit d8df1674 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 282686: Multiple projects sharing the same Bugzilla codebase (different…

Bug 282686: Multiple projects sharing the same Bugzilla codebase (different datastores) - Patch by guillomovitch@zarb.org r=wurblzap a=justdave
parent 0e9fdfdc
...@@ -50,11 +50,23 @@ use base qw(Exporter); ...@@ -50,11 +50,23 @@ use base qw(Exporter);
# graphs (since the path will be wrong in the HTML). This will be fixed at # graphs (since the path will be wrong in the HTML). This will be fixed at
# some point. # some point.
# constant paths
our $libpath = '.'; our $libpath = '.';
our $localconfig = "$libpath/localconfig";
our $datadir = "$libpath/data";
our $attachdir = "$datadir/attachments";
our $templatedir = "$libpath/template"; our $templatedir = "$libpath/template";
# variable paths
our $project;
our $localconfig;
our $datadir;
if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) {
$project = $1;
$localconfig = "$libpath/localconfig.$project";
$datadir = "$libpath/data/$project";
} else {
$localconfig = "$libpath/localconfig";
$datadir = "$libpath/data";
}
our $attachdir = "$datadir/attachments";
our $webdotdir = "$datadir/webdot"; our $webdotdir = "$datadir/webdot";
# Module stuff # Module stuff
...@@ -71,8 +83,8 @@ our $webdotdir = "$datadir/webdot"; ...@@ -71,8 +83,8 @@ our $webdotdir = "$datadir/webdot";
( (
admin => [qw(GetParamList UpdateParams SetParam WriteParams)], admin => [qw(GetParamList UpdateParams SetParam WriteParams)],
db => [qw($db_driver $db_host $db_port $db_name $db_user $db_pass $db_sock)], db => [qw($db_driver $db_host $db_port $db_name $db_user $db_pass $db_sock)],
locations => [qw($libpath $localconfig $attachdir locations => [qw($libpath $localconfig $attachdir $datadir $templatedir
$datadir $templatedir $webdotdir)], $webdotdir $project)],
); );
Exporter::export_ok_tags('admin', 'db', 'locations'); Exporter::export_ok_tags('admin', 'db', 'locations');
......
...@@ -34,7 +34,7 @@ package Bugzilla::Template; ...@@ -34,7 +34,7 @@ package Bugzilla::Template;
use strict; use strict;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $templatedir $datadir); use Bugzilla::Config qw(:DEFAULT $templatedir $datadir $project);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Error; use Bugzilla::Error;
...@@ -110,10 +110,21 @@ sub getTemplateIncludePath { ...@@ -110,10 +110,21 @@ sub getTemplateIncludePath {
} }
my $languages = trim(Param('languages')); my $languages = trim(Param('languages'));
if (not ($languages =~ /,/)) { if (not ($languages =~ /,/)) {
return $template_include_path = if ($project) {
["$templatedir/$languages/custom", $template_include_path = [
"$templatedir/$languages/extension", "$templatedir/$languages/$project",
"$templatedir/$languages/default"]; "$templatedir/$languages/custom",
"$templatedir/$languages/extension",
"$templatedir/$languages/default"
];
} else {
$template_include_path = [
"$templatedir/$languages/custom",
"$templatedir/$languages/extension",
"$templatedir/$languages/default"
];
}
return $template_include_path;
} }
my @languages = sortAcceptLanguage($languages); my @languages = sortAcceptLanguage($languages);
my @accept_language = sortAcceptLanguage($ENV{'HTTP_ACCEPT_LANGUAGE'} || "" ); my @accept_language = sortAcceptLanguage($ENV{'HTTP_ACCEPT_LANGUAGE'} || "" );
...@@ -129,11 +140,27 @@ sub getTemplateIncludePath { ...@@ -129,11 +140,27 @@ sub getTemplateIncludePath {
} }
} }
push(@usedlanguages, Param('defaultlanguage')); push(@usedlanguages, Param('defaultlanguage'));
return $template_include_path = if ($project) {
[map(("$templatedir/$_/custom", $template_include_path = [
"$templatedir/$_/extension", map((
"$templatedir/$_/default"), "$templatedir/$_/$project",
@usedlanguages)]; "$templatedir/$_/custom",
"$templatedir/$_/extension",
"$templatedir/$_/default"
), @usedlanguages
)
];
} else {
$template_include_path = [
map((
"$templatedir/$_/custom",
"$templatedir/$_/extension",
"$templatedir/$_/default"
), @usedlanguages
)
];
}
return $template_include_path;
} }
sub put_header { sub put_header {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment