From 8915b45948596ef9d595aa5832c56579ba548b69 Mon Sep 17 00:00:00 2001
From: Loic d'Anterroches
Date: Fri, 19 Jun 2009 16:20:33 +0200
Subject: [PATCH] Fixed issue 209, erroneous details with private repository
---
src/IDF/Project.php | 19 +++++++++++++++++++
src/IDF/templates/idf/source/git/help.html | 2 +-
src/IDF/templates/idf/source/git/tree.html | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/IDF/Project.php b/src/IDF/Project.php
index 1e2e810..7c0f37b 100644
--- a/src/IDF/Project.php
+++ b/src/IDF/Project.php
@@ -349,9 +349,28 @@ class IDF_Project extends Pluf_Model
return new Pluf_Template_ContextVars($tags);
}
+ /**
+ * Get the access url to the repository.
+ *
+ * This will return the right url based on the user.
+ *
+ * @param Pluf_User The user (null)
+ */
+ public function getSourceAccessUrl($user=null)
+ {
+ $right = $this->getConf()->getVal('source_access_rights', 'all');
+ if (($user == null or $user->isAnonymous())
+ and $right == 'all' and !$this->private) {
+ return $this->getRemoteAccessUrl();
+ }
+ return $this->getWriteRemoteAccessUrl($user);
+ }
+
+
/**
* Get the remote access url to the repository.
*
+ * This will always return the anonymous access url.
*/
public function getRemoteAccessUrl()
{
diff --git a/src/IDF/templates/idf/source/git/help.html b/src/IDF/templates/idf/source/git/help.html
index de939c9..9e72ba9 100644
--- a/src/IDF/templates/idf/source/git/help.html
+++ b/src/IDF/templates/idf/source/git/help.html
@@ -8,7 +8,7 @@ code.{/blocktrans}
{trans 'Command-Line Access'}
-git clone {if $project.private}{$project.getWriteRemoteAccessUrl($user)}{else}{$project.getRemoteAccessUrl()}{/if}
+git clone {$project.getSourceAccessUrl($user)}
{aurl 'url', 'IDF_Views_User::myAccount'}
{blocktrans}You may need to provide your SSH key. The synchronization of your SSH key can take a couple of minutes. You can learn more about SSH key authentification.{/blocktrans}
diff --git a/src/IDF/templates/idf/source/git/tree.html b/src/IDF/templates/idf/source/git/tree.html
index 58755e5..b97db05 100644
--- a/src/IDF/templates/idf/source/git/tree.html
+++ b/src/IDF/templates/idf/source/git/tree.html
@@ -47,7 +47,7 @@
{aurl 'url', 'IDF_Views_Source::download', array($project.shortname, $commit)}
- {trans 'Download this version'} {trans 'or'} git clone {if $project.private}{$project.getWriteRemoteAccessUrl($user)}{else}{$project.getRemoteAccessUrl()}{/if}
+ {trans 'Download this version'} {trans 'or'} git clone {$project.getSourceAccessUrl($user)}
{/block}