Add option to generate abbreviated hashes in urls
[gitphp.git] / include / git / projectlist / ProjectListBase.class.php
blob:a/include/git/projectlist/ProjectListBase.class.php -> blob:b/include/git/projectlist/ProjectListBase.class.php
--- a/include/git/projectlist/ProjectListBase.class.php
+++ b/include/git/projectlist/ProjectListBase.class.php
@@ -362,6 +362,8 @@
 
 		if ($config->HasValue('gitphp.description')) {
 			$project->SetDescription($config->GetValue('gitphp.description'));
+		} else if ($config->HasValue('gitweb.description')) {
+			$project->SetDescription($config->GetValue('gitweb.description'));
 		}
 
 		if ($config->HasValue('gitphp.category')) {
@@ -396,6 +398,10 @@
 			$project->SetAbbreviateLength($config->GetValue('core.abbrev'));
 		}
 
+		if ($config->HasValue('gitphp.allowedusers')) {
+			$project->SetAllowedUsers($config->GetValue('gitphp.allowedusers', true));
+		}
+
 	}
 
 	/**
@@ -411,19 +417,19 @@
 		if (!$this->config)
 			return;
 
-		if ($this->config->HasKey('cloneurl')) {
+		if ($this->config->GetValue('cloneurl')) {
 			$project->SetCloneUrl(GitPHP_Util::AddSlash($this->config->GetValue('cloneurl'), false) . $project->GetProject());
 		}
 
-		if ($this->config->HasKey('pushurl')) {
+		if ($this->config->GetValue('pushurl')) {
 			$project->SetPushUrl(GitPHP_Util::AddSlash($this->config->GetValue('pushurl'), false) . $project->GetProject());
 		}
 
-		if ($this->config->HasKey('bugpattern')) {
+		if ($this->config->GetValue('bugpattern')) {
 			$project->SetBugPattern($this->config->GetValue('bugpattern'));
 		}
 
-		if ($this->config->HasKey('bugurl')) {
+		if ($this->config->GetValue('bugurl')) {
 			$project->SetBugUrl($this->config->GetValue('bugurl'));
 		}
 
@@ -452,6 +458,19 @@
 		$this->Sort();
 
 		$this->ApplySettings();
+	}
+
+	/**
+	 * Filter projects by user access
+	 *
+	 * @param string $username username
+	 */
+	public function FilterByUser($username)
+	{
+		foreach ($this->projects as $path => $project) {
+			if (!$project->UserCanAccess($username))
+				unset($this->projects[$path]);
+		}
 	}
 
 	/**
@@ -605,6 +624,9 @@
 		if (isset($projData['website']) && is_string($projData['website'])) {
 			$project->SetWebsite($projData['website']);
 		}
+		if (!empty($projData['allowedusers'])) {
+			$project->SetAllowedUsers($projData['allowedusers']);
+		}
 	}
 
 	/**

comments