* Copyright 2004, GForge, LLC * * This file is part of FusionForge. * * FusionForge is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * FusionForge is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FusionForge; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ class SVNPlugin extends SCM { function SVNPlugin () { global $gfconfig; $this->SCM () ; $this->name = 'scmsvn'; $this->text = 'SVN'; $this->hooks[] = 'scm_page'; $this->hooks[] = 'scm_admin_update'; $this->hooks[] = 'scm_admin_page'; // to be revised $this->hooks[] = 'scm_stats'; $this->hooks[] = 'scm_plugin'; require_once $gfconfig.'plugins/scmsvn/config.php' ; $this->default_svn_server = $default_svn_server ; $this->enabled_by_default = $enabled_by_default ; $this->use_ssh = $use_ssh; $this->use_dav = $use_dav; $this->use_ssl = $use_ssl; $this->svn_root = $svn_root; $this->register () ; } function getDefaultServer() { return $this->default_svn_server ; } function CallHook ($hookname, $params) { global $HTML ; switch ($hookname) { case 'scm_page': $group_id = $params['group_id'] ; $this->getPage ($group_id) ; break ; case 'scm_admin_update': $this->AdminUpdate ($params) ; break ; case 'scm_admin_page': $this->getAdminPage ($params) ; break ; case 'scm_stats': $this->getStats ($params) ; break; case 'scm_plugin': $scm_plugins=& $params['scm_plugins']; $scm_plugins[]=$this->name; break; default: // Forgot something } } function getPage ($group_id) { global $HTML, $sys_scm_snapshots_path; $project =& group_get_object($group_id); if (!$project || !is_object($project)) { return false; } elseif ($project->isError()) { return false; } if ($project->usesPlugin ($this->name)) { // SVN browser links must be displayed if // project enables anon SVN or if logged-in // user is a member of the group $displaySvnBrowser = $project->enableAnonSCM(); if(session_loggedin()) { $perm =& $project->getPermission(session_get_user()); if ($perm && is_object($perm) && !$perm->isError() && $perm->isMember()) { $displaySvnBrowser = true; } } // Table for summary info print '
' ;
print _(' Documentation for Subversion (sometimes referred to as "SVN") is available here. '); // Anonymous SVN Instructions if ($project->enableAnonSCM()) { print _('Anonymous Subversion Access This project\'s SVN repository can be checked out through anonymous access with the following command(s). '); print '';
if ($this->use_ssh) {
print 'svn checkout svn://'.$project->getSCMBox().'/'.$this->svn_root.'/'.$project->getUnixName().' Developer Subversion Access via SSH Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Substitute developername with the proper values. Enter your site password when prompted. '); print 'svn checkout svn+ssh://'._('developername').'@' . $project->getSCMBox() . '/'. $this->svn_root .'/'. $project->getUnixName().' ' ; } if ($this->use_dav) { echo _('Developer Subversion Access via DAV Only project developers can access the SVN tree via this method. Substitute developername with the proper values. Enter your site password when prompted. '); print 'svn checkout --username '._('developername').' http'.(($this->use_ssl) ? 's' : '').'://'. $project->getSCMBox() .'/'. $this->svn_root .'/'.$project->getUnixName().' ' ; } // SVN Snapshot if ($displaySvnBrowser) { $filename=$project->getUnixName().'-scm-latest.tar.gz'; if (file_exists($sys_scm_snapshots_path.'/'.$filename)) { print '[' ; print util_make_link ("/snapshots.php?group_id=$group_id", _('Download The Nightly SVN Tree Snapshot') ) ; print '] '; } } print ' | ' ;
// SVN Browsing
echo $HTML->boxTop(_('Repository History'));
echo $this->getDetailedStats(array('group_id'=>$group_id)).' '; if ($displaySvnBrowser) { echo _('Browse the Subversion Tree Browsing the SVN tree gives you a great view into the current status of this project\'s code. You may also view the complete histories of any file in the repository. '); echo '[' ; echo util_make_link ("/scm/viewvc.php/?root=".$project->getUnixName(), _('Browse Subversion Repository') ) ; echo '] ' ; } echo $HTML->boxBottom(); print ' |
c($group->enableAnonSCM()).' />'._('Enable Anonymous Access').'
'; } } function getStats ($params) { $group_id = $params['group_id'] ; $project =& group_get_object($group_id); if (!$project || !is_object($project)) { return false; } elseif ($project->isError()) { return false; } if ($project->usesPlugin ($this->name)) { list($commit_num, $add_num) = $this->getTotalStats($group_id); echo ' (SVN: '.sprintf(_('%1$s updates, %2$s adds'), number_format($commit_num, 0), number_format($add_num, 0)).')'; } } // Get the total stats for a group function getTotalStats($group_id) { $result = db_query(" SELECT SUM(commits) AS commits, SUM(adds) AS adds FROM stats_cvs_group WHERE group_id='$group_id'"); $commit_num = db_result($result,0,0); $add_num = db_result($result,0,1); if (!$commit_num) { $commit_num=0; } if (!$add_num) { $add_num=0; } return array($commit_num, $add_num); } function getDetailedStats ($params) { global $HTML; $group_id = $params['group_id'] ; $result = db_query(' SELECT u.realname, u.user_name, u.user_id, sum(commits) as commits, sum(adds) as adds, sum(adds+commits) as combined FROM stats_cvs_user s, users u WHERE group_id=\''.$group_id.'\' AND s.user_id=u.user_id AND (commits>0 OR adds >0) GROUP BY group_id, realname, user_name ORDER BY combined DESC, realname; '); if (db_numrows($result) > 0) { $tableHeaders = array( _('Name'), _('Adds'), _('Updates') ); echo $HTML->listTableTop($tableHeaders); $i = 0; $total = array('adds' => 0, 'commits' => 0); while($data = db_fetch_array($result)) { echo '