*
* Copyright 2009, Roland Mas
* Copyright 2009, Mehdi Dogguy <mehdi@debian.org>
- * Copyright 2012-2013, Franck Villaume - TrivialDev
+ * Copyright 2012-2014, Franck Villaume - TrivialDev
* Copyright © 2013
* Thorsten Glaser <t.glaser@tarent.de>
* http://fusionforge.org
count($repo_list)) . '</h2>';
$b .= '<p>';
- $b .= ngettext('This project\'s Git repository can be checked out through anonymous access with the following command.',
- 'This project\'s Git repositories can be checked out through anonymous access with the following commands.',
+ $b .= ngettext("This project's Git repository can be checked out through anonymous access with the following command.",
+ "This project's Git repositories can be checked out through anonymous access with the following commands.",
count($repo_list));
$b .= '</p>';
if ($rows > 0) {
$b .= '<h2>';
- $b .= ngettext('Developer\'s repository',
- 'Developer\'s repositories',
+ $b .= ngettext("Developer's repository",
+ "Developer's repositories",
$rows);
$b .= '</h2>'."\n";
$b .= '<p>';
- $b .= ngettext('One of this project\'s members also has a personal Git repository that can be checked out anonymously.',
- 'Some of this project\'s members also have personal Git repositories that can be checked out anonymously.',
+ $b .= ngettext("One of this project's members also has a personal Git repository that can be checked out anonymously.",
+ "Some of this project's members also have personal Git repositories that can be checked out anonymously.",
$rows);
$b .= '</p>';
$b .= '<p>';
if (session_loggedin()) {
$u = user_get_object(user_getid());
$d = $u->getUnixName();
- $validSetup = 0;
- $b = '';
if (forge_get_config('use_ssh', 'scmgit')) {
- $b .= '<h2>';
- $b = '<h2>' . ngettext('Developer Access to the Git repository via SSH',
+ $b = '<h2>';
+ $b = ngettext('Developer Access to the Git repository via SSH',
'Developer Access to the Git repositories via SSH',
- count($repo_list)) . '</h2>';
+ count($repo_list));
$b .= '</h2>';
$b .= '<p>';
- $b .= ngettext('Only project developers can access the Git repository via this method. SSH must be installed on your client machine. Enter your site password when prompted.',
- 'Only project developers can access the Git repositories via this method. SSH must be installed on your client machine. Enter your site password when prompted.',
+ $b .= ngettext('Only project developers can access the Git repository via this method.',
+ 'Only project developers can access the Git repositories via this method.',
count($repo_list));
-
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
foreach ($repo_list as $repo_name) {
$b .= '<p><tt>git clone git+ssh://'.$d.'@' . $project->getSCMBox() . '/'. forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/'. $repo_name .'.git</tt></p>';
}
-
- $validSetup = 1;
- }
- if (forge_get_config('use_dav', 'scmgit')) {
+ } elseif (forge_get_config('use_dav', 'scmgit')) {
$protocol = forge_get_config('use_ssl', 'scmgit')? 'https' : 'http';
- $b .= '<h2>';
- $b = '<h2>' . ngettext('Developer Access to the Git repository via HTTP',
+ $b = '<h2>';
+ $b = ngettext('Developer Access to the Git repository via HTTP',
'Developer Access to the Git repositories via HTTP',
- count($repo_list)) . '</h2>';
-
+ count($repo_list));
$b .= '</h2>';
$b .= '<p>';
- $b .= ngettext('Only project developers can access the Git repository via this method. Enter your site password when prompted.',
- 'Only project developers can access the Git repositories via this method. Enter your site password when prompted.',
+ $b .= ngettext('Only project developers can access the Git repository via this method.',
+ 'Only project developers can access the Git repositories via this method.',
count($repo_list));
-
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
foreach ($repo_list as $repo_name) {
$b .= '<p><tt>git clone '.$protocol.'://'.$d.'@' . $project->getSCMBox() . '/'. forge_get_config('scm_root', 'scmgit') .'/'. $project->getUnixName() .'/'. $repo_name .'.git</tt></p>';
}
-
- $validSetup = 1;
- }
- if ($validSetup == 0) {
- $b = '<p class="warning">'._('Missing configuration for access in scmgit.ini : use_ssh and use_dav disabled').'</p>';
}
} else {
if (forge_get_config('use_ssh', 'scmgit')) {
$b = '<h2>';
- $b = '<h2>' . ngettext('Developer Access to the Git repository via SSH',
+ $b = ngettext('Developer Access to the Git repository via SSH',
'Developer Access to the Git repositories via SSH',
- count($repo_list)) . '</h2>';
-
+ count($repo_list));
$b .= '</h2>';
$b .= '<p>';
- $b .= ngettext('Only project developers can access the Git repository via this method. SSH must be installed on your client machine. Substitute <em>developername</em> with the proper value. Enter your site password when prompted.',
- 'Only project developers can access the Git repositories via this method. SSH must be installed on your client machine. Substitute <em>developername</em> with the proper value. Enter your site password when prompted.',
+ $b .= ngettext('Only project developers can access the Git repository via this method.',
+ 'Only project developers can access the Git repositories via this method.',
count($repo_list));
-
+ $b .= ' ';
+ $b .= _('SSH must be installed on your client machine.');
+ $b .= ' ';
+ $b .= _('Substitute <em>developername</em> with the proper value.');
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
foreach ($repo_list as $repo_name) {
$b .= '<p><tt>git clone git+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . '/'. forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/'. $repo_name .'.git</tt></p>';
}
-
- }
- if (forge_get_config('use_dav', 'scmgit')) {
+ } elseif (forge_get_config('use_dav', 'scmgit')) {
$protocol = forge_get_config('use_ssl', 'scmgit')? 'https' : 'http';
$b = '<h2>';
- $b = '<h2>' . ngettext('Developer Access to the Git repository via HTTP',
+ $b .= ngettext('Developer Access to the Git repository via HTTP',
'Developer Access to the Git repositories via HTTP',
- count($repo_list)) . '</h2>';
+ count($repo_list));
$b .= '</h2>';
$b .= '<p>';
- $b .= ngettext('Only project developers can access the Git repository via this method. Enter your site password when prompted.',
- 'Only project developers can access the Git repositories via this method. Enter your site password when prompted.',
+ $b .= ngettext('Only project developers can access the Git repository via this method.',
+ 'Only project developers can access the Git repositories via this method.',
count($repo_list));
-
+ $b .= ' ';
+ $b .= _('Enter your site password when prompted.');
$b .= '</p>';
foreach ($repo_list as $repo_name) {
$b .= '<p><tt>git clone '.$protocol.'://<i>'._('developername').'</i>@' . $project->getSCMBox() . '/'. forge_get_config('scm_root', 'scmgit') .'/'. $project->getUnixName() .'/'. $repo_name .'.git</tt></p>';
}
-
}
}
+ if (!isset($b)) {
+ $b = '<h2>'._('Developer Git Access').'</h2>';
+ $b .= '<p class="error">Error: No access protocol has been allowed for the Git plugin in scmgit.ini: : use_ssh and use_dav are disabled</p>';
+ }
+
if (session_loggedin()) {
- $u =& user_get_object(user_getid());
+ $u = user_get_object(user_getid());
if ($u->getUnixStatus() == 'A') {
$result = db_query_params('SELECT * FROM scm_personal_repos p WHERE p.group_id=$1 AND p.user_id=$2 AND plugin_id=$3',
array($project->getID(),
$b .= _('Request a personal repository');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('You can clone the project repository into a personal one into which you alone will be able to write. Other members of the project will only have read access. Access for non-members will follow the same rules as for the project\'s main repository. Note that the personal repository may take some time before it is created (less than an hour in most situations).');
+ $b .= _("You can clone the project repository into a personal one into which you alone will be able to write. Other members of the project will only have read access. Access for non-members will follow the same rules as for the project's main repository. Note that the personal repository may take some time before it is created (less than an hour in most situations).");
$b .= '</p>';
$b .= '<p>';
$b .= sprintf(_('<a href="%s">Request a personal repository</a>.'),
}
function printBrowserPage($params) {
+ global $HTML;
$project = $this->checkParams($params);
if (!$project) {
return;
if ($params['user_id']) {
$user = user_get_object($params['user_id']);
echo $project->getUnixName().'/users/'.$user->getUnixName();
- print '<iframe src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/users/'.$user->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
+ print '<iframe id="scm_iframe" src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/users/'.$user->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
} elseif ($this->browserDisplayable($project)) {
- print '<iframe src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
+ print '<iframe id="scm_iframe" src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
}
}
+ html_use_jqueryautoheight();
+ echo $HTML->getJavascripts();
+ echo '<script type="text/javascript">//<![CDATA[
+ jQuery(\'#scm_iframe\').iframeAutoHeight({heightOffset: 50});
+ //]]></script>';
}
function getBrowserLinkBlock($project) {
global $HTML;
$b = $HTML->boxMiddle(_('Git Repository Browser'));
$b .= '<p>';
- $b .= _('Browsing the Git 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 .= _("Browsing the Git 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 .= '</p>';
$b .= '<p>[';
$b .= util_make_link("/scm/browser.php?group_id=".$project->getID(),
"$repodir/hooks/post-update");
}
if (!is_file("$repodir/hooks/post-update")) {
- $f = fopen("$repodir/hooks/post-update");
+ $f = fopen("$repodir/hooks/post-update", 'w');
fwrite($f, "exec git-update-server-info\n");
fclose($f);
}
- if (is_file ("$repodir/hooks/post-update")) {
+ if (is_file("$repodir/hooks/post-update")) {
system("chmod +x $repodir/hooks/post-update");
}
$f = fopen("$repodir/description", "w");
return $list;
}
- function gatherStats ($params) {
- $project = $this->checkParams ($params);
+ function gatherStats($params) {
+ $project = $this->checkParams($params);
if (!$project) {
return false;
}
- if (!$project->usesPlugin ($this->name)) {
+ if (!$project->usesPlugin($this->name)) {
return false;
}
$updates = 0;
$repo = forge_get_config('repos_path', 'scmgit') . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git';
- if (!is_dir ($repo) || !is_dir ("$repo/refs")) {
+ if (!is_dir($repo) || !is_dir("$repo/refs")) {
// echo "No repository $repo\n";
return false;
}
- $pipe = popen ("GIT_DIR=\"$repo\" git log --since=@$start_time --until=@$end_time --all --pretty='format:%n%an <%ae>' --name-status 2>/dev/null", 'r' );
+ $pipe = popen("GIT_DIR=\"$repo\" git log --since=@$start_time --until=@$end_time --all --pretty='format:%n%an <%ae>' --name-status 2>/dev/null", 'r' );
db_begin();
// cleaning stats_cvs_* table for the current day
- $res = db_query_params ('DELETE FROM stats_cvs_group WHERE month=$1 AND day=$2 AND group_id=$3',
+ $res = db_query_params('DELETE FROM stats_cvs_group WHERE month=$1 AND day=$2 AND group_id=$3',
array($month_string,
$day,
$project->getID()));
if(!$res) {
echo "Error while cleaning stats_cvs_group\n";
- db_rollback ();
+ db_rollback();
return false;
}
$last_user = "";
- while (!feof($pipe) && $data = fgets ($pipe)) {
+ while (!feof($pipe) && $data = fgets($pipe)) {
$line = trim($data);
if (strlen($line) > 0) {
$result = preg_match("/^(?P<name>.+) <(?P<mail>.+)>/", $line, $matches);
$result = preg_match("/^(?P<mode>[AMD])\s+(?P<file>.+)$/", $line, $matches);
if (!$result) continue;
if ($last_user == "") continue;
- if (!isset ($usr_adds[$last_user])) $usr_adds[$last_user] = 0;
- if (!isset ($usr_updates[$last_user])) $usr_updates[$last_user] = 0;
- if (!isset ($usr_deletes[$last_user])) $usr_deletes[$last_user] = 0;
+ if (!isset($usr_adds[$last_user])) $usr_adds[$last_user] = 0;
+ if (!isset($usr_updates[$last_user])) $usr_updates[$last_user] = 0;
+ if (!isset($usr_deletes[$last_user])) $usr_deletes[$last_user] = 0;
if ($matches['mode'] == 'A') {
$usr_adds[$last_user]++;
$adds++;
// inserting group results in stats_cvs_groups
if ($updates > 0 || $adds > 0) {
- if (!db_query_params ('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
+ if (!db_query_params('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
array($month_string,
$day,
$project->getID(),
$updates,
$adds))) {
echo "Error while inserting into stats_cvs_group\n";
- db_rollback ();
+ db_rollback();
return false;
}
}
// building the user list
$user_list = array_unique( array_merge( array_keys( $usr_adds ), array_keys( $usr_updates ) ) );
- foreach ( $user_list as $user ) {
+ foreach ($user_list as $user) {
// Trying to get user id from user name or email
- $u = &user_get_object_by_name ($user);
+ $u = user_get_object_by_name($user);
if ($u) {
$user_id = $u->getID();
} else {
}
}
- $uu = isset ($usr_updates[$user]) ? $usr_updates[$user] : 0;
- $ua = isset ($usr_adds[$user]) ? $usr_adds[$user] : 0;
+ $uu = isset($usr_updates[$user]) ? $usr_updates[$user] : 0;
+ $ua = isset($usr_adds[$user]) ? $usr_adds[$user] : 0;
if ($uu > 0 || $ua > 0) {
- if (!db_query_params ('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
+ if (!db_query_params('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
array($month_string,
$day,
$project->getID(),
$uu,
$ua))) {
echo "Error while inserting into stats_cvs_user\n";
- db_rollback ();
+ db_rollback();
return false;
}
}
db_commit();
}
- function generateSnapshots ($params) {
+ function generateSnapshots($params) {
- $project = $this->checkParams ($params);
+ $project = $this->checkParams($params);
if (!$project) {
return false;
}
$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
- if (!$project->usesPlugin ($this->name)) {
+ if (!$project->usesPlugin($this->name)) {
return false;
}
if (!$project->enableAnonSCM()) {
if (is_file($snapshot)) {
- unlink ($snapshot);
+ unlink($snapshot);
}
if (is_file($tarball)) {
- unlink ($tarball);
+ unlink($tarball);
}
return false;
}
$toprepo = forge_get_config('repos_path', 'scmgit');
$repo = $toprepo . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git';
- if (!is_dir ($repo)) {
+ if (!is_dir($repo)) {
if (is_file($snapshot)) {
- unlink ($snapshot);
+ unlink($snapshot);
}
if (is_file($tarball)) {
- unlink ($tarball);
+ unlink($tarball);
}
return false;
}
return false;
}
- $tmp = trim (`mktemp -d`);
+ $tmp = trim(`mktemp -d`);
if ($tmp == '') {
return false;
}
- $today = date ('Y-m-d');
+ $today = date('Y-m-d');
system("GIT_DIR=\"$repo\" git archive --format=tar --prefix=$group_name-scm-$today/ HEAD |".forge_get_config('compression_method')." > $tmp/snapshot");
- chmod ("$tmp/snapshot", 0644);
- copy ("$tmp/snapshot", $snapshot);
- unlink ("$tmp/snapshot");
+ chmod("$tmp/snapshot", 0644);
+ copy("$tmp/snapshot", $snapshot);
+ unlink("$tmp/snapshot");
system("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball");
- chmod ("$tmp/tarball", 0644);
- copy ("$tmp/tarball", $tarball);
- unlink ("$tmp/tarball");
+ chmod("$tmp/tarball", 0644);
+ copy("$tmp/tarball", $tarball);
+ unlink("$tmp/tarball");
system("rm -rf $tmp");
}
action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
<input type="hidden" name="group_id" value="<?php echo $params['group_id'] ?>" />
<input type="hidden" name="create_repository" value="1" />
-<p><strong><?php echo _('Repository name:') ?></strong><?php echo utils_requiredField(); ?><br />
+<p><strong><?php echo _('Repository name')._(':'); ?></strong><?php echo utils_requiredField(); ?><br />
<input type="text" required="required" size="20" name="repo_name" value="" /></p>
<p><strong><?php echo _('Description:'); ?></strong><br />
<input type="text" size="60" name="description" value="" /></p>