<?php
-/** FusionForge Subversion plugin
+/**
+ * FusionForge Subversion plugin
*
* Copyright 2003-2010, Roland Mas, Franck Villaume
* Copyright 2004, GForge, LLC
function printShortStats($params) {
$project = $this->checkParams($params);
if (!$project) {
- return false;
+ return;
}
- if ($project->usesPlugin($this->name)) {
+ if ($project->usesPlugin($this->name) && forge_check_perm('scm', $project->getID(), 'read')) {
$result = db_query_params('SELECT sum(commits) AS commits, sum(adds) AS adds FROM stats_cvs_group WHERE group_id=$1',
array ($project->getID())) ;
$commit_num = db_result($result,0,'commits');
}
function getBlurb() {
- return '<p>' . _('Documentation for Subversion (sometimes referred to as "SVN") is available <a href="http://svnbook.red-bean.com/">here</a>.') . '</p>';
+ return '<p>'
+ . sprintf(_('Documentation for %1$s is available at <a href="%2$s">%2$s</a>.'),
+ 'Subversion (“SVN”)',
+ 'http://svnbook.red-bean.com/')
+ . '</p>';
}
function topModule($project) {
$module = $this->topModule($project);
if (session_loggedin()) {
- $u =& user_get_object(user_getid());
+ $u = user_get_object(user_getid());
$d = $u->getUnixName() ;
if (forge_get_config('use_ssh', 'scmsvn')) {
$b .= '<h2>';
- $b .= _('Developer Subversion Access via SSH');
+ $b .= sprintf(_('Developer %s Access via SSH'), 'Subversion');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
+ $b .= sprintf(_('Only project developers can access the %s tree via this method.'), 'Subversion');
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>svn checkout svn+ssh://'.$d.'@' . $this->getBoxForProject($project) . $this->svn_root_fs .'/'. $project->getUnixName().$module.'</tt></p>' ;
}
$b .= _('Developer Subversion Access via DAV');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the SVN tree via this method. Enter your site password when prompted.');
+ $b .= sprintf(_('Only project developers can access the %s tree via this method.'), 'Subversion');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>svn checkout --username '.$d.' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $this->getBoxForProject($project) . $this->svn_root_dav .'/'.$project->getUnixName().$module.'</tt></p>' ;
}
} else {
if (forge_get_config('use_ssh', 'scmsvn')) {
$b .= '<h2>';
- $b .= _('Developer Subversion Access via SSH');
+ $b .= sprintf(_('Developer %s Access via SSH'), 'Subversion');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.');
+ $b .= sprintf(_('Only project developers can access the %s tree via this method.'), 'Subversion');
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Substitute <em>developername</em> with the proper values.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . $this->svn_root_fs .'/'. $project->getUnixName().$module.'</tt></p>' ;
}
$b .= _('Developer Subversion Access via DAV');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the SVN tree via this method. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.');
+ $b .= sprintf(_('Only project developers can access the %s tree via this method.'), 'Subversion');
+ $b .= ' ';
+ $b .= _('Substitute <em>developername</em> with the proper values.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $this->getBoxForProject($project) . $this->svn_root_dav .'/'.$project->getUnixName().$module.'</tt></p>' ;
}
function getBrowserLinkBlock($project) {
global $HTML ;
- $b = $HTML->boxMiddle(_('Subversion Repository Browser'));
+ $b = $HTML->boxMiddle(sprintf(_('%s Repository Browser'), 'Subversion'));
$b .= '<p>';
- $b .= _('Browsing the Subversion tree gives you a view into the current status of this project\'s code. You may also view the complete histories of any file in the repository.');
+ $b .= sprintf(_("Browsing the %s tree gives you a view into the current status of this project's code."), 'Subversion');
+ $b .= ' ';
+ $b .= _('You may also view the complete histories of any file in the repository.');
$b .= '</p>';
$b .= '<p>[' ;
$b .= util_make_link ("/scm/browser.php?group_id=".$project->getID(),
- _('Browse Subversion Repository')
+ sprintf(_('Browse %s Repository'), 'Subversion')
) ;
$b .= ']</p>' ;
return $b ;
function printBrowserPage($params) {
$project = $this->checkParams($params);
if (!$project) {
- return false;
+ return;
}
if ($project->usesPlugin($this->name)) {
if ($ret != 0) {
return false;
}
+ system ("svn mkdir -m'Init' file:///$repo/trunk file:///$repo/tags file:///$repo/branches >/dev/null") ;
if (forge_get_config('use_ssh', 'scmsvn')) {
$unix_group = 'scm_' . $project->getUnixName() ;
system ("find $repo -type d | xargs -I{} chmod g+s {}") ;
system ("chmod -R g-rwx,o-rwx $repo") ;
system ("chown -R $unix_user:$unix_group $repo") ;
}
- system ("svn mkdir -m'Init' file:///$repo/trunk file:///$repo/tags file:///$repo/branches >/dev/null") ;
}
- $this->installOrUpdateCmds($project, $project->getUnixName(), $repo);
-
if (forge_get_config('use_ssh', 'scmsvn')) {
$unix_group = 'scm_' . $project->getUnixName();
system("find $repo -type d | xargs -I{} chmod g+s {}");
$updates = 0;
$usr_adds = array();
$usr_updates = array();
-
+
$repo = forge_get_config('repos_path', 'scmsvn') . '/' . $project->getUnixName();
if (!is_dir ($repo) || !is_file ("$repo/format")) {
echo "No repository $repo\n";
db_rollback();
return false;
}
-
+
$res = db_query_params ('DELETE FROM stats_cvs_user WHERE month=$1 AND day=$2 AND group_id=$3',
array ($month_string,
$day,
db_rollback () ;
return false ;
}
-
+
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "SVNPluginStartElement", "SVNPluginEndElement");
xml_set_character_data_handler($xml_parser, "SVNPluginCharData");
foreach ( $user_list as $user ) {
// trying to get user id from user name
- $u = &user_get_object_by_name ($user) ;
+ $u = user_get_object_by_name ($user) ;
if ($u) {
$user_id = $u->getID();
} else {
$dir = $project->getUnixName ()."-$today" ;
system ("mkdir -p $tmp") ;
$code = 0 ;
- system ("svn ls file://$repo/trunk > /dev/null", $code) ;
+ system ("svn ls file://$repo/trunk > /dev/null 2> /dev/null", $code) ;
if ($code == 0) {
system ("cd $tmp ; svn export file://$repo/trunk $dir > /dev/null 2>&1") ;
system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> $tmp/snapshot") ;
}
}
}
- $params['ids'][] = 'scm';
- $params['texts'][] = _('SCM SVN Commits');
+ $params['ids'][] = $this->name;
+ $params['texts'][] = _('Subversion Commits');
return true;
}
-
- function installOrUpdateCmds($project, $unix_group_name, $repos) {
-
- $hooks = array();
- $params = array();
- $params['unix_group_name'] = $unix_group_name;
- $group = group_get_object_by_name($unix_group_name);
- $params['group_id'] = $group->getID();
- $params['repos'] = $repos;
- $params['hooks'] = &$hooks;
- plugin_hook_by_reference('cmd_for_post_commit_hook', $params);
-
- foreach ($params['hooks'] as $plugin => $cmd ) {
- if (getenv('sys_localinc')) {
- $cmd = 'sys_localinc='.getenv(sys_localinc).' '.$cmd;
- }
- $contents = @file_get_contents($repos."/hooks/post-commit");
- if ($project->usesPlugin($plugin)) {
- if (strstr($contents, "#begin added by $plugin") === false ) {
- $this->installCmdInHook($repos, $plugin, $cmd);
- } else {
- $this->updateCmdInHook($repos, $plugin, $cmd);
- }
- } elseif (!$project->usesPlugin($plugin) &&
- (strstr($contents, "#begin added by $plugin") !== false )) {
- $this->removeCmdInHook($repos, $plugin);
- }
- }
- }
-
- function installCmdInHook($repos, $name, $text) {
-
- if (file_exists($repos.'/hooks/post-commit')) {
- $FOut = fopen($repos.'/hooks/post-commit', "a+");
- $Line = '';
- } else {
- $FOut = fopen($repos.'/hooks/post-commit', "w");
- $Line = '#!/bin/sh'."\n"; // add this line to first line or else the script fails
- }
-
- if ($FOut) {
- $Line .= "\n#begin added by $name\n$text\n#end added by $name\n";
-
- fwrite($FOut, $Line);
-
- system("chmod 700 $repos/hooks/post-commit");
- fclose($FOut);
- }
- }
-
- function updateCmdInHook($repos, $plugin, $text) {
-
- $contents = @file_get_contents($repos."/hooks/post-commit");
-
- $new = preg_replace("/(#begin added by $plugin\n)(.*)(\n#end added by $plugin)/s", '$1{COMMAND}$3', $contents);
- $new = str_replace('{COMMAND}', $text, $new);
-
- if ($contents !== $new) {
- $fout = fopen($repos.'/hooks/post-commit', "w");
- fwrite($fout, $new);
- fclose($fout);
- }
- }
-
- function removeCmdInHook($repos, $plugin) {
-
- $contents = @file_get_contents($repos."/hooks/post-commit");
- $new = preg_replace("/#begin added by $plugin\n.*?\n#end added by $plugin/s", '', $contents);
-
- if ($contents !== $new) {
- if (preg_match("/^#\!\/bin\/sh(\n+)$/s", $new)) {
- unlink($repos.'/hooks/post-commit');
- } else {
- $fout = fopen($repos.'/hooks/post-commit', "w");
- fwrite($fout, $new);
- fclose($fout);
- }
- }
- }
}
// End of class, helper functions now
// mode: php
// c-file-style: "bsd"
// End:
-
-?>