* Copyright 2009, Roland Mas
* Copyright 2009, Mehdi Dogguy <mehdi@debian.org>
* Copyright 2013, Thorsten Glaser <t.glaser@tarent.de>
- * Copyright 2012-2014,2016-2018, Franck Villaume - TrivialDev
+ * Copyright 2012-2014,2016-2018,2021, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge.
forge_define_config_item('default_server', 'scmgit', forge_get_config('scm_host'));
forge_define_config_item('repos_path', 'scmgit', forge_get_config('chroot').'/scmrepos/git');
-forge_define_config_item('use_ssh', 'scmgit', false);
-forge_set_config_item_bool('use_ssh', 'scmgit');
-forge_define_config_item('use_ssl', 'scmgit', true);
-forge_set_config_item_bool('use_ssl', 'scmgit');
+forge_define_config_item_bool('use_ssh', 'scmgit', false);
+forge_define_config_item_bool('use_ssl', 'scmgit', true);
forge_define_config_item('ssh_port', 'core', 22);
class GitPlugin extends SCMPlugin {
$htmlRepo = '';
foreach ($clone_commands as $cmd) {
- $htmlRepo .= html_e('kbd', array(), $cmd).html_e('br');;
+ $htmlRepo .= html_e('kbd', array(), $cmd).html_e('br');
}
$b .= html_e('p', array(), $htmlRepo);
$rows));
$htmlRepo = '';
for ($i=0; $i<$rows; $i++) {
- $user_id = db_result($result, $i, 'user_id');
$user_name = db_result($result, $i, 'user_name');
$real_name = db_result($result, $i, 'realname');
$htmlRepo .= html_e('kbd', array(), 'git clone '.$protocol.'://'.$this->getBoxForProject($project).'/anonscm/git/'.$project->getUnixName().'/users/'.$user_name.'.git')
- . ' ('.util_make_link_u($user_name, $user_id, $real_name).')'
+ . ' ('.util_make_link_u($user_name, $real_name).')'
. html_e('br');
}
$b .= html_e('p', array(), $htmlRepo);
if (forge_get_config('use_ssh', 'scmgit')) {
$b .= '<div id="tabber-gitssh" class="tabbertab" >';
$b .= html_e('p', array(), _('SSH must be installed on your client machine.'));
+ $b .= html_e('p', array(), _('Additionally, a public ssh key must be available in the FusionForge settings of the respective user.'));
$htmlRepo = '';
foreach ($repo_list as $repo_name) {
if (forge_get_config('use_shell_limited')) {
'Only project developers can access the Git repositories via this method.',
count($repo_list)).
' '. _('SSH must be installed on your client machine.').
+ ' '. _('Additionally, a public ssh key must be available in the FusionForge settings of the respective user.').
' '. _('Substitute <em>developername</em> with the proper value.'));
$htmlRepo = '';
foreach ($repo_list as $repo_name) {
if (forge_get_config('use_shell_limited')) {
- $htmlRepo .= html_e('kbd', array(), 'git clone '.html_e('i', array(), _('developername'), true, false).'@'.$this->getBoxForProject($project).$ssh_port.':'.$project->getUnixName().'/'.$repo_name.'.git').html_e('br');
+ $htmlRepo .= html_e('kbd', array(), 'git clone '.html_e('em', array(), _('developername'), true, false).'@'.$this->getBoxForProject($project).$ssh_port.':'.$project->getUnixName().'/'.$repo_name.'.git').html_e('br');
} else {
- $htmlRepo .= html_e('kbd', array(), 'git clone git+ssh://'.html_e('i', array(), _('developername'), true, false).'@'.$this->getBoxForProject($project).$ssh_port.forge_get_config('repos_path', 'scmgit').'/'.$project->getUnixName().'/'.$repo_name.'.git').html_e('br');
+ $htmlRepo .= html_e('kbd', array(), 'git clone git+ssh://'.html_e('em', array(), _('developername'), true, false).'@'.$this->getBoxForProject($project).$ssh_port.forge_get_config('repos_path', 'scmgit').'/'.$project->getUnixName().'/'.$repo_name.'.git').html_e('br');
}
}
$b .= html_e('p', array(), $htmlRepo);
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)).
- ' '. _('Enter your site password when prompted.'));
+ ' '. _('Enter your site password when prompted.').
+ ' '. _('Substitute <em>developername</em> with the proper value.'));
$htmlRepo = '';
foreach ($repo_list as $repo_name) {
- $htmlRepo .= '<kbd>git clone '.$protocol.'://<i>'._('developername').'</i>@'.$this->getBoxForProject($project).'/authscm/<i>'._('developername').'</i>/git/'.$project->getUnixName() .'/'. $repo_name .'.git</kbd><br />';
+ $htmlRepo .= '<kbd>git clone '.$protocol.'://'.html_e('em', array(), _('developername'), true, false).'@'.$this->getBoxForProject($project).'/authscm/'.html_e('em', array(), _('developername'), true, false).'/git/'.$project->getUnixName() .'/'. $repo_name .'.git</kbd><br />';
}
$b .= html_e('p', array(), $htmlRepo);
$b .= '</div>';
if ($params['scm_plugin'] != $this->name) {
return;
}
- global $HTML;
- $useautoheight = 0;
$project = $this->checkParams($params);
if (!$project) {
return;
$output = '';
$project = $this->checkParams($params);
- if (!$project) return false;
- if (!$project->isActive()) return false;
-
+ if (!$project) {
+ return false;
+ }
$project_name = $project->getUnixName();
$unix_group_ro = $project_name . '_scmro';
$unix_group_rw = $project_name . '_scmrw';
$rootdir = forge_get_config('repos_path', 'scmgit');
fwrite($f, "\$projectroot = '$rootdir';\n");
fwrite($f, "\$projects_list = '$config_dir/gitweb.list';\n");
- fwrite($f, "\$anon_clone_url = '". util_make_url('/anonscm/git') . "';\n");
- fwrite($f, "\$logo = '". util_make_url('/plugins/scmgit/git-logo.png') . "';\n");
- fwrite($f, "\$favicon = '". util_make_url('/plugins/scmgit/git-favicon.png')."';\n");
- fwrite($f, "\$stylesheet = '". util_make_url('/plugins/scmgit/gitweb.css')."';\n");
- fwrite($f, "\$javascript = '". util_make_url('/plugins/scmgit/gitweb.js')."';\n");
- fwrite($f, "\$site_html_head_string = '<script type=\"text/javascript\" src=\"". util_make_url('/scripts/iframe-resizer/iframeResizer.contentWindow.js'). "\" />';\n");
+ $protocol = forge_get_config('use_ssl', 'scmgit')? 'https://' : 'http://';
+ fwrite($f, "\$anon_clone_url = '".$protocol.forge_get_config('scm_host').'/anonscm/git'."';\n");
+ fwrite($f, "\$logo = '".$protocol.forge_get_config('scm_host').'/plugins/scmgit/git-logo.png'."';\n");
+ fwrite($f, "\$favicon = '".$protocol.forge_get_config('scm_host').'/plugins/scmgit/git-favicon.png'."';\n");
+ fwrite($f, "\$stylesheet = '".$protocol.forge_get_config('scm_host').'/plugins/scmgit/gitweb.css'."';\n");
+ fwrite($f, "\$javascript = '".$protocol.forge_get_config('scm_host').'/plugins/scmgit/gitweb.js'."';\n");
+ fwrite($f, "\$site_html_head_string = '<script type=\"text/javascript\" src=\"".$protocol.forge_get_config('scm_host').'/scripts/iframe-resizer/iframeResizer.contentWindow.js'. "\" />';\n");
fwrite($f, "\$prevent_xss = 'true';\n");
fwrite($f, "\$site_footer = '".forge_get_config('source_path')."/plugins/scmgit/www/gitweb_footer.html';\n");
fwrite($f, "\$feature{'actions'}{'default'} = [('project home', '" .
fwrite($f, "\$per_request_config = sub {\n");
- fwrite($f, "push @git_base_url_list, qq,". util_make_url('/anonscm/git') .",;\n");
+ fwrite($f, "push @git_base_url_list, qq,".forge_get_config('scm_host').'/anonscm/git'.",;\n");
- $protocol = forge_get_config('use_ssl', 'scmgit')? 'https' : 'http';
if (forge_get_config('use_smarthttp', 'scmgit')) {
- fwrite($f, "if (defined \$ENV{ITKUID} && \$ENV{ITKUID} ne '".forge_get_config('apache_user')."') { push @git_base_url_list, qq,$protocol://\$ENV{ITKUID}\@".forge_get_config('scm_host')."/authscm/\$ENV{ITKUID}/git,; }\n");
+ fwrite($f, "if (defined \$ENV{ITKUID} && \$ENV{ITKUID} ne '".forge_get_config('apache_user')."') { push @git_base_url_list, qq,$protocol\$ENV{ITKUID}\@".forge_get_config('scm_host')."/authscm/\$ENV{ITKUID}/git,; }\n");
}
if (forge_get_config('use_ssh', 'scmgit')) {
$year = $params['year'];
$month = $params['month'];
$day = $params['day'];
- $month_string = sprintf("%04d%02d", $year, $month);
- $start_time = gmmktime(0, 0, 0, $month, $day, $year);
- $end_time = $start_time + 86400;
-
$repolist = $this->getRepositories($project);
foreach ($repolist as $repo_name) {
$this->gatherStatsRepo($project, $repo_name, $year, $month, $day);
} else {
// Short-commit stats line
$result = preg_match("/^(?P<mode>[AMD])\s+(?P<file>.+)$/", $line, $matches);
- if (!$result)
+ if (!$result) {
continue;
- if ($last_user == "")
+ }
+ if ($last_user == "") {
continue;
- if (!isset($usr_adds[$last_user]))
+ }
+ if (!isset($usr_adds[$last_user])) {
$usr_adds[$last_user] = 0;
- if (!isset($usr_updates[$last_user]))
+ }
+ if (!isset($usr_updates[$last_user])) {
$usr_updates[$last_user] = 0;
- if (!isset($usr_deletes[$last_user]))
+ }
+ if (!isset($usr_deletes[$last_user])) {
$usr_deletes[$last_user] = 0;
+ }
if ($matches['mode'] == 'A') {
$usr_adds[$last_user]++;
$adds++;
function widgets($params) {
require_once 'common/widget/WidgetLayoutManager.class.php';
if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USER) {
+ // user mypage widgets
$params['fusionforge_widgets'][] = 'plugin_scmgit_user_myrepositories';
+ } else if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USERHOME) {
+ // user Profile page
+ $params['fusionforge_widgets'][] = 'plugin_scmgit_user_userrepositories';
}
return true;
}
*/
function myPageBox($params) {
global $gfplugins;
- $user = UserManager::instance()->getCurrentUser();
require_once 'common/widget/WidgetLayoutManager.class.php';
if ($params['widget'] == 'plugin_scmgit_user_myrepositories') {
require_once $gfplugins.$this->name.'/common/scmgit_Widget_MyRepositories.class.php';
- $params['instance'] = new scmgit_Widget_MyRepositories(WidgetLayoutManager::OWNER_TYPE_USER, $user->getId());
+ $params['instance'] = new scmgit_Widget_MyRepositories(WidgetLayoutManager::OWNER_TYPE_USER, user_getid());
+ } elseif ($params['widget'] == 'plugin_scmgit_user_userrepositories') {
+ require_once $gfplugins.$this->name.'/common/scmgit_Widget_UserRepositories.class.php';
+ $params['instance'] = new scmgit_Widget_UserRepositories(WidgetLayoutManager::OWNER_TYPE_USERHOME, $params['owner_id']);
}
}
$project = group_get_object($row['group_id']);
if (!$project || !is_object($project)) {
continue;
- } elseif ($project->isError()) {
+ } elseif ($project->isError() || !$project->isActive()) {
continue;
}
if (!$project->usesPlugin($this->name)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $script_url);
curl_setopt($ch, CURLOPT_FILE, $f);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, forge_get_config('use_ssl_verification'));
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, forge_get_config('use_ssl_verification'));
curl_setopt($ch, CURLOPT_COOKIE, @$_SERVER['HTTP_COOKIE']); // for session validation
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // for session validation
curl_setopt($ch, CURLOPT_HTTPHEADER,
$result = array();
$result['section'] = 'scm';
$result['group_id'] = $project->getID();
- $result['ref_id'] = 'browser.php?group_id='.$project->getID().'&scm_plugin='.$this->name.'&commit='.$splitedLine[3];
+ $result['ref_id'] = 'browser.php?group_id='.$project->getID().'&scm_plugin='.$this->name.'&repo_name='.$repo_name.'&commit='.$splitedLine[3];
$result['description'] = htmlspecialchars($splitedLine[2]).' (repository: '.$repo_name.' commit: '.$splitedLine[3].')';
$userObject = user_get_object_by_email($splitedLine[1]);
if (is_a($userObject, 'FFUser')) {
'description' => $data['description'],
'clone_url' => $data['clone_url']);
}
- if (count($existing_repos) == 0) {
+ if (empty($existing_repos)) {
echo $HTML->information(_('No extra Git repository for project').' '.$project_name);
} else {
echo html_e('h2', array(), sprintf(ngettext('Extra Git repository for project %1$s',
count($existing_repos)), $project_name));
$titleArr = array(_('Repository name'), ('Initial repository description'), _('Initial clone URL (if any)'), _('Delete'));
echo $HTML->listTableTop($titleArr);
- foreach ($existing_repos as $key => $repo) {
+ foreach ($existing_repos as $repo) {
$cells = array();
$cells[][] = html_e('kbd', array(), $repo['repo_name']);
$cells[][] = $repo['description'];
}
}
- function getCommits($project, $user = null, $nb_commits) {
+ function getCommits($project, $user, $nb_commits) {
$commits = array();
if ($project->usesPlugin($this->name) && forge_check_perm('scm', $project->getID(), 'read')) {
// Grab&parse commit log
$protocol = forge_get_config('use_ssl', 'scmgit') ? 'https://' : 'http://';
$u = session_get_user();
- if ($project->enableAnonSCM())
+ if ($project->enableAnonSCM()) {
$server_script = '/anonscm/gitlog';
- else
+ } else {
$server_script = '/authscm/'.$u->getUnixName().'/gitlog';
+ }
if ($user) {
$email = $user->getEmail();
$realname = $user->getFirstName().' '.$user->getLastName();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $script_url);
curl_setopt($ch, CURLOPT_FILE, $f);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, forge_get_config('use_ssl_verification'));
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, forge_get_config('use_ssl_verification'));
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']); // for session validation
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // for session validation
curl_setopt($ch, CURLOPT_HTTPHEADER,
}
}
foreach ($tstamps as $t => $v) {
- $res = db_query_params("INSERT INTO scm_activities (group_id, plugin_id, repository_id, tstamp) VALUES ($1,$2,$3,$4)",
+ db_query_params("INSERT INTO scm_activities (group_id, plugin_id, repository_id, tstamp) VALUES ($1,$2,$3,$4)",
array($rdata['gid'],
$this->getID(),
$rdata['rid'],
return $repoarr;
}
}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End: