Completed
Push — master ( ae6394...970eb8 )
by John
31:32 queued 02:08
created
lib/private/Files/Stream/HashWrapper.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -28,58 +28,58 @@
 block discarded – undo
28 28
 use Icewind\Streams\Wrapper;
29 29
 
30 30
 class HashWrapper extends Wrapper {
31
-	protected $callback;
32
-	protected $hash;
31
+    protected $callback;
32
+    protected $hash;
33 33
 
34
-	public static function wrap($source, string $algo, callable $callback) {
35
-		$hash = hash_init($algo);
36
-		$context = stream_context_create([
37
-			'hash' => [
38
-				'source' => $source,
39
-				'callback' => $callback,
40
-				'hash' => $hash,
41
-			],
42
-		]);
43
-		return Wrapper::wrapSource($source, $context, 'hash', self::class);
44
-	}
34
+    public static function wrap($source, string $algo, callable $callback) {
35
+        $hash = hash_init($algo);
36
+        $context = stream_context_create([
37
+            'hash' => [
38
+                'source' => $source,
39
+                'callback' => $callback,
40
+                'hash' => $hash,
41
+            ],
42
+        ]);
43
+        return Wrapper::wrapSource($source, $context, 'hash', self::class);
44
+    }
45 45
 
46
-	protected function open() {
47
-		$context = $this->loadContext('hash');
46
+    protected function open() {
47
+        $context = $this->loadContext('hash');
48 48
 
49
-		$this->callback = $context['callback'];
50
-		$this->hash = $context['hash'];
51
-		return true;
52
-	}
49
+        $this->callback = $context['callback'];
50
+        $this->hash = $context['hash'];
51
+        return true;
52
+    }
53 53
 
54
-	public function dir_opendir($path, $options) {
55
-		return $this->open();
56
-	}
54
+    public function dir_opendir($path, $options) {
55
+        return $this->open();
56
+    }
57 57
 
58
-	public function stream_open($path, $mode, $options, &$opened_path) {
59
-		return $this->open();
60
-	}
58
+    public function stream_open($path, $mode, $options, &$opened_path) {
59
+        return $this->open();
60
+    }
61 61
 
62
-	public function stream_read($count) {
63
-		$result = parent::stream_read($count);
64
-		hash_update($this->hash, $result);
65
-		return $result;
66
-	}
62
+    public function stream_read($count) {
63
+        $result = parent::stream_read($count);
64
+        hash_update($this->hash, $result);
65
+        return $result;
66
+    }
67 67
 
68
-	public function stream_close() {
69
-		if (is_callable($this->callback)) {
70
-			// if the stream is closed as a result of the end-of-request GC, the hash context might be cleaned up before this stream
71
-			if ($this->hash instanceof \HashContext) {
72
-				try {
73
-					$hash = @hash_final($this->hash);
74
-					if ($hash) {
75
-						call_user_func($this->callback, $hash);
76
-					}
77
-				} catch (\Throwable $e) {
78
-				}
79
-			}
80
-			// prevent further calls by potential PHP 7 GC ghosts
81
-			$this->callback = null;
82
-		}
83
-		return parent::stream_close();
84
-	}
68
+    public function stream_close() {
69
+        if (is_callable($this->callback)) {
70
+            // if the stream is closed as a result of the end-of-request GC, the hash context might be cleaned up before this stream
71
+            if ($this->hash instanceof \HashContext) {
72
+                try {
73
+                    $hash = @hash_final($this->hash);
74
+                    if ($hash) {
75
+                        call_user_func($this->callback, $hash);
76
+                    }
77
+                } catch (\Throwable $e) {
78
+                }
79
+            }
80
+            // prevent further calls by potential PHP 7 GC ghosts
81
+            $this->callback = null;
82
+        }
83
+        return parent::stream_close();
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/public/Color.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,9 +133,9 @@
 block discarded – undo
133 133
 	 */
134 134
 	public function alphaBlending(float $opacity, Color $source): Color {
135 135
 		return new Color(
136
-			(int)((1 - $opacity) * $source->red() + $opacity * $this->red()),
137
-			(int)((1 - $opacity) * $source->green() + $opacity * $this->green()),
138
-			(int)((1 - $opacity) * $source->blue() + $opacity * $this->blue())
136
+			(int) ((1 - $opacity) * $source->red() + $opacity * $this->red()),
137
+			(int) ((1 - $opacity) * $source->green() + $opacity * $this->green()),
138
+			(int) ((1 - $opacity) * $source->blue() + $opacity * $this->blue())
139 139
 		);
140 140
 	}
141 141
 
Please login to merge, or discard this patch.
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -10,129 +10,129 @@
 block discarded – undo
10 10
  * @since 25.0.0
11 11
  */
12 12
 class Color {
13
-	private int $r;
14
-	private int $g;
15
-	private int $b;
13
+    private int $r;
14
+    private int $g;
15
+    private int $b;
16 16
 
17
-	/**
18
-	 * @since 25.0.0
19
-	 */
20
-	public function __construct($r, $g, $b) {
21
-		$this->r = $r;
22
-		$this->g = $g;
23
-		$this->b = $b;
24
-	}
17
+    /**
18
+     * @since 25.0.0
19
+     */
20
+    public function __construct($r, $g, $b) {
21
+        $this->r = $r;
22
+        $this->g = $g;
23
+        $this->b = $b;
24
+    }
25 25
 
26
-	/**
27
-	 * Returns the red color component of this color as an int from 0 to 255
28
-	 *
29
-	 * @since 25.0.0
30
-	 */
31
-	public function red(): int {
32
-		return $this->r;
33
-	}
26
+    /**
27
+     * Returns the red color component of this color as an int from 0 to 255
28
+     *
29
+     * @since 25.0.0
30
+     */
31
+    public function red(): int {
32
+        return $this->r;
33
+    }
34 34
 
35
-	/**
36
-	 * Returns the red color component of this color as a float from 0 to 1
37
-	 *
38
-	 * @since 25.0.0
39
-	 */
40
-	public function redF(): float {
41
-		return $this->r / 255;
42
-	}
35
+    /**
36
+     * Returns the red color component of this color as a float from 0 to 1
37
+     *
38
+     * @since 25.0.0
39
+     */
40
+    public function redF(): float {
41
+        return $this->r / 255;
42
+    }
43 43
 
44
-	/**
45
-	 * Returns the green color component of this color as an int from 0 to 255
46
-	 *
47
-	 * @since 25.0.0
48
-	 */
49
-	public function green(): int {
50
-		return $this->g;
51
-	}
44
+    /**
45
+     * Returns the green color component of this color as an int from 0 to 255
46
+     *
47
+     * @since 25.0.0
48
+     */
49
+    public function green(): int {
50
+        return $this->g;
51
+    }
52 52
 
53
-	/**
54
-	 * Returns the green color component of this color as a float from 0 to 1
55
-	 *
56
-	 * @since 25.0.0
57
-	 */
58
-	public function greenF(): float {
59
-		return $this->g / 255;
60
-	}
53
+    /**
54
+     * Returns the green color component of this color as a float from 0 to 1
55
+     *
56
+     * @since 25.0.0
57
+     */
58
+    public function greenF(): float {
59
+        return $this->g / 255;
60
+    }
61 61
 
62
-	/**
63
-	 * Returns the green blue component of this color as an int from 0 to 255
64
-	 *
65
-	 * @since 25.0.0
66
-	 */
67
-	public function blue(): int {
68
-		return $this->b;
69
-	}
62
+    /**
63
+     * Returns the green blue component of this color as an int from 0 to 255
64
+     *
65
+     * @since 25.0.0
66
+     */
67
+    public function blue(): int {
68
+        return $this->b;
69
+    }
70 70
 
71
-	/**
72
-	 * Returns the blue color component of this color as a float from 0 to 1
73
-	 *
74
-	 * @since 25.0.0
75
-	 */
76
-	public function blueF(): float {
77
-		return $this->g / 255;
78
-	}
71
+    /**
72
+     * Returns the blue color component of this color as a float from 0 to 1
73
+     *
74
+     * @since 25.0.0
75
+     */
76
+    public function blueF(): float {
77
+        return $this->g / 255;
78
+    }
79 79
 
80
-	/**
81
-	 * Returns the name of the color in the format "#RRGGBB"; i.e. a "#" character followed by three two-digit hexadecimal numbers.
82
-	 *
83
-	 * @since 25.0.0
84
-	 */
85
-	public function name(): string {
86
-		return sprintf('#%02x%02x%02x', $this->r, $this->g, $this->b);
87
-	}
80
+    /**
81
+     * Returns the name of the color in the format "#RRGGBB"; i.e. a "#" character followed by three two-digit hexadecimal numbers.
82
+     *
83
+     * @since 25.0.0
84
+     */
85
+    public function name(): string {
86
+        return sprintf('#%02x%02x%02x', $this->r, $this->g, $this->b);
87
+    }
88 88
 
89
-	/**
90
-	 * Mix two colors
91
-	 *
92
-	 * @param int $steps the number of intermediate colors that should be generated for the palette
93
-	 * @param Color $color1 the first color
94
-	 * @param Color $color2 the second color
95
-	 * @return list<Color>
96
-	 * @since 25.0.0
97
-	 */
98
-	public static function mixPalette(int $steps, Color $color1, Color $color2): array {
99
-		$palette = [$color1];
100
-		$step = self::stepCalc($steps, [$color1, $color2]);
101
-		for ($i = 1; $i < $steps; $i++) {
102
-			$r = intval($color1->red() + ($step[0] * $i));
103
-			$g = intval($color1->green() + ($step[1] * $i));
104
-			$b = intval($color1->blue() + ($step[2] * $i));
105
-			$palette[] = new Color($r, $g, $b);
106
-		}
107
-		return $palette;
108
-	}
89
+    /**
90
+     * Mix two colors
91
+     *
92
+     * @param int $steps the number of intermediate colors that should be generated for the palette
93
+     * @param Color $color1 the first color
94
+     * @param Color $color2 the second color
95
+     * @return list<Color>
96
+     * @since 25.0.0
97
+     */
98
+    public static function mixPalette(int $steps, Color $color1, Color $color2): array {
99
+        $palette = [$color1];
100
+        $step = self::stepCalc($steps, [$color1, $color2]);
101
+        for ($i = 1; $i < $steps; $i++) {
102
+            $r = intval($color1->red() + ($step[0] * $i));
103
+            $g = intval($color1->green() + ($step[1] * $i));
104
+            $b = intval($color1->blue() + ($step[2] * $i));
105
+            $palette[] = new Color($r, $g, $b);
106
+        }
107
+        return $palette;
108
+    }
109 109
 
110
-	/**
111
-	 * Alpha blend another color with a given opacity to this color
112
-	 *
113
-	 * @return Color The new color
114
-	 * @since 25.0.0
115
-	 */
116
-	public function alphaBlending(float $opacity, Color $source): Color {
117
-		return new Color(
118
-			(int)((1 - $opacity) * $source->red() + $opacity * $this->red()),
119
-			(int)((1 - $opacity) * $source->green() + $opacity * $this->green()),
120
-			(int)((1 - $opacity) * $source->blue() + $opacity * $this->blue())
121
-		);
122
-	}
110
+    /**
111
+     * Alpha blend another color with a given opacity to this color
112
+     *
113
+     * @return Color The new color
114
+     * @since 25.0.0
115
+     */
116
+    public function alphaBlending(float $opacity, Color $source): Color {
117
+        return new Color(
118
+            (int)((1 - $opacity) * $source->red() + $opacity * $this->red()),
119
+            (int)((1 - $opacity) * $source->green() + $opacity * $this->green()),
120
+            (int)((1 - $opacity) * $source->blue() + $opacity * $this->blue())
121
+        );
122
+    }
123 123
 
124
-	/**
125
-	 * Calculate steps between two Colors
126
-	 * @param int $steps start color
127
-	 * @param Color[] $ends end color
128
-	 * @return array{0: int, 1: int, 2: int} [r,g,b] steps for each color to go from $steps to $ends
129
-	 * @since 25.0.0
130
-	 */
131
-	private static function stepCalc(int $steps, array $ends): array {
132
-		$step = [];
133
-		$step[0] = ($ends[1]->red() - $ends[0]->red()) / $steps;
134
-		$step[1] = ($ends[1]->green() - $ends[0]->green()) / $steps;
135
-		$step[2] = ($ends[1]->blue() - $ends[0]->blue()) / $steps;
136
-		return $step;
137
-	}
124
+    /**
125
+     * Calculate steps between two Colors
126
+     * @param int $steps start color
127
+     * @param Color[] $ends end color
128
+     * @return array{0: int, 1: int, 2: int} [r,g,b] steps for each color to go from $steps to $ends
129
+     * @since 25.0.0
130
+     */
131
+    private static function stepCalc(int $steps, array $ends): array {
132
+        $step = [];
133
+        $step[0] = ($ends[1]->red() - $ends[0]->red()) / $steps;
134
+        $step[1] = ($ends[1]->green() - $ends[0]->green()) / $steps;
135
+        $step[2] = ($ends[1]->blue() - $ends[0]->blue()) / $steps;
136
+        return $step;
137
+    }
138 138
 }
Please login to merge, or discard this patch.
lib/private/Avatar/PlaceholderAvatar.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		$ext = 'png';
113 113
 
114 114
 		if ($size === -1) {
115
-			$path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $ext;
115
+			$path = 'avatar-placeholder'.($darkTheme ? '-dark' : '').'.'.$ext;
116 116
 		} else {
117
-			$path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $size . '.' . $ext;
117
+			$path = 'avatar-placeholder'.($darkTheme ? '-dark' : '').'.'.$size.'.'.$ext;
118 118
 		}
119 119
 
120 120
 		try {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 				$file = $this->folder->newFile($path);
133 133
 				$file->putContent($data);
134 134
 			} catch (NotPermittedException $e) {
135
-				$this->logger->error('Failed to save avatar placeholder for ' . $this->user->getUID());
135
+				$this->logger->error('Failed to save avatar placeholder for '.$this->user->getUID());
136 136
 				throw new NotFoundException();
137 137
 			}
138 138
 		}
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -24,109 +24,109 @@
 block discarded – undo
24 24
  * for faster retrieval, unlike the GuestAvatar.
25 25
  */
26 26
 class PlaceholderAvatar extends Avatar {
27
-	public function __construct(
28
-		private ISimpleFolder $folder,
29
-		private User $user,
30
-		LoggerInterface $logger,
31
-	) {
32
-		parent::__construct($logger);
33
-	}
34
-
35
-	/**
36
-	 * Check if an avatar exists for the user
37
-	 */
38
-	public function exists(): bool {
39
-		return true;
40
-	}
41
-
42
-	/**
43
-	 * Sets the users avatar.
44
-	 *
45
-	 * @param IImage|resource|string $data An image object, imagedata or path to set a new avatar
46
-	 * @throws \Exception if the provided file is not a jpg or png image
47
-	 * @throws \Exception if the provided image is not valid
48
-	 * @throws NotSquareException if the image is not square
49
-	 */
50
-	public function set($data): void {
51
-		// unimplemented for placeholder avatars
52
-	}
53
-
54
-	/**
55
-	 * Removes the users avatar.
56
-	 */
57
-	public function remove(bool $silent = false): void {
58
-		$avatars = $this->folder->getDirectoryListing();
59
-
60
-		foreach ($avatars as $avatar) {
61
-			$avatar->delete();
62
-		}
63
-	}
64
-
65
-	/**
66
-	 * Returns the avatar for an user.
67
-	 *
68
-	 * If there is no avatar file yet, one is generated.
69
-	 *
70
-	 * @throws NotFoundException
71
-	 * @throws \OCP\Files\NotPermittedException
72
-	 * @throws \OCP\PreConditionNotMetException
73
-	 */
74
-	public function getFile(int $size, bool $darkTheme = false): ISimpleFile {
75
-		$ext = 'png';
76
-
77
-		if ($size === -1) {
78
-			$path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $ext;
79
-		} else {
80
-			$path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $size . '.' . $ext;
81
-		}
82
-
83
-		try {
84
-			$file = $this->folder->getFile($path);
85
-		} catch (NotFoundException $e) {
86
-			if ($size <= 0) {
87
-				throw new NotFoundException;
88
-			}
89
-
90
-			if (!$data = $this->generateAvatarFromSvg($size, $darkTheme)) {
91
-				$data = $this->generateAvatar($this->getDisplayName(), $size, $darkTheme);
92
-			}
93
-
94
-			try {
95
-				$file = $this->folder->newFile($path);
96
-				$file->putContent($data);
97
-			} catch (NotPermittedException $e) {
98
-				$this->logger->error('Failed to save avatar placeholder for ' . $this->user->getUID());
99
-				throw new NotFoundException();
100
-			}
101
-		}
102
-
103
-		return $file;
104
-	}
105
-
106
-	/**
107
-	 * Returns the user display name.
108
-	 */
109
-	public function getDisplayName(): string {
110
-		return $this->user->getDisplayName();
111
-	}
112
-
113
-	/**
114
-	 * Handles user changes.
115
-	 *
116
-	 * @param string $feature The changed feature
117
-	 * @param mixed $oldValue The previous value
118
-	 * @param mixed $newValue The new value
119
-	 * @throws NotPermittedException
120
-	 * @throws \OCP\PreConditionNotMetException
121
-	 */
122
-	public function userChanged(string $feature, $oldValue, $newValue): void {
123
-		$this->remove();
124
-	}
125
-
126
-	/**
127
-	 * Check if the avatar of a user is a custom uploaded one
128
-	 */
129
-	public function isCustomAvatar(): bool {
130
-		return false;
131
-	}
27
+    public function __construct(
28
+        private ISimpleFolder $folder,
29
+        private User $user,
30
+        LoggerInterface $logger,
31
+    ) {
32
+        parent::__construct($logger);
33
+    }
34
+
35
+    /**
36
+     * Check if an avatar exists for the user
37
+     */
38
+    public function exists(): bool {
39
+        return true;
40
+    }
41
+
42
+    /**
43
+     * Sets the users avatar.
44
+     *
45
+     * @param IImage|resource|string $data An image object, imagedata or path to set a new avatar
46
+     * @throws \Exception if the provided file is not a jpg or png image
47
+     * @throws \Exception if the provided image is not valid
48
+     * @throws NotSquareException if the image is not square
49
+     */
50
+    public function set($data): void {
51
+        // unimplemented for placeholder avatars
52
+    }
53
+
54
+    /**
55
+     * Removes the users avatar.
56
+     */
57
+    public function remove(bool $silent = false): void {
58
+        $avatars = $this->folder->getDirectoryListing();
59
+
60
+        foreach ($avatars as $avatar) {
61
+            $avatar->delete();
62
+        }
63
+    }
64
+
65
+    /**
66
+     * Returns the avatar for an user.
67
+     *
68
+     * If there is no avatar file yet, one is generated.
69
+     *
70
+     * @throws NotFoundException
71
+     * @throws \OCP\Files\NotPermittedException
72
+     * @throws \OCP\PreConditionNotMetException
73
+     */
74
+    public function getFile(int $size, bool $darkTheme = false): ISimpleFile {
75
+        $ext = 'png';
76
+
77
+        if ($size === -1) {
78
+            $path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $ext;
79
+        } else {
80
+            $path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $size . '.' . $ext;
81
+        }
82
+
83
+        try {
84
+            $file = $this->folder->getFile($path);
85
+        } catch (NotFoundException $e) {
86
+            if ($size <= 0) {
87
+                throw new NotFoundException;
88
+            }
89
+
90
+            if (!$data = $this->generateAvatarFromSvg($size, $darkTheme)) {
91
+                $data = $this->generateAvatar($this->getDisplayName(), $size, $darkTheme);
92
+            }
93
+
94
+            try {
95
+                $file = $this->folder->newFile($path);
96
+                $file->putContent($data);
97
+            } catch (NotPermittedException $e) {
98
+                $this->logger->error('Failed to save avatar placeholder for ' . $this->user->getUID());
99
+                throw new NotFoundException();
100
+            }
101
+        }
102
+
103
+        return $file;
104
+    }
105
+
106
+    /**
107
+     * Returns the user display name.
108
+     */
109
+    public function getDisplayName(): string {
110
+        return $this->user->getDisplayName();
111
+    }
112
+
113
+    /**
114
+     * Handles user changes.
115
+     *
116
+     * @param string $feature The changed feature
117
+     * @param mixed $oldValue The previous value
118
+     * @param mixed $newValue The new value
119
+     * @throws NotPermittedException
120
+     * @throws \OCP\PreConditionNotMetException
121
+     */
122
+    public function userChanged(string $feature, $oldValue, $newValue): void {
123
+        $this->remove();
124
+    }
125
+
126
+    /**
127
+     * Check if the avatar of a user is a custom uploaded one
128
+     */
129
+    public function isCustomAvatar(): bool {
130
+        return false;
131
+    }
132 132
 }
Please login to merge, or discard this patch.
lib/public/Profile/BeforeTemplateRenderedEvent.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@
 block discarded – undo
34 34
  * @since 25.0.0
35 35
  */
36 36
 class BeforeTemplateRenderedEvent extends Event {
37
-	private string $userId;
37
+    private string $userId;
38 38
 
39
-	/**
40
-	 * @since 25.0.0
41
-	 */
42
-	public function __construct(string $userId) {
43
-		parent::__construct();
39
+    /**
40
+     * @since 25.0.0
41
+     */
42
+    public function __construct(string $userId) {
43
+        parent::__construct();
44 44
 
45
-		$this->userId = $userId;
46
-	}
45
+        $this->userId = $userId;
46
+    }
47 47
 
48
-	/**
49
-	 * @since 25.0.0
50
-	 */
51
-	public function getUserId(): string {
52
-		return $this->userId;
53
-	}
48
+    /**
49
+     * @since 25.0.0
50
+     */
51
+    public function getUserId(): string {
52
+        return $this->userId;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/settings/templates/settings/personal/personal.info.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
 /** @var array $_ */
28 28
 
29 29
 script('settings', [
30
-	'usersettings',
31
-	'templates',
32
-	'federationsettingsview',
33
-	'federationscopemenu',
34
-	'settings/personalInfo',
35
-	'vue-settings-personal-info',
30
+    'usersettings',
31
+    'templates',
32
+    'federationsettingsview',
33
+    'federationscopemenu',
34
+    'settings/personalInfo',
35
+    'vue-settings-personal-info',
36 36
 ]);
37 37
 ?>
38 38
 <?php if (!$_['isFairUseOfFreePushService']) : ?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,11 +53,14 @@
 block discarded – undo
53 53
 		<div class="personal-settings-setting-box personal-settings-setting-box-detail">
54 54
 			<div id="vue-details-section"></div>
55 55
 		</div>
56
-	<?php else: ?>
56
+	<?php else {
57
+    : ?>
57 58
 		<div class="personal-settings-setting-box personal-settings-setting-box-detail--without-profile">
58 59
 			<div id="vue-details-section"></div>
59 60
 		</div>
60
-	<?php endif; ?>
61
+	<?php endif;
62
+}
63
+?>
61 64
 	<div class="personal-settings-setting-box">
62 65
 		<div id="vue-displayname-section"></div>
63 66
 	</div>
Please login to merge, or discard this patch.
lib/public/Dashboard/IOptionWidget.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
  * @since 25.0.0
31 31
  */
32 32
 interface IOptionWidget extends IWidget {
33
-	/**
34
-	 * Get additional options for the widget
35
-	 * @since 25.0.0
36
-	 */
37
-	public function getWidgetOptions(): WidgetOptions;
33
+    /**
34
+     * Get additional options for the widget
35
+     * @since 25.0.0
36
+     */
37
+    public function getWidgetOptions(): WidgetOptions;
38 38
 }
Please login to merge, or discard this patch.
lib/public/Dashboard/Model/WidgetOptions.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,33 +29,33 @@
 block discarded – undo
29 29
  * @since 25.0.0
30 30
  */
31 31
 class WidgetOptions {
32
-	private bool $roundItemIcons;
32
+    private bool $roundItemIcons;
33 33
 
34
-	/**
35
-	 * @param bool $roundItemIcons
36
-	 * @since 25.0.0
37
-	 */
38
-	public function __construct(bool $roundItemIcons) {
39
-		$this->roundItemIcons = $roundItemIcons;
40
-	}
34
+    /**
35
+     * @param bool $roundItemIcons
36
+     * @since 25.0.0
37
+     */
38
+    public function __construct(bool $roundItemIcons) {
39
+        $this->roundItemIcons = $roundItemIcons;
40
+    }
41 41
 
42
-	/**
43
-	 * Get the default set of options
44
-	 *
45
-	 * @return WidgetOptions
46
-	 * @since 25.0.0
47
-	 */
48
-	public static function getDefault(): WidgetOptions {
49
-		return new WidgetOptions(false);
50
-	}
42
+    /**
43
+     * Get the default set of options
44
+     *
45
+     * @return WidgetOptions
46
+     * @since 25.0.0
47
+     */
48
+    public static function getDefault(): WidgetOptions {
49
+        return new WidgetOptions(false);
50
+    }
51 51
 
52
-	/**
53
-	 * Whether the clients should render icons for widget items as round icons
54
-	 *
55
-	 * @return bool
56
-	 * @since 25.0.0
57
-	 */
58
-	public function withRoundItemIcons(): bool {
59
-		return $this->roundItemIcons;
60
-	}
52
+    /**
53
+     * Whether the clients should render icons for widget items as round icons
54
+     *
55
+     * @return bool
56
+     * @since 25.0.0
57
+     */
58
+    public function withRoundItemIcons(): bool {
59
+        return $this->roundItemIcons;
60
+    }
61 61
 }
Please login to merge, or discard this patch.
apps/settings/lib/Settings/Personal/PersonalInfo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	private function getGroups(IUser $user): array {
236 236
 		$groups = array_map(
237
-			static function (IGroup $group) {
237
+			static function(IGroup $group) {
238 238
 				return $group->getDisplayName();
239 239
 			},
240 240
 			$this->groupManager->getUserGroups($user)
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		];
258 258
 
259 259
 		$additionalEmails = array_map(
260
-			function (IAccountProperty $property) {
260
+			function(IAccountProperty $property) {
261 261
 				return [
262 262
 					'name' => $property->getName(),
263 263
 					'value' => $property->getValue(),
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		$emailMap = [
273 273
 			'primaryEmail' => $systemEmail,
274 274
 			'additionalEmails' => $additionalEmails,
275
-			'notificationEmail' => (string)$account->getUser()->getPrimaryEMailAddress(),
275
+			'notificationEmail' => (string) $account->getUser()->getPrimaryEMailAddress(),
276 276
 		];
277 277
 
278 278
 		return $emailMap;
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 				default:
367 367
 					$message = $this->l->t('Verify');
368 368
 			}
369
-			$messageParameters[$property . 'Message'] = $message;
369
+			$messageParameters[$property.'Message'] = $message;
370 370
 		}
371 371
 		return $messageParameters;
372 372
 	}
Please login to merge, or discard this patch.
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -33,287 +33,287 @@
 block discarded – undo
33 33
 
34 34
 class PersonalInfo implements ISettings {
35 35
 
36
-	/** @var ProfileManager */
37
-	private $profileManager;
38
-
39
-	public function __construct(
40
-		private IConfig $config,
41
-		private IUserManager $userManager,
42
-		private IGroupManager $groupManager,
43
-		private IAccountManager $accountManager,
44
-		ProfileManager $profileManager,
45
-		private IAppManager $appManager,
46
-		private IFactory $l10nFactory,
47
-		private IL10N $l,
48
-		private IInitialState $initialStateService,
49
-		private IManager $manager,
50
-	) {
51
-		$this->profileManager = $profileManager;
52
-	}
53
-
54
-	public function getForm(): TemplateResponse {
55
-		$federationEnabled = $this->appManager->isEnabledForUser('federation');
56
-		$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
57
-		$lookupServerUploadEnabled = false;
58
-		if ($federatedFileSharingEnabled) {
59
-			/** @var FederatedShareProvider $shareProvider */
60
-			$shareProvider = Server::get(FederatedShareProvider::class);
61
-			$lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
62
-		}
63
-
64
-		$uid = \OC_User::getUser();
65
-		$user = $this->userManager->get($uid);
66
-		$account = $this->accountManager->getAccount($user);
67
-
68
-		// make sure FS is setup before querying storage related stuff...
69
-		\OC_Util::setupFS($user->getUID());
70
-
71
-		$storageInfo = \OC_Helper::getStorageInfo('/');
72
-		if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
73
-			$totalSpace = $this->l->t('Unlimited');
74
-		} else {
75
-			$totalSpace = Util::humanFileSize($storageInfo['total']);
76
-		}
77
-
78
-		$messageParameters = $this->getMessageParameters($account);
79
-
80
-		$parameters = [
81
-			'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
82
-			'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
83
-			'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
84
-		] + $messageParameters;
85
-
86
-		$personalInfoParameters = [
87
-			'userId' => $uid,
88
-			'avatar' => $this->getProperty($account, IAccountManager::PROPERTY_AVATAR),
89
-			'groups' => $this->getGroups($user),
90
-			'quota' => $storageInfo['quota'],
91
-			'totalSpace' => $totalSpace,
92
-			'usage' => Util::humanFileSize($storageInfo['used']),
93
-			'usageRelative' => round($storageInfo['relative']),
94
-			'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
95
-			'emailMap' => $this->getEmailMap($account),
96
-			'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
97
-			'defaultPhoneRegion' => $this->config->getSystemValueString('default_phone_region'),
98
-			'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
99
-			'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
100
-			'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
101
-			'fediverse' => $this->getProperty($account, IAccountManager::PROPERTY_FEDIVERSE),
102
-			'languageMap' => $this->getLanguageMap($user),
103
-			'localeMap' => $this->getLocaleMap($user),
104
-			'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
105
-			'profileEnabled' => $this->profileManager->isProfileEnabled($user),
106
-			'organisation' => $this->getProperty($account, IAccountManager::PROPERTY_ORGANISATION),
107
-			'role' => $this->getProperty($account, IAccountManager::PROPERTY_ROLE),
108
-			'headline' => $this->getProperty($account, IAccountManager::PROPERTY_HEADLINE),
109
-			'biography' => $this->getProperty($account, IAccountManager::PROPERTY_BIOGRAPHY),
110
-			'birthdate' => $this->getProperty($account, IAccountManager::PROPERTY_BIRTHDATE),
111
-			'firstDayOfWeek' => $this->config->getUserValue($uid, 'core', AUserDataOCSController::USER_FIELD_FIRST_DAY_OF_WEEK),
112
-			'pronouns' => $this->getProperty($account, IAccountManager::PROPERTY_PRONOUNS),
113
-		];
114
-
115
-		$accountParameters = [
116
-			'avatarChangeSupported' => $user->canChangeAvatar(),
117
-			'displayNameChangeSupported' => $user->canChangeDisplayName(),
118
-			'emailChangeSupported' => $user->canChangeEmail(),
119
-			'federationEnabled' => $federationEnabled,
120
-			'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
121
-		];
122
-
123
-		$profileParameters = [
124
-			'profileConfig' => $this->profileManager->getProfileConfigWithMetadata($user, $user),
125
-		];
126
-
127
-		$this->initialStateService->provideInitialState('profileEnabledGlobally', $this->profileManager->isProfileEnabled());
128
-		$this->initialStateService->provideInitialState('personalInfoParameters', $personalInfoParameters);
129
-		$this->initialStateService->provideInitialState('accountParameters', $accountParameters);
130
-		$this->initialStateService->provideInitialState('profileParameters', $profileParameters);
131
-
132
-		return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
133
-	}
134
-
135
-	/**
136
-	 * Check if is fair use of free push service
137
-	 * @return boolean
138
-	 */
139
-	private function isFairUseOfFreePushService(): bool {
140
-		return $this->manager->isFairUseOfFreePushService();
141
-	}
142
-
143
-	/**
144
-	 * returns the property data in an
145
-	 * associative array
146
-	 */
147
-	private function getProperty(IAccount $account, string $property): array {
148
-		$property = [
149
-			'name' => $account->getProperty($property)->getName(),
150
-			'value' => $account->getProperty($property)->getValue(),
151
-			'scope' => $account->getProperty($property)->getScope(),
152
-			'verified' => $account->getProperty($property)->getVerified(),
153
-		];
154
-
155
-		return $property;
156
-	}
157
-
158
-	/**
159
-	 * returns the section ID string, e.g. 'sharing'
160
-	 * @since 9.1
161
-	 */
162
-	public function getSection(): string {
163
-		return 'personal-info';
164
-	}
165
-
166
-	/**
167
-	 * @return int whether the form should be rather on the top or bottom of
168
-	 *             the admin section. The forms are arranged in ascending order of the
169
-	 *             priority values. It is required to return a value between 0 and 100.
170
-	 *
171
-	 * E.g.: 70
172
-	 * @since 9.1
173
-	 */
174
-	public function getPriority(): int {
175
-		return 10;
176
-	}
177
-
178
-	/**
179
-	 * returns a sorted list of the user's group GIDs
180
-	 */
181
-	private function getGroups(IUser $user): array {
182
-		$groups = array_map(
183
-			static function (IGroup $group) {
184
-				return $group->getDisplayName();
185
-			},
186
-			$this->groupManager->getUserGroups($user)
187
-		);
188
-		sort($groups);
189
-
190
-		return $groups;
191
-	}
192
-
193
-	/**
194
-	 * returns the primary email and additional emails in an
195
-	 * associative array
196
-	 */
197
-	private function getEmailMap(IAccount $account): array {
198
-		$systemEmail = [
199
-			'name' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getName(),
200
-			'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(),
201
-			'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(),
202
-			'verified' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(),
203
-		];
204
-
205
-		$additionalEmails = array_map(
206
-			function (IAccountProperty $property) {
207
-				return [
208
-					'name' => $property->getName(),
209
-					'value' => $property->getValue(),
210
-					'scope' => $property->getScope(),
211
-					'verified' => $property->getVerified(),
212
-					'locallyVerified' => $property->getLocallyVerified(),
213
-				];
214
-			},
215
-			$account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties(),
216
-		);
217
-
218
-		$emailMap = [
219
-			'primaryEmail' => $systemEmail,
220
-			'additionalEmails' => $additionalEmails,
221
-			'notificationEmail' => (string)$account->getUser()->getPrimaryEMailAddress(),
222
-		];
223
-
224
-		return $emailMap;
225
-	}
226
-
227
-	/**
228
-	 * returns the user's active language, common languages, and other languages in an
229
-	 * associative array
230
-	 */
231
-	private function getLanguageMap(IUser $user): array {
232
-		$forceLanguage = $this->config->getSystemValue('force_language', false);
233
-		if ($forceLanguage !== false) {
234
-			return [];
235
-		}
236
-
237
-		$uid = $user->getUID();
238
-
239
-		$userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
240
-		$languages = $this->l10nFactory->getLanguages();
241
-
242
-		// associate the user language with the proper array
243
-		$userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
244
-		$userLang = $languages['commonLanguages'][$userLangIndex];
245
-		// search in the other languages
246
-		if ($userLangIndex === false) {
247
-			$userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
248
-			$userLang = $languages['otherLanguages'][$userLangIndex];
249
-		}
250
-		// if user language is not available but set somehow: show the actual code as name
251
-		if (!is_array($userLang)) {
252
-			$userLang = [
253
-				'code' => $userConfLang,
254
-				'name' => $userConfLang,
255
-			];
256
-		}
257
-
258
-		return array_merge(
259
-			['activeLanguage' => $userLang],
260
-			$languages
261
-		);
262
-	}
263
-
264
-	private function getLocaleMap(IUser $user): array {
265
-		$forceLanguage = $this->config->getSystemValue('force_locale', false);
266
-		if ($forceLanguage !== false) {
267
-			return [];
268
-		}
269
-
270
-		$uid = $user->getUID();
271
-		$userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
272
-		$userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale($userLang));
273
-		$localeCodes = $this->l10nFactory->findAvailableLocales();
274
-		$userLocale = array_filter($localeCodes, fn ($value) => $userLocaleString === $value['code']);
275
-
276
-		if (!empty($userLocale)) {
277
-			$userLocale = reset($userLocale);
278
-		}
279
-
280
-		$localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => str_starts_with($localeCode['code'], $userLang)));
281
-		$otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => !str_starts_with($localeCode['code'], $userLang)));
282
-
283
-		if (!$userLocale) {
284
-			$userLocale = [
285
-				'code' => 'en',
286
-				'name' => 'English'
287
-			];
288
-		}
289
-
290
-		return [
291
-			'activeLocaleLang' => $userLocaleString,
292
-			'activeLocale' => $userLocale,
293
-			'localesForLanguage' => $localesForLanguage,
294
-			'otherLocales' => $otherLocales,
295
-		];
296
-	}
297
-
298
-	/**
299
-	 * returns the message parameters
300
-	 */
301
-	private function getMessageParameters(IAccount $account): array {
302
-		$needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER];
303
-		$messageParameters = [];
304
-		foreach ($needVerifyMessage as $property) {
305
-			switch ($account->getProperty($property)->getVerified()) {
306
-				case IAccountManager::VERIFIED:
307
-					$message = $this->l->t('Verifying');
308
-					break;
309
-				case IAccountManager::VERIFICATION_IN_PROGRESS:
310
-					$message = $this->l->t('Verifying …');
311
-					break;
312
-				default:
313
-					$message = $this->l->t('Verify');
314
-			}
315
-			$messageParameters[$property . 'Message'] = $message;
316
-		}
317
-		return $messageParameters;
318
-	}
36
+    /** @var ProfileManager */
37
+    private $profileManager;
38
+
39
+    public function __construct(
40
+        private IConfig $config,
41
+        private IUserManager $userManager,
42
+        private IGroupManager $groupManager,
43
+        private IAccountManager $accountManager,
44
+        ProfileManager $profileManager,
45
+        private IAppManager $appManager,
46
+        private IFactory $l10nFactory,
47
+        private IL10N $l,
48
+        private IInitialState $initialStateService,
49
+        private IManager $manager,
50
+    ) {
51
+        $this->profileManager = $profileManager;
52
+    }
53
+
54
+    public function getForm(): TemplateResponse {
55
+        $federationEnabled = $this->appManager->isEnabledForUser('federation');
56
+        $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
57
+        $lookupServerUploadEnabled = false;
58
+        if ($federatedFileSharingEnabled) {
59
+            /** @var FederatedShareProvider $shareProvider */
60
+            $shareProvider = Server::get(FederatedShareProvider::class);
61
+            $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
62
+        }
63
+
64
+        $uid = \OC_User::getUser();
65
+        $user = $this->userManager->get($uid);
66
+        $account = $this->accountManager->getAccount($user);
67
+
68
+        // make sure FS is setup before querying storage related stuff...
69
+        \OC_Util::setupFS($user->getUID());
70
+
71
+        $storageInfo = \OC_Helper::getStorageInfo('/');
72
+        if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
73
+            $totalSpace = $this->l->t('Unlimited');
74
+        } else {
75
+            $totalSpace = Util::humanFileSize($storageInfo['total']);
76
+        }
77
+
78
+        $messageParameters = $this->getMessageParameters($account);
79
+
80
+        $parameters = [
81
+            'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
82
+            'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
83
+            'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
84
+        ] + $messageParameters;
85
+
86
+        $personalInfoParameters = [
87
+            'userId' => $uid,
88
+            'avatar' => $this->getProperty($account, IAccountManager::PROPERTY_AVATAR),
89
+            'groups' => $this->getGroups($user),
90
+            'quota' => $storageInfo['quota'],
91
+            'totalSpace' => $totalSpace,
92
+            'usage' => Util::humanFileSize($storageInfo['used']),
93
+            'usageRelative' => round($storageInfo['relative']),
94
+            'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
95
+            'emailMap' => $this->getEmailMap($account),
96
+            'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
97
+            'defaultPhoneRegion' => $this->config->getSystemValueString('default_phone_region'),
98
+            'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
99
+            'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
100
+            'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
101
+            'fediverse' => $this->getProperty($account, IAccountManager::PROPERTY_FEDIVERSE),
102
+            'languageMap' => $this->getLanguageMap($user),
103
+            'localeMap' => $this->getLocaleMap($user),
104
+            'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
105
+            'profileEnabled' => $this->profileManager->isProfileEnabled($user),
106
+            'organisation' => $this->getProperty($account, IAccountManager::PROPERTY_ORGANISATION),
107
+            'role' => $this->getProperty($account, IAccountManager::PROPERTY_ROLE),
108
+            'headline' => $this->getProperty($account, IAccountManager::PROPERTY_HEADLINE),
109
+            'biography' => $this->getProperty($account, IAccountManager::PROPERTY_BIOGRAPHY),
110
+            'birthdate' => $this->getProperty($account, IAccountManager::PROPERTY_BIRTHDATE),
111
+            'firstDayOfWeek' => $this->config->getUserValue($uid, 'core', AUserDataOCSController::USER_FIELD_FIRST_DAY_OF_WEEK),
112
+            'pronouns' => $this->getProperty($account, IAccountManager::PROPERTY_PRONOUNS),
113
+        ];
114
+
115
+        $accountParameters = [
116
+            'avatarChangeSupported' => $user->canChangeAvatar(),
117
+            'displayNameChangeSupported' => $user->canChangeDisplayName(),
118
+            'emailChangeSupported' => $user->canChangeEmail(),
119
+            'federationEnabled' => $federationEnabled,
120
+            'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
121
+        ];
122
+
123
+        $profileParameters = [
124
+            'profileConfig' => $this->profileManager->getProfileConfigWithMetadata($user, $user),
125
+        ];
126
+
127
+        $this->initialStateService->provideInitialState('profileEnabledGlobally', $this->profileManager->isProfileEnabled());
128
+        $this->initialStateService->provideInitialState('personalInfoParameters', $personalInfoParameters);
129
+        $this->initialStateService->provideInitialState('accountParameters', $accountParameters);
130
+        $this->initialStateService->provideInitialState('profileParameters', $profileParameters);
131
+
132
+        return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
133
+    }
134
+
135
+    /**
136
+     * Check if is fair use of free push service
137
+     * @return boolean
138
+     */
139
+    private function isFairUseOfFreePushService(): bool {
140
+        return $this->manager->isFairUseOfFreePushService();
141
+    }
142
+
143
+    /**
144
+     * returns the property data in an
145
+     * associative array
146
+     */
147
+    private function getProperty(IAccount $account, string $property): array {
148
+        $property = [
149
+            'name' => $account->getProperty($property)->getName(),
150
+            'value' => $account->getProperty($property)->getValue(),
151
+            'scope' => $account->getProperty($property)->getScope(),
152
+            'verified' => $account->getProperty($property)->getVerified(),
153
+        ];
154
+
155
+        return $property;
156
+    }
157
+
158
+    /**
159
+     * returns the section ID string, e.g. 'sharing'
160
+     * @since 9.1
161
+     */
162
+    public function getSection(): string {
163
+        return 'personal-info';
164
+    }
165
+
166
+    /**
167
+     * @return int whether the form should be rather on the top or bottom of
168
+     *             the admin section. The forms are arranged in ascending order of the
169
+     *             priority values. It is required to return a value between 0 and 100.
170
+     *
171
+     * E.g.: 70
172
+     * @since 9.1
173
+     */
174
+    public function getPriority(): int {
175
+        return 10;
176
+    }
177
+
178
+    /**
179
+     * returns a sorted list of the user's group GIDs
180
+     */
181
+    private function getGroups(IUser $user): array {
182
+        $groups = array_map(
183
+            static function (IGroup $group) {
184
+                return $group->getDisplayName();
185
+            },
186
+            $this->groupManager->getUserGroups($user)
187
+        );
188
+        sort($groups);
189
+
190
+        return $groups;
191
+    }
192
+
193
+    /**
194
+     * returns the primary email and additional emails in an
195
+     * associative array
196
+     */
197
+    private function getEmailMap(IAccount $account): array {
198
+        $systemEmail = [
199
+            'name' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getName(),
200
+            'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(),
201
+            'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(),
202
+            'verified' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(),
203
+        ];
204
+
205
+        $additionalEmails = array_map(
206
+            function (IAccountProperty $property) {
207
+                return [
208
+                    'name' => $property->getName(),
209
+                    'value' => $property->getValue(),
210
+                    'scope' => $property->getScope(),
211
+                    'verified' => $property->getVerified(),
212
+                    'locallyVerified' => $property->getLocallyVerified(),
213
+                ];
214
+            },
215
+            $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties(),
216
+        );
217
+
218
+        $emailMap = [
219
+            'primaryEmail' => $systemEmail,
220
+            'additionalEmails' => $additionalEmails,
221
+            'notificationEmail' => (string)$account->getUser()->getPrimaryEMailAddress(),
222
+        ];
223
+
224
+        return $emailMap;
225
+    }
226
+
227
+    /**
228
+     * returns the user's active language, common languages, and other languages in an
229
+     * associative array
230
+     */
231
+    private function getLanguageMap(IUser $user): array {
232
+        $forceLanguage = $this->config->getSystemValue('force_language', false);
233
+        if ($forceLanguage !== false) {
234
+            return [];
235
+        }
236
+
237
+        $uid = $user->getUID();
238
+
239
+        $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
240
+        $languages = $this->l10nFactory->getLanguages();
241
+
242
+        // associate the user language with the proper array
243
+        $userLangIndex = array_search($userConfLang, array_column($languages['commonLanguages'], 'code'));
244
+        $userLang = $languages['commonLanguages'][$userLangIndex];
245
+        // search in the other languages
246
+        if ($userLangIndex === false) {
247
+            $userLangIndex = array_search($userConfLang, array_column($languages['otherLanguages'], 'code'));
248
+            $userLang = $languages['otherLanguages'][$userLangIndex];
249
+        }
250
+        // if user language is not available but set somehow: show the actual code as name
251
+        if (!is_array($userLang)) {
252
+            $userLang = [
253
+                'code' => $userConfLang,
254
+                'name' => $userConfLang,
255
+            ];
256
+        }
257
+
258
+        return array_merge(
259
+            ['activeLanguage' => $userLang],
260
+            $languages
261
+        );
262
+    }
263
+
264
+    private function getLocaleMap(IUser $user): array {
265
+        $forceLanguage = $this->config->getSystemValue('force_locale', false);
266
+        if ($forceLanguage !== false) {
267
+            return [];
268
+        }
269
+
270
+        $uid = $user->getUID();
271
+        $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
272
+        $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale($userLang));
273
+        $localeCodes = $this->l10nFactory->findAvailableLocales();
274
+        $userLocale = array_filter($localeCodes, fn ($value) => $userLocaleString === $value['code']);
275
+
276
+        if (!empty($userLocale)) {
277
+            $userLocale = reset($userLocale);
278
+        }
279
+
280
+        $localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => str_starts_with($localeCode['code'], $userLang)));
281
+        $otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => !str_starts_with($localeCode['code'], $userLang)));
282
+
283
+        if (!$userLocale) {
284
+            $userLocale = [
285
+                'code' => 'en',
286
+                'name' => 'English'
287
+            ];
288
+        }
289
+
290
+        return [
291
+            'activeLocaleLang' => $userLocaleString,
292
+            'activeLocale' => $userLocale,
293
+            'localesForLanguage' => $localesForLanguage,
294
+            'otherLocales' => $otherLocales,
295
+        ];
296
+    }
297
+
298
+    /**
299
+     * returns the message parameters
300
+     */
301
+    private function getMessageParameters(IAccount $account): array {
302
+        $needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER];
303
+        $messageParameters = [];
304
+        foreach ($needVerifyMessage as $property) {
305
+            switch ($account->getProperty($property)->getVerified()) {
306
+                case IAccountManager::VERIFIED:
307
+                    $message = $this->l->t('Verifying');
308
+                    break;
309
+                case IAccountManager::VERIFICATION_IN_PROGRESS:
310
+                    $message = $this->l->t('Verifying …');
311
+                    break;
312
+                default:
313
+                    $message = $this->l->t('Verify');
314
+            }
315
+            $messageParameters[$property . 'Message'] = $message;
316
+        }
317
+        return $messageParameters;
318
+    }
319 319
 }
