Passed
Push — master ( 22a9c5...0b7449 )
by Joas
12:22 queued 12s
created
apps/systemtags/lib/Controller/LastUsedController.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,32 +29,32 @@
 block discarded – undo
29 29
 
30 30
 class LastUsedController extends Controller {
31 31
 
32
-	/** @var IConfig */
33
-	protected $config;
32
+    /** @var IConfig */
33
+    protected $config;
34 34
 
35
-	/** @var IUserSession */
36
-	protected $userSession;
35
+    /** @var IUserSession */
36
+    protected $userSession;
37 37
 
38
-	/**
39
-	 * @param string $appName
40
-	 * @param IRequest $request
41
-	 * @param IConfig $config
42
-	 * @param IUserSession $userSession
43
-	 */
44
-	public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) {
45
-		parent::__construct($appName, $request);
46
-		$this->config = $config;
47
-		$this->userSession = $userSession;
48
-	}
38
+    /**
39
+     * @param string $appName
40
+     * @param IRequest $request
41
+     * @param IConfig $config
42
+     * @param IUserSession $userSession
43
+     */
44
+    public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) {
45
+        parent::__construct($appName, $request);
46
+        $this->config = $config;
47
+        $this->userSession = $userSession;
48
+    }
49 49
 
50
-	/**
51
-	 * @NoAdminRequired
52
-	 */
53
-	public function getLastUsedTagIds() {
54
-		$lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]');
55
-		$tagIds = json_decode($lastUsed, true);
56
-		return new DataResponse(array_map(function ($id) {
57
-			return (string) $id;
58
-		}, $tagIds));
59
-	}
50
+    /**
51
+     * @NoAdminRequired
52
+     */
53
+    public function getLastUsedTagIds() {
54
+        $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]');
55
+        $tagIds = json_decode($lastUsed, true);
56
+        return new DataResponse(array_map(function ($id) {
57
+            return (string) $id;
58
+        }, $tagIds));
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 	public function getLastUsedTagIds() {
54 54
 		$lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]');
55 55
 		$tagIds = json_decode($lastUsed, true);
