aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-06-02 15:38:19 +0330
committerSimon L <szaimen@e.mail.de>2023-06-12 09:46:07 +0200
commit0bae21b1d1709e136a580b4ef2dc3cc725ca27b8 (patch)
treed86d68c9c2a7f70260863d62d7cd9c6af270e7ca /apps/dav/lib/CalDAV
parentc93be182dc0172eed377ba70ce54cd7c83689764 (diff)
downloadnextcloud-server-0bae21b1d1709e136a580b4ef2dc3cc725ca27b8.tar.gz
nextcloud-server-0bae21b1d1709e136a580b4ef2dc3cc725ca27b8.zip
Refactors "strpos" calls in /apps/dav to improve code readability.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'apps/dav/lib/CalDAV')
-rw-r--r--apps/dav/lib/CalDAV/Activity/Backend.php6
-rw-r--r--apps/dav/lib/CalDAV/Integration/ExternalCalendar.php4
-rw-r--r--apps/dav/lib/CalDAV/Publishing/PublishPlugin.php2
-rw-r--r--apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php8
-rw-r--r--apps/dav/lib/CalDAV/Schedule/Plugin.php6
5 files changed, 13 insertions, 13 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php
index 781a456b5b3..661a3dcc9ae 100644
--- a/apps/dav/lib/CalDAV/Activity/Backend.php
+++ b/apps/dav/lib/CalDAV/Activity/Backend.php
@@ -455,9 +455,9 @@ class Backend {
$action = $action . '_' . $object['type'];
- if ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'COMPLETED') {
+ if ($object['type'] === 'todo' && str_starts_with($action, Event::SUBJECT_OBJECT_UPDATE) && $object['status'] === 'COMPLETED') {
$action .= '_completed';
- } elseif ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'NEEDS-ACTION') {
+ } elseif ($object['type'] === 'todo' && str_starts_with($action, Event::SUBJECT_OBJECT_UPDATE) && $object['status'] === 'NEEDS-ACTION') {
$action .= '_needs_action';
}
@@ -491,7 +491,7 @@ class Backend {
],
];
- if ($object['type'] === 'event' && strpos($action, Event::SUBJECT_OBJECT_DELETE) === false && $this->appManager->isEnabledForUser('calendar')) {
+ if ($object['type'] === 'event' && !str_contains($action, Event::SUBJECT_OBJECT_DELETE) && $this->appManager->isEnabledForUser('calendar')) {
$params['object']['link']['object_uri'] = $objectData['uri'];
$params['object']['link']['calendar_uri'] = $calendarData['uri'];
$params['object']['link']['owner'] = $owner;
diff --git a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php
index 9c801a08a26..0afb11c2673 100644
--- a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php
+++ b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php
@@ -98,7 +98,7 @@ abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties {
* @return bool
*/
public static function isAppGeneratedCalendar(string $calendarUri):bool {
- return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
+ return str_starts_with($calendarUri, self::PREFIX) && substr_count($calendarUri, self::DELIMITER) >= 2;
}
/**
@@ -126,6 +126,6 @@ abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties {
* @return bool
*/
public static function doesViolateReservedName(string $calendarUri):bool {
- return strpos($calendarUri, self::PREFIX) === 0;
+ return str_starts_with($calendarUri, self::PREFIX);
}
}
diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
index aabf78da1aa..35a3478046b 100644
--- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
+++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
@@ -156,7 +156,7 @@ class PublishPlugin extends ServerPlugin {
// Only handling xml
$contentType = $request->getHeader('Content-Type');
- if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
+ if (!str_contains($contentType, 'application/xml') && !str_contains($contentType, 'text/xml')) {
return;
}
diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php
index d2ad4cafb98..32642bee195 100644
--- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php
+++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php
@@ -160,7 +160,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
* @return array
*/
public function getPrincipalByPath($path) {
- if (strpos($path, $this->principalPrefix) !== 0) {
+ if (!str_starts_with($path, $this->principalPrefix)) {
return null;
}
[, $name] = \Sabre\Uri\split($path);
@@ -443,7 +443,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
}
$usersGroups = $this->groupManager->getUserGroupIds($user);
- if (strpos($uri, 'mailto:') === 0) {
+ if (str_starts_with($uri, 'mailto:')) {
$email = substr($uri, 7);
$query = $this->db->getQueryBuilder();
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions'])
@@ -463,9 +463,9 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
return $this->rowToPrincipal($row)['uri'];
}
- if (strpos($uri, 'principal:') === 0) {
+ if (str_starts_with($uri, 'principal:')) {
$path = substr($uri, 10);
- if (strpos($path, $this->principalPrefix) !== 0) {
+ if (!str_starts_with($path, $this->principalPrefix)) {
return null;
}
diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php
index 0751638b697..2845ccdf6c2 100644
--- a/apps/dav/lib/CalDAV/Schedule/Plugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php
@@ -310,10 +310,10 @@ EOF;
return null;
}
- $isResourceOrRoom = strpos($principalUrl, 'principals/calendar-resources') === 0 ||
- strpos($principalUrl, 'principals/calendar-rooms') === 0;
+ $isResourceOrRoom = str_starts_with($principalUrl, 'principals/calendar-resources') ||
+ str_starts_with($principalUrl, 'principals/calendar-rooms');
- if (strpos($principalUrl, 'principals/users') === 0) {
+ if (str_starts_with($principalUrl, 'principals/users')) {
[, $userId] = split($principalUrl);
$uri = $this->config->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI);
$displayName = CalDavBackend::PERSONAL_CALENDAR_NAME;