@@ -93,6 +93,8 @@ public function getOutOfOffice(string $userId): DataResponse {
9393 'lastDay ' => $ data ->getLastDay (),
9494 'status ' => $ data ->getStatus (),
9595 'message ' => $ data ->getMessage (),
96+ 'replacementUserId ' => $ data ->getReplacementUserId (),
97+ 'replacementUserDisplayName ' => $ data ->getReplacementUserDisplayName (),
9698 ]);
9799 }
98100
@@ -103,24 +105,37 @@ public function getOutOfOffice(string $userId): DataResponse {
103105 * @param string $lastDay Last day of the absence in format `YYYY-MM-DD`
104106 * @param string $status Short text that is set as user status during the absence
105107 * @param string $message Longer multiline message that is shown to others during the absence
106- * @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>
108+ * @param string $replacementUserId User id of the replacement user
109+ * @param string $replacementUserDisplayName Display name of the replacement user
110+ * @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>
107111 *
108112 * 200: Absence data
109113 * 400: When the first day is not before the last day
110114 * 401: When the user is not logged in
115+ * 404: When the replacementUserId was provided but replacement user was not found
111116 */
112117 #[NoAdminRequired]
113118 public function setOutOfOffice (
114119 string $ firstDay ,
115120 string $ lastDay ,
116121 string $ status ,
117122 string $ message ,
123+ string $ replacementUserId = '' ,
124+ string $ replacementUserDisplayName = ''
125+
118126 ): DataResponse {
119127 $ user = $ this ->userSession ?->getUser();
120128 if ($ user === null ) {
121129 return new DataResponse (null , Http::STATUS_UNAUTHORIZED );
122130 }
123131
132+ if ($ replacementUserId !== '' ) {
133+ $ replacementUser = $ this ->userManager ->get ($ replacementUserId );
134+ if ($ replacementUser === null ) {
135+ return new DataResponse (null , Http::STATUS_NOT_FOUND );
136+ }
137+ }
138+
124139 $ parsedFirstDay = new DateTimeImmutable ($ firstDay );
125140 $ parsedLastDay = new DateTimeImmutable ($ lastDay );
126141 if ($ parsedFirstDay ->getTimestamp () > $ parsedLastDay ->getTimestamp ()) {
@@ -133,6 +148,8 @@ public function setOutOfOffice(
133148 $ lastDay ,
134149 $ status ,
135150 $ message ,
151+ $ replacementUserId ,
152+ $ replacementUserDisplayName
136153 );
137154 $ this ->coordinator ->clearCache ($ user ->getUID ());
138155
@@ -143,6 +160,8 @@ public function setOutOfOffice(
143160 'lastDay ' => $ data ->getLastDay (),
144161 'status ' => $ data ->getStatus (),
145162 'message ' => $ data ->getMessage (),
163+ 'replacementUserId ' => $ data ->getReplacementUserId (),
164+ 'replacementUserDisplayName ' => $ data ->getReplacementUserDisplayName (),
146165 ]);
147166 }
148167
0 commit comments