Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
];

/** @var array parameters to index */
public static array $indexParameters = [
private const INDEXED_PARAMETERS = [
'ATTENDEE' => ['CN'],
'ORGANIZER' => ['CN'],
];
Expand Down Expand Up @@ -3386,9 +3386,9 @@ public function updateProperties($calendarId, $objectUri, $calendarData, $calend
$query->executeStatement();
}

if (array_key_exists($property->name, self::$indexParameters)) {
if (array_key_exists($property->name, self::INDEXED_PARAMETERS)) {
$parameters = $property->parameters();
$indexedParametersForProperty = self::$indexParameters[$property->name];
$indexedParametersForProperty = self::INDEXED_PARAMETERS[$property->name];

foreach ($parameters as $key => $value) {
if (in_array($key, $indexedParametersForProperty)) {
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
private string $dbCardsPropertiesTable = 'cards_properties';

/** @var array properties to index */
public static array $indexProperties = [
private const INDEXED_PROPERTIES = [
'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO',
'CLOUD', 'X-SOCIALPROFILE'];
Expand Down Expand Up @@ -1384,7 +1384,7 @@ protected function updateProperties($addressBookId, $cardUri, $vCardSerialized)
);

foreach ($vCard->children() as $property) {
if (!in_array($property->name, self::$indexProperties)) {
if (!in_array($property->name, self::INDEXED_PROPERTIES)) {
continue;
}
$preferred = 0;
Expand Down
6 changes: 3 additions & 3 deletions apps/dav/lib/Search/ContactsSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
use Sabre\VObject\Reader;

class ContactsSearchProvider implements IFilteringProvider {
private static array $searchPropertiesRestricted = [
private const SEARCH_PROPERTIES_RESTRICTED = [
'N',
'FN',
'NICKNAME',
'EMAIL',
];

private static array $searchProperties = [
private const SEARCH_PROPERTIES = [
'N',
'FN',
'NICKNAME',
Expand Down Expand Up @@ -87,7 +87,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
$searchResults = $this->backend->searchPrincipalUri(
$principalUri,
$query->getFilter('term')?->get() ?? '',
$query->getFilter('title-only')?->get() ? self::$searchPropertiesRestricted : self::$searchProperties,
$query->getFilter('title-only')?->get() ? self::SEARCH_PROPERTIES_RESTRICTED : self::SEARCH_PROPERTIES,
[
'limit' => $query->getLimit(),
'offset' => $query->getCursor(),
Expand Down
20 changes: 10 additions & 10 deletions apps/dav/lib/Search/EventsSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EventsSearchProvider extends ACalendarSearchProvider implements IFiltering
/**
* @var string[]
*/
private static $searchProperties = [
private const SEARCH_PROPERTIES = [
'SUMMARY',
'LOCATION',
'DESCRIPTION',
Expand All @@ -42,17 +42,17 @@ class EventsSearchProvider extends ACalendarSearchProvider implements IFiltering
];

/**
* @var string[]
* @var array<string, string[]>
*/
private static $searchParameters = [
private const SEARCH_PARAMETERS = [
'ATTENDEE' => ['CN'],
'ORGANIZER' => ['CN'],
];

/**
* @var string
*/
private static $componentType = 'VEVENT';
private const COMPONENT_TYPE = 'VEVENT';

/**
* @inheritDoc
Expand Down Expand Up @@ -102,9 +102,9 @@ public function search(
$searchResults = $this->backend->searchPrincipalUri(
$principalUri,
$term,
[self::$componentType],
self::$searchProperties,
self::$searchParameters,
[self::COMPONENT_TYPE],
self::SEARCH_PROPERTIES,
self::SEARCH_PARAMETERS,
[
'limit' => $query->getLimit(),
'offset' => $query->getCursor(),
Expand All @@ -122,9 +122,9 @@ public function search(
$attendeeSearchResults = $this->backend->searchPrincipalUri(
$principalUri,
$personDisplayName,
[self::$componentType],
[self::COMPONENT_TYPE],
['ATTENDEE'],
self::$searchParameters,
self::SEARCH_PARAMETERS,
[
'limit' => $query->getLimit(),
'offset' => $query->getCursor(),
Expand All @@ -148,7 +148,7 @@ public function search(
}
}
$formattedResults = \array_map(function (array $eventRow) use ($calendarsById, $subscriptionsById): SearchResultEntry {
$component = $this->getPrimaryComponent($eventRow['calendardata'], self::$componentType);
$component = $this->getPrimaryComponent($eventRow['calendardata'], self::COMPONENT_TYPE);
$title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled event'));

if ($eventRow['calendartype'] === CalDavBackend::CALENDAR_TYPE_CALENDAR) {
Expand Down
14 changes: 7 additions & 7 deletions apps/dav/lib/Search/TasksSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TasksSearchProvider extends ACalendarSearchProvider {
/**
* @var string[]
*/
private static $searchProperties = [
private const SEARCH_PROPERTIES = [
'SUMMARY',
'DESCRIPTION',
'CATEGORIES',
Expand All @@ -33,12 +33,12 @@ class TasksSearchProvider extends ACalendarSearchProvider {
/**
* @var string[]
*/
private static $searchParameters = [];
private const SEARCH_PARAMETERS = [];

/**
* @var string
*/
private static $componentType = 'VTODO';
private const COMPONENT_TYPE = 'VTODO';

/**
* @inheritDoc
Expand Down Expand Up @@ -83,9 +83,9 @@ public function search(
$searchResults = $this->backend->searchPrincipalUri(
$principalUri,
$query->getFilter('term')?->get() ?? '',
[self::$componentType],
self::$searchProperties,
self::$searchParameters,
[self::COMPONENT_TYPE],
self::SEARCH_PROPERTIES,
self::SEARCH_PARAMETERS,
[
'limit' => $query->getLimit(),
'offset' => $query->getCursor(),
Expand All @@ -94,7 +94,7 @@ public function search(
]
);
$formattedResults = \array_map(function (array $taskRow) use ($calendarsById, $subscriptionsById):SearchResultEntry {
$component = $this->getPrimaryComponent($taskRow['calendardata'], self::$componentType);
$component = $this->getPrimaryComponent($taskRow['calendardata'], self::COMPONENT_TYPE);
$title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled task'));

if ($taskRow['calendartype'] === CalDavBackend::CALENDAR_TYPE_CALENDAR) {
Expand Down
9 changes: 4 additions & 5 deletions apps/encryption/lib/Services/PassphraseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
use Psr\Log\LoggerInterface;

class PassphraseService {

/** @var array<string, bool> */
private static array $passwordResetUsers = [];
private array $passwordResetUsers = [];

public function __construct(
private Util $util,
Expand All @@ -39,9 +38,9 @@ public function __construct(

public function setProcessingReset(string $uid, bool $processing = true): void {
if ($processing) {
self::$passwordResetUsers[$uid] = true;
$this->passwordResetUsers[$uid] = true;
} else {
unset(self::$passwordResetUsers[$uid]);
unset($this->passwordResetUsers[$uid]);
}
}

Expand All @@ -51,7 +50,7 @@ public function setProcessingReset(string $uid, bool $processing = true): void {
public function setPassphraseForUser(string $userId, string $password, ?string $recoveryPassword = null): bool {
// if we are in the process to resetting a user password, we have nothing
// to do here
if (isset(self::$passwordResetUsers[$userId])) {
if (isset($this->passwordResetUsers[$userId])) {
return true;
}

Expand Down
34 changes: 0 additions & 34 deletions apps/files/lib/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,9 @@
*/
namespace OCA\Files;

use OC\NavigationManager;
use OCA\Files\Service\ChunkedUploadConfig;
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\INavigationManager;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Server;
use Psr\Log\LoggerInterface;

class App {
private static ?INavigationManager $navigationManager = null;

/**
* Returns the app's navigation manager
*/
public static function getNavigationManager(): INavigationManager {
// TODO: move this into a service in the Application class
if (self::$navigationManager === null) {
self::$navigationManager = new NavigationManager(
Server::get(IAppManager::class),
Server::get(IUrlGenerator::class),
Server::get(IFactory::class),
Server::get(IUserSession::class),
Server::get(IGroupManager::class),
Server::get(IConfig::class),
Server::get(LoggerInterface::class),
Server::get(IEventDispatcher::class),
);
self::$navigationManager->clear(false);
}
return self::$navigationManager;
}

public static function extendJsConfig($settings): void {
$appConfig = json_decode($settings['array']['oc_appconfig'], true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use OCP\Security\ISecureRandom;

class BackupCodeStorage {
private static $CODE_LENGTH = 16;
private const CODE_LENGTH = 16;

public function __construct(
private BackupCodeMapper $mapper,
Expand All @@ -40,7 +40,7 @@ public function createCodes(IUser $user, int $number = 10): array {

$uid = $user->getUID();
foreach (range(1, min([$number, 20])) as $i) {
$code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE);
$code = $this->random->generate(self::CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE);

$dbCode = new BackupCode();
$dbCode->setUserId($uid);
Expand Down
9 changes: 2 additions & 7 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,9 @@ protected function getSystemValue(string $varName): string {
}

protected function getValue(string $varName): string {
static $defaults;
if (is_null($defaults)) {
$defaults = $this->getDefaults();
}
return Server::get(IConfig::class)->getAppValue('user_ldap',
$this->configPrefix . $varName,
$defaults[$varName]);
$this->getDefaults()[$varName]);
}

/**
Expand Down Expand Up @@ -571,7 +567,7 @@ public function getDefaults(): array {
*/
public function getConfigTranslationArray(): array {
//TODO: merge them into one representation
static $array = [
return [
'ldap_host' => 'ldapHost',
'ldap_port' => 'ldapPort',
'ldap_backup_host' => 'ldapBackupHost',
Expand Down Expand Up @@ -644,7 +640,6 @@ public function getConfigTranslationArray(): array {
'ldap_attr_anniversarydate' => 'ldapAttributeAnniversaryDate',
'ldap_attr_pronouns' => 'ldapAttributePronouns',
];
return $array;
}

/**
Expand Down
13 changes: 5 additions & 8 deletions apps/user_ldap/lib/Mapping/UserMapping.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OCA\User_LDAP\Mapping;

use OCP\HintException;
use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\Server;
use OCP\Support\Subscription\IAssertion;

/**
Expand All @@ -30,6 +32,7 @@ public function __construct(
IAppConfig $config,
bool $isCLI,
private IAssertion $assertion,
private IRequest $request,
) {
parent::__construct($dbc, $cacheFactory, $config, $isCLI);
}
Expand All @@ -41,13 +44,7 @@ public function map($fdn, $name, $uuid): bool {
try {
$this->assertion->createUserIsLegit();
} catch (HintException $e) {
static $isProvisioningApi = null;

if ($isProvisioningApi === null) {
$request = Server::get(IRequest::class);
$isProvisioningApi = \preg_match(self::PROV_API_REGEX, $request->getRequestUri()) === 1;
}
if ($isProvisioningApi) {
if (\preg_match(self::PROV_API_REGEX, $this->request->getRequestUri()) === 1) {
// only throw when prov API is being used, since functionality
// should not break for end users (e.g. when sharing).
// On direct API usage, e.g. on users page, this is desired.
Expand Down
Loading
Loading