56
-		return new DataResponse(array_map(function ($id) {
56
+		return new DataResponse(array_map(function($id) {
57 57
 			return (string) $id;
58 58
 		}, $tagIds));
59 59
 	}
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Command/Expire.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@
 block discarded – undo
31 31
 use OCP\Command\ICommand;
32 32
 
33 33
 class Expire implements ICommand {
34
-	use FileAccess;
34
+    use FileAccess;
35 35
 
36
-	/**
37
-	 * @var string
38
-	 */
39
-	private $user;
36
+    /**
37
+     * @var string
38
+     */
39
+    private $user;
40 40
 
41
-	/**
42
-	 * @param string $user
43
-	 */
44
-	public function __construct($user) {
45
-		$this->user = $user;
46
-	}
41
+    /**
42
+     * @param string $user
43
+     */
44
+    public function __construct($user) {
45
+        $this->user = $user;
46
+    }
47 47
 
48
-	public function handle() {
49
-		$userManager = \OC::$server->getUserManager();
50
-		if (!$userManager->userExists($this->user)) {
51
-			// User has been deleted already
52
-			return;
53
-		}
48
+    public function handle() {
49
+        $userManager = \OC::$server->getUserManager();
50
+        if (!$userManager->userExists($this->user)) {
51
+            // User has been deleted already
52
+            return;
53
+        }
54 54
 
55
-		\OC_Util::tearDownFS();
56
-		\OC_Util::setupFS($this->user);
57
-		Trashbin::expire($this->user);
58
-		\OC_Util::tearDownFS();
59
-	}
55
+        \OC_Util::tearDownFS();
56
+        \OC_Util::setupFS($this->user);
57
+        Trashbin::expire($this->user);
58
+        \OC_Util::tearDownFS();
59
+    }
60 60
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Command/ExpireTrash.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		} else {
91 91
 			$p = new ProgressBar($output);
92 92
 			$p->start();
93
-			$this->userManager->callForSeenUsers(function (IUser $user) use ($p) {
93
+			$this->userManager->callForSeenUsers(function(IUser $user) use ($p) {
94 94
 				$p->advance();
95 95
 				$this->expireTrashForUser($user);
96 96
 			});
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		\OC_Util::setupFS($user);
119 119
 
120 120
 		// Check if this user has a trashbin directory
121
-		$view = new \OC\Files\View('/' . $user);
121
+		$view = new \OC\Files\View('/'.$user);
122 122
 		if (!$view->is_dir('/files_trashbin/files')) {
123 123
 			return false;
124 124
 		}
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -38,95 +38,95 @@
 block discarded – undo
38 38
 
39 39
 class ExpireTrash extends Command {
40 40
 
41
-	/**
42
-	 * @var Expiration
43
-	 */
44
-	private $expiration;
41
+    /**
42
+     * @var Expiration
43
+     */
44
+    private $expiration;
45 45
 
46
-	/**
47
-	 * @var IUserManager
48
-	 */
49
-	private $userManager;
46
+    /**
47
+     * @var IUserManager
48
+     */
49
+    private $userManager;
50 50
 
51
-	/**
52
-	 * @param IUserManager|null $userManager
53
-	 * @param Expiration|null $expiration
54
-	 */
55
-	public function __construct(IUserManager $userManager = null,
56
-								Expiration $expiration = null) {
57
-		parent::__construct();
51
+    /**
52
+     * @param IUserManager|null $userManager
53
+     * @param Expiration|null $expiration
54
+     */
55
+    public function __construct(IUserManager $userManager = null,
56
+                                Expiration $expiration = null) {
57
+        parent::__construct();
58 58
 
59
-		$this->userManager = $userManager;
60
-		$this->expiration = $expiration;
61
-	}
59
+        $this->userManager = $userManager;
60
+        $this->expiration = $expiration;
61
+    }
62 62
 
63
-	protected function configure() {
64
-		$this
65
-			->setName('trashbin:expire')
66
-			->setDescription('Expires the users trashbin')
67
-			->addArgument(
68
-				'user_id',
69
-				InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
70
-				'expires the trashbin of the given user(s), if no user is given the trash for all users will be expired'
71
-			);
72
-	}
63
+    protected function configure() {
64
+        $this
65
+            ->setName('trashbin:expire')
66
+            ->setDescription('Expires the users trashbin')
67
+            ->addArgument(
68
+                'user_id',
69
+                InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
70
+                'expires the trashbin of the given user(s), if no user is given the trash for all users will be expired'
71
+            );
72
+    }
73 73
 
74
-	protected function execute(InputInterface $input, OutputInterface $output): int {
75
-		$maxAge = $this->expiration->getMaxAgeAsTimestamp();
76
-		if (!$maxAge) {
77
-			$output->writeln("Auto expiration is configured - keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed)");
78
-			return 1;
79
-		}
74
+    protected function execute(InputInterface $input, OutputInterface $output): int {
75
+        $maxAge = $this->expiration->getMaxAgeAsTimestamp();
76
+        if (!$maxAge) {
77
+            $output->writeln("Auto expiration is configured - keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed)");
78
+            return 1;
79
+        }
80 80
 
81
-		$users = $input->getArgument('user_id');
82
-		if (!empty($users)) {
83
-			foreach ($users as $user) {
84
-				if ($this->userManager->userExists($user)) {
85
-					$output->writeln("Remove deleted files of   <info>$user</info>");
86
-					$userObject = $this->userManager->get($user);
87
-					$this->expireTrashForUser($userObject);
88
-				} else {
89
-					$output->writeln("<error>Unknown user $user</error>");
90
-					return 1;
91
-				}
92
-			}
93
-		} else {
94
-			$p = new ProgressBar($output);
95
-			$p->start();
96
-			$this->userManager->callForSeenUsers(function (IUser $user) use ($p) {
97
-				$p->advance();
98
-				$this->expireTrashForUser($user);
99
-			});
100
-			$p->finish();
101
-			$output->writeln('');
102
-		}
103
-		return 0;
104
-	}
81
+        $users = $input->getArgument('user_id');
82
+        if (!empty($users)) {
83
+            foreach ($users as $user) {
84
+                if ($this->userManager->userExists($user)) {
85
+                    $output->writeln("Remove deleted files of   <info>$user</info>");
86
+                    $userObject = $this->userManager->get($user);
87
+                    $this->expireTrashForUser($userObject);
88
+                } else {
89
+                    $output->writeln("<error>Unknown user $user</error>");
90
+                    return 1;
91
+                }
92
+            }
93
+        } else {
94
+            $p = new ProgressBar($output);
95
+            $p->start();
96
+            $this->userManager->callForSeenUsers(function (IUser $user) use ($p) {
97
+                $p->advance();
98
+                $this->expireTrashForUser($user);
99
+            });
100
+            $p->finish();
101
+            $output->writeln('');
102
+        }
103
+        return 0;
104
+    }
105 105
 
106
-	public function expireTrashForUser(IUser $user) {
107
-		$uid = $user->getUID();
108
-		if (!$this->setupFS($uid)) {
109
-			return;
110
-		}
111
-		$dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
112
-		Trashbin::deleteExpiredFiles($dirContent, $uid);
113
-	}
106
+    public function expireTrashForUser(IUser $user) {
107
+        $uid = $user->getUID();
108
+        if (!$this->setupFS($uid)) {
109
+            return;
110
+        }
111
+        $dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
112
+        Trashbin::deleteExpiredFiles($dirContent, $uid);
113
+    }
114 114
 
115
-	/**
116
-	 * Act on behalf on trash item owner
117
-	 * @param string $user
118
-	 * @return boolean
119
-	 */
120
-	protected function setupFS($user) {
121
-		\OC_Util::tearDownFS();
122
-		\OC_Util::setupFS($user);
115
+    /**
116
+     * Act on behalf on trash item owner
117
+     * @param string $user
118
+     * @return boolean
119
+     */
120
+    protected function setupFS($user) {
121
+        \OC_Util::tearDownFS();
122
+        \OC_Util::setupFS($user);
123 123
 
124
-		// Check if this user has a trashbin directory
125
-		$view = new \OC\Files\View('/' . $user);
126
-		if (!$view->is_dir('/files_trashbin/files')) {
127
-			return false;
128
-		}
124
+        // Check if this user has a trashbin directory
125
+        $view = new \OC\Files\View('/' . $user);
126
+        if (!$view->is_dir('/files_trashbin/files')) {
127
+            return false;
128
+        }
129 129
 
130
-		return true;
131
-	}
130
+        return true;
131
+    }
132 132
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			return;
79 79
 		}
80 80
 
81
-		$this->userManager->callForSeenUsers(function (IUser $user) {
81
+		$this->userManager->callForSeenUsers(function(IUser $user) {
82 82
 			$uid = $user->getUID();
83 83
 			if (!$this->setupFS($uid)) {
84 84
 				return;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		\OC_Util::setupFS($user);
101 101
 
102 102
 		// Check if this user has a trashbin directory
103
-		$view = new \OC\Files\View('/' . $user);
103
+		$view = new \OC\Files\View('/'.$user);
104 104
 		if (!$view->is_dir('/files_trashbin/files')) {
105 105
 			return false;
106 106
 		}
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -36,84 +36,84 @@
 block discarded – undo
36 36
 
37 37
 class ExpireTrash extends \OC\BackgroundJob\TimedJob {
38 38
 
39
-	/** @var IConfig */
40
-	private $config;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	/**
43
-	 * @var Expiration
44
-	 */
45
-	private $expiration;
42
+    /**
43
+     * @var Expiration
44
+     */
45
+    private $expiration;
46 46
 
47
-	/**
48
-	 * @var IUserManager
49
-	 */
50
-	private $userManager;
47
+    /**
48
+     * @var IUserManager
49
+     */
50
+    private $userManager;
51 51
 
52
-	public function __construct(IConfig $config = null,
53
-								IUserManager $userManager = null,
54
-								Expiration $expiration = null) {
55
-		// Run once per 30 minutes
56
-		$this->setInterval(60 * 30);
52
+    public function __construct(IConfig $config = null,
53
+                                IUserManager $userManager = null,
54
+                                Expiration $expiration = null) {
55
+        // Run once per 30 minutes
56
+        $this->setInterval(60 * 30);
57 57
 
58
-		if ($config === null || $expiration === null || $userManager === null) {
59
-			$this->fixDIForJobs();
60
-		} else {
61
-			$this->config = $config;
62
-			$this->userManager = $userManager;
63
-			$this->expiration = $expiration;
64
-		}
65
-	}
58
+        if ($config === null || $expiration === null || $userManager === null) {
59
+            $this->fixDIForJobs();
60
+        } else {
61
+            $this->config = $config;
62
+            $this->userManager = $userManager;
63
+            $this->expiration = $expiration;
64
+        }
65
+    }
66 66
 
67
-	protected function fixDIForJobs() {
68
-		/** @var Application $application */
69
-		$application = \OC::$server->query(Application::class);
70
-		$this->config = $application->getContainer()->get(IConfig::class);
71
-		$this->userManager = \OC::$server->getUserManager();
72
-		$this->expiration = $application->getContainer()->query('Expiration');
73
-	}
67
+    protected function fixDIForJobs() {
68
+        /** @var Application $application */
69
+        $application = \OC::$server->query(Application::class);
70
+        $this->config = $application->getContainer()->get(IConfig::class);
71
+        $this->userManager = \OC::$server->getUserManager();
72
+        $this->expiration = $application->getContainer()->query('Expiration');
73
+    }
74 74
 
75
-	/**
76
-	 * @param $argument
77
-	 * @throws \Exception
78
-	 */
79
-	protected function run($argument) {
80
-		$backgroundJob = $this->config->getAppValue('files_trashbin', 'background_job_expire_trash', 'yes');
81
-		if ($backgroundJob === 'no') {
82
-			return;
83
-		}
75
+    /**
76
+     * @param $argument
77
+     * @throws \Exception
78
+     */
79
+    protected function run($argument) {
80
+        $backgroundJob = $this->config->getAppValue('files_trashbin', 'background_job_expire_trash', 'yes');
81
+        if ($backgroundJob === 'no') {
82
+            return;
83
+        }
84 84
 
85
-		$maxAge = $this->expiration->getMaxAgeAsTimestamp();
86
-		if (!$maxAge) {
87
-			return;
88
-		}
85
+        $maxAge = $this->expiration->getMaxAgeAsTimestamp();
86
+        if (!$maxAge) {
87
+            return;
88
+        }
89 89
 
90
-		$this->userManager->callForSeenUsers(function (IUser $user) {
91
-			$uid = $user->getUID();
92
-			if (!$this->setupFS($uid)) {
93
-				return;
94
-			}
95
-			$dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
96
-			Trashbin::deleteExpiredFiles($dirContent, $uid);
97
-		});
90
+        $this->userManager->callForSeenUsers(function (IUser $user) {
91
+            $uid = $user->getUID();
92
+            if (!$this->setupFS($uid)) {
93
+                return;
94
+            }
95
+            $dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
96
+            Trashbin::deleteExpiredFiles($dirContent, $uid);
97
+        });
98 98
 
99
-		\OC_Util::tearDownFS();
100
-	}
99
+        \OC_Util::tearDownFS();
100
+    }
101 101
 
102
-	/**
103
-	 * Act on behalf on trash item owner
104
-	 * @param string $user
105
-	 * @return boolean
106
-	 */
107
-	protected function setupFS($user) {
108
-		\OC_Util::tearDownFS();
109
-		\OC_Util::setupFS($user);
102
+    /**
103
+     * Act on behalf on trash item owner
104
+     * @param string $user
105
+     * @return boolean
106
+     */
107
+    protected function setupFS($user) {
108
+        \OC_Util::tearDownFS();
109
+        \OC_Util::setupFS($user);
110 110
 
111
-		// Check if this user has a trashbin directory
112
-		$view = new \OC\Files\View('/' . $user);
113
-		if (!$view->is_dir('/files_trashbin/files')) {
114
-			return false;
115
-		}
111
+        // Check if this user has a trashbin directory
112
+        $view = new \OC\Files\View('/' . $user);
113
+        if (!$view->is_dir('/files_trashbin/files')) {
114
+            return false;
115
+        }
116 116
 
117
-		return true;
118
-	}
117
+        return true;
118
+    }
119 119
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Helper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		$result = [];
45 45
 		$timestamp = null;
46 46
 
47
-		$view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
47
+		$view = new \OC\Files\View('/'.$user.'/files_trashbin/files');
48 48
 
49 49
 		if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) {
50 50
 			throw new \Exception('Directory does not exists');
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 			];
92 92
 			if ($originalPath) {
93 93
 				if ($originalPath !== '.') {
94
-					$i['extraData'] = $originalPath . '/' . $originalName;
94
+					$i['extraData'] = $originalPath.'/'.$originalName;
95 95
 				} else {
96 96
 					$i['extraData'] = $originalName;
97 97
 				}
98 98
 			}
99
-			$result[] = new FileInfo($absoluteDir . '/' . $i['name'], $storage, $internalPath . '/' . $i['name'], $i, $mount);
99
+			$result[] = new FileInfo($absoluteDir.'/'.$i['name'], $storage, $internalPath.'/'.$i['name'], $i, $mount);
100 100
 		}
101 101
 
102 102
 		if ($sortAttribute !== '') {
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -36,95 +36,95 @@
 block discarded – undo
36 36
 use OCP\Files\Cache\ICacheEntry;
37 37
 
38 38
 class Helper {
39
-	/**
40
-	 * Retrieves the contents of a trash bin directory.
41
-	 *
42
-	 * @param string $dir path to the directory inside the trashbin
43
-	 * or empty to retrieve the root of the trashbin
44
-	 * @param string $user
45
-	 * @param string $sortAttribute attribute to sort on or empty to disable sorting
46
-	 * @param bool $sortDescending true for descending sort, false otherwise
47
-	 * @return \OCP\Files\FileInfo[]
48
-	 */
49
-	public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) {
50
-		$result = [];
51
-		$timestamp = null;
39
+    /**
40
+     * Retrieves the contents of a trash bin directory.
41
+     *
42
+     * @param string $dir path to the directory inside the trashbin
43
+     * or empty to retrieve the root of the trashbin
44
+     * @param string $user
45
+     * @param string $sortAttribute attribute to sort on or empty to disable sorting
46
+     * @param bool $sortDescending true for descending sort, false otherwise
47
+     * @return \OCP\Files\FileInfo[]
48
+     */
49
+    public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) {
50
+        $result = [];
51
+        $timestamp = null;
52 52
 
53
-		$view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
53
+        $view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
54 54
 
55
-		if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) {
56
-			throw new \Exception('Directory does not exists');
57
-		}
55
+        if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) {
56
+            throw new \Exception('Directory does not exists');
57
+        }
58 58
 
59
-		$mount = $view->getMount($dir);
60
-		$storage = $mount->getStorage();
61
-		$absoluteDir = $view->getAbsolutePath($dir);
62
-		$internalPath = $mount->getInternalPath($absoluteDir);
59
+        $mount = $view->getMount($dir);
60
+        $storage = $mount->getStorage();
61
+        $absoluteDir = $view->getAbsolutePath($dir);
62
+        $internalPath = $mount->getInternalPath($absoluteDir);
63 63
 
64
-		$originalLocations = \OCA\Files_Trashbin\Trashbin::getLocations($user);
65
-		$dirContent = $storage->getCache()->getFolderContents($mount->getInternalPath($view->getAbsolutePath($dir)));
66
-		foreach ($dirContent as $entry) {
67
-			$entryName = $entry->getName();
68
-			$name = $entryName;
69
-			if ($dir === '' || $dir === '/') {
70
-				$pathparts = pathinfo($entryName);
71
-				$timestamp = substr($pathparts['extension'], 1);
72
-				$name = $pathparts['filename'];
73
-			} elseif ($timestamp === null) {
74
-				// for subfolders we need to calculate the timestamp only once
75
-				$parts = explode('/', ltrim($dir, '/'));
76
-				$timestamp = substr(pathinfo($parts[0], PATHINFO_EXTENSION), 1);
77
-			}
78
-			$originalPath = '';
79
-			$originalName = substr($entryName, 0, -strlen($timestamp) - 2);
80
-			if (isset($originalLocations[$originalName][$timestamp])) {
81
-				$originalPath = $originalLocations[$originalName][$timestamp];
82
-				if (substr($originalPath, -1) === '/') {
83
-					$originalPath = substr($originalPath, 0, -1);
84
-				}
85
-			}
86
-			$type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file';
87
-			$i = [
88
-				'name' => $name,
89
-				'mtime' => $timestamp,
90
-				'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name),
91
-				'type' => $type,
92
-				'directory' => ($dir === '/') ? '' : $dir,
93
-				'size' => $entry->getSize(),
94
-				'etag' => '',
95
-				'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE,
96
-				'fileid' => $entry->getId(),
97
-			];
98
-			if ($originalPath) {
99
-				if ($originalPath !== '.') {
100
-					$i['extraData'] = $originalPath . '/' . $originalName;
101
-				} else {
102
-					$i['extraData'] = $originalName;
103
-				}
104
-			}
105
-			$result[] = new FileInfo($absoluteDir . '/' . $i['name'], $storage, $internalPath . '/' . $i['name'], $i, $mount);
106
-		}
64
+        $originalLocations = \OCA\Files_Trashbin\Trashbin::getLocations($user);
65
+        $dirContent = $storage->getCache()->getFolderContents($mount->getInternalPath($view->getAbsolutePath($dir)));
66
+        foreach ($dirContent as $entry) {
67
+            $entryName = $entry->getName();
68
+            $name = $entryName;
69
+            if ($dir === '' || $dir === '/') {
70
+                $pathparts = pathinfo($entryName);
71
+                $timestamp = substr($pathparts['extension'], 1);
72
+                $name = $pathparts['filename'];
73
+            } elseif ($timestamp === null) {
74
+                // for subfolders we need to calculate the timestamp only once
75
+                $parts = explode('/', ltrim($dir, '/'));
76
+                $timestamp = substr(pathinfo($parts[0], PATHINFO_EXTENSION), 1);
77
+            }
78
+            $originalPath = '';
79
+            $originalName = substr($entryName, 0, -strlen($timestamp) - 2);
80
+            if (isset($originalLocations[$originalName][$timestamp])) {
81
+                $originalPath = $originalLocations[$originalName][$timestamp];
82
+                if (substr($originalPath, -1) === '/') {
83
+                    $originalPath = substr($originalPath, 0, -1);
84
+                }
85
+            }
86
+            $type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file';
87
+            $i = [
88
+                'name' => $name,
89
+                'mtime' => $timestamp,
90
+                'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name),
91
+                'type' => $type,
92
+                'directory' => ($dir === '/') ? '' : $dir,
93
+                'size' => $entry->getSize(),
94
+                'etag' => '',
95
+                'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE,
96
+                'fileid' => $entry->getId(),
97
+            ];
98
+            if ($originalPath) {
99
+                if ($originalPath !== '.') {
100
+                    $i['extraData'] = $originalPath . '/' . $originalName;
101
+                } else {
102
+                    $i['extraData'] = $originalName;
103
+                }
104
+            }
105
+            $result[] = new FileInfo($absoluteDir . '/' . $i['name'], $storage, $internalPath . '/' . $i['name'], $i, $mount);
106
+        }
107 107
 
108
-		if ($sortAttribute !== '') {
109
-			return \OCA\Files\Helper::sortFiles($result, $sortAttribute, $sortDescending);
110
-		}
111
-		return $result;
112
-	}
108
+        if ($sortAttribute !== '') {
109
+            return \OCA\Files\Helper::sortFiles($result, $sortAttribute, $sortDescending);
110
+        }
111
+        return $result;
112
+    }
113 113
 
114
-	/**
115
-	 * Format file infos for JSON
116
-	 *
117
-	 * @param \OCP\Files\FileInfo[] $fileInfos file infos
118
-	 */
119
-	public static function formatFileInfos($fileInfos) {
120
-		$files = [];
121
-		foreach ($fileInfos as $i) {
122
-			$entry = \OCA\Files\Helper::formatFileInfo($i);
123
-			$entry['id'] = $i->getId();
124
-			$entry['etag'] = $entry['mtime']; // add fake etag, it is only needed to identify the preview image
125
-			$entry['permissions'] = \OCP\Constants::PERMISSION_READ;
126
-			$files[] = $entry;
127
-		}
128
-		return $files;
129
-	}
114
+    /**
115
+     * Format file infos for JSON
116
+     *
117
+     * @param \OCP\Files\FileInfo[] $fileInfos file infos
118
+     */
119
+    public static function formatFileInfos($fileInfos) {
120
+        $files = [];
121
+        foreach ($fileInfos as $i) {
122
+            $entry = \OCA\Files\Helper::formatFileInfo($i);
123
+            $entry['id'] = $i->getId();
124
+            $entry['etag'] = $entry['mtime']; // add fake etag, it is only needed to identify the preview image
125
+            $entry['permissions'] = \OCP\Constants::PERMISSION_READ;
126
+            $files[] = $entry;
127
+        }
128
+        return $files;
129
+    }
130 130
 }
Please login to merge, or discard this patch.
apps/comments/lib/Notification/Listener.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -27,91 +27,91 @@
 block discarded – undo
27 27
 use OCP\Notification\IManager;
28 28
 
29 29
 class Listener {
30
-	/** @var IManager */
31
-	protected $notificationManager;
30
+    /** @var IManager */
31
+    protected $notificationManager;
32 32
 
33
-	/** @var IUserManager */
34
-	protected $userManager;
33
+    /** @var IUserManager */
34
+    protected $userManager;
35 35
 
36
-	/**
37
-	 * Listener constructor.
38
-	 *
39
-	 * @param IManager $notificationManager
40
-	 * @param IUserManager $userManager
41
-	 */
42
-	public function __construct(
43
-		IManager $notificationManager,
44
-		IUserManager $userManager
45
-	) {
46
-		$this->notificationManager = $notificationManager;
47
-		$this->userManager = $userManager;
48
-	}
36
+    /**
37
+     * Listener constructor.
38
+     *
39
+     * @param IManager $notificationManager
40
+     * @param IUserManager $userManager
41
+     */
42
+    public function __construct(
43
+        IManager $notificationManager,
44
+        IUserManager $userManager
45
+    ) {
46
+        $this->notificationManager = $notificationManager;
47
+        $this->userManager = $userManager;
48
+    }
49 49
 
50
-	/**
51
-	 * @param CommentsEvent $event
52
-	 */
53
-	public function evaluate(CommentsEvent $event) {
54
-		$comment = $event->getComment();
50
+    /**
51
+     * @param CommentsEvent $event
52
+     */
53
+    public function evaluate(CommentsEvent $event) {
54
+        $comment = $event->getComment();
55 55
 
56
-		$mentions = $this->extractMentions($comment->getMentions());
57
-		if (empty($mentions)) {
58
-			// no one to notify
59
-			return;
60
-		}
56
+        $mentions = $this->extractMentions($comment->getMentions());
57
+        if (empty($mentions)) {
58
+            // no one to notify
59
+            return;
60
+        }
61 61
 
62
-		$notification = $this->instantiateNotification($comment);
62
+        $notification = $this->instantiateNotification($comment);
63 63
 
64
-		foreach ($mentions as $uid) {
65
-			if (($comment->getActorType() === 'users' && $uid === $comment->getActorId())
66
-				|| !$this->userManager->userExists($uid)
67
-			) {
68
-				// do not notify unknown users or yourself
69
-				continue;
70
-			}
64
+        foreach ($mentions as $uid) {
65
+            if (($comment->getActorType() === 'users' && $uid === $comment->getActorId())
66
+                || !$this->userManager->userExists($uid)
67
+            ) {
68
+                // do not notify unknown users or yourself
69
+                continue;
70
+            }
71 71
 
72
-			$notification->setUser($uid);
73
-			if ($event->getEvent() === CommentsEvent::EVENT_DELETE
74
-				|| $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE) {
75
-				$this->notificationManager->markProcessed($notification);
76
-			} else {
77
-				$this->notificationManager->notify($notification);
78
-			}
79
-		}
80
-	}
72
+            $notification->setUser($uid);
73
+            if ($event->getEvent() === CommentsEvent::EVENT_DELETE
74
+                || $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE) {
75
+                $this->notificationManager->markProcessed($notification);
76
+            } else {
77
+                $this->notificationManager->notify($notification);
78
+            }
79
+        }
80
+    }
81 81
 
82
-	/**
83
-	 * creates a notification instance and fills it with comment data
84
-	 *
85
-	 * @param IComment $comment
86
-	 * @return \OCP\Notification\INotification
87
-	 */
88
-	public function instantiateNotification(IComment $comment) {
89
-		$notification = $this->notificationManager->createNotification();
90
-		$notification
91
-			->setApp('comments')
92
-			->setObject('comment', $comment->getId())
93
-			->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ])
94
-			->setDateTime($comment->getCreationDateTime());
82
+    /**
83
+     * creates a notification instance and fills it with comment data
84
+     *
85
+     * @param IComment $comment
86
+     * @return \OCP\Notification\INotification
87
+     */
88
+    public function instantiateNotification(IComment $comment) {
89
+        $notification = $this->notificationManager->createNotification();
90
+        $notification
91
+            ->setApp('comments')
92
+            ->setObject('comment', $comment->getId())
93
+            ->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ])
94
+            ->setDateTime($comment->getCreationDateTime());
95 95
 
96
-		return $notification;
97
-	}
96
+        return $notification;
97
+    }
98 98
 
99
-	/**
100
-	 * flattens the mention array returned from comments to a list of user ids.
101
-	 *
102
-	 * @param array $mentions
103
-	 * @return string[] containing the mentions, e.g. ['alice', 'bob']
104
-	 */
105
-	public function extractMentions(array $mentions) {
106
-		if (empty($mentions)) {
107
-			return [];
108
-		}
109
-		$uids = [];
110
-		foreach ($mentions as $mention) {
111
-			if ($mention['type'] === 'user') {
112
-				$uids[] = $mention['id'];
113
-			}
114
-		}
115
-		return $uids;
116
-	}
99
+    /**
100
+     * flattens the mention array returned from comments to a list of user ids.
101
+     *
102
+     * @param array $mentions
103
+     * @return string[] containing the mentions, e.g. ['alice', 'bob']
104
+     */
105
+    public function extractMentions(array $mentions) {
106
+        if (empty($mentions)) {
107
+            return [];
108
+        }
109
+        $uids = [];
110
+        foreach ($mentions as $mention) {
111
+            if ($mention['type'] === 'user') {
112
+                $uids[] = $mention['id'];
113
+            }
114
+        }
115
+        return $uids;
116
+    }
117 117
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 		$notification
91 91
 			->setApp('comments')
92 92
 			->setObject('comment', $comment->getId())
93
-			->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ])
93
+			->setSubject('mention', [$comment->getObjectType(), $comment->getObjectId()])
94 94
 			->setDateTime($comment->getCreationDateTime());
95 95
 
96 96
 		return $notification;
Please login to merge, or discard this patch.
apps/comments/lib/EventHandler.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -36,56 +36,56 @@
 block discarded – undo
36 36
  * @package OCA\Comments
37 37
  */
38 38
 class EventHandler implements ICommentsEventHandler {
39
-	/** @var ActivityListener */
40
-	private $activityListener;
39
+    /** @var ActivityListener */
40
+    private $activityListener;
41 41
 
42
-	/** @var NotificationListener */
43
-	private $notificationListener;
42
+    /** @var NotificationListener */
43
+    private $notificationListener;
44 44
 
45
-	public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
46
-		$this->activityListener = $activityListener;
47
-		$this->notificationListener = $notificationListener;
48
-	}
45
+    public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
46
+        $this->activityListener = $activityListener;
47
+        $this->notificationListener = $notificationListener;
48
+    }
49 49
 
