Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f39e1d0 authored by Ronak Patel's avatar Ronak Patel
Browse files

Apply 1 suggestion(s) to 1 file(s)

parent ca118007
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -18,26 +18,31 @@ class FilesystemService {
	private $logger;
	/** @var IGroupManager */
	private $groupManager;

	public function __construct(IUserManager $userManager, IConfig $config, ILogger $logger, IGroupManager $groupManager) {
		$this->userManager = $userManager;
		$this->config = $config;
		$this->logger = $logger;
		$this->groupManager = $groupManager;
	}

	public function addUserInFilesEnabledGroup($username): bool {
		$user = $this->userManager->get($username);
		if (!$user) {
			return false;
		}

		$groupName = $this->config->getSystemValue('files_access_group_name', '');
		if (!$this->groupManager->groupExists($groupName)) {
			$this->logger->error("$groupName group not exist.");
			return false;
		}

		$group = $this->groupManager->get($groupName);
		$group->addUser($user);
		return true;
	}

	public function checkFilesGroupAccess($username): bool {
		$groupName = $this->config->getSystemValue('files_access_group_name', '');
		
@@ -45,9 +50,11 @@ class FilesystemService {
			$this->logger->error("$groupName group not exist.");
			return false;
		}

		if ($this->groupManager->isInGroup($username, $groupName)) {
			return true;
		}

		return false;
	}