Completed
Pull Request — master (#6982)
by Blizzz
14:41
created
apps/comments/lib/AppInfo/Application.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
 
29 29
 class Application extends App {
30 30
 
31
-	public function __construct (array $urlParams = array()) {
32
-		parent::__construct('comments', $urlParams);
33
-		$container = $this->getContainer();
31
+    public function __construct (array $urlParams = array()) {
32
+        parent::__construct('comments', $urlParams);
33
+        $container = $this->getContainer();
34 34
 
35
-		$container->registerAlias('NotificationsController', Notifications::class);
35
+        $container->registerAlias('NotificationsController', Notifications::class);
36 36
 
37
-		$jsSettingsHelper = new JSSettingsHelper($container->getServer());
38
-		Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
39
-	}
37
+        $jsSettingsHelper = new JSSettingsHelper($container->getServer());
38
+        Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
39
+    }
40 40
 }
Please login to merge, or discard this patch.
apps/comments/lib/JSSettingsHelper.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
 use OCP\IServerContainer;
28 28
 
29 29
 class JSSettingsHelper {
30
-	/** @var IServerContainer */
31
-	private $c;
30
+    /** @var IServerContainer */
31
+    private $c;
32 32
 
33
-	public function __construct(IServerContainer $c) {
34
-		$this->c = $c;
35
-	}
33
+    public function __construct(IServerContainer $c) {
34
+        $this->c = $c;
35
+    }
36 36
 
37
-	public function extend(array $settings) {
38
-		$appConfig = json_decode($settings['array']['oc_appconfig'], true);
37
+    public function extend(array $settings) {
38
+        $appConfig = json_decode($settings['array']['oc_appconfig'], true);
39 39
 
40
-		$value = (int)$this->c->getConfig()->getAppValue('comments', 'maxAutoCompleteResults', 10);
41
-		$appConfig['comments']['maxAutoCompleteResults'] = $value;
40
+        $value = (int)$this->c->getConfig()->getAppValue('comments', 'maxAutoCompleteResults', 10);
41
+        $appConfig['comments']['maxAutoCompleteResults'] = $value;
42 42
 
43
-		$settings['array']['oc_appconfig'] = json_encode($appConfig);
44
-	}
43
+        $settings['array']['oc_appconfig'] = json_encode($appConfig);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
core/Controller/AutoCompleteController.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -32,70 +32,70 @@
 block discarded – undo
32 32
 use OCP\Share;
33 33
 
34 34
 class AutoCompleteController extends Controller {
35
-	/** @var ISearch */
36
-	private $collaboratorSearch;
37
-	/** @var IManager */
38
-	private $autoCompleteManager;
39
-	/** @var IConfig */
40
-	private $config;
35
+    /** @var ISearch */
36
+    private $collaboratorSearch;
37
+    /** @var IManager */
38
+    private $autoCompleteManager;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	public function __construct(
43
-		$appName,
44
-		IRequest $request,
45
-		ISearch $collaboratorSearch,
46
-		IManager $autoCompleteManager,
47
-		IConfig $config
48
-	) {
49
-		parent::__construct($appName, $request);
42
+    public function __construct(
43
+        $appName,
44
+        IRequest $request,
45
+        ISearch $collaboratorSearch,
46
+        IManager $autoCompleteManager,
47
+        IConfig $config
48
+    ) {
49
+        parent::__construct($appName, $request);
50 50
 
51
-		$this->collaboratorSearch = $collaboratorSearch;
52
-		$this->autoCompleteManager = $autoCompleteManager;
53
-		$this->config = $config;
54
-	}
51
+        $this->collaboratorSearch = $collaboratorSearch;
52
+        $this->autoCompleteManager = $autoCompleteManager;
53
+        $this->config = $config;
54
+    }
55 55
 
56
-	/**
57
-	 * @NoAdminRequired
58
-	 *
59
-	 * @param string $search
60
-	 * @param string $itemType
61
-	 * @param string $itemId
62
-	 * @param string|null $sorter can be piped, top prio first, e.g.: "commenters|share-recipients"
63
-	 * @param array $shareTypes
64
-	 * @param int $limit
65
-	 * @return DataResponse
66
-	 */
67
-	public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [Share::SHARE_TYPE_USER], $limit = 10) {
68
-		// if enumeration/user listings are disabled, we'll receive an empty
69
-		// result from search() – thus nothing else to do here.
70
-		list($results,) = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
56
+    /**
57
+     * @NoAdminRequired
58
+     *
59
+     * @param string $search
60
+     * @param string $itemType
61
+     * @param string $itemId
62
+     * @param string|null $sorter can be piped, top prio first, e.g.: "commenters|share-recipients"
63
+     * @param array $shareTypes
64
+     * @param int $limit
65
+     * @return DataResponse
66
+     */
67
+    public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [Share::SHARE_TYPE_USER], $limit = 10) {
68
+        // if enumeration/user listings are disabled, we'll receive an empty
69
+        // result from search() – thus nothing else to do here.
70
+        list($results,) = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
71 71
 
72
-		// there won't be exact matches without a search string
73
-		unset($results['exact']);
72
+        // there won't be exact matches without a search string
73
+        unset($results['exact']);
74 74
 
75
-		$sorters = array_reverse(explode('|', $sorter));
76
-		$this->autoCompleteManager->runSorters($sorters, $results, [
77
-			'itemType' => $itemType,
78
-			'itemId' => $itemId,
79
-		]);
75
+        $sorters = array_reverse(explode('|', $sorter));
76
+        $this->autoCompleteManager->runSorters($sorters, $results, [
77
+            'itemType' => $itemType,
78
+            'itemId' => $itemId,
79
+        ]);
80 80
 
81
-		// transform to expected format
82
-		$results = $this->prepareResultArray($results);
81
+        // transform to expected format
82
+        $results = $this->prepareResultArray($results);
83 83
 
84
-		return new DataResponse($results);
85
-	}
84
+        return new DataResponse($results);
85
+    }
86 86
 
87 87
 
88
-	protected function prepareResultArray(array $results) {
89
-		$output = [];
90
-		foreach ($results as $type => $subResult) {
91
-			foreach ($subResult as $result) {
92
-				$output[] = [
93
-					'id' => $result['value']['shareWith'],
94
-					'label' => $result['label'],
95
-					'source' => $type,
96
-				];
97
-			}
98
-		}
99
-		return $output;
100
-	}
88
+    protected function prepareResultArray(array $results) {
89
+        $output = [];
90
+        foreach ($results as $type => $subResult) {
91
+            foreach ($subResult as $result) {
92
+                $output[] = [
93
+                    'id' => $result['value']['shareWith'],
94
+                    'label' => $result['label'],
95
+                    'source' => $type,
96
+                ];
97
+            }
98
+        }
99
+        return $output;
100
+    }
101 101
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -33,78 +33,78 @@
 block discarded – undo
33 33
 
34 34
 class ShareRecipientSorter implements ISorter {
35 35
 
36
-	/** @var IManager */
37
-	private $shareManager;
38
-	/** @var Folder */
39
-	private $rootFolder;
40
-	/** @var IUserSession */
41
-	private $userSession;
36
+    /** @var IManager */
37
+    private $shareManager;
38
+    /** @var Folder */
39
+    private $rootFolder;
40
+    /** @var IUserSession */
41
+    private $userSession;
42 42
 
43
-	public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) {
44
-		$this->shareManager = $shareManager;
45
-		$this->rootFolder = $rootFolder;
46
-		$this->userSession = $userSession;
47
-	}
43
+    public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) {
44
+        $this->shareManager = $shareManager;
45
+        $this->rootFolder = $rootFolder;
46
+        $this->userSession = $userSession;
47
+    }
48 48
 
49
-	public function getId() {
50
-		return 'share-recipients';
51
-	}
49
+    public function getId() {
50
+        return 'share-recipients';
51
+    }
52 52
 
53
-	public function sort(array &$sortArray, array $context) {
54
-		// let's be tolerant. Comments  uses "files" by default, other usages are often singular
55
-		if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
56
-			return;
57
-		}
58
-		$user = $this->userSession->getUser();
59
-		if($user === null) {
60
-			return;
61
-		}
62
-		$userFolder = $this->rootFolder->getUserFolder($user->getUID());
63
-		/** @var Node[] $nodes */
64
-		$nodes = $userFolder->getById((int)$context['itemId']);
65
-		if(count($nodes) === 0) {
66
-			return;
67
-		}
68
-		$al = $this->shareManager->getAccessList($nodes[0]);
53
+    public function sort(array &$sortArray, array $context) {
54
+        // let's be tolerant. Comments  uses "files" by default, other usages are often singular
55
+        if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
56
+            return;
57
+        }
58
+        $user = $this->userSession->getUser();
59
+        if($user === null) {
60
+            return;
61
+        }
62
+        $userFolder = $this->rootFolder->getUserFolder($user->getUID());
63
+        /** @var Node[] $nodes */
64
+        $nodes = $userFolder->getById((int)$context['itemId']);
65
+        if(count($nodes) === 0) {
66
+            return;
67
+        }
68
+        $al = $this->shareManager->getAccessList($nodes[0]);
69 69
 
70
-		foreach ($sortArray as $type => &$byType) {
71
-			if(!isset($al[$type]) || !is_array($al[$type])) {
72
-				continue;
73
-			}
70
+        foreach ($sortArray as $type => &$byType) {
71
+            if(!isset($al[$type]) || !is_array($al[$type])) {
72
+                continue;
73
+            }
74 74
 
75
-			// at least on PHP 5.6 usort turned out to be not stable. So we add
76
-			// the current index to the value and compare it on a draw
77
-			$i = 0;
78
-			$workArray = array_map(function($element) use (&$i) {
79
-				return [$i++, $element];
80
-			}, $byType);
75
+            // at least on PHP 5.6 usort turned out to be not stable. So we add
76
+            // the current index to the value and compare it on a draw
77
+            $i = 0;
78
+            $workArray = array_map(function($element) use (&$i) {
79
+                return [$i++, $element];
80
+            }, $byType);
81 81
 
82
-			usort($workArray, function ($a, $b) use ($al, $type) {
83
-				$result = $this->compare($a[1], $b[1], $al[$type]);
84
-				if($result === 0) {
85
-					$result = $a[0] - $b[0];
86
-				}
87
-				return $result;
88
-			});
82
+            usort($workArray, function ($a, $b) use ($al, $type) {
83
+                $result = $this->compare($a[1], $b[1], $al[$type]);
84
+                if($result === 0) {
85
+                    $result = $a[0] - $b[0];
86
+                }
87
+                return $result;
88
+            });
89 89
 
90
-			// and remove the index values again
91
-			$byType = array_column($workArray, 1);
92
-		}
93
-	}
90
+            // and remove the index values again
91
+            $byType = array_column($workArray, 1);
92
+        }
93
+    }
94 94
 