50
-	/**
51
-	 * @param CommentsEvent $event
52
-	 */
53
-	public function handle(CommentsEvent $event) {
54
-		if ($event->getComment()->getObjectType() !== 'files') {
55
-			// this is a 'files'-specific Handler
56
-			return;
57
-		}
50
+    /**
51
+     * @param CommentsEvent $event
52
+     */
53
+    public function handle(CommentsEvent $event) {
54
+        if ($event->getComment()->getObjectType() !== 'files') {
55
+            // this is a 'files'-specific Handler
56
+            return;
57
+        }
58 58
 
59
-		$eventType = $event->getEvent();
60
-		if ($eventType === CommentsEvent::EVENT_ADD
61
-		) {
62
-			$this->notificationHandler($event);
63
-			$this->activityHandler($event);
64
-			return;
65
-		}
59
+        $eventType = $event->getEvent();
60
+        if ($eventType === CommentsEvent::EVENT_ADD
61
+        ) {
62
+            $this->notificationHandler($event);
63
+            $this->activityHandler($event);
64
+            return;
65
+        }
66 66
 
67
-		$applicableEvents = [
68
-			CommentsEvent::EVENT_PRE_UPDATE,
69
-			CommentsEvent::EVENT_UPDATE,
70
-			CommentsEvent::EVENT_DELETE,
71
-		];
72
-		if (in_array($eventType, $applicableEvents)) {
73
-			$this->notificationHandler($event);
74
-			return;
75
-		}
76
-	}
67
+        $applicableEvents = [
68
+            CommentsEvent::EVENT_PRE_UPDATE,
69
+            CommentsEvent::EVENT_UPDATE,
70
+            CommentsEvent::EVENT_DELETE,
71
+        ];
72
+        if (in_array($eventType, $applicableEvents)) {
73
+            $this->notificationHandler($event);
74
+            return;
75
+        }
76
+    }
77 77
 
