]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 282686: Multiple projects sharing the same Bugzilla codebase (different datastore...
authorlpsolit%gmail.com <>
Fri, 16 Sep 2005 05:16:51 +0000 (05:16 +0000)
committerlpsolit%gmail.com <>
Fri, 16 Sep 2005 05:16:51 +0000 (05:16 +0000)
Bugzilla/Config.pm
Bugzilla/Template.pm

index c124d62bd8bc82c0c6182443514290d13f413ffb..5ebc74e52035f6b025ff1b5b5f61e701b5ace5fa 100644 (file)
@@ -50,11 +50,23 @@ use base qw(Exporter);
 # graphs (since the path will be wrong in the HTML). This will be fixed at
 # some point.
 
+# constant paths
 our $libpath = '.';
-our $localconfig = "$libpath/localconfig";
-our $datadir = "$libpath/data";
-our $attachdir = "$datadir/attachments";
 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";
 
 # Module stuff
@@ -71,8 +83,8 @@ our $webdotdir = "$datadir/webdot";
   (
    admin => [qw(GetParamList UpdateParams SetParam WriteParams)],
    db => [qw($db_driver $db_host $db_port $db_name $db_user $db_pass $db_sock)],
-   locations => [qw($libpath $localconfig $attachdir
-                    $datadir $templatedir $webdotdir)],
+   locations => [qw($libpath $localconfig $attachdir $datadir $templatedir
+                    $webdotdir $project)],
   );
 Exporter::export_ok_tags('admin', 'db', 'locations');
 
index 92201507ff50ab41ed55a65528b6116ca4cd163b..a4b8084d0692558d9e1254e2d1da74af9600acb6 100644 (file)
@@ -34,7 +34,7 @@ package Bugzilla::Template;
 use strict;
 
 use Bugzilla::Constants;
-use Bugzilla::Config qw(:DEFAULT $templatedir $datadir);
+use Bugzilla::Config qw(:DEFAULT $templatedir $datadir $project);
 use Bugzilla::Util;
 use Bugzilla::User;
 use Bugzilla::Error;
@@ -110,10 +110,21 @@ sub getTemplateIncludePath {
     }
     my $languages = trim(Param('languages'));
     if (not ($languages =~ /,/)) {
-        return $template_include_path =
-               ["$templatedir/$languages/custom",
-                "$templatedir/$languages/extension",
-                "$templatedir/$languages/default"];
+       if ($project) {
+           $template_include_path = [
+               "$templatedir/$languages/$project",
+               "$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 @accept_language = sortAcceptLanguage($ENV{'HTTP_ACCEPT_LANGUAGE'} || "" );
@@ -129,11 +140,27 @@ sub getTemplateIncludePath {
         }
     }
     push(@usedlanguages, Param('defaultlanguage'));
-    return $template_include_path =
-        [map(("$templatedir/$_/custom",
-              "$templatedir/$_/extension",
-              "$templatedir/$_/default"),
-             @usedlanguages)];
+    if ($project) {
+        $template_include_path = [
+           map((
+               "$templatedir/$_/$project",
+               "$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 {