Esempio n. 1
0
 public function test_listFile()
 {
     USVN_SVNUtils::createSVN('tests/tmp/svn/test');
     USVN_SVNUtils::createStandardDirectories('tests/tmp/svn/test');
     USVN_SVNUtils::checkoutSvn('tests/tmp/svn/test', 'tests/tmp/out');
     $path = getcwd();
     chdir('tests/tmp/out');
     mkdir('trunk/testdir');
     `svn add trunk/testdir`;
     touch('trunk/testfile');
     `svn add trunk/testfile`;
     `svn commit --non-interactive -m Test`;
     chdir($path);
     $svn = new USVN_SVN('test');
     $res = $svn->listFile('/');
     $this->assertEquals(3, count($res));
     $this->assertContains(array("name" => "trunk", "isDirectory" => true, "path" => "/trunk/"), $res);
     $this->assertContains(array("name" => "branches", "isDirectory" => true, "path" => "/branches/"), $res);
     $this->assertContains(array("name" => "tags", "isDirectory" => true, "path" => "/tags/"), $res);
     $res = $svn->listFile('/trunk');
     $this->assertEquals(2, count($res));
     $this->assertContains(array("name" => "testdir", "isDirectory" => true, "path" => "/trunk/testdir/"), $res);
     $this->assertContains(array("name" => "testfile", "isDirectory" => false, "path" => "/trunk/testfile"), $res);
 }
Esempio n. 2
0
 /**
  * Get list files of subversion directory.
  */
 public function getListFileAction()
 {
     $path = str_replace('//', '/', $_GET['name']);
     $project_name = str_replace(USVN_URL_SEP, '/', $this->_request->getParam('project'));
     $SVN = new USVN_SVN($project_name);
     $tab = $SVN->listFile($path);
     ob_start();
     echo $this->getTopLink($project_name, $path);
     $user = $this->getRequest()->getParam('user');
     /* @var $user USVN_Db_Table_Row_User */
     $table = new USVN_Db_Table_Projects();
     $project = $table->findByName($this->getRequest()->getParam('project'));
     $read = false;
     $acces_rights = new USVN_FilesAccessRights($project->id);
     $groups = $user->getAllGroupsFor($project);
     foreach ($groups as $group) {
         $access = $acces_rights->findByPath($group->id, $path);
         if ($access['read']) {
             $read = true;
             break;
         }
     }
     if (!$read && ($user->is_admin || $project->userIsAdmin($user))) {
         $read = true;
     }
     if ($read) {
         echo '<table class="usvn_table">';
         echo '<thead>';
         echo '<tr><th>', T_('Name'), '</th><th>', T_('File revision'), '</th><th width="50px">', T_('Action'), '</th></tr>';
         echo '</thead>';
         echo '<tbody>';
         $i = 0;
         if ($path != "/" && $path != "//") {
             if (dirname($path) == "\\") {
                 $pathbefore = "/";
             } else {
                 $pathbefore = dirname($path) . "/";
             }
             echo "<tr class=\"" . (++$i % 2 ? 'even' : 'odd') . "\"><td>";
             echo "<a href='javascript:getListFile(" . "\"" . $pathbefore . "\"" . ");'>" . $this->view->img('folder.png', T_('Folder')) . " ..</a></td><td></td><td></td></tr>";
         }
         foreach ($tab as &$tabl) {
             $tabl['path_raw'] = $tabl['path'];
             $tabl['path'] = rawurlencode($tabl['path']);
             echo "<tr class=\"" . (++$i % 2 ? 'even' : 'odd') . "\">";
             $dir = false;
             if ($tabl['isDirectory'] == 1) {
                 $dir = true;
                 $tabl['isDirectory'] = $this->view->img('folder.png', T_('Folder'));
             } else {
                 $tabl['isDirectory'] = $this->view->img('file.png', T_('File'));
             }
             echo "<td>";
             if ($dir) {
                 echo "<a href='javascript:getListFile(\"{$tabl['path']}\");'>{$tabl['isDirectory']} {$tabl['name']}</a></td>";
             } else {
                 $tabl['size'] = round($tabl['size'] / 1000.0, 2) . ' Ko';
                 echo "<a href=\"" . $this->view->url(array('project' => $project->name, 'file' => substr($tabl['path_raw'], 1)), 'show', false, false) . "\">{$tabl['isDirectory']} {$tabl['name']}</a> <span style=\"font-size: 8px; text-align: right;\">({$tabl['size']})</span></td>";
             }
             if (isset($tabl['revision'])) {
                 echo "<td><a href=\"" . $this->view->url(array('project' => $project->name, 'action' => 'commit', 'commit' => $tabl['revision']), 'commit') . "\">{$tabl['revision']}</a> by {$tabl['author']}</td>";
             } else {
                 echo "<td></td>";
             }
             echo "<td class=\"align-center\"><a href='javascript:dumpRights(\"{$tabl['path']}\");'>" . $this->view->img('lock.png', T_('Rights')) . "</a></td></tr>";
         }
         echo "</tbody></table>";
     } else {
         echo T_("You don't have read access to this folder");
     }
     $txthtml = ob_get_clean();
     echo "<txthtml><![CDATA[";
     echo $txthtml;
     echo "]]></txthtml>\n";
     $this->view->browser = $tab;
 }
Esempio n. 3
0
 public function indexAction()
 {
     $this->view->project = $this->_project;
     $SVN = new USVN_SVN($this->_project->name);
     $config = Zend_Registry::get('config');
     $this->view->subversion_url = $config->subversion->url . $this->_project->name;
     foreach ($SVN->listFile('/') as $dir) {
         if ($dir['name'] == 'trunk') {
             $this->view->subversion_url .= '/trunk';
         }
     }
     $this->view->log = $SVN->log(5);
 }