78
-	/**
79
-	 * @param CommentsEvent $event
80
-	 */
81
-	private function activityHandler(CommentsEvent $event) {
82
-		$this->activityListener->commentEvent($event);
83
-	}
78
+    /**
79
+     * @param CommentsEvent $event
80
+     */
81
+    private function activityHandler(CommentsEvent $event) {
82
+        $this->activityListener->commentEvent($event);
83
+    }
84 84
 
85
-	/**
86
-	 * @param CommentsEvent $event
87
-	 */
88
-	private function notificationHandler(CommentsEvent $event) {
89
-		$this->notificationListener->evaluate($event);
90
-	}
85
+    /**
86
+     * @param CommentsEvent $event
87
+     */
88
+    private function notificationHandler(CommentsEvent $event) {
89
+        $this->notificationListener->evaluate($event);
90
+    }
91 91
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/User_Proxy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @return string|false
198 198
 	 */
199 199
 	public function loginName2UserName($loginName) {
200
-		$id = 'LOGINNAME,' . $loginName;
200
+		$id = 'LOGINNAME,'.$loginName;
201 201
 		return $this->handleRequest($id, 'loginName2UserName', [$loginName]);
202 202
 	}
203 203
 	
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return string|false with the username
209 209
 	 */
210 210
 	public function dn2UserName($dn) {
211
-		$id = 'DN,' . $dn;
211
+		$id = 'DN,'.$dn;
212 212
 		return $this->handleRequest($id, 'dn2UserName', [$dn]);
213 213
 	}
