Browse Source

Add option to show restricted projects as disabled

Chris Han 11 years ago
parent
commit
c3c8003e76

+ 10 - 0
config/gitphp.conf.defaults.php

@@ -286,6 +286,16 @@ $gitphp_conf['cleanurl'] = false;
  */
 //$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;
+
 /*
 
 

+ 4 - 0
css/gitphpskin.css

@@ -555,6 +555,10 @@ div.projectSearch {
 	margin-left: 8px;
 }
 
+.projectRow.disabled {
+	color: #888;
+}
+
 
 /*
  * Tree view

+ 0 - 3
include/controller/ControllerBase.class.php

@@ -122,9 +122,6 @@ abstract class GitPHP_ControllerBase
 
 		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'])) {

+ 6 - 0
include/controller/Controller_ProjectList.class.php

@@ -19,6 +19,12 @@ class GitPHP_Controller_ProjectList extends GitPHP_ControllerBase
 
 		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';
 	}

+ 2 - 2
js/modules/projectsearch.js

@@ -60,12 +60,12 @@ define(["jquery", 'modules/resources', 'modules/hassearchreset'],
 		}
 
 		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;
 			}

+ 15 - 3
templates/projectlist.tpl

@@ -75,11 +75,21 @@ git source code archive
       {/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">
+        {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="projectDescription"><a href="{geturl project=$proj}" class="list">{$proj->GetDescription()|escape}</a></td>
       <td class="projectOwner"><em>{$proj->GetOwner()|escape:'html'}</em></td>
       {assign var=projecthead value=$proj->GetHeadCommit()}
       <td class="projectAge">
@@ -96,6 +106,7 @@ git source code archive
 	{/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 @@ git source code archive
 	<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}