Please login to merge, or discard this patch.
lib/private/User/Listeners/BeforeUserDeletedListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 			// no avatar to remove
58 58
 		} catch (\Exception $e) {
59 59
 			// Ignore exceptions
60
-			$this->logger->info('Could not cleanup avatar of ' . $user->getUID(), [
60
+			$this->logger->info('Could not cleanup avatar of '.$user->getUID(), [
61 61
 				'exception' => $e,
62 62
 			]);
63 63
 		}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -20,36 +20,36 @@
 block discarded – undo
20 20
  * @template-implements IEventListener<BeforeUserDeletedEvent>
21 21
  */
22 22
 class BeforeUserDeletedListener implements IEventListener {
23
-	private IAvatarManager $avatarManager;
24
-	private ICredentialsManager $credentialsManager;
25
-	private LoggerInterface $logger;
26
-
27
-	public function __construct(LoggerInterface $logger, IAvatarManager $avatarManager, ICredentialsManager $credentialsManager) {
28
-		$this->avatarManager = $avatarManager;
29
-		$this->credentialsManager = $credentialsManager;
30
-		$this->logger = $logger;
31
-	}
32
-
33
-	public function handle(Event $event): void {
34
-		if (!($event instanceof BeforeUserDeletedEvent)) {
35
-			return;
36
-		}
37
-
38
-		$user = $event->getUser();
39
-
40
-		// Delete avatar on user deletion
41
-		try {
42
-			$avatar = $this->avatarManager->getAvatar($user->getUID());
43
-			$avatar->remove(true);
44
-		} catch (NotFoundException $e) {
45
-			// no avatar to remove
46
-		} catch (\Exception $e) {
47
-			// Ignore exceptions
48
-			$this->logger->info('Could not cleanup avatar of ' . $user->getUID(), [
49
-				'exception' => $e,
50
-			]);
51
-		}
52
-		// Delete storages credentials on user deletion
53
-		$this->credentialsManager->erase($user->getUID());
54
-	}
23
+    private IAvatarManager $avatarManager;
24
+    private ICredentialsManager $credentialsManager;
25
+    private LoggerInterface $logger;
26
+
27
+    public function __construct(LoggerInterface $logger, IAvatarManager $avatarManager, ICredentialsManager $credentialsManager) {
28
+        $this->avatarManager = $avatarManager;
29
+        $this->credentialsManager = $credentialsManager;
30
+        $this->logger = $logger;
31
+    }
32
+
33
+    public function handle(Event $event): void {
34
+        if (!($event instanceof BeforeUserDeletedEvent)) {
35
+            return;
36
+        }
37
+
38
+        $user = $event->getUser();
39
+
40
+        // Delete avatar on user deletion
41
+        try {
42
+            $avatar = $this->avatarManager->getAvatar($user->getUID());
43
+            $avatar->remove(true);
44
+        } catch (NotFoundException $e) {
45
+            // no avatar to remove
46
+        } catch (\Exception $e) {
47
+            // Ignore exceptions
48
+            $this->logger->info('Could not cleanup avatar of ' . $user->getUID(), [
49
+                'exception' => $e,
50
+            ]);
51
+        }
52
+        // Delete storages credentials on user deletion
53
+        $this->credentialsManager->erase($user->getUID());
54
+    }
55 55
 }
Please login to merge, or discard this patch.