Filter project list based on logged in user
Filter project list based on logged in user

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -122,6 +122,9 @@
 
 		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/git/projectlist/ProjectListBase.class.php
+++ b/include/git/projectlist/ProjectListBase.class.php
@@ -456,6 +456,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]);
+		}
 	}
 
 	/**

comments