* * 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 CVSPlugin extends SCM { function CVSPlugin () { global $cvs_root; global $gfconfig; $this->SCM () ; $this->name = 'scmcvs'; $this->text = 'CVS'; $this->hooks[] = 'scm_page'; $this->hooks[] = 'scm_admin_update'; $this->hooks[] = 'scm_admin_page'; $this->hooks[] = 'scm_stats'; $this->hooks[] = 'scm_plugin'; require_once $GLOBALS['gfconfig'].'plugins/scmcvs/config.php' ; $this->default_cvs_server = $default_cvs_server ; if ($cvs_root) { $this->cvs_root = $cvs_root; } else { $this->cvs_root = "/cvsroot"; } //$this->default_cvs_server = $default_cvs_server ; //$this->this_server = $this_server ; $this->enabled_by_default = $enabled_by_default ; $this->register () ; } function getDefaultServer() { return $this->default_cvs_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 ; $project =& group_get_object($group_id); if (!$project || !is_object($project)) { return false; } elseif ($project->isError()) { return false; } if ($project->usesPlugin($this->name)) { print _('Some CVS documentation is available Here'); $cvsrootend=$project->getSCMBox().':/cvsroot/'.$project->getUnixName(); $cvsrootend = $project->getSCMBox().':'.$this->cvs_root.'/'.$project->getUnixName(); // CVS browser links must be displayed if // project enables anon CVS or if logged-in // user is a member of the group $displayCvsBrowser = $project->enableAnonSCM(); if(session_loggedin()) { $perm =& $project->getPermission(session_get_user()); if ($perm && is_object($perm) && !$perm->isError() && $perm->isMember()) { $displayCvsBrowser = true; } } // Table for summary info print '
' ; // Anonymous CVS Instructions if ($project->enableAnonSCM()){ echo _('

Anonymous CVS Access

This project\'s CVS repository can be checked out through anonymous (pserver) CVS with the following instruction set. The module you wish to check out must be specified as the modulename. When prompted for a password for anonymous, simply press the Enter key.

'); print '

cvs -d :pserver:anonymous@' . $cvsrootend.' login
cvs -d :pserver:anonymous@' . $cvsrootend.' checkout '._('modulename').'

'; } // Developer Access echo _('

Developer CVS Access via SSH

Only project developers can access the CVS tree via this method. SSH must be installed on your client machine. Substitute modulename and developername with the proper values. Enter your site password when prompted.

'); print '

export CVS_RSH=ssh
cvs -d :ext:'._('developername').'@'.$cvsrootend.' checkout '._('modulename').'

'; // CVS Snapshot if ($displayCvsBrowser) { print '

[' ; print util_make_link ("/snapshots.php?group_id=$group_id", _('Download The Nightly CVS Tree Snapshot') ) ; print ']

'; } print '
' ; // CVS Browsing echo $HTML->boxTop(_('Repository History')); echo $this->getDetailedStats(array('group_id'=>$group_id)).'

'; if ($displayCvsBrowser){ echo _('Browse the CVS Tree

Browsing the CVS 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 CVS Repository') ) ; echo ']

' ; $hook_params['project_name'] = $project->getUnixName(); plugin_hook ("cvs_stats", $hook_params) ; } echo $HTML->boxBottom(); print '
' ; } } function adminUpdate ($params) { $group =& group_get_object($params['group_id']); if (!$group || !is_object($group)) { return false; } elseif ($group->isError()) { return false; } if ($group->usesPlugin($this->name)) { if ($params['scmcvs_enable_anoncvs']) { $group->SetUsesAnonSCM(true); } else { $group->SetUsesAnonSCM(false); } if ($params['scmcvs_enable_pserver']) { $group->SetUsesPserver(true); } else { $group->SetUsesPserver(false); } } } // This function is used to render checkboxes below function c($v) { if ($v) { return 'checked="checked"'; } else { return ''; } } function getAdminPage ($params) { $group =& group_get_object($params['group_id']); if ($group->usesPlugin($this->name)) { print '

c($group->enableAnonSCM()).' />'._('Enable Anonymous Access').'
c($group->enablePserver()).' />'._('Enable pserver').'

' ; } } 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)) { $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,'commits'); $add_num = db_result($result,0,'adds'); if (!$commit_num) { $commit_num=0; } if (!$add_num) { $add_num=0; } echo ' (CVS: '.sprintf(_('%1$s commits, %2$s adds'), number_format($commit_num, 0), number_format($add_num, 0)).")"; } } 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'), _('Commits') ); echo $HTML->listTableTop($tableHeaders); $i = 0; $total = array('adds' => 0, 'commits' => 0); while($data = db_fetch_array($result)) { echo 'boxGetAltRowStyle($i) .'>'; echo '' ; echo util_make_link_u ($data['user_name'], $data['user_id'], $data['realname']) ; echo ''.$data['adds']. ''. ''.$data['commits'].''; $total['adds'] += $data['adds']; $total['commits'] += $data['commits']; $i++; } echo 'boxGetAltRowStyle($i) .'>'; echo ''._('Total').':'. ''.$total['adds']. ''. ''.$total['commits'].''; echo ''; echo $HTML->listTableBottom(); echo '
'; } } } // Local Variables: // mode: php // c-file-style: "bsd" // End: ?>