214 214
 
Please login to merge, or discard this patch.
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -37,351 +37,351 @@
 block discarded – undo
37 37
 use OCP\Notification\IManager as INotificationManager;
38 38
 
39 39
 class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
40
-	private $backends = [];
41
-	/** @var User_LDAP */
42
-	private $refBackend = null;
40
+    private $backends = [];
41
+    /** @var User_LDAP */
42
+    private $refBackend = null;
43 43
 
44
-	public function __construct(
45
-		Helper $helper,
46
-		ILDAPWrapper $ldap,
47
-		IConfig $ocConfig,
48
-		INotificationManager $notificationManager,
49
-		IUserSession $userSession,
50
-		UserPluginManager $userPluginManager
51
-	) {
52
-		parent::__construct($ldap);
53
-		$serverConfigPrefixes = $helper->getServerConfigurationPrefixes(true);
54
-		foreach ($serverConfigPrefixes as $configPrefix) {
55
-			$this->backends[$configPrefix] =
56
-				new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager);
44
+    public function __construct(
45
+        Helper $helper,
46
+        ILDAPWrapper $ldap,
47
+        IConfig $ocConfig,
48
+        INotificationManager $notificationManager,
49
+        IUserSession $userSession,
50
+        UserPluginManager $userPluginManager
51
+    ) {
52
+        parent::__construct($ldap);
53
+        $serverConfigPrefixes = $helper->getServerConfigurationPrefixes(true);
54
+        foreach ($serverConfigPrefixes as $configPrefix) {
55
+            $this->backends[$configPrefix] =
56
+                new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager);
57 57
 
58
-			if (is_null($this->refBackend)) {
59
-				$this->refBackend = &$this->backends[$configPrefix];
60
-			}
61
-		}
62
-	}
58
+            if (is_null($this->refBackend)) {
59
+                $this->refBackend = &$this->backends[$configPrefix];
60
+            }
61
+        }
62
+    }
63 63
 
