<?php
-/** FusionForge Bazaar plugin
+/**
+ * FusionForge Bazaar plugin
*
* Copyright 2009, Roland Mas
+ * Copyright 2013, Franck Villaume - TrivialDev
*
* This file is part of FusionForge.
*
return false ;
}
- 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');
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") ;
}
}