<?php
-/** FusionForge Bazaar plugin
+/**
+ * FusionForge Bazaar plugin
*
* Copyright 2009, Roland Mas
+ * Copyright 2013, Franck Villaume - TrivialDev
*
* This file is part of FusionForge.
*
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 Bazaar (sometimes referred to as "bzr") is available <a href="http://bazaar-vcs.org/Documentation">here</a>.') . '</p>';
+ return '<p>'
+ . sprintf(_('Documentation for %1$s is available at <a href="%2$s">%2$s</a>.'),
+ 'Bazaar (“bzr”)',
+ 'http://bazaar-vcs.org/Documentation')
+ . '</p>';
}
function getInstructionsForAnon ($project) {
$u =& user_get_object(user_getid()) ;
$d = $u->getUnixName() ;
$b .= '<h2>';
- $b .= _('Developer Bazaar Access via SSH');
+ $b .= sprintf(_('Developer %s Access via SSH'), 'Bazaar');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the Bazaar branches 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.'), 'Bazaar');
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>bzr checkout bzr+ssh://'.$d.'@' . $this->getBoxForProject($project) . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
} else {
$b .= '<h2>';
- $b .= _('Developer Bazaar Access via SSH');
+ $b .= sprintf(_('Developer %s Access via SSH'), 'Bazaar');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the Bazaar branches via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper value. Enter your site password when prompted.');
+ $b .= sprintf(_('Only project developers can access the %s tree via this method.'), 'Bazaar');
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Substitute <i>developername</i> with the proper values.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>bzr checkout bzr+ssh://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . forge_get_config('repos_path', 'scmbzr') .'/'. $project->getUnixName().'/'._('branchname').'</tt></p>' ;
}
}
function getSnapshotPara ($project) {
- return ;
+ return;
}
function getBrowserLinkBlock ($project) {
global $HTML ;
- $b = $HTML->boxMiddle(_('Bazaar Repository Browser'));
+ $b = $HTML->boxMiddle(sprintf(_('%s Repository Browser'), 'Bazaar'));
$b .= '<p>';
- $b .= _('Browsing the Bazaar 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."), 'Bazaar');
+ $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 Bazaar Repository')
+ sprintf(_('Browse %s Repository'), 'Bazaar')
) ;
$b .= ']</p>' ;
return $b ;
}
function getStatsBlock ($project) {
- return ;
+ return;
}
function printBrowserPage ($params) {
- global $HTML;
-
$project = $this->checkParams ($params) ;
if (!$project) {
- return false ;
+ return;
}
if ($project->usesPlugin ($this->name)) {
return false;
}
+ $project_name = $project->getUnixName();
+
$repo = forge_get_config('repos_path', 'scmbzr') . '/' . $project->getUnixName() ;
- $unix_group = 'scm_' . $project->getUnixName() ;
+ $unix_group = 'scm_' . $project_name ;
$repo_exists = false ;
if (is_dir ($repo)) {
$line = fgets ($pipe) ;
fclose ($pipe) ;
- if (preg_match ("/^Shared repository/", $line) != 0) {
+ if (preg_match ("/^Shared repository/", $line) != 0
+ || preg_match ("/^Repository branch/", $line) != 0) {
$repo_exists = true ;
}
}
if (!$repo_exists) {
+ $tmp_repo = util_mkdtemp('.bzr', $project_name);
+ if ($tmp_repo == false) {
+ return false;
+ }
+
+ system ("bzr init-repo --no-trees $tmp_repo >/dev/null") ;
+ system ("find $tmp_repo/.bzr -type d | xargs chmod g+s") ;
+ system ("chmod -R g+wX,o+rX-w $tmp_repo/.bzr") ;
+ system ("chgrp $unix_group $tmp_repo/.bzr") ;
+
system ("mkdir -p $repo") ;
- system ("bzr init-repo --no-trees $repo >/dev/null") ;
- system ("find $repo -type d | xargs chmod g+s") ;
+ system ("chgrp $unix_group $repo") ;
+ system ("chmod g+s $repo") ;
+ system ("mv $tmp_repo/.bzr $repo/.bzr");
+ rmdir ($tmp_repo);
}
-
- system ("chgrp -R $unix_group $repo") ;
+
if ($project->enableAnonSCM()) {
- system ("chmod -R g+wX,o+rX-w $repo") ;
+ system ("chmod o+rX-w $repo") ;
} else {
- system ("chmod -R g+wX,o-rwx $repo") ;
+ system ("chmod o-rwx $repo") ;
}
}
function updateRepositoryList ($params) {
$groups = $this->getGroups () ;
- $dir = '/var/lib/gforge/plugins/scmbzr/public-repositories' ;
+ $dir = forge_get_config('data_path').'/plugins/scmbzr/public-repositories' ;
+
+ if (!is_dir($dir)) {
+ mkdir ($dir, 0644, true);
+ }
$oldlist = array () ;
$dh = opendir ($dir) ;
}
if (! $project->enableAnonSCM()) {
- unlink ($snapshot) ;
- unlink ($tarball) ;
+ if (file_exists ($snapshot)) unlink ($snapshot) ;
+ if (file_exists ($tarball)) unlink ($tarball) ;
return false;
}
$repo = $toprepo . '/' . $project->getUnixName() ;
if (!is_dir ($repo) || !is_file ("$repo/format")) {
- unlink ($snapshot) ;
- unlink ($tarball) ;
+ if (file_exists ($snapshot)) unlink ($snapshot) ;
+ if (file_exists ($tarball)) unlink ($tarball) ;
return false ;
}