@@ -28,36 +28,36 @@ |
||
28 | 28 | * @since 25.0.0 |
29 | 29 | */ |
30 | 30 | interface IReferenceProvider { |
31 | - /** |
|
32 | - * Validate that a given reference identifier matches the current provider |
|
33 | - * |
|
34 | - * @since 25.0.0 |
|
35 | - */ |
|
36 | - public function matchReference(string $referenceText): bool; |
|
31 | + /** |
|
32 | + * Validate that a given reference identifier matches the current provider |
|
33 | + * |
|
34 | + * @since 25.0.0 |
|
35 | + */ |
|
36 | + public function matchReference(string $referenceText): bool; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Return a reference with its metadata for a given reference identifier |
|
40 | - * |
|
41 | - * @since 25.0.0 |
|
42 | - */ |
|
43 | - public function resolveReference(string $referenceText): ?IReference; |
|
38 | + /** |
|
39 | + * Return a reference with its metadata for a given reference identifier |
|
40 | + * |
|
41 | + * @since 25.0.0 |
|
42 | + */ |
|
43 | + public function resolveReference(string $referenceText): ?IReference; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Return true if the reference metadata can be globally cached |
|
47 | - * |
|
48 | - * @since 25.0.0 |
|
49 | - */ |
|
50 | - public function getCachePrefix(string $referenceId): string; |
|
45 | + /** |
|
46 | + * Return true if the reference metadata can be globally cached |
|
47 | + * |
|
48 | + * @since 25.0.0 |
|
49 | + */ |
|
50 | + public function getCachePrefix(string $referenceId): string; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return a custom cache key to be used for caching the metadata |
|
54 | - * This could be for example the current user id if the reference |
|
55 | - * access permissions are different for each user |
|
56 | - * |
|
57 | - * Should return null, if the cache is only related to the |
|
58 | - * reference id and has no further dependency |
|
59 | - * |
|
60 | - * @since 25.0.0 |
|
61 | - */ |
|
62 | - public function getCacheKey(string $referenceId): ?string; |
|
52 | + /** |
|
53 | + * Return a custom cache key to be used for caching the metadata |
|
54 | + * This could be for example the current user id if the reference |
|
55 | + * access permissions are different for each user |
|
56 | + * |
|
57 | + * Should return null, if the cache is only related to the |
|
58 | + * reference id and has no further dependency |
|
59 | + * |
|
60 | + * @since 25.0.0 |
|
61 | + */ |
|
62 | + public function getCacheKey(string $referenceId): ?string; |
|
63 | 63 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | if ($_['passwordChangeSupported']) { |
26 | - \OCP\Util::addScript('settings', 'vue-settings-personal-password'); |
|
26 | + \OCP\Util::addScript('settings', 'vue-settings-personal-password'); |
|
27 | 27 | } |
28 | 28 | ?> |
29 | 29 | <div id="security-password"></div> |
@@ -28,58 +28,58 @@ |
||
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 | } |
@@ -133,9 +133,9 @@ |
||
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 |
@@ -10,129 +10,129 @@ |
||
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: float, 1: float, 2: float} [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: float, 1: float, 2: float} [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 | } |
@@ -112,9 +112,9 @@ discard block |
||
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 |
||
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 | } |
@@ -24,109 +24,109 @@ |
||
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 | } |
@@ -34,21 +34,21 @@ |
||
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 | } |
@@ -27,12 +27,12 @@ |
||
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']) : ?> |
@@ -53,11 +53,14 @@ |
||
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> |
@@ -30,9 +30,9 @@ |
||
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 | } |
@@ -29,33 +29,33 @@ |
||
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 | } |