Add option to show restricted projects as disabled
--- a/config/gitphp.conf.defaults.php
+++ b/config/gitphp.conf.defaults.php
@@ -285,6 +285,16 @@
* with the string GIT_SILENT in the commit message.
*/
//$gitphp_conf['feedfilter'] = '/GIT_SILENT/';
+
+/*
+ * showrestrictedprojects
+ * By default, when user-based restrictions are enabled,
+ * projects that are not available to the logged in user
+ * will be hidden in the project list. Setting this option
+ * will instead display these projects as disabled in the
+ * project list.
+ */
+$gitphp_conf['showrestrictedprojects'] = false;
/*
--- a/css/gitphpskin.css
+++ b/css/gitphpskin.css
@@ -555,6 +555,10 @@
margin-left: 8px;
}
+.projectRow.disabled {
+ color: #888;
+}
+
/*
* Tree view
--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -122,9 +122,6 @@
if ($this->multiProject) {
$this->projectList->LoadProjects();
- if ($this->userList && ($this->userList->GetCount() > 0)) {
- $this->projectList->FilterByUser((!empty($_SESSION['gitphpuser']) ? $_SESSION['gitphpuser'] : null));
- }
}
if (!empty($this->params['project'])) {
--- a/include/controller/Controller_ProjectList.class.php
+++ b/include/controller/Controller_ProjectList.class.php
@@ -18,6 +18,12 @@
$this->multiProject = true;
parent::Initialize();
+
+ if ($this->userList && ($this->userList->GetCount() > 0)) {
+ if (!$this->config->GetValue('showrestrictedprojects') || (isset($this->params['opml']) && ($this->params['opml'] === true)) || (isset($this->params['txt']) && ($this->params['txt'] === true))) {
+ $this->projectList->FilterByUser((!empty($_SESSION['gitphpuser']) ? $_SESSION['gitphpuser'] : null));
+ }
+ }
if (empty($this->params['sort']))
$this->params['sort'] = 'project';
--- a/js/modules/projectsearch.js
+++ b/js/modules/projectsearch.js
@@ -60,12 +60,12 @@
}
function searchRow(row, searchString) {
- var projectName = row.find('td.projectName a').text();
+ var projectName = row.find('td.projectName span').text();
if ((projectName.length > 0) && (projectName.toLowerCase().indexOf(searchString) != -1)) {
return true;
}
- var projectDesc = row.find('td.projectDescription a').text();
+ var projectDesc = row.find('td.projectDescription span').text();
if ((projectDesc.length > 0) && (projectDesc.toLowerCase().indexOf(searchString) != -1)) {
return true;
}
--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -75,11 +75,21 @@
{/if}
{/if}
- <tr class="{cycle values="light,dark"} projectRow">
+ <tr class="{cycle values="light,dark"} projectRow {if $loginenabled && !$proj->UserCanAccess($loggedinuser)}disabled{/if}">
<td class="projectName">
- <a href="{geturl project=$proj}" class="list {if $currentcategory != ''}indent{/if}">{$proj->GetProject()}</a>
+ {if !$loginenabled || $proj->UserCanAccess($loggedinuser)}
+ <a href="{geturl project=$proj}" class="list {if $currentcategory != ''}indent{/if}"><span>{$proj->GetProject()}</span></a>
+ {else}
+ <span {if $currentcategory != ''}class="indent"{/if}>{$proj->GetProject()}</span>
+ {/if}
</td>
- <td class="projectDescription"><a href="{geturl project=$proj}" class="list">{$proj->GetDescription()|escape}</a></td>
+ <td class="projectDescription">
+ {if !$loginenabled || $proj->UserCanAccess($loggedinuser)}
+ <a href="{geturl project=$proj}" class="list"><span>{$proj->GetDescription()|escape}</span></a>
+ {else}
+ <span>{$proj->GetDescription()|escape}</span>
+ {/if}
+ </td>
<td class="projectOwner"><em>{$proj->GetOwner()|escape:'html'}</em></td>
{assign var=projecthead value=$proj->GetHeadCommit()}
<td class="projectAge">
@@ -96,6 +106,7 @@
{/if}
</td>
<td class="link">
+ {if !$loginenabled || $proj->UserCanAccess($loggedinuser)}
<a href="{geturl project=$proj}">{t}summary{/t}</a>
{if $projecthead}
|
@@ -104,6 +115,7 @@
<a href="{geturl project=$proj action=tree}">{t}tree{/t}</a> |
<a href="{geturl project=$proj action=snapshot hash=HEAD}" class="snapshotTip">{t}snapshot{/t}</a>
{/if}
+ {/if}
</td>
</tr>
{foreachelse}