64
-	/**
65
-	 * Tries the backends one after the other until a positive result is returned from the specified method
66
-	 *
67
-	 * @param string $id the uid connected to the request
68
-	 * @param string $method the method of the user backend that shall be called
69
-	 * @param array $parameters an array of parameters to be passed
70
-	 * @return mixed the result of the method or false
71
-	 */
72
-	protected function walkBackends($id, $method, $parameters) {
73
-		$uid = $id;
74
-		$cacheKey = $this->getUserCacheKey($uid);
75
-		foreach ($this->backends as $configPrefix => $backend) {
76
-			$instance = $backend;
77
-			if (!method_exists($instance, $method)
78
-				&& method_exists($this->getAccess($configPrefix), $method)) {
79
-				$instance = $this->getAccess($configPrefix);
80
-			}
81
-			if ($result = call_user_func_array([$instance, $method], $parameters)) {
82
-				if (!$this->isSingleBackend()) {
83
-					$this->writeToCache($cacheKey, $configPrefix);
84
-				}
85
-				return $result;
86
-			}
87
-		}
88
-		return false;
89
-	}
64
+    /**
65
+     * Tries the backends one after the other until a positive result is returned from the specified method
66
+     *
67
+     * @param string $id the uid connected to the request
68
+     * @param string $method the method of the user backend that shall be called
69
+     * @param array $parameters an array of parameters to be passed
70
+     * @return mixed the result of the method or false
71
+     */
72
+    protected function walkBackends($id, $method, $parameters) {
73
+        $uid = $id;
74
+        $cacheKey = $this->getUserCacheKey($uid);
75
+        foreach ($this->backends as $configPrefix => $backend) {
76
+            $instance = $backend;
77
+            if (!method_exists($instance, $method)
78
+                && method_exists($this->getAccess($configPrefix), $method)) {
79
+                $instance = $this->getAccess($configPrefix);
80
+            }
81
+            if ($result = call_user_func_array([$instance, $method], $parameters)) {
82
+                if (!$this->isSingleBackend()) {
83
+                    $this->writeToCache($cacheKey, $configPrefix);
84
+                }
85
+                return $result;
86
+            }
87
+        }
88
+        return false;
89
+    }
90 90
 
91
-	/**
92
-	 * Asks the backend connected to the server that supposely takes care of the uid from the request.
93
-	 *
94
-	 * @param string $id the uid connected to the request
95
-	 * @param string $method the method of the user backend that shall be called
96
-	 * @param array $parameters an array of parameters to be passed
97
-	 * @param mixed $passOnWhen the result matches this variable
98
-	 * @return mixed the result of the method or false
99
-	 */
100
-	protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen) {
101
-		$uid = $id;
102
-		$cacheKey = $this->getUserCacheKey($uid);
103
-		$prefix = $this->getFromCache($cacheKey);
104
-		//in case the uid has been found in the past, try this stored connection first
105
-		if (!is_null($prefix)) {
106
-			if (isset($this->backends[$prefix])) {
107
-				$instance = $this->backends[$prefix];
108
-				if (!method_exists($instance, $method)
109
-					&& method_exists($this->getAccess($prefix), $method)) {
110
-					$instance = $this->getAccess($prefix);
111
-				}
112
-				$result = call_user_func_array([$instance, $method], $parameters);
113
-				if ($result === $passOnWhen) {
114
-					//not found here, reset cache to null if user vanished
115
-					//because sometimes methods return false with a reason
116
-					$userExists = call_user_func_array(
117
-						[$this->backends[$prefix], 'userExistsOnLDAP'],
118
-						[$uid]
119
-					);
120
-					if (!$userExists) {
121
-						$this->writeToCache($cacheKey, null);
122
-					}
123
-				}
124
-				return $result;
125
-			}
126
-		}
127
-		return false;
128
-	}
91
+    /**
92
+     * Asks the backend connected to the server that supposely takes care of the uid from the request.
93
+     *
94
+     * @param string $id the uid connected to the request
95
+     * @param string $method the method of the user backend that shall be called
96
+     * @param array $parameters an array of parameters to be passed
97
+     * @param mixed $passOnWhen the result matches this variable
98
+     * @return mixed the result of the method or false
99
+     */
100
+    protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen) {
101
+        $uid = $id;
102
+        $cacheKey = $this->getUserCacheKey($uid);
103
+        $prefix = $this->getFromCache($cacheKey);
104
+        //in case the uid has been found in the past, try this stored connection first
105
+        if (!is_null($prefix)) {
106
+            if (isset($this->backends[$prefix])) {
107
+                $instance = $this->backends[$prefix];
108
+                if (!method_exists($instance, $method)
109
+                    && method_exists($this->getAccess($prefix), $method)) {
110
+                    $instance = $this->getAccess($prefix);
111
+                }
112
+                $result = call_user_func_array([$instance, $method], $parameters);
113
+                if ($result === $passOnWhen) {
114
+                    //not found here, reset cache to null if user vanished
115
+                    //because sometimes methods return false with a reason
116
+                    $userExists = call_user_func_array(
117
+                        [$this->backends[$prefix], 'userExistsOnLDAP'],
118
+                        [$uid]
119
+                    );
120
+                    if (!$userExists) {
121
+                        $this->writeToCache($cacheKey, null);
122
+                    }
123
+                }
124
+                return $result;
125
+            }
126
+        }
127
+        return false;
128
+    }
129 129
 
130
-	protected function activeBackends(): int {
131
-		return count($this->backends);
132
-	}
130
+    protected function activeBackends(): int {
131
+        return count($this->backends);
132
+    }
133 133
 
134
-	/**
135
-	 * Check if backend implements actions
136
-	 *
137
-	 * @param int $actions bitwise-or'ed actions
138
-	 * @return boolean
139
-	 *
140
-	 * Returns the supported actions as int to be
141
-	 * compared with \OC\User\Backend::CREATE_USER etc.
142
-	 */
143
-	public function implementsActions($actions) {
144
-		//it's the same across all our user backends obviously
145
-		return $this->refBackend->implementsActions($actions);
146
-	}
134
+    /**
135
+     * Check if backend implements actions
136
+     *
137
+     * @param int $actions bitwise-or'ed actions
138
+     * @return boolean
139
+     *
140
+     * Returns the supported actions as int to be
141
+     * compared with \OC\User\Backend::CREATE_USER etc.
142
+     */
143
+    public function implementsActions($actions) {
144
+        //it's the same across all our user backends obviously
145
+        return $this->refBackend->implementsActions($actions);
146
+    }
147 147
 
148
-	/**
149
-	 * Backend name to be shown in user management
150
-	 *
151
-	 * @return string the name of the backend to be shown
152
-	 */
153
-	public function getBackendName() {
154
-		return $this->refBackend->getBackendName();
155
-	}
148
+    /**
149
+     * Backend name to be shown in user management
150
+     *
151
+     * @return string the name of the backend to be shown
152
+     */
153
+    public function getBackendName() {
154
+        return $this->refBackend->getBackendName();
155
+    }
156 156
 