95
-	/**
96
-	 * @param array $a
97
-	 * @param array $b
98
-	 * @param array $al
99
-	 * @return int
100
-	 */
101
-	protected function compare(array $a, array $b, array $al) {
102
-		$a = $a['value']['shareWith'];
103
-		$b = $b['value']['shareWith'];
95
+    /**
96
+     * @param array $a
97
+     * @param array $b
98
+     * @param array $al
99
+     * @return int
100
+     */
101
+    protected function compare(array $a, array $b, array $al) {
102
+        $a = $a['value']['shareWith'];
103
+        $b = $b['value']['shareWith'];
104 104
 
105
-		$valueA = (int)in_array($a, $al, true);
106
-		$valueB = (int)in_array($b, $al, true);
105
+        $valueA = (int)in_array($a, $al, true);
106
+        $valueB = (int)in_array($b, $al, true);
107 107
 
108
-		return $valueB - $valueA;
109
-	}
108
+        return $valueB - $valueA;
109
+    }
110 110
 }
Please login to merge, or discard this patch.
apps/comments/lib/Collaboration/CommentersSorter.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -29,87 +29,87 @@
 block discarded – undo
29 29
 
30 30
 class CommentersSorter implements ISorter {
31 31
 
32
-	/** @var ICommentsManager */
33
-	private $commentsManager;
34
-
35
-	public function __construct(ICommentsManager $commentsManager) {
36
-		$this->commentsManager = $commentsManager;
37
-	}
38
-
39
-	public function getId() {
40
-		return 'commenters';
41
-	}
42
-
43
-	/**
44
-	 * Sorts people who commented on the given item atop (descelating) of the
45
-	 * others
46
-	 *
47
-	 * @param array $sortArray
48
-	 * @param array $context
49
-	 */
50
-	public function sort(array &$sortArray, array $context) {
51
-		$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
52
-		if(count($commenters) === 0) {
53
-			return;
54
-		}
55
-
56
-		foreach ($sortArray as $type => &$byType) {
57
-			if(!isset($commenters[$type])) {
58
-				continue;
59
-			}
60
-
61
-			// at least on PHP 5.6 usort turned out to be not stable. So we add
62
-			// the current index to the value and compare it on a draw
63
-			$i = 0;
64
-			$workArray = array_map(function($element) use (&$i) {
65
-				return [$i++, $element];
66
-			}, $byType);
67
-
68
-			usort($workArray, function ($a, $b) use ($commenters, $type) {
69
-				$r = $this->compare($a[1], $b[1], $commenters[$type]);
70
-				if($r === 0) {
71
-					$r = $a[0] - $b[0];
72
-				}
73
-				return $r;
74
-			});
75
-
76
-			// and remove the index values again
77
-			$byType = array_column($workArray, 1);
78
-		}
79
-	}
80
-
81
-	/**
82
-	 * @param $type
83
-	 * @param $id
84
-	 * @return array
85
-	 */
86
-	protected function retrieveCommentsInformation($type, $id) {
87
-		$comments = $this->commentsManager->getForObject($type, $id);
88
-		if(count($comments) === 0) {
89
-			return [];
90
-		}
91
-
92
-		$actors = [];
93
-		foreach ($comments as $comment) {
94
-			if(!isset($actors[$comment->getActorType()])) {
95
-				$actors[$comment->getActorType()] = [];
96
-			}
97
-			if(!isset($actors[$comment->getActorType()][$comment->getActorId()])) {
98
-				$actors[$comment->getActorType()][$comment->getActorId()] = 1;
99
-			} else {
100
-				$actors[$comment->getActorType()][$comment->getActorId()]++;
101
-			}
102
-		}
103
-		return $actors;
104
-	}
105
-
106
-	protected function compare(array $a, array $b, array $commenters) {
107
-		$a = $a['value']['shareWith'];
108
-		$b = $b['value']['shareWith'];
109
-
110
-		$valueA = isset($commenters[$a]) ? $commenters[$a] : 0;
111
-		$valueB = isset($commenters[$b]) ? $commenters[$b] : 0;
112
-
113
-		return $valueB - $valueA;
114
-	}
32
+    /** @var ICommentsManager */
33
+    private $commentsManager;
34
+
35
+    public function __construct(ICommentsManager $commentsManager) {
36
+        $this->commentsManager = $commentsManager;
37
+    }
38
+
39
+    public function getId() {
40
+        return 'commenters';
41
+    }
42
+
43
+    /**
44
+     * Sorts people who commented on the given item atop (descelating) of the
45
+     * others
46
+     *
47
+     * @param array $sortArray
48
+     * @param array $context
49
+     */
50
+    public function sort(array &$sortArray, array $context) {
51
+        $commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
52
+        if(count($commenters) === 0) {
53
+            return;
54
+        }
55
+
56
+        foreach ($sortArray as $type => &$byType) {
57
+            if(!isset($commenters[$type])) {
58
+                continue;
59
+            }
60
+
61
+            // at least on PHP 5.6 usort turned out to be not stable. So we add
62
+            // the current index to the value and compare it on a draw
63
+            $i = 0;
64
+            $workArray = array_map(function($element) use (&$i) {
65
+                return [$i++, $element];
66
+            }, $byType);
67
+
68
+            usort($workArray, function ($a, $b) use ($commenters, $type) {
69
+                $r = $this->compare($a[1], $b[1], $commenters[$type]);
70
+                if($r === 0) {
71
+                    $r = $a[0] - $b[0];
72
+                }
73
+                return $r;
74
+            });
75
+
76
+            // and remove the index values again
77
+            $byType = array_column($workArray, 1);
78
+        }
79
+    }
80
+
81
+    /**
82
+     * @param $type
83
+     * @param $id
84
+     * @return array
85
+     */
86
+    protected function retrieveCommentsInformation($type, $id) {
87
+        $comments = $this->commentsManager->getForObject($type, $id);
88
+        if(count($comments) === 0) {
89
+            return [];
90
+        }
91
+
92
+        $actors = [];
93
+        foreach ($comments as $comment) {
94
+            if(!isset($actors[$comment->getActorType()])) {
95
+                $actors[$comment->getActorType()] = [];
96
+            }
97
+            if(!isset($actors[$comment->getActorType()][$comment->getActorId()])) {
98
+                $actors[$comment->getActorType()][$comment->getActorId()] = 1;
99
+            } else {
100
+                $actors[$comment->getActorType()][$comment->getActorId()]++;
101
+            }
102
+        }
103
+        return $actors;
104
+    }
105
+
106
+    protected function compare(array $a, array $b, array $commenters) {
107
+        $a = $a['value']['shareWith'];
108
+        $b = $b['value']['shareWith'];
109
+
110
+        $valueA = isset($commenters[$a]) ? $commenters[$a] : 0;
111
+        $valueB = isset($commenters[$b]) ? $commenters[$b] : 0;
112
+
113
+        return $valueB - $valueA;
114
+    }
115 115
 }
Please login to merge, or discard this patch.