Repository can now take in an array of repositories to include to explicitly allow...
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Apr 2007 05:27:14 +0000 (05:27 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 10 Apr 2007 05:27:14 +0000 (05:27 +0000)
includes/config.php.new
includes/init.php
includes/repository.php

index e51b96159bdf4621b3bc5fe27584eb587d28f32c..592c6d8851428fc4520e766f9984f2948830aa22 100644 (file)
@@ -23,7 +23,8 @@
 // ///////////////////////// REPOSITORY PATH
 // -------------------------------------------------------------------
 // The path to your repository or the parent-path for a directory of
-// repositories
+// repositories. This can also be an array to specify individual
+// repository paths.
 $conf['repository']['path'] = '/home/svn/repos/';
 
 // ###################################################################
@@ -32,6 +33,11 @@ $conf['repository']['path'] = '/home/svn/repos/';
 // Set this to TRUE if the above path is actually a parent-path
 $conf['repository']['iscontainer'] = false;
 
+// Repository names to include in the container. If this array is empty,
+// all repositories will be added, otherwise it will only be the ones
+// in the array.
+$conf['repository']['include'] = array();
+
 // ###################################################################
 // ///////////////////////// WEB PATH
 // -------------------------------------------------------------------
index ba393ac067c7c04c8efd23b24382c10add1d3a33..1f9a911f4c6cb4d7d10fa63a161795f6fd2ea01e 100644 (file)
@@ -67,7 +67,7 @@ $viewsvn->trigger =& new Imaginary();
 // ###################################################################
 // setup repository
 require_once('./includes/repository.php');
-BSRegister::Register('repos', $repos = new Repository($conf['repository']['path'], $conf['repository']['iscontainer']));
+BSRegister::Register('repos', $repos = new Repository($conf['repository']['path'], $conf['repository']['iscontainer'], $conf['repository']['include']));
 
 // ###################################################################
 // path manager
index 51f78fe0864322164fcbd917301d1318332e5673..a6bb37df09352b90a2de223ec6d619a4e34ac977 100644 (file)
@@ -40,13 +40,7 @@ class Repository
        * @var  array
        */
        private $repositories = array();
-       
-       /**
-       * Root path to the repository
-       * @var string
-       */
-       private $path;
-       
+
        /**
        * Whether or not the path is a container
        * @var  bool
@@ -57,39 +51,50 @@ class Repository
        /**
        * Constructor: prepare for repository
        *
-       * @param        string  Path to repository or container
+       * @param        mixed   Path to repository or container
        * @param        bool    Whether the path is a container
+       * @param        array   Array of paths to include (only applicable with containers)
        */
-       function __construct($path, $iscontainer)
+       function __construct($path, $iscontainer, $include)
        {
                global $viewsvn;
                
-               $this->path = BSFunctions::FetchSourcePath($path);
-               $this->container = (bool)$iscontainer;
-               
-               if ($this->container)
+               if (is_array($include) AND sizeof($include) > 0 AND $iscontainer)
+               {
+                       $this->container = (sizeof($include) > 1);
+                       foreach ($include AS $repos)
+                       {
+                               $this->repositories[$repos] = BSFunctions::FetchSourcePath(BSFunctions::FetchSourcePath($path) . $repos);
+                       }
+               }
+               else
                {
-                       if ($dir = @opendir($this->path))
+                       $path = BSFunctions::FetchSourcePath($path);
+                       $this->container = (bool)$iscontainer;
+                       if ($this->container)
                        {
-                               while (($file = readdir($dir)) !== false)
+                               if ($dir = @opendir($path))
                                {
-                                       if (is_dir($this->path . $file) AND $file{0} != '.'  AND is_dir($this->path . $file . '/' . 'db'))
+                                       while (($file = readdir($dir)) !== false)
                                        {
-                                               $this->repositories[] = $file;
+                                               if (is_dir($path . $file) AND $file{0} != '.'  AND is_dir($path . $file . '/' . 'db'))
+                                               {
+                                                       $this->repositories[$file] = $path . $file;
+                                               }
                                        }
+                                       closedir($dir);
                                }
-                               closedir($dir);
                        }
-               }
-               else
-               {
-                       if (is_dir($this->path . 'db'))
+                       else
                        {
-                               $this->repositories[] = $this->path;
+                               if (is_dir($path . 'db'))
+                               {
+                                       $this->repositories[basename($path)] = $path;
+                               }
                        }
                }
                
-               sort($this->repositories);
+               ksort($this->repositories);
                
                if (sizeof($this->repositories) < 1)
                {
@@ -105,7 +110,7 @@ class Repository
        */
        public function fetchList()
        {
-               return $this->repositories;
+               return array_keys($this->repositories);
        }
        
        // ###################################################################
@@ -120,19 +125,12 @@ class Repository
        {
                global $viewsvn;
                
-               if (!in_array($repository, $this->repositories))
+               if (!isset($this->repositories[$repository]))
                {
                        $viewsvn->trigger->error(_('Invalid repository name specified'));
                }
                
-               if ($this->container)
-               {
-                       return 'file://' . $this->path . $repository;
-               }
-               else
-               {
-                       return 'file://' . $this->path;
-               }
+               return 'file://' . $this->repositories[$repository];
        }
        
        // ###################################################################