157
-	/**
158
-	 * Get a list of all users
159
-	 *
160
-	 * @param string $search
161
-	 * @param null|int $limit
162
-	 * @param null|int $offset
163
-	 * @return string[] an array of all uids
164
-	 */
165
-	public function getUsers($search = '', $limit = 10, $offset = 0) {
166
-		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
167
-		$users = [];
168
-		foreach ($this->backends as $backend) {
169
-			$backendUsers = $backend->getUsers($search, $limit, $offset);
170
-			if (is_array($backendUsers)) {
171
-				$users = array_merge($users, $backendUsers);
172
-			}
173
-		}
174
-		return $users;
175
-	}
157
+    /**
158
+     * Get a list of all users
159
+     *
160
+     * @param string $search
161
+     * @param null|int $limit
162
+     * @param null|int $offset
163
+     * @return string[] an array of all uids
164
+     */
165
+    public function getUsers($search = '', $limit = 10, $offset = 0) {
166
+        //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
167
+        $users = [];
168
+        foreach ($this->backends as $backend) {
169
+            $backendUsers = $backend->getUsers($search, $limit, $offset);
170
+            if (is_array($backendUsers)) {
171
+                $users = array_merge($users, $backendUsers);
172
+            }
173
+        }
174
+        return $users;
175
+    }
176 176
 
177
-	/**
178
-	 * check if a user exists
179
-	 *
180
-	 * @param string $uid the username
181
-	 * @return boolean
182
-	 */
183
-	public function userExists($uid) {
184
-		$existsOnLDAP = false;
185
-		$existsLocally = $this->handleRequest($uid, 'userExists', [$uid]);
186
-		if ($existsLocally) {
187
-			$existsOnLDAP = $this->userExistsOnLDAP($uid);
188
-		}
189
-		if ($existsLocally && !$existsOnLDAP) {
190
-			try {
191
-				$user = $this->getLDAPAccess($uid)->userManager->get($uid);
192
-				if ($user instanceof User) {
193
-					$user->markUser();
194
-				}
195
-			} catch (\Exception $e) {
196
-				// ignore
197
-			}
198
-		}
199
-		return $existsLocally;
200
-	}
177
+    /**
178
+     * check if a user exists
179
+     *
180
+     * @param string $uid the username
181
+     * @return boolean
182
+     */
183
+    public function userExists($uid) {
184
+        $existsOnLDAP = false;
185
+        $existsLocally = $this->handleRequest($uid, 'userExists', [$uid]);
186
+        if ($existsLocally) {
187
+            $existsOnLDAP = $this->userExistsOnLDAP($uid);
188
+        }
189
+        if ($existsLocally && !$existsOnLDAP) {
190
+            try {
191
+                $user = $this->getLDAPAccess($uid)->userManager->get($uid);
192
+                if ($user instanceof User) {
193
+                    $user->markUser();
194
+                }
195
+            } catch (\Exception $e) {
196
+                // ignore
197
+            }
198
+        }
199
+        return $existsLocally;
200
+    }
201 201
 
202
-	/**
203
-	 * check if a user exists on LDAP
204
-	 *
205
-	 * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
206
-	 * name or an instance of that user
207
-	 */
208
-	public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
209
-		$id = ($user instanceof User) ? $user->getUsername() : $user;
210
-		return $this->handleRequest($id, 'userExistsOnLDAP', [$user, $ignoreCache]);
211
-	}
202
+    /**
203
+     * check if a user exists on LDAP
204
+     *
205
+     * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
206
+     * name or an instance of that user
207
+     */
208
+    public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
209
+        $id = ($user instanceof User) ? $user->getUsername() : $user;
210
+        return $this->handleRequest($id, 'userExistsOnLDAP', [$user, $ignoreCache]);
211
+    }
212 212
 
213
-	/**
214
-	 * Check if the password is correct
215
-	 *
216
-	 * @param string $uid The username
217
-	 * @param string $password The password
218
-	 * @return bool
219
-	 *
220
-	 * Check if the password is correct without logging in the user
221
-	 */
222
-	public function checkPassword($uid, $password) {
223
-		return $this->handleRequest($uid, 'checkPassword', [$uid, $password]);
224
-	}
213
+    /**
214
+     * Check if the password is correct
215
+     *
216
+     * @param string $uid The username
217
+     * @param string $password The password
218
+     * @return bool
219
+     *
220
+     * Check if the password is correct without logging in the user
221
+     */
222
+    public function checkPassword($uid, $password) {
223
+        return $this->handleRequest($uid, 'checkPassword', [$uid, $password]);
224
+    }
225 225
 
226
-	/**
227
-	 * returns the username for the given login name, if available
228
-	 *
229
-	 * @param string $loginName
230
-	 * @return string|false
231
-	 */
232
-	public function loginName2UserName($loginName) {
233
-		$id = 'LOGINNAME,' . $loginName;
234
-		return $this->handleRequest($id, 'loginName2UserName', [$loginName]);
235
-	}
226
+    /**
227
+     * returns the username for the given login name, if available
228
+     *
229
+     * @param string $loginName
230
+     * @return string|false
231
+     */
232
+    public function loginName2UserName($loginName) {
233
+        $id = 'LOGINNAME,' . $loginName;
234
+        return $this->handleRequest($id, 'loginName2UserName', [$loginName]);
235
+    }
236 236
 
237
-	/**
238
-	 * returns the username for the given LDAP DN, if available
239
-	 *
240
-	 * @param string $dn
241
-	 * @return string|false with the username
242
-	 */
243
-	public function dn2UserName($dn) {
244
-		$id = 'DN,' . $dn;
245
-		return $this->handleRequest($id, 'dn2UserName', [$dn]);
246
-	}
237
+    /**
238
+     * returns the username for the given LDAP DN, if available
239
+     *
240
+     * @param string $dn
241
+     * @return string|false with the username
242
+     */
243
+    public function dn2UserName($dn) {
244
+        $id = 'DN,' . $dn;
245
+        return $this->handleRequest($id, 'dn2UserName', [$dn]);
246
+    }
247 247
 
248
-	/**
249
-	 * get the user's home directory
250
-	 *
251
-	 * @param string $uid the username
252
-	 * @return boolean
253
-	 */
254
-	public function getHome($uid) {
255
-		return $this->handleRequest($uid, 'getHome', [$uid]);
256
-	}
248
+    /**
249
+     * get the user's home directory
250
+     *
251
+     * @param string $uid the username
252
+     * @return boolean
253
+     */
254
+    public function getHome($uid) {
255
+        return $this->handleRequest($uid, 'getHome', [$uid]);
256
+    }
257 257
 
258
-	/**
259
-	 * get display name of the user
260
-	 *
261
-	 * @param string $uid user ID of the user
262
-	 * @return string display name
263
-	 */
264
-	public function getDisplayName($uid) {
265
-		return $this->handleRequest($uid, 'getDisplayName', [$uid]);
266
-	}
258
+    /**
259
+     * get display name of the user
260
+     *
261
+     * @param string $uid user ID of the user
262
+     * @return string display name
263
+     */
264
+    public function getDisplayName($uid) {
265
+        return $this->handleRequest($uid, 'getDisplayName', [$uid]);
266
+    }
267 267
 
268
-	/**
269
-	 * set display name of the user
270
-	 *
271
-	 * @param string $uid user ID of the user
272
-	 * @param string $displayName new display name
273
-	 * @return string display name
274
-	 */
275
-	public function setDisplayName($uid, $displayName) {
276
-		return $this->handleRequest($uid, 'setDisplayName', [$uid, $displayName]);
277
-	}
268
+    /**
269
+     * set display name of the user
270
+     *
271
+     * @param string $uid user ID of the user
272
+     * @param string $displayName new display name
273
+     * @return string display name
274
+     */
275
+    public function setDisplayName($uid, $displayName) {
276
+        return $this->handleRequest($uid, 'setDisplayName', [$uid, $displayName]);
277
+    }
278 278
 
279
-	/**
280
-	 * checks whether the user is allowed to change his avatar in Nextcloud
281
-	 *
282
-	 * @param string $uid the Nextcloud user name
283
-	 * @return boolean either the user can or cannot
284
-	 */
285
-	public function canChangeAvatar($uid) {
286
-		return $this->handleRequest($uid, 'canChangeAvatar', [$uid], true);
287
-	}
279
+    /**
280
+     * checks whether the user is allowed to change his avatar in Nextcloud
281
+     *
282
+     * @param string $uid the Nextcloud user name
283
+     * @return boolean either the user can or cannot
284
+     */
285
+    public function canChangeAvatar($uid) {
286
+        return $this->handleRequest($uid, 'canChangeAvatar', [$uid], true);
287
+    }
288 288
 
289
-	/**
290
-	 * Get a list of all display names and user ids.
291
-	 *
292
-	 * @param string $search
293
-	 * @param int|null $limit
294
-	 * @param int|null $offset
295
-	 * @return array an array of all displayNames (value) and the corresponding uids (key)
296
-	 */
297
-	public function getDisplayNames($search = '', $limit = null, $offset = null) {
298
-		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
299
-		$users = [];
300
-		foreach ($this->backends as $backend) {
301
-			$backendUsers = $backend->getDisplayNames($search, $limit, $offset);
302
-			if (is_array($backendUsers)) {
303
-				$users = $users + $backendUsers;
304
-			}
305
-		}
306
-		return $users;
307
-	}
289
+    /**
290
+     * Get a list of all display names and user ids.
291
+     *
292
+     * @param string $search
293
+     * @param int|null $limit
294
+     * @param int|null $offset
295
+     * @return array an array of all displayNames (value) and the corresponding uids (key)
296
+     */
297
+    public function getDisplayNames($search = '', $limit = null, $offset = null) {
298
+        //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
299
+        $users = [];
300
+        foreach ($this->backends as $backend) {
301
+            $backendUsers = $backend->getDisplayNames($search, $limit, $offset);
302
+            if (is_array($backendUsers)) {
303
+                $users = $users + $backendUsers;
304
+            }
305
+        }
306
+        return $users;
307
+    }
308 308
 
309
-	/**
310
-	 * delete a user
311
-	 *
312
-	 * @param string $uid The username of the user to delete
313
-	 * @return bool
314
-	 *
315
-	 * Deletes a user
316
-	 */
317
-	public function deleteUser($uid) {
318
-		return $this->handleRequest($uid, 'deleteUser', [$uid]);
319
-	}
309
+    /**
310
+     * delete a user
311
+     *
312
+     * @param string $uid The username of the user to delete
313
+     * @return bool
314
+     *
315
+     * Deletes a user
316
+     */
317
+    public function deleteUser($uid) {
318
+        return $this->handleRequest($uid, 'deleteUser', [$uid]);
319
+    }
320 320
 
321
-	/**
322
-	 * Set password
323
-	 *
324
-	 * @param string $uid The username
325
-	 * @param string $password The new password
326
-	 * @return bool
327
-	 *
328
-	 */
329
-	public function setPassword($uid, $password) {
330
-		return $this->handleRequest($uid, 'setPassword', [$uid, $password]);
331
-	}
321
+    /**
322
+     * Set password
323
+     *
324
+     * @param string $uid The username
325
+     * @param string $password The new password
326
+     * @return bool
327
+     *
328
+     */
329
+    public function setPassword($uid, $password) {
330
+        return $this->handleRequest($uid, 'setPassword', [$uid, $password]);
331
+    }
332 332
 
333
-	/**
334
-	 * @return bool
335
-	 */
336
-	public function hasUserListings() {
337
-		return $this->refBackend->hasUserListings();
338
-	}
333
+    /**
334
+     * @return bool
335
+     */
336
+    public function hasUserListings() {
337
+        return $this->refBackend->hasUserListings();
338
+    }
339 339
 
340
-	/**
341
-	 * Count the number of users
342
-	 *
343
-	 * @return int|bool
344
-	 */
345
-	public function countUsers() {
346
-		$users = false;
347
-		foreach ($this->backends as $backend) {
348
-			$backendUsers = $backend->countUsers();
349
-			if ($backendUsers !== false) {
350
-				$users += $backendUsers;
351
-			}
352
-		}
353
-		return $users;
354
-	}
340
+    /**
341
+     * Count the number of users
342
+     *
343
+     * @return int|bool
344
+     */
345
+    public function countUsers() {
346
+        $users = false;
347
+        foreach ($this->backends as $backend) {
348
+            $backendUsers = $backend->countUsers();
349
+            if ($backendUsers !== false) {
350
+                $users += $backendUsers;
351
+            }
352
+        }
353
+        return $users;
354
+    }
355 355
 
356
-	/**
357
-	 * Return access for LDAP interaction.
358
-	 *
359
-	 * @param string $uid
360
-	 * @return Access instance of Access for LDAP interaction
361
-	 */
362
-	public function getLDAPAccess($uid) {
363
-		return $this->handleRequest($uid, 'getLDAPAccess', [$uid]);
364
-	}
356
+    /**
357
+     * Return access for LDAP interaction.
358
+     *
359
+     * @param string $uid
360
+     * @return Access instance of Access for LDAP interaction
361
+     */
362
+    public function getLDAPAccess($uid) {
363
+        return $this->handleRequest($uid, 'getLDAPAccess', [$uid]);
364
+    }
365 365
 
366
-	/**
367
-	 * Return a new LDAP connection for the specified user.
368
-	 * The connection needs to be closed manually.
369
-	 *
370
-	 * @param string $uid
371
-	 * @return resource|\LDAP\Connection The LDAP connection
372
-	 */
373
-	public function getNewLDAPConnection($uid) {
374
-		return $this->handleRequest($uid, 'getNewLDAPConnection', [$uid]);
375
-	}
366
+    /**
367
+     * Return a new LDAP connection for the specified user.
368
+     * The connection needs to be closed manually.
369
+     *
370
+     * @param string $uid
371
+     * @return resource|\LDAP\Connection The LDAP connection
372
+     */
373
+    public function getNewLDAPConnection($uid) {
374
+        return $this->handleRequest($uid, 'getNewLDAPConnection', [$uid]);
375
+    }
376 376
 
377
-	/**
378
-	 * Creates a new user in LDAP
379
-	 *
380
-	 * @param $username
381
-	 * @param $password
382
-	 * @return bool
383
-	 */
384
-	public function createUser($username, $password) {
385
-		return $this->handleRequest($username, 'createUser', [$username, $password]);
386
-	}
377
+    /**
378
+     * Creates a new user in LDAP
379
+     *
380
+     * @param $username
381
+     * @param $password
382
+     * @return bool
383
+     */
384
+    public function createUser($username, $password) {
385
+        return $this->handleRequest($username, 'createUser', [$username, $password]);
386
+    }
387 387
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/BackendUtility.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 namespace OCA\User_LDAP;
27 27
 
28 28
 abstract class BackendUtility {
29
-	protected $access;
29
+    protected $access;
30 30
 
31
-	/**
32
-	 * constructor, make sure the subclasses call this one!
33
-	 * @param Access $access an instance of Access for LDAP interaction
34
-	 */
35
-	public function __construct(Access $access) {
36
-		$this->access = $access;
37
-	}
31
+    /**
32
+     * constructor, make sure the subclasses call this one!
33
+     * @param Access $access an instance of Access for LDAP interaction
34
+     */
35
+    public function __construct(Access $access) {
36
+        $this->access = $access;
37
+    }
38 38
 }
Please login to merge, or discard this patch.