Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>tags/v28.0.0rc1
public function __construct( | public function __construct( | ||||
private IAuditLogger $logger, | private IAuditLogger $logger, | ||||
) {} | |||||
) { | |||||
} | |||||
/** | /** | ||||
* Log a single action with a log level of info | * Log a single action with a log level of info | ||||
* @param bool $obfuscateParameters | * @param bool $obfuscateParameters | ||||
*/ | */ | ||||
public function log(string $text, | public function log(string $text, | ||||
array $params, | |||||
array $elements, | |||||
bool $obfuscateParameters = false): void { | |||||
array $params, | |||||
array $elements, | |||||
bool $obfuscateParameters = false): void { | |||||
foreach ($elements as $element) { | foreach ($elements as $element) { | ||||
if (!isset($params[$element])) { | if (!isset($params[$element])) { | ||||
if ($obfuscateParameters) { | if ($obfuscateParameters) { |
*/ | */ | ||||
public function assign(string $uid): void { | public function assign(string $uid): void { | ||||
$this->log( | $this->log( | ||||
'UserID assigned: "%s"', | |||||
'UserID assigned: "%s"', | |||||
[ 'uid' => $uid ], | [ 'uid' => $uid ], | ||||
[ 'uid' ] | [ 'uid' ] | ||||
); | ); |
* Register hooks in order to log them | * Register hooks in order to log them | ||||
*/ | */ | ||||
private function registerHooks(IAuditLogger $logger, | private function registerHooks(IAuditLogger $logger, | ||||
ContainerInterface $serverContainer): void { | |||||
ContainerInterface $serverContainer): void { | |||||
$this->userManagementHooks($logger, $serverContainer->get(IUserSession::class)); | $this->userManagementHooks($logger, $serverContainer->get(IUserSession::class)); | ||||
$this->groupHooks($logger, $serverContainer->get(IGroupManager::class)); | $this->groupHooks($logger, $serverContainer->get(IGroupManager::class)); | ||||
$this->authHooks($logger); | $this->authHooks($logger); | ||||
} | } | ||||
private function userManagementHooks(IAuditLogger $logger, | private function userManagementHooks(IAuditLogger $logger, | ||||
IUserSession $userSession): void { | |||||
IUserSession $userSession): void { | |||||
$userActions = new UserManagement($logger); | $userActions = new UserManagement($logger); | ||||
Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); | Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); | ||||
} | } | ||||
private function groupHooks(IAuditLogger $logger, | private function groupHooks(IAuditLogger $logger, | ||||
IGroupManager $groupManager): void { | |||||
IGroupManager $groupManager): void { | |||||
$groupActions = new GroupManagement($logger); | $groupActions = new GroupManagement($logger); | ||||
assert($groupManager instanceof GroupManager); | assert($groupManager instanceof GroupManager); | ||||
} | } | ||||
private function appHooks(IAuditLogger $logger, | private function appHooks(IAuditLogger $logger, | ||||
IEventDispatcher $eventDispatcher): void { | |||||
IEventDispatcher $eventDispatcher): void { | |||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) use ($logger) { | $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) use ($logger) { | ||||
$appActions = new AppManagement($logger); | $appActions = new AppManagement($logger); | ||||
$appActions->enableApp($event->getAppID()); | $appActions->enableApp($event->getAppID()); | ||||
} | } | ||||
private function consoleHooks(IAuditLogger $logger, | private function consoleHooks(IAuditLogger $logger, | ||||
IEventDispatcher $eventDispatcher): void { | |||||
IEventDispatcher $eventDispatcher): void { | |||||
$eventDispatcher->addListener(ConsoleEvent::class, function (ConsoleEvent $event) use ($logger) { | $eventDispatcher->addListener(ConsoleEvent::class, function (ConsoleEvent $event) use ($logger) { | ||||
$appActions = new Console($logger); | $appActions = new Console($logger); | ||||
$appActions->runCommand($event->getArguments()); | $appActions->runCommand($event->getArguments()); | ||||
} | } | ||||
private function fileHooks(IAuditLogger $logger, | private function fileHooks(IAuditLogger $logger, | ||||
IEventDispatcher $eventDispatcher): void { | |||||
IEventDispatcher $eventDispatcher): void { | |||||
$fileActions = new Files($logger); | $fileActions = new Files($logger); | ||||
$eventDispatcher->addListener( | $eventDispatcher->addListener( | ||||
BeforePreviewFetchedEvent::class, | BeforePreviewFetchedEvent::class, | ||||
} | } | ||||
private function securityHooks(IAuditLogger $logger, | private function securityHooks(IAuditLogger $logger, | ||||
IEventDispatcher $eventDispatcher): void { | |||||
IEventDispatcher $eventDispatcher): void { | |||||
$eventDispatcher->addListener(TwoFactorProviderChallengePassed::class, function (TwoFactorProviderChallengePassed $event) use ($logger) { | $eventDispatcher->addListener(TwoFactorProviderChallengePassed::class, function (TwoFactorProviderChallengePassed $event) use ($logger) { | ||||
$security = new Security($logger); | $security = new Security($logger); | ||||
$security->twofactorSuccess($event->getUser(), $event->getProvider()); | $security->twofactorSuccess($event->getUser(), $event->getProvider()); |
*/ | */ | ||||
namespace OCA\AdminAudit\BackgroundJobs; | namespace OCA\AdminAudit\BackgroundJobs; | ||||
use OCP\BackgroundJob\TimedJob; | |||||
use OCP\AppFramework\Utility\ITimeFactory; | use OCP\AppFramework\Utility\ITimeFactory; | ||||
use OCP\BackgroundJob\TimedJob; | |||||
use OCP\IConfig; | use OCP\IConfig; | ||||
use OCP\Log\RotationTrait; | use OCP\Log\RotationTrait; | ||||
'verb' => 'POST', | 'verb' => 'POST', | ||||
'root' => '/ocm', | 'root' => '/ocm', | ||||
], | ], | ||||
// [ | |||||
// 'name' => 'RequestHandler#inviteAccepted', | |||||
// 'url' => '/invite-accepted', | |||||
// 'verb' => 'POST', | |||||
// 'root' => '/ocm', | |||||
// ] | |||||
// [ | |||||
// 'name' => 'RequestHandler#inviteAccepted', | |||||
// 'url' => '/invite-accepted', | |||||
// 'verb' => 'POST', | |||||
// 'root' => '/ocm', | |||||
// ] | |||||
], | ], | ||||
]; | ]; |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** |
use OCA\Comments\Listener\LoadSidebarScripts; | use OCA\Comments\Listener\LoadSidebarScripts; | ||||
use OCA\Comments\MaxAutoCompleteResultsInitialState; | use OCA\Comments\MaxAutoCompleteResultsInitialState; | ||||
use OCA\Comments\Notification\Notifier; | use OCA\Comments\Notification\Notifier; | ||||
use OCA\Comments\Search\LegacyProvider; | |||||
use OCA\Comments\Search\CommentsSearchProvider; | use OCA\Comments\Search\CommentsSearchProvider; | ||||
use OCA\Comments\Search\LegacyProvider; | |||||
use OCA\Files\Event\LoadAdditionalScriptsEvent; | use OCA\Files\Event\LoadAdditionalScriptsEvent; | ||||
use OCA\Files\Event\LoadSidebar; | use OCA\Files\Event\LoadSidebar; | ||||
use OCP\AppFramework\App; | use OCP\AppFramework\App; | ||||
use OCP\AppFramework\Bootstrap\IBootstrap; | use OCP\AppFramework\Bootstrap\IBootstrap; | ||||
use OCP\AppFramework\Bootstrap\IRegistrationContext; | use OCP\AppFramework\Bootstrap\IRegistrationContext; | ||||
use OCP\Comments\CommentsEntityEvent; | use OCP\Comments\CommentsEntityEvent; | ||||
use OCP\Comments\ICommentsManager; | |||||
use OCP\ISearch; | use OCP\ISearch; | ||||
use OCP\IServerContainer; | use OCP\IServerContainer; | ||||
use OCP\Comments\ICommentsManager; | |||||
class Application extends App implements IBootstrap { | class Application extends App implements IBootstrap { | ||||
public const APP_ID = 'comments'; | public const APP_ID = 'comments'; |
namespace OCA\Comments\Controller; | namespace OCA\Comments\Controller; | ||||
use OCP\AppFramework\Controller; | use OCP\AppFramework\Controller; | ||||
use OCP\AppFramework\Http; | |||||
use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI; | use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI; | ||||
use OCP\AppFramework\Http\NotFoundResponse; | use OCP\AppFramework\Http\NotFoundResponse; | ||||
use OCP\AppFramework\Http\RedirectResponse; | use OCP\AppFramework\Http\RedirectResponse; | ||||
use OCP\AppFramework\Http; | |||||
use OCP\Comments\IComment; | use OCP\Comments\IComment; | ||||
use OCP\Comments\ICommentsManager; | use OCP\Comments\ICommentsManager; | ||||
use OCP\Files\IRootFolder; | use OCP\Files\IRootFolder; |
namespace OCA\Comments\Search; | namespace OCA\Comments\Search; | ||||
use OCP\Comments\IComment; | use OCP\Comments\IComment; | ||||
use OCP\Comments\ICommentsManager; | |||||
use OCP\Files\Folder; | use OCP\Files\Folder; | ||||
use OCP\Files\Node; | use OCP\Files\Node; | ||||
use OCP\Files\NotFoundException; | use OCP\Files\NotFoundException; | ||||
use OCP\IUser; | use OCP\IUser; | ||||
use OCP\Search\Provider; | use OCP\Search\Provider; | ||||
use OCP\Comments\ICommentsManager; | |||||
use function count; | use function count; | ||||
class LegacyProvider extends Provider { | class LegacyProvider extends Provider { |
} | } | ||||
public function findExisting(IUser $user, | public function findExisting(IUser $user, | ||||
?string $uid, | |||||
?string $email, | |||||
?string $cloudId): ?string { | |||||
?string $uid, | |||||
?string $email, | |||||
?string $cloudId): ?string { | |||||
$addressbooksQuery = $this->db->getQueryBuilder(); | $addressbooksQuery = $this->db->getQueryBuilder(); | ||||
$cardQuery = $this->db->getQueryBuilder(); | $cardQuery = $this->db->getQueryBuilder(); | ||||
$propQuery = $this->db->getQueryBuilder(); | $propQuery = $this->db->getQueryBuilder(); |
* @return RecentContact[] | * @return RecentContact[] | ||||
*/ | */ | ||||
public function findMatch(IUser $user, | public function findMatch(IUser $user, | ||||
?string $uid, | |||||
?string $email, | |||||
?string $cloudId): array { | |||||
?string $uid, | |||||
?string $email, | |||||
?string $cloudId): array { | |||||
$qb = $this->db->getQueryBuilder(); | $qb = $this->db->getQueryBuilder(); | ||||
$or = $qb->expr()->orX(); | $or = $qb->expr()->orX(); |
use OCP\IUserManager; | use OCP\IUserManager; | ||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
use Sabre\VObject\Component\VCard; | use Sabre\VObject\Component\VCard; | ||||
use Sabre\VObject\Reader; | |||||
use Sabre\VObject\UUIDUtil; | use Sabre\VObject\UUIDUtil; | ||||
use Throwable; | |||||
class ContactInteractionListener implements IEventListener { | class ContactInteractionListener implements IEventListener { | ||||
namespace OCA\Dashboard\Controller; | namespace OCA\Dashboard\Controller; | ||||
use OCA\Dashboard\ResponseDefinitions; | use OCA\Dashboard\ResponseDefinitions; | ||||
use OCP\AppFramework\OCSController; | |||||
use OCP\AppFramework\Http; | use OCP\AppFramework\Http; | ||||
use OCP\AppFramework\Http\DataResponse; | use OCP\AppFramework\Http\DataResponse; | ||||
use OCP\AppFramework\OCSController; | |||||
use OCP\Dashboard\IAPIWidget; | |||||
use OCP\Dashboard\IAPIWidgetV2; | |||||
use OCP\Dashboard\IButtonWidget; | use OCP\Dashboard\IButtonWidget; | ||||
use OCP\Dashboard\IIconWidget; | use OCP\Dashboard\IIconWidget; | ||||
use OCP\Dashboard\IOptionWidget; | |||||
use OCP\Dashboard\IManager; | use OCP\Dashboard\IManager; | ||||
use OCP\Dashboard\IOptionWidget; | |||||
use OCP\Dashboard\IReloadableWidget; | use OCP\Dashboard\IReloadableWidget; | ||||
use OCP\Dashboard\IWidget; | use OCP\Dashboard\IWidget; | ||||
use OCP\Dashboard\Model\WidgetButton; | use OCP\Dashboard\Model\WidgetButton; | ||||
use OCP\Dashboard\Model\WidgetItem; | |||||
use OCP\Dashboard\Model\WidgetOptions; | use OCP\Dashboard\Model\WidgetOptions; | ||||
use OCP\IConfig; | use OCP\IConfig; | ||||
use OCP\IRequest; | use OCP\IRequest; | ||||
use OCP\Dashboard\IAPIWidget; | |||||
use OCP\Dashboard\IAPIWidgetV2; | |||||
use OCP\Dashboard\Model\WidgetItem; | |||||
use OCP\Dashboard\Model\WidgetItems; | |||||
/** | /** | ||||
* @psalm-import-type DashboardWidget from ResponseDefinitions | * @psalm-import-type DashboardWidget from ResponseDefinitions | ||||
* @psalm-import-type DashboardWidgetItem from ResponseDefinitions | * @psalm-import-type DashboardWidgetItem from ResponseDefinitions |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** |
// Backends | // Backends | ||||
use OC\KnownUser\KnownUserService; | use OC\KnownUser\KnownUserService; | ||||
use OCA\DAV\CalDAV\CalDavBackend; | use OCA\DAV\CalDAV\CalDavBackend; | ||||
use OCA\DAV\Connector\LegacyDAVACL; | |||||
use OCA\DAV\CalDAV\CalendarRoot; | use OCA\DAV\CalDAV\CalendarRoot; | ||||
use OCA\DAV\Connector\LegacyDAVACL; | |||||
use OCA\DAV\Connector\Sabre\Auth; | use OCA\DAV\Connector\Sabre\Auth; | ||||
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin; | use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin; | ||||
use OCA\DAV\Connector\Sabre\MaintenancePlugin; | use OCA\DAV\Connector\Sabre\MaintenancePlugin; |
use OCA\DAV\Events\CardUpdatedEvent; | use OCA\DAV\Events\CardUpdatedEvent; | ||||
use OCA\DAV\Events\SubscriptionCreatedEvent; | use OCA\DAV\Events\SubscriptionCreatedEvent; | ||||
use OCA\DAV\Events\SubscriptionDeletedEvent; | use OCA\DAV\Events\SubscriptionDeletedEvent; | ||||
use OCA\DAV\Listener\OutOfOfficeListener; | |||||
use OCP\Accounts\UserUpdatedEvent; | |||||
use OCP\EventDispatcher\IEventDispatcher; | |||||
use OCP\Federation\Events\TrustedServerRemovedEvent; | |||||
use OCA\DAV\HookManager; | use OCA\DAV\HookManager; | ||||
use OCA\DAV\Listener\ActivityUpdaterListener; | use OCA\DAV\Listener\ActivityUpdaterListener; | ||||
use OCA\DAV\Listener\AddressbookListener; | use OCA\DAV\Listener\AddressbookListener; | ||||
use OCA\DAV\Listener\CalendarShareUpdateListener; | use OCA\DAV\Listener\CalendarShareUpdateListener; | ||||
use OCA\DAV\Listener\CardListener; | use OCA\DAV\Listener\CardListener; | ||||
use OCA\DAV\Listener\ClearPhotoCacheListener; | use OCA\DAV\Listener\ClearPhotoCacheListener; | ||||
use OCA\DAV\Listener\OutOfOfficeListener; | |||||
use OCA\DAV\Listener\SubscriptionListener; | use OCA\DAV\Listener\SubscriptionListener; | ||||
use OCA\DAV\Listener\TrustedServerRemovedListener; | use OCA\DAV\Listener\TrustedServerRemovedListener; | ||||
use OCA\DAV\Listener\UserPreferenceListener; | use OCA\DAV\Listener\UserPreferenceListener; | ||||
use OCA\DAV\SetupChecks\NeedsSystemAddressBookSync; | use OCA\DAV\SetupChecks\NeedsSystemAddressBookSync; | ||||
use OCA\DAV\UserMigration\CalendarMigrator; | use OCA\DAV\UserMigration\CalendarMigrator; | ||||
use OCA\DAV\UserMigration\ContactsMigrator; | use OCA\DAV\UserMigration\ContactsMigrator; | ||||
use OCP\Accounts\UserUpdatedEvent; | |||||
use OCP\AppFramework\App; | use OCP\AppFramework\App; | ||||
use OCP\AppFramework\Bootstrap\IBootContext; | use OCP\AppFramework\Bootstrap\IBootContext; | ||||
use OCP\AppFramework\Bootstrap\IBootstrap; | use OCP\AppFramework\Bootstrap\IBootstrap; | ||||
use OCP\Config\BeforePreferenceDeletedEvent; | use OCP\Config\BeforePreferenceDeletedEvent; | ||||
use OCP\Config\BeforePreferenceSetEvent; | use OCP\Config\BeforePreferenceSetEvent; | ||||
use OCP\Contacts\IManager as IContactsManager; | use OCP\Contacts\IManager as IContactsManager; | ||||
use OCP\EventDispatcher\IEventDispatcher; | |||||
use OCP\Federation\Events\TrustedServerRemovedEvent; | |||||
use OCP\Files\AppData\IAppDataFactory; | use OCP\Files\AppData\IAppDataFactory; | ||||
use OCP\IUser; | use OCP\IUser; | ||||
use OCP\User\Events\OutOfOfficeChangedEvent; | use OCP\User\Events\OutOfOfficeChangedEvent; | ||||
} | } | ||||
public function registerHooks(HookManager $hm, | public function registerHooks(HookManager $hm, | ||||
IEventDispatcher $dispatcher, | |||||
IAppContainer $container) { | |||||
IEventDispatcher $dispatcher, | |||||
IAppContainer $container) { | |||||
$hm->setup(); | $hm->setup(); | ||||
// first time login event setup | // first time login event setup | ||||
} | } | ||||
private function setupContactsProvider(IContactsManager $contactsManager, | private function setupContactsProvider(IContactsManager $contactsManager, | ||||
IAppContainer $container, | |||||
string $userID): void { | |||||
IAppContainer $container, | |||||
string $userID): void { | |||||
/** @var ContactsManager $cm */ | /** @var ContactsManager $cm */ | ||||
$cm = $container->query(ContactsManager::class); | $cm = $container->query(ContactsManager::class); | ||||
$urlGenerator = $container->getServer()->getURLGenerator(); | $urlGenerator = $container->getServer()->getURLGenerator(); | ||||
} | } | ||||
private function setupSystemContactsProvider(IContactsManager $contactsManager, | private function setupSystemContactsProvider(IContactsManager $contactsManager, | ||||
IAppContainer $container): void { | |||||
IAppContainer $container): void { | |||||
/** @var ContactsManager $cm */ | /** @var ContactsManager $cm */ | ||||
$cm = $container->query(ContactsManager::class); | $cm = $container->query(ContactsManager::class); | ||||
$urlGenerator = $container->getServer()->getURLGenerator(); | $urlGenerator = $container->getServer()->getURLGenerator(); | ||||
} | } | ||||
public function registerCalendarManager(ICalendarManager $calendarManager, | public function registerCalendarManager(ICalendarManager $calendarManager, | ||||
IAppContainer $container): void { | |||||
IAppContainer $container): void { | |||||
$calendarManager->register(function () use ($container, $calendarManager) { | $calendarManager->register(function () use ($container, $calendarManager) { | ||||
$user = \OC::$server->getUserSession()->getUser(); | $user = \OC::$server->getUserSession()->getUser(); | ||||
if ($user !== null) { | if ($user !== null) { | ||||
} | } | ||||
private function setupCalendarProvider(ICalendarManager $calendarManager, | private function setupCalendarProvider(ICalendarManager $calendarManager, | ||||
IAppContainer $container, | |||||
$userId) { | |||||
IAppContainer $container, | |||||
$userId) { | |||||
$cm = $container->query(CalendarManager::class); | $cm = $container->query(CalendarManager::class); | ||||
$cm->setupCalendarProvider($calendarManager, $userId); | $cm->setupCalendarProvider($calendarManager, $userId); | ||||
} | } | ||||
public function registerCalendarReminders(NotificationProviderManager $manager, | public function registerCalendarReminders(NotificationProviderManager $manager, | ||||
LoggerInterface $logger): void { | |||||
LoggerInterface $logger): void { | |||||
try { | try { | ||||
$manager->registerProvider(AudioProvider::class); | $manager->registerProvider(AudioProvider::class); | ||||
$manager->registerProvider(EmailProvider::class); | $manager->registerProvider(EmailProvider::class); |
* BuildReminderIndexBackgroundJob constructor. | * BuildReminderIndexBackgroundJob constructor. | ||||
*/ | */ | ||||
public function __construct(IDBConnection $db, | public function __construct(IDBConnection $db, | ||||
ReminderService $reminderService, | |||||
LoggerInterface $logger, | |||||
IJobList $jobList, | |||||
ITimeFactory $timeFactory) { | |||||
ReminderService $reminderService, | |||||
LoggerInterface $logger, | |||||
IJobList $jobList, | |||||
ITimeFactory $timeFactory) { | |||||
parent::__construct($timeFactory); | parent::__construct($timeFactory); | ||||
$this->db = $db; | $this->db = $db; | ||||
$this->reminderService = $reminderService; | $this->reminderService = $reminderService; |
private $service; | private $service; | ||||
public function __construct(ITimeFactory $time, | public function __construct(ITimeFactory $time, | ||||
RetentionService $service) { | |||||
RetentionService $service) { | |||||
parent::__construct($time); | parent::__construct($time); | ||||
$this->service = $service; | $this->service = $service; | ||||
private $config; | private $config; | ||||
public function __construct(ITimeFactory $time, | public function __construct(ITimeFactory $time, | ||||
ReminderService $reminderService, | |||||
IConfig $config) { | |||||
ReminderService $reminderService, | |||||
IConfig $config) { | |||||
parent::__construct($time); | parent::__construct($time); | ||||
$this->reminderService = $reminderService; | $this->reminderService = $reminderService; | ||||
$this->config = $config; | $this->config = $config; |
private $config; | private $config; | ||||
public function __construct(ITimeFactory $time, | public function __construct(ITimeFactory $time, | ||||
BirthdayService $birthdayService, | |||||
IConfig $config) { | |||||
BirthdayService $birthdayService, | |||||
IConfig $config) { | |||||
parent::__construct($time); | parent::__construct($time); | ||||
$this->birthdayService = $birthdayService; | $this->birthdayService = $birthdayService; |
*/ | */ | ||||
namespace OCA\DAV\BackgroundJob; | namespace OCA\DAV\BackgroundJob; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | |||||
use OCP\BackgroundJob\TimedJob; | |||||
use OCA\DAV\AppInfo\Application; | use OCA\DAV\AppInfo\Application; | ||||
use OCA\DAV\CalDAV\CalDavBackend; | use OCA\DAV\CalDAV\CalDavBackend; | ||||
use OCA\DAV\CardDAV\CardDavBackend; | use OCA\DAV\CardDAV\CardDavBackend; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | |||||
use OCP\BackgroundJob\TimedJob; | |||||
use OCP\IConfig; | use OCP\IConfig; | ||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
* @param IJobList $jobList | * @param IJobList $jobList | ||||
*/ | */ | ||||
public function __construct(ITimeFactory $time, | public function __construct(ITimeFactory $time, | ||||
IUserManager $userManager, | |||||
IJobList $jobList) { | |||||
IUserManager $userManager, | |||||
IJobList $jobList) { | |||||
parent::__construct($time); | parent::__construct($time); | ||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
$this->jobList = $jobList; | $this->jobList = $jobList; |
private $calDavBackend; | private $calDavBackend; | ||||
public function __construct(ITimeFactory $time, | public function __construct(ITimeFactory $time, | ||||
IResourceManager $resourceManager, | |||||
IRoomManager $roomManager, | |||||
IDBConnection $dbConnection, | |||||
CalDavBackend $calDavBackend) { | |||||
IResourceManager $resourceManager, | |||||
IRoomManager $roomManager, | |||||
IDBConnection $dbConnection, | |||||
CalDavBackend $calDavBackend) { | |||||
parent::__construct($time); | parent::__construct($time); | ||||
$this->resourceManager = $resourceManager; | $this->resourceManager = $resourceManager; | ||||
$this->roomManager = $roomManager; | $this->roomManager = $roomManager; | ||||
* @param string $principalPrefix | * @param string $principalPrefix | ||||
*/ | */ | ||||
private function runForBackend($backendManager, | private function runForBackend($backendManager, | ||||
string $dbTable, | |||||
string $dbTableMetadata, | |||||
string $foreignKey, | |||||
string $principalPrefix): void { | |||||
string $dbTable, | |||||
string $dbTableMetadata, | |||||
string $foreignKey, | |||||
string $principalPrefix): void { | |||||
$backends = $backendManager->getBackends(); | $backends = $backendManager->getBackends(); | ||||
foreach ($backends as $backend) { | foreach ($backends as $backend) { | ||||
* @return int Insert id | * @return int Insert id | ||||
*/ | */ | ||||
private function addToCache(string $table, | private function addToCache(string $table, | ||||
string $backendId, | |||||
$remote): int { | |||||
string $backendId, | |||||
$remote): int { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->insert($table) | $query->insert($table) | ||||
->values([ | ->values([ | ||||
* @param array $metadata | * @param array $metadata | ||||
*/ | */ | ||||
private function addMetadataToCache(string $table, | private function addMetadataToCache(string $table, | ||||
string $foreignKey, | |||||
int $foreignId, | |||||
array $metadata): void { | |||||
string $foreignKey, | |||||
int $foreignId, | |||||
array $metadata): void { | |||||
foreach ($metadata as $key => $value) { | foreach ($metadata as $key => $value) { | ||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->insert($table) | $query->insert($table) | ||||
* @param int $id | * @param int $id | ||||
*/ | */ | ||||
private function deleteFromCache(string $table, | private function deleteFromCache(string $table, | ||||
int $id): void { | |||||
int $id): void { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->delete($table) | $query->delete($table) | ||||
->where($query->expr()->eq('id', $query->createNamedParameter($id))) | ->where($query->expr()->eq('id', $query->createNamedParameter($id))) | ||||
* @param int $id | * @param int $id | ||||
*/ | */ | ||||
private function deleteMetadataFromCache(string $table, | private function deleteMetadataFromCache(string $table, | ||||
string $foreignKey, | |||||
int $id): void { | |||||
string $foreignKey, | |||||
int $id): void { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->delete($table) | $query->delete($table) | ||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id))) | ->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id))) | ||||
* @param IResource|IRoom $remote | * @param IResource|IRoom $remote | ||||
*/ | */ | ||||
private function updateCache(string $table, | private function updateCache(string $table, | ||||
int $id, | |||||
$remote): void { | |||||
int $id, | |||||
$remote): void { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->update($table) | $query->update($table) | ||||
->set('email', $query->createNamedParameter($remote->getEMail())) | ->set('email', $query->createNamedParameter($remote->getEMail())) | ||||
* @param array $cachedMetadata | * @param array $cachedMetadata | ||||
*/ | */ | ||||
private function updateMetadataCache(string $dbTable, | private function updateMetadataCache(string $dbTable, | ||||
string $foreignKey, | |||||
int $id, | |||||
array $metadata, | |||||
array $cachedMetadata): void { | |||||
string $foreignKey, | |||||
int $id, | |||||
array $metadata, | |||||
array $cachedMetadata): void { | |||||
$newMetadata = array_diff_key($metadata, $cachedMetadata); | $newMetadata = array_diff_key($metadata, $cachedMetadata); | ||||
$deletedMetadata = array_diff_key($cachedMetadata, $metadata); | $deletedMetadata = array_diff_key($cachedMetadata, $metadata); | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
private function getAllMetadataOfCache(string $table, | private function getAllMetadataOfCache(string $table, | ||||
string $foreignKey, | |||||
int $id): array { | |||||
string $foreignKey, | |||||
int $id): array { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->select(['key', 'value']) | $query->select(['key', 'value']) | ||||
->from($table) | ->from($table) | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
private function getAllCachedByBackend(string $tableName, | private function getAllCachedByBackend(string $tableName, | ||||
string $backendId): array { | |||||
string $backendId): array { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->select('resource_id') | $query->select('resource_id') | ||||
->from($tableName) | ->from($tableName) | ||||
* @param $principalUri | * @param $principalUri | ||||
*/ | */ | ||||
private function deleteCalendarDataForResource(string $principalPrefix, | private function deleteCalendarDataForResource(string $principalPrefix, | ||||
string $principalUri): void { | |||||
string $principalUri): void { | |||||
$calendar = $this->calDavBackend->getCalendarByUri( | $calendar = $this->calDavBackend->getCalendarByUri( | ||||
implode('/', [$principalPrefix, $principalUri]), | implode('/', [$principalPrefix, $principalUri]), | ||||
CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI); | CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI); | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
private function getIdForBackendAndResource(string $table, | private function getIdForBackendAndResource(string $table, | ||||
string $backendId, | |||||
string $resourceId): int { | |||||
string $backendId, | |||||
string $resourceId): int { | |||||
$query = $this->dbConnection->getQueryBuilder(); | $query = $this->dbConnection->getQueryBuilder(); | ||||
$query->select('id') | $query->select('id') | ||||
->from($table) | ->from($table) |
use OCP\BackgroundJob\IJob; | use OCP\BackgroundJob\IJob; | ||||
use OCP\BackgroundJob\IJobList; | use OCP\BackgroundJob\IJobList; | ||||
use OCP\BackgroundJob\TimedJob; | use OCP\BackgroundJob\TimedJob; | ||||
use OCP\Files\Node; | |||||
use OCP\Files\File; | use OCP\Files\File; | ||||
use OCP\Files\Folder; | use OCP\Files\Folder; | ||||
use OCP\Files\IRootFolder; | use OCP\Files\IRootFolder; |
protected IConfig $config; | protected IConfig $config; | ||||
public function __construct(ITimeFactory $timeFactory, | public function __construct(ITimeFactory $timeFactory, | ||||
IDBConnection $connection, | |||||
IJobList $jobList, | |||||
LoggerInterface $logger, | |||||
IManager $manager, | |||||
IConfig $config) { | |||||
IDBConnection $connection, | |||||
IJobList $jobList, | |||||
LoggerInterface $logger, | |||||
IManager $manager, | |||||
IConfig $config) { | |||||
parent::__construct($timeFactory); | parent::__construct($timeFactory); | ||||
$this->connection = $connection; | $this->connection = $connection; | ||||
$this->jobList = $jobList; | $this->jobList = $jobList; |
namespace OCA\DAV\BulkUpload; | namespace OCA\DAV\BulkUpload; | ||||
use OCA\DAV\Connector\Sabre\MtimeSanitizer; | |||||
use OCP\AppFramework\Http; | |||||
use OCP\Files\DavUtil; | |||||
use OCP\Files\Folder; | |||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
use Sabre\DAV\Server; | use Sabre\DAV\Server; | ||||
use Sabre\DAV\ServerPlugin; | use Sabre\DAV\ServerPlugin; | ||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\HTTP\ResponseInterface; | use Sabre\HTTP\ResponseInterface; | ||||
use OCP\Files\DavUtil; | |||||
use OCP\Files\Folder; | |||||
use OCP\AppFramework\Http; | |||||
use OCA\DAV\Connector\Sabre\MtimeSanitizer; | |||||
class BulkUploadPlugin extends ServerPlugin { | class BulkUploadPlugin extends ServerPlugin { | ||||
private Folder $userFolder; | private Folder $userFolder; |
namespace OCA\DAV\BulkUpload; | namespace OCA\DAV\BulkUpload; | ||||
use Sabre\HTTP\RequestInterface; | |||||
use OCP\AppFramework\Http; | |||||
use Sabre\DAV\Exception; | use Sabre\DAV\Exception; | ||||
use Sabre\DAV\Exception\BadRequest; | use Sabre\DAV\Exception\BadRequest; | ||||
use Sabre\DAV\Exception\LengthRequired; | use Sabre\DAV\Exception\LengthRequired; | ||||
use OCP\AppFramework\Http; | |||||
use Sabre\HTTP\RequestInterface; | |||||
class MultipartRequestParser { | class MultipartRequestParser { | ||||
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** | ||||
namespace OCA\DAV\CalDAV\AppCalendar; | namespace OCA\DAV\CalDAV\AppCalendar; | ||||
use OCA\DAV\CalDAV\Plugin; | |||||
use OCA\DAV\CalDAV\Integration\ExternalCalendar; | use OCA\DAV\CalDAV\Integration\ExternalCalendar; | ||||
use OCA\DAV\CalDAV\Plugin; | |||||
use OCP\Calendar\ICalendar; | use OCP\Calendar\ICalendar; | ||||
use OCP\Calendar\ICreateFromString; | use OCP\Calendar\ICreateFromString; | ||||
use OCP\Constants; | use OCP\Constants; |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** |
* BirthdayService constructor. | * BirthdayService constructor. | ||||
*/ | */ | ||||
public function __construct(CalDavBackend $calDavBackEnd, | public function __construct(CalDavBackend $calDavBackEnd, | ||||
CardDavBackend $cardDavBackEnd, | |||||
GroupPrincipalBackend $principalBackend, | |||||
IConfig $config, | |||||
IDBConnection $dbConnection, | |||||
IL10N $l10n) { | |||||
CardDavBackend $cardDavBackEnd, | |||||
GroupPrincipalBackend $principalBackend, | |||||
IConfig $config, | |||||
IDBConnection $dbConnection, | |||||
IL10N $l10n) { | |||||
$this->calDavBackEnd = $calDavBackEnd; | $this->calDavBackEnd = $calDavBackEnd; | ||||
$this->cardDavBackEnd = $cardDavBackEnd; | $this->cardDavBackEnd = $cardDavBackEnd; | ||||
$this->principalBackend = $principalBackend; | $this->principalBackend = $principalBackend; | ||||
} | } | ||||
public function onCardChanged(int $addressBookId, | public function onCardChanged(int $addressBookId, | ||||
string $cardUri, | |||||
string $cardData): void { | |||||
string $cardUri, | |||||
string $cardData): void { | |||||
if (!$this->isGloballyEnabled()) { | if (!$this->isGloballyEnabled()) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
public function onCardDeleted(int $addressBookId, | public function onCardDeleted(int $addressBookId, | ||||
string $cardUri): void { | |||||
string $cardUri): void { | |||||
if (!$this->isGloballyEnabled()) { | if (!$this->isGloballyEnabled()) { | ||||
return; | return; | ||||
} | } | ||||
* @throws InvalidDataException | * @throws InvalidDataException | ||||
*/ | */ | ||||
public function buildDateFromContact(string $cardData, | public function buildDateFromContact(string $cardData, | ||||
string $dateField, | |||||
string $postfix, | |||||
?string $reminderOffset):?VCalendar { | |||||
string $dateField, | |||||
string $postfix, | |||||
?string $reminderOffset):?VCalendar { | |||||
if (empty($cardData)) { | if (empty($cardData)) { | ||||
return null; | return null; | ||||
} | } | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function birthdayEvenChanged(string $existingCalendarData, | public function birthdayEvenChanged(string $existingCalendarData, | ||||
VCalendar $newCalendarData):bool { | |||||
VCalendar $newCalendarData):bool { | |||||
try { | try { | ||||
$existingBirthday = Reader::read($existingCalendarData); | $existingBirthday = Reader::read($existingCalendarData); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
* @throws \Sabre\DAV\Exception\BadRequest | * @throws \Sabre\DAV\Exception\BadRequest | ||||
*/ | */ | ||||
private function updateCalendar(string $cardUri, | private function updateCalendar(string $cardUri, | ||||
string $cardData, | |||||
array $book, | |||||
int $calendarId, | |||||
array $type, | |||||
?string $reminderOffset):void { | |||||
string $cardData, | |||||
array $book, | |||||
int $calendarId, | |||||
array $type, | |||||
?string $reminderOffset):void { | |||||
$objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics'; | $objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics'; | ||||
$calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['postfix'], $reminderOffset); | $calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['postfix'], $reminderOffset); | ||||
$existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri); | $existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri); | ||||
* @return string The formatted title | * @return string The formatted title | ||||
*/ | */ | ||||
private function formatTitle(string $field, | private function formatTitle(string $field, | ||||
string $name, | |||||
int $year = null, | |||||
bool $supports4Byte = true):string { | |||||
string $name, | |||||
int $year = null, | |||||
bool $supports4Byte = true):string { | |||||
if ($supports4Byte) { | if ($supports4Byte) { | ||||
switch ($field) { | switch ($field) { | ||||
case 'BDAY': | case 'BDAY': |
use OCP\Calendar\Exceptions\CalendarException; | use OCP\Calendar\Exceptions\CalendarException; | ||||
use OCP\Calendar\ICreateFromString; | use OCP\Calendar\ICreateFromString; | ||||
use OCP\Calendar\IHandleImipMessage; | use OCP\Calendar\IHandleImipMessage; | ||||
use OCP\Calendar\ISchedulingInformation; | |||||
use OCP\Constants; | use OCP\Constants; | ||||
use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp; | use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp; | ||||
use Sabre\DAV\Exception\Conflict; | use Sabre\DAV\Exception\Conflict; | ||||
private array $calendarInfo; | private array $calendarInfo; | ||||
public function __construct(Calendar $calendar, | public function __construct(Calendar $calendar, | ||||
array $calendarInfo, | |||||
CalDavBackend $backend) { | |||||
array $calendarInfo, | |||||
CalDavBackend $backend) { | |||||
$this->calendar = $calendar; | $this->calendar = $calendar; | ||||
$this->calendarInfo = $calendarInfo; | $this->calendarInfo = $calendarInfo; | ||||
$this->backend = $backend; | $this->backend = $backend; |
* @param array $objectData | * @param array $objectData | ||||
*/ | */ | ||||
public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, | public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, | ||||
array $calendarInfo, | |||||
array $objectData) { | |||||
array $calendarInfo, | |||||
array $objectData) { | |||||
parent::__construct($caldavBackend, $calendarInfo, $objectData); | parent::__construct($caldavBackend, $calendarInfo, $objectData); | ||||
if ($this->isShared()) { | if ($this->isShared()) { |
*/ | */ | ||||
namespace OCA\DAV\CalDAV; | namespace OCA\DAV\CalDAV; | ||||
use OCA\DAV\AppInfo\Application; | |||||
use OCA\DAV\CalDAV\Schedule\IMipService; | use OCA\DAV\CalDAV\Schedule\IMipService; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | |||||
use OCP\IConfig; | |||||
use Sabre\VObject\Component\VCalendar; | use Sabre\VObject\Component\VCalendar; | ||||
use Sabre\VObject\Component\VEvent; | use Sabre\VObject\Component\VEvent; | ||||
use Sabre\VObject\Component\VTimeZone; | |||||
use Sabre\VObject\Component\VTodo; | |||||
use function max; | |||||
class EventComparisonService { | class EventComparisonService { | ||||
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/* | /* | ||||
* * | * * | ||||
namespace OCA\DAV\CalDAV\FreeBusy; | namespace OCA\DAV\CalDAV\FreeBusy; | ||||
use DateTimeInterface; | |||||
use DateTimeZone; | |||||
use Sabre\VObject\Component\VCalendar; | use Sabre\VObject\Component\VCalendar; | ||||
/** | /** |
* @param IConfig $config | * @param IConfig $config | ||||
*/ | */ | ||||
public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, | public function __construct(CalDavBackend $caldavBackend, IL10N $l10n, | ||||
IConfig $config, LoggerInterface $logger) { | |||||
IConfig $config, LoggerInterface $logger) { | |||||
$this->caldavBackend = $caldavBackend; | $this->caldavBackend = $caldavBackend; | ||||
$this->l10n = $l10n; | $this->l10n = $l10n; | ||||
$this->config = $config; | $this->config = $config; |
$this->server = $server; | $this->server = $server; | ||||
$this->server->on('method:POST', [$this, 'httpPost']); | $this->server->on('method:POST', [$this, 'httpPost']); | ||||
$this->server->on('propFind', [$this, 'propFind']); | |||||
$this->server->on('propFind', [$this, 'propFind']); | |||||
} | } | ||||
public function propFind(PropFind $propFind, INode $node) { | public function propFind(PropFind $propFind, INode $node) { | ||||
case '{'.self::NS_CALENDARSERVER.'}publish-calendar': | case '{'.self::NS_CALENDARSERVER.'}publish-calendar': | ||||
// We can only deal with IShareableCalendar objects | |||||
if (!$node instanceof Calendar) { | |||||
return; | |||||
} | |||||
$this->server->transactionType = 'post-publish-calendar'; | |||||
// We can only deal with IShareableCalendar objects | |||||
if (!$node instanceof Calendar) { | |||||
return; | |||||
} | |||||
$this->server->transactionType = 'post-publish-calendar'; | |||||
// Getting ACL info | |||||
$acl = $this->server->getPlugin('acl'); | |||||
// Getting ACL info | |||||
$acl = $this->server->getPlugin('acl'); | |||||
// If there's no ACL support, we allow everything | |||||
if ($acl) { | |||||
/** @var \Sabre\DAVACL\Plugin $acl */ | |||||
$acl->checkPrivileges($path, '{DAV:}write'); | |||||
// If there's no ACL support, we allow everything | |||||
if ($acl) { | |||||
/** @var \Sabre\DAVACL\Plugin $acl */ | |||||
$acl->checkPrivileges($path, '{DAV:}write'); | |||||
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; | |||||
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); | |||||
if ($limitSharingToOwner && !$isOwner) { | |||||
return; | |||||
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; | |||||
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); | |||||
if ($limitSharingToOwner && !$isOwner) { | |||||
return; | |||||
} | |||||
} | } | ||||
} | |||||
$node->setPublishStatus(true); | |||||
$node->setPublishStatus(true); | |||||
// iCloud sends back the 202, so we will too. | |||||
$response->setStatus(202); | |||||
// iCloud sends back the 202, so we will too. | |||||
$response->setStatus(202); | |||||
// Adding this because sending a response body may cause issues, | |||||
// and I wanted some type of indicator the response was handled. | |||||
$response->setHeader('X-Sabre-Status', 'everything-went-well'); | |||||
// Adding this because sending a response body may cause issues, | |||||
// and I wanted some type of indicator the response was handled. | |||||
$response->setHeader('X-Sabre-Status', 'everything-went-well'); | |||||
// Breaking the event chain | |||||
return false; | |||||
// Breaking the event chain | |||||
return false; | |||||
case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': | case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': | ||||
// We can only deal with IShareableCalendar objects | |||||
if (!$node instanceof Calendar) { | |||||
return; | |||||
} | |||||
$this->server->transactionType = 'post-unpublish-calendar'; | |||||
// We can only deal with IShareableCalendar objects | |||||
if (!$node instanceof Calendar) { | |||||
return; | |||||
} | |||||
$this->server->transactionType = 'post-unpublish-calendar'; | |||||
// Getting ACL info | |||||
$acl = $this->server->getPlugin('acl'); | |||||
// Getting ACL info | |||||
$acl = $this->server->getPlugin('acl'); | |||||
// If there's no ACL support, we allow everything | |||||
if ($acl) { | |||||
/** @var \Sabre\DAVACL\Plugin $acl */ | |||||
$acl->checkPrivileges($path, '{DAV:}write'); | |||||
// If there's no ACL support, we allow everything | |||||
if ($acl) { | |||||
/** @var \Sabre\DAVACL\Plugin $acl */ | |||||
$acl->checkPrivileges($path, '{DAV:}write'); | |||||
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; | |||||
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); | |||||
if ($limitSharingToOwner && !$isOwner) { | |||||
return; | |||||
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; | |||||
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); | |||||
if ($limitSharingToOwner && !$isOwner) { | |||||
return; | |||||
} | |||||
} | } | ||||
} | |||||
$node->setPublishStatus(false); | |||||
$node->setPublishStatus(false); | |||||
$response->setStatus(200); | |||||
$response->setStatus(200); | |||||
// Adding this because sending a response body may cause issues, | |||||
// and I wanted some type of indicator the response was handled. | |||||
$response->setHeader('X-Sabre-Status', 'everything-went-well'); | |||||
// Adding this because sending a response body may cause issues, | |||||
// and I wanted some type of indicator the response was handled. | |||||
$response->setHeader('X-Sabre-Status', 'everything-went-well'); | |||||
// Breaking the event chain | |||||
return false; | |||||
// Breaking the event chain | |||||
return false; | |||||
} | } | ||||
} | } |
* @param ITimeFactory $timeFactory | * @param ITimeFactory $timeFactory | ||||
*/ | */ | ||||
public function __construct(IDBConnection $db, | public function __construct(IDBConnection $db, | ||||
ITimeFactory $timeFactory) { | |||||
ITimeFactory $timeFactory) { | |||||
$this->db = $db; | $this->db = $db; | ||||
$this->timeFactory = $timeFactory; | $this->timeFactory = $timeFactory; | ||||
} | } | ||||
* @return int The insert id | * @return int The insert id | ||||
*/ | */ | ||||
public function insertReminder(int $calendarId, | public function insertReminder(int $calendarId, | ||||
int $objectId, | |||||
string $uid, | |||||
bool $isRecurring, | |||||
int $recurrenceId, | |||||
bool $isRecurrenceException, | |||||
string $eventHash, | |||||
string $alarmHash, | |||||
string $type, | |||||
bool $isRelative, | |||||
int $notificationDate, | |||||
bool $isRepeatBased):int { | |||||
int $objectId, | |||||
string $uid, | |||||
bool $isRecurring, | |||||
int $recurrenceId, | |||||
bool $isRecurrenceException, | |||||
string $eventHash, | |||||
string $alarmHash, | |||||
string $type, | |||||
bool $isRelative, | |||||
int $notificationDate, | |||||
bool $isRepeatBased):int { | |||||
$query = $this->db->getQueryBuilder(); | $query = $this->db->getQueryBuilder(); | ||||
$query->insert('calendar_reminders') | $query->insert('calendar_reminders') | ||||
->values([ | ->values([ | ||||
* @param int $newNotificationDate | * @param int $newNotificationDate | ||||
*/ | */ | ||||
public function updateReminder(int $reminderId, | public function updateReminder(int $reminderId, | ||||
int $newNotificationDate):void { | |||||
int $newNotificationDate):void { | |||||
$query = $this->db->getQueryBuilder(); | $query = $this->db->getQueryBuilder(); | ||||
$query->update('calendar_reminders') | $query->update('calendar_reminders') | ||||
->set('notification_date', $query->createNamedParameter($newNotificationDate)) | ->set('notification_date', $query->createNamedParameter($newNotificationDate)) |
* @return void | * @return void | ||||
*/ | */ | ||||
public function send(VEvent $vevent, | public function send(VEvent $vevent, | ||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []): void; | |||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []): void; | |||||
} | } |
protected $config; | protected $config; | ||||
public function __construct(LoggerInterface $logger, | public function __construct(LoggerInterface $logger, | ||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator, | |||||
IConfig $config) { | |||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator, | |||||
IConfig $config) { | |||||
$this->logger = $logger; | $this->logger = $logger; | ||||
$this->l10nFactory = $l10nFactory; | $this->l10nFactory = $l10nFactory; | ||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
abstract public function send(VEvent $vevent, | abstract public function send(VEvent $vevent, | ||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []): void; | |||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []): void; | |||||
/** | /** | ||||
* @return string | * @return string |
private IMailer $mailer; | private IMailer $mailer; | ||||
public function __construct(IConfig $config, | public function __construct(IConfig $config, | ||||
IMailer $mailer, | |||||
LoggerInterface $logger, | |||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator) { | |||||
IMailer $mailer, | |||||
LoggerInterface $logger, | |||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator) { | |||||
parent::__construct($logger, $l10nFactory, $urlGenerator, $config); | parent::__construct($logger, $l10nFactory, $urlGenerator, $config); | ||||
$this->mailer = $mailer; | $this->mailer = $mailer; | ||||
} | } | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
public function send(VEvent $vevent, | public function send(VEvent $vevent, | ||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []):void { | |||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []):void { | |||||
$fallbackLanguage = $this->getFallbackLanguage(); | $fallbackLanguage = $this->getFallbackLanguage(); | ||||
$organizerEmailAddress = null; | $organizerEmailAddress = null; | ||||
* @param array $eventData | * @param array $eventData | ||||
*/ | */ | ||||
private function addBulletList(IEMailTemplate $template, | private function addBulletList(IEMailTemplate $template, | ||||
IL10N $l10n, | |||||
string $calendarDisplayName, | |||||
VEvent $vevent):void { | |||||
IL10N $l10n, | |||||
string $calendarDisplayName, | |||||
VEvent $vevent):void { | |||||
$template->addBodyListItem($calendarDisplayName, $l10n->t('Calendar:'), | $template->addBodyListItem($calendarDisplayName, $l10n->t('Calendar:'), | ||||
$this->getAbsoluteImagePath('actions/info.png')); | $this->getAbsoluteImagePath('actions/info.png')); | ||||
* @return array<string, string[]> | * @return array<string, string[]> | ||||
*/ | */ | ||||
private function sortEMailAddressesByLanguage(array $emails, | private function sortEMailAddressesByLanguage(array $emails, | ||||
string $defaultLanguage):array { | |||||
string $defaultLanguage):array { | |||||
$sortedByLanguage = []; | $sortedByLanguage = []; | ||||
foreach ($emails as $emailAddress => $parameters) { | foreach ($emails as $emailAddress => $parameters) { | ||||
} | } | ||||
private function isDayEqual(DateTime $dtStart, | private function isDayEqual(DateTime $dtStart, | ||||
DateTime $dtEnd):bool { | |||||
DateTime $dtEnd):bool { | |||||
return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); | return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); | ||||
} | } | ||||
private $timeFactory; | private $timeFactory; | ||||
public function __construct(IConfig $config, | public function __construct(IConfig $config, | ||||
IManager $manager, | |||||
LoggerInterface $logger, | |||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator, | |||||
ITimeFactory $timeFactory) { | |||||
IManager $manager, | |||||
LoggerInterface $logger, | |||||
L10NFactory $l10nFactory, | |||||
IURLGenerator $urlGenerator, | |||||
ITimeFactory $timeFactory) { | |||||
parent::__construct($logger, $l10nFactory, $urlGenerator, $config); | parent::__construct($logger, $l10nFactory, $urlGenerator, $config); | ||||
$this->manager = $manager; | $this->manager = $manager; | ||||
$this->timeFactory = $timeFactory; | $this->timeFactory = $timeFactory; | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
public function send(VEvent $vevent, | public function send(VEvent $vevent, | ||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []):void { | |||||
?string $calendarDisplayName, | |||||
array $principalEmailAddresses, | |||||
array $users = []):void { | |||||
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'yes') !== 'yes') { | if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'yes') !== 'yes') { | ||||
return; | return; | ||||
} | } |
* @param ITimeFactory $timeFactory | * @param ITimeFactory $timeFactory | ||||
*/ | */ | ||||
public function __construct(IFactory $factory, | public function __construct(IFactory $factory, | ||||
IURLGenerator $urlGenerator, | |||||
ITimeFactory $timeFactory) { | |||||
IURLGenerator $urlGenerator, | |||||
ITimeFactory $timeFactory) { | |||||
$this->l10nFactory = $factory; | $this->l10nFactory = $factory; | ||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
$this->timeFactory = $timeFactory; | $this->timeFactory = $timeFactory; | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
public function prepare(INotification $notification, | public function prepare(INotification $notification, | ||||
string $languageCode):INotification { | |||||
string $languageCode):INotification { | |||||
if ($notification->getApp() !== Application::APP_ID) { | if ($notification->getApp() !== Application::APP_ID) { | ||||
throw new \InvalidArgumentException('Notification not from this app'); | throw new \InvalidArgumentException('Notification not from this app'); | ||||
} | } | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
private function isDayEqual(DateTime $dtStart, | private function isDayEqual(DateTime $dtStart, | ||||
DateTime $dtEnd):bool { | |||||
DateTime $dtEnd):bool { | |||||
return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); | return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); | ||||
} | } | ||||
]; | ]; | ||||
public function __construct(Backend $backend, | public function __construct(Backend $backend, | ||||
NotificationProviderManager $notificationProviderManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
CalDavBackend $caldavBackend, | |||||
ITimeFactory $timeFactory, | |||||
IConfig $config, | |||||
LoggerInterface $logger, | |||||
Principal $principalConnector) { | |||||
NotificationProviderManager $notificationProviderManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
CalDavBackend $caldavBackend, | |||||
ITimeFactory $timeFactory, | |||||
IConfig $config, | |||||
LoggerInterface $logger, | |||||
Principal $principalConnector) { | |||||
$this->backend = $backend; | $this->backend = $backend; | ||||
$this->notificationProviderManager = $notificationProviderManager; | $this->notificationProviderManager = $notificationProviderManager; | ||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
private function getRemindersForVAlarm(VAlarm $valarm, | private function getRemindersForVAlarm(VAlarm $valarm, | ||||
array $objectData, | |||||
DateTimeZone $calendarTimeZone, | |||||
string $eventHash = null, | |||||
string $alarmHash = null, | |||||
bool $isRecurring = false, | |||||
bool $isRecurrenceException = false):array { | |||||
array $objectData, | |||||
DateTimeZone $calendarTimeZone, | |||||
string $eventHash = null, | |||||
string $alarmHash = null, | |||||
bool $isRecurring = false, | |||||
bool $isRecurrenceException = false):array { | |||||
if ($eventHash === null) { | if ($eventHash === null) { | ||||
$eventHash = $this->getEventHash($valarm->parent); | $eventHash = $this->getEventHash($valarm->parent); | ||||
} | } | ||||
* @param VEvent $vevent | * @param VEvent $vevent | ||||
*/ | */ | ||||
private function deleteOrProcessNext(array $reminder, | private function deleteOrProcessNext(array $reminder, | ||||
VObject\Component\VEvent $vevent):void { | |||||
VObject\Component\VEvent $vevent):void { | |||||
if ($reminder['is_repeat_based'] || | if ($reminder['is_repeat_based'] || | ||||
!$reminder['is_recurring'] || | !$reminder['is_recurring'] || | ||||
!$reminder['is_relative'] || | !$reminder['is_relative'] || | ||||
* @return VEvent|null | * @return VEvent|null | ||||
*/ | */ | ||||
private function getVEventByRecurrenceId(VObject\Component\VCalendar $vcalendar, | private function getVEventByRecurrenceId(VObject\Component\VCalendar $vcalendar, | ||||
int $recurrenceId, | |||||
bool $isRecurrenceException):?VEvent { | |||||
int $recurrenceId, | |||||
bool $isRecurrenceException):?VEvent { | |||||
$vevents = $this->getAllVEventsFromVCalendar($vcalendar); | $vevents = $this->getAllVEventsFromVCalendar($vcalendar); | ||||
if (count($vevents) === 0) { | if (count($vevents) === 0) { | ||||
return null; | return null; |
private $cuType; | private $cuType; | ||||
public function __construct(IDBConnection $dbConnection, | public function __construct(IDBConnection $dbConnection, | ||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper, | |||||
string $principalPrefix, | |||||
string $dbPrefix, | |||||
string $cuType) { | |||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper, | |||||
string $principalPrefix, | |||||
string $dbPrefix, | |||||
string $cuType) { | |||||
$this->db = $dbConnection; | $this->db = $dbConnection; | ||||
$this->userSession = $userSession; | $this->userSession = $userSession; | ||||
$this->groupManager = $groupManager; | $this->groupManager = $groupManager; | ||||
} | } | ||||
[, $name] = \Sabre\Uri\split($path); | [, $name] = \Sabre\Uri\split($path); | ||||
[$backendId, $resourceId] = explode('-', $name, 2); | |||||
[$backendId, $resourceId] = explode('-', $name, 2); | |||||
$query = $this->db->getQueryBuilder(); | $query = $this->db->getQueryBuilder(); | ||||
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname']) | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname']) | ||||
case IRoomMetadata::CAPACITY: | case IRoomMetadata::CAPACITY: | ||||
case IResourceMetadata::VEHICLE_SEATING_CAPACITY: | case IResourceMetadata::VEHICLE_SEATING_CAPACITY: | ||||
$results[] = $this->searchPrincipalsByCapacity($prop,$value); | |||||
$results[] = $this->searchPrincipalsByCapacity($prop, $value); | |||||
break; | break; | ||||
default: | default: | ||||
} | } | ||||
[, $name] = \Sabre\Uri\split($path); | [, $name] = \Sabre\Uri\split($path); | ||||
[$backendId, $resourceId] = explode('-', $name, 2); | |||||
[$backendId, $resourceId] = explode('-', $name, 2); | |||||
$query = $this->db->getQueryBuilder(); | $query = $this->db->getQueryBuilder(); | ||||
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) | $query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) |
* ResourcePrincipalBackend constructor. | * ResourcePrincipalBackend constructor. | ||||
*/ | */ | ||||
public function __construct(IDBConnection $dbConnection, | public function __construct(IDBConnection $dbConnection, | ||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper) { | |||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper) { | |||||
parent::__construct($dbConnection, $userSession, $groupManager, $logger, | parent::__construct($dbConnection, $userSession, $groupManager, $logger, | ||||
$proxyMapper, 'principals/calendar-resources', 'resource', 'RESOURCE'); | $proxyMapper, 'principals/calendar-resources', 'resource', 'RESOURCE'); | ||||
} | } |
* RoomPrincipalBackend constructor. | * RoomPrincipalBackend constructor. | ||||
*/ | */ | ||||
public function __construct(IDBConnection $dbConnection, | public function __construct(IDBConnection $dbConnection, | ||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper) { | |||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
LoggerInterface $logger, | |||||
ProxyMapper $proxyMapper) { | |||||
parent::__construct($dbConnection, $userSession, $groupManager, $logger, | parent::__construct($dbConnection, $userSession, $groupManager, $logger, | ||||
$proxyMapper, 'principals/calendar-rooms', 'room', 'ROOM'); | $proxyMapper, 'principals/calendar-rooms', 'room', 'ROOM'); | ||||
} | } |
private $calDavBackend; | private $calDavBackend; | ||||
public function __construct(IConfig $config, | public function __construct(IConfig $config, | ||||
ITimeFactory $time, | |||||
CalDavBackend $calDavBackend) { | |||||
ITimeFactory $time, | |||||
CalDavBackend $calDavBackend) { | |||||
$this->config = $config; | $this->config = $config; | ||||
$this->time = $time; | $this->time = $time; | ||||
$this->calDavBackend = $calDavBackend; | $this->calDavBackend = $calDavBackend; |
private EventComparisonService $eventComparisonService; | private EventComparisonService $eventComparisonService; | ||||
public function __construct(IConfig $config, | public function __construct(IConfig $config, | ||||
IMailer $mailer, | |||||
LoggerInterface $logger, | |||||
ITimeFactory $timeFactory, | |||||
Defaults $defaults, | |||||
IUserManager $userManager, | |||||
$userId, | |||||
IMipService $imipService, | |||||
EventComparisonService $eventComparisonService) { | |||||
IMailer $mailer, | |||||
LoggerInterface $logger, | |||||
ITimeFactory $timeFactory, | |||||
Defaults $defaults, | |||||
IUserManager $userManager, | |||||
$userId, | |||||
IMipService $imipService, | |||||
EventComparisonService $eventComparisonService) { | |||||
parent::__construct(''); | parent::__construct(''); | ||||
$this->userId = $userId; | $this->userId = $userId; | ||||
$this->config = $config; | $this->config = $config; | ||||
$itip_msg = $iTipMessage->message->serialize(); | $itip_msg = $iTipMessage->message->serialize(); | ||||
$message->attachInline( | $message->attachInline( | ||||
$itip_msg, | |||||
$itip_msg, | |||||
'event.ics', | 'event.ics', | ||||
'text/calendar; method=' . $iTipMessage->method, | |||||
'text/calendar; method=' . $iTipMessage->method, | |||||
); | ); | ||||
try { | try { |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/* | /* | ||||
* DAV App | * DAV App | ||||
]; | ]; | ||||
public function __construct(URLGenerator $urlGenerator, | public function __construct(URLGenerator $urlGenerator, | ||||
IConfig $config, | |||||
IDBConnection $db, | |||||
ISecureRandom $random, | |||||
L10NFactory $l10nFactory) { | |||||
IConfig $config, | |||||
IDBConnection $db, | |||||
ISecureRandom $random, | |||||
L10NFactory $l10nFactory) { | |||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
$this->config = $config; | $this->config = $config; | ||||
$this->db = $db; | $this->db = $db; | ||||
return $default; | return $default; | ||||
} | } | ||||
$newstring = $vevent->$property->getValue(); | $newstring = $vevent->$property->getValue(); | ||||
if(isset($oldVEvent->$property) && $oldVEvent->$property->getValue() !== $newstring ) { | |||||
if(isset($oldVEvent->$property) && $oldVEvent->$property->getValue() !== $newstring) { | |||||
$oldstring = $oldVEvent->$property->getValue(); | $oldstring = $oldVEvent->$property->getValue(); | ||||
return sprintf($strikethrough, $oldstring, $newstring); | return sprintf($strikethrough, $oldstring, $newstring); | ||||
} | } | ||||
if(!empty($oldVEvent)) { | if(!empty($oldVEvent)) { | ||||
$oldMeetingWhen = $this->generateWhenString($oldVEvent); | $oldMeetingWhen = $this->generateWhenString($oldVEvent); | ||||
$data['meeting_title_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'SUMMARY', $data['meeting_title']); | |||||
$data['meeting_title_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'SUMMARY', $data['meeting_title']); | |||||
$data['meeting_description_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'DESCRIPTION', $data['meeting_description']); | $data['meeting_description_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'DESCRIPTION', $data['meeting_description']); | ||||
$data['meeting_location_html'] = $this->generateLinkifiedDiffString($vEvent, $oldVEvent, 'LOCATION', $data['meeting_location']); | $data['meeting_location_html'] = $this->generateLinkifiedDiffString($vEvent, $oldVEvent, 'LOCATION', $data['meeting_location']); | ||||
$strikethrough = "<span style='text-decoration: line-through'>%s</span>"; | $strikethrough = "<span style='text-decoration: line-through'>%s</span>"; | ||||
$newMeetingWhen = $this->generateWhenString($vEvent); | $newMeetingWhen = $this->generateWhenString($vEvent); | ||||
$newSummary = isset($vEvent->SUMMARY) && (string)$vEvent->SUMMARY !== '' ? (string)$vEvent->SUMMARY : $this->l10n->t('Untitled event');; | |||||
$newSummary = isset($vEvent->SUMMARY) && (string)$vEvent->SUMMARY !== '' ? (string)$vEvent->SUMMARY : $this->l10n->t('Untitled event'); | |||||
; | |||||
$newDescription = isset($vEvent->DESCRIPTION) && (string)$vEvent->DESCRIPTION !== '' ? (string)$vEvent->DESCRIPTION : $defaultVal; | $newDescription = isset($vEvent->DESCRIPTION) && (string)$vEvent->DESCRIPTION !== '' ? (string)$vEvent->DESCRIPTION : $defaultVal; | ||||
$newUrl = isset($vEvent->URL) && (string)$vEvent->URL !== '' ? sprintf('<a href="%1$s">%1$s</a>', $vEvent->URL) : $defaultVal; | $newUrl = isset($vEvent->URL) && (string)$vEvent->URL !== '' ? sprintf('<a href="%1$s">%1$s</a>', $vEvent->URL) : $defaultVal; | ||||
$newLocation = isset($vEvent->LOCATION) && (string)$vEvent->LOCATION !== '' ? (string)$vEvent->LOCATION : $defaultVal; | $newLocation = isset($vEvent->LOCATION) && (string)$vEvent->LOCATION !== '' ? (string)$vEvent->LOCATION : $defaultVal; | ||||
htmlspecialchars($organizer->getNormalizedValue()), | htmlspecialchars($organizer->getNormalizedValue()), | ||||
htmlspecialchars($organizerName ?: $organizerEmail)); | htmlspecialchars($organizerName ?: $organizerEmail)); | ||||
$organizerText = sprintf('%s <%s>', $organizerName, $organizerEmail); | $organizerText = sprintf('%s <%s>', $organizerName, $organizerEmail); | ||||
if(isset($organizer['PARTSTAT']) ) { | |||||
if(isset($organizer['PARTSTAT'])) { | |||||
/** @var Parameter $partstat */ | /** @var Parameter $partstat */ | ||||
$partstat = $organizer['PARTSTAT']; | $partstat = $organizer['PARTSTAT']; | ||||
if(strcasecmp($partstat->getValue(), 'ACCEPTED') === 0) { | if(strcasecmp($partstat->getValue(), 'ACCEPTED') === 0) { |
use OCP\IConfig; | use OCP\IConfig; | ||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
use Sabre\CalDAV\ICalendar; | use Sabre\CalDAV\ICalendar; | ||||
use Sabre\CalDAV\Schedule\IOutbox; | |||||
use Sabre\DAV\INode; | use Sabre\DAV\INode; | ||||
use Sabre\DAV\IProperties; | use Sabre\DAV\IProperties; | ||||
use Sabre\DAV\PropFind; | use Sabre\DAV\PropFind; | ||||
use Sabre\DAVACL\IPrincipal; | use Sabre\DAVACL\IPrincipal; | ||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\HTTP\ResponseInterface; | use Sabre\HTTP\ResponseInterface; | ||||
use Sabre\VObject; | |||||
use Sabre\VObject\Component; | use Sabre\VObject\Component; | ||||
use Sabre\VObject\Component\VCalendar; | use Sabre\VObject\Component\VCalendar; | ||||
use Sabre\VObject\Component\VEvent; | use Sabre\VObject\Component\VEvent; |
class Status { | class Status { | ||||
public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null){} | |||||
public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null) { | |||||
} | |||||
public function getStatus(): string { | public function getStatus(): string { | ||||
return $this->status; | return $this->status; |
*/ | */ | ||||
namespace OCA\DAV\CalDAV\Status; | namespace OCA\DAV\CalDAV\Status; | ||||
use DateTimeZone; | |||||
use OC\Calendar\CalendarQuery; | use OC\Calendar\CalendarQuery; | ||||
use OCA\DAV\CalDAV\CalendarImpl; | use OCA\DAV\CalDAV\CalendarImpl; | ||||
use OCA\DAV\CalDAV\FreeBusy\FreeBusyGenerator; | use OCA\DAV\CalDAV\FreeBusy\FreeBusyGenerator; | ||||
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; | use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; | ||||
use OCA\DAV\CalDAV\IUser; | |||||
use OCA\DAV\CalDAV\Schedule\Plugin as SchedulePlugin; | use OCA\DAV\CalDAV\Schedule\Plugin as SchedulePlugin; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | use OCP\AppFramework\Utility\ITimeFactory; | ||||
use OCP\Calendar\IManager; | use OCP\Calendar\IManager; | ||||
use OCP\Calendar\ISchedulingInformation; | |||||
use OCP\IL10N; | use OCP\IL10N; | ||||
use OCP\IUser as User; | use OCP\IUser as User; | ||||
use OCP\UserStatus\IUserStatus; | use OCP\UserStatus\IUserStatus; | ||||
use Sabre\DAVACL\Exception\NeedPrivileges; | use Sabre\DAVACL\Exception\NeedPrivileges; | ||||
use Sabre\DAVACL\Plugin as AclPlugin; | use Sabre\DAVACL\Plugin as AclPlugin; | ||||
use Sabre\VObject\Component; | use Sabre\VObject\Component; | ||||
use Sabre\VObject\Component\VCalendar; | |||||
use Sabre\VObject\Component\VEvent; | use Sabre\VObject\Component\VEvent; | ||||
use Sabre\VObject\Parameter; | use Sabre\VObject\Parameter; | ||||
use Sabre\VObject\Property; | use Sabre\VObject\Property; | ||||
class StatusService { | class StatusService { | ||||
public function __construct(private ITimeFactory $timeFactory, | public function __construct(private ITimeFactory $timeFactory, | ||||
private IManager $calendarManager, | |||||
private InvitationResponseServer $server, | |||||
private IL10N $l10n, | |||||
private FreeBusyGenerator $generator){} | |||||
private IManager $calendarManager, | |||||
private InvitationResponseServer $server, | |||||
private IL10N $l10n, | |||||
private FreeBusyGenerator $generator) { | |||||
} | |||||
public function processCalendarAvailability(User $user, ?string $availability): ?Status { | public function processCalendarAvailability(User $user, ?string $availability): ?Status { | ||||
$userId = $user->getUID(); | $userId = $user->getUID(); | ||||
foreach ($calendarEvents as $calendarEvent) { | foreach ($calendarEvents as $calendarEvent) { | ||||
$vEvent = new VEvent($calendar, 'VEVENT'); | $vEvent = new VEvent($calendar, 'VEVENT'); | ||||
foreach($calendarEvent['objects'] as $component) { | foreach($calendarEvent['objects'] as $component) { | ||||
foreach ($component as $key => $value) { | |||||
foreach ($component as $key => $value) { | |||||
$vEvent->add($key, $value[0]); | $vEvent->add($key, $value[0]); | ||||
} | } | ||||
} | } |
private $calDavBackend; | private $calDavBackend; | ||||
public function __construct(string $name, | public function __construct(string $name, | ||||
array $objectData, | |||||
string $principalUri, | |||||
CalDavBackend $calDavBackend) { | |||||
array $objectData, | |||||
string $principalUri, | |||||
CalDavBackend $calDavBackend) { | |||||
$this->name = $name; | $this->name = $name; | ||||
$this->objectData = $objectData; | $this->objectData = $objectData; | ||||
$this->calDavBackend = $calDavBackend; | $this->calDavBackend = $calDavBackend; |
private $principalInfo; | private $principalInfo; | ||||
public function __construct(CalDavBackend $caldavBackend, | public function __construct(CalDavBackend $caldavBackend, | ||||
array $principalInfo) { | |||||
array $principalInfo) { | |||||
$this->caldavBackend = $caldavBackend; | $this->caldavBackend = $caldavBackend; | ||||
$this->principalInfo = $principalInfo; | $this->principalInfo = $principalInfo; | ||||
} | } |
private $server; | private $server; | ||||
public function __construct(IRequest $request, | public function __construct(IRequest $request, | ||||
RetentionService $retentionService) { | |||||
RetentionService $retentionService) { | |||||
$this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1'; | $this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1'; | ||||
$this->retentionService = $retentionService; | $this->retentionService = $retentionService; | ||||
} | } |
private $principalInfo; | private $principalInfo; | ||||
public function __construct(CalDavBackend $caldavBackend, | public function __construct(CalDavBackend $caldavBackend, | ||||
array $principalInfo) { | |||||
array $principalInfo) { | |||||
$this->caldavBackend = $caldavBackend; | $this->caldavBackend = $caldavBackend; | ||||
$this->principalInfo = $principalInfo; | $this->principalInfo = $principalInfo; | ||||
} | } |
use Sabre\VObject\Component; | use Sabre\VObject\Component; | ||||
use Sabre\VObject\DateTimeParser; | use Sabre\VObject\DateTimeParser; | ||||
use Sabre\VObject\InvalidDataException; | use Sabre\VObject\InvalidDataException; | ||||
use Sabre\VObject\Recur\NoInstancesException; | |||||
use Sabre\VObject\ParseException; | use Sabre\VObject\ParseException; | ||||
use Sabre\VObject\Reader; | use Sabre\VObject\Reader; | ||||
use Sabre\VObject\Recur\NoInstancesException; | |||||
use Sabre\VObject\Splitter\ICalendar; | use Sabre\VObject\Splitter\ICalendar; | ||||
use Sabre\VObject\UUIDUtil; | use Sabre\VObject\UUIDUtil; | ||||
use function count; | use function count; |
protected $userManager; | protected $userManager; | ||||
public function __construct(IActivityManager $activityManager, | public function __construct(IActivityManager $activityManager, | ||||
IGroupManager $groupManager, | |||||
IUserSession $userSession, | |||||
IAppManager $appManager, | |||||
IUserManager $userManager) { | |||||
IGroupManager $groupManager, | |||||
IUserSession $userSession, | |||||
IAppManager $appManager, | |||||
IUserManager $userManager) { | |||||
$this->activityManager = $activityManager; | $this->activityManager = $activityManager; | ||||
$this->groupManager = $groupManager; | $this->groupManager = $groupManager; | ||||
$this->userSession = $userSession; | $this->userSession = $userSession; |
protected $eventMerger; | protected $eventMerger; | ||||
public function __construct(IFactory $languageFactory, | public function __construct(IFactory $languageFactory, | ||||
IURLGenerator $url, | |||||
IManager $activityManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventMerger $eventMerger) { | |||||
IURLGenerator $url, | |||||
IManager $activityManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventMerger $eventMerger) { | |||||
parent::__construct($userManager, $groupManager, $url); | parent::__construct($userManager, $groupManager, $url); | ||||
$this->languageFactory = $languageFactory; | $this->languageFactory = $languageFactory; | ||||
$this->activityManager = $activityManager; | $this->activityManager = $activityManager; |
protected $url; | protected $url; | ||||
public function __construct(IUserManager $userManager, | public function __construct(IUserManager $userManager, | ||||
IGroupManager $groupManager, | |||||
IURLGenerator $urlGenerator) { | |||||
IGroupManager $groupManager, | |||||
IURLGenerator $urlGenerator) { | |||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
$this->groupManager = $groupManager; | $this->groupManager = $groupManager; | ||||
$this->url = $urlGenerator; | $this->url = $urlGenerator; |
protected $appManager; | protected $appManager; | ||||
public function __construct(IFactory $languageFactory, | public function __construct(IFactory $languageFactory, | ||||
IURLGenerator $url, | |||||
IManager $activityManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventMerger $eventMerger, | |||||
IAppManager $appManager) { | |||||
IURLGenerator $url, | |||||
IManager $activityManager, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventMerger $eventMerger, | |||||
IAppManager $appManager) { | |||||
parent::__construct($userManager, $groupManager, $url); | parent::__construct($userManager, $groupManager, $url); | ||||
$this->languageFactory = $languageFactory; | $this->languageFactory = $languageFactory; | ||||
$this->activityManager = $activityManager; | $this->activityManager = $activityManager; |
* @param IUrlGenerator $urlGenerator | * @param IUrlGenerator $urlGenerator | ||||
*/ | */ | ||||
public function __construct( | public function __construct( | ||||
AddressBook $addressBook, | |||||
array $addressBookInfo, | |||||
CardDavBackend $backend, | |||||
IURLGenerator $urlGenerator) { | |||||
AddressBook $addressBook, | |||||
array $addressBookInfo, | |||||
CardDavBackend $backend, | |||||
IURLGenerator $urlGenerator) { | |||||
$this->addressBook = $addressBook; | $this->addressBook = $addressBook; | ||||
$this->addressBookInfo = $addressBookInfo; | $this->addressBookInfo = $addressBookInfo; | ||||
$this->backend = $backend; | $this->backend = $backend; |
* @param string $principalPrefix | * @param string $principalPrefix | ||||
*/ | */ | ||||
public function __construct(\Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, | public function __construct(\Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, | ||||
\Sabre\CardDAV\Backend\BackendInterface $carddavBackend, | |||||
PluginManager $pluginManager, | |||||
?IUser $user, | |||||
?IGroupManager $groupManager, | |||||
string $principalPrefix = 'principals') { | |||||
\Sabre\CardDAV\Backend\BackendInterface $carddavBackend, | |||||
PluginManager $pluginManager, | |||||
?IUser $user, | |||||
?IGroupManager $groupManager, | |||||
string $principalPrefix = 'principals') { | |||||
parent::__construct($principalBackend, $carddavBackend, $principalPrefix); | parent::__construct($principalBackend, $carddavBackend, $principalPrefix); | ||||
$this->pluginManager = $pluginManager; | $this->pluginManager = $pluginManager; | ||||
$this->user = $user; | $this->user = $user; |
*/ | */ | ||||
namespace OCA\DAV\CardDAV; | namespace OCA\DAV\CardDAV; | ||||
class Card extends \Sabre\CardDAV\Card | |||||
{ | |||||
class Card extends \Sabre\CardDAV\Card { | |||||
public function getId(): int { | public function getId(): int { | ||||
return (int) $this->cardData['id']; | return (int) $this->cardData['id']; | ||||
} | } |
*/ | */ | ||||
namespace OCA\DAV\CardDAV; | namespace OCA\DAV\CardDAV; | ||||
use OC\Search\Filter\DateTimeFilter; | |||||
use OCA\DAV\Connector\Sabre\Principal; | use OCA\DAV\Connector\Sabre\Principal; | ||||
use OCA\DAV\DAV\Sharing\Backend; | use OCA\DAV\DAV\Sharing\Backend; | ||||
use OCA\DAV\DAV\Sharing\IShareable; | use OCA\DAV\DAV\Sharing\IShareable; | ||||
use OCP\IDBConnection; | use OCP\IDBConnection; | ||||
use OCP\IGroupManager; | use OCP\IGroupManager; | ||||
use OCP\IUserManager; | use OCP\IUserManager; | ||||
use OC\Search\Filter\DateTimeFilter; | |||||
use PDO; | use PDO; | ||||
use Sabre\CardDAV\Backend\BackendInterface; | use Sabre\CardDAV\Backend\BackendInterface; | ||||
use Sabre\CardDAV\Backend\SyncSupport; | use Sabre\CardDAV\Backend\SyncSupport; | ||||
* @param IEventDispatcher $dispatcher | * @param IEventDispatcher $dispatcher | ||||
*/ | */ | ||||
public function __construct(IDBConnection $db, | public function __construct(IDBConnection $db, | ||||
Principal $principalBackend, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventDispatcher $dispatcher) { | |||||
Principal $principalBackend, | |||||
IUserManager $userManager, | |||||
IGroupManager $groupManager, | |||||
IEventDispatcher $dispatcher) { | |||||
$this->db = $db; | $this->db = $db; | ||||
$this->principalBackend = $principalBackend; | $this->principalBackend = $principalBackend; | ||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
public function searchPrincipalUri(string $principalUri, | public function searchPrincipalUri(string $principalUri, | ||||
string $pattern, | |||||
array $searchProperties, | |||||
array $options = []): array { | |||||
string $pattern, | |||||
array $searchProperties, | |||||
array $options = []): array { | |||||
return $this->atomic(function () use ($principalUri, $pattern, $searchProperties, $options) { | return $this->atomic(function () use ($principalUri, $pattern, $searchProperties, $options) { | ||||
$addressBookIds = array_map(static function ($row):int { | $addressBookIds = array_map(static function ($row):int { | ||||
return (int) $row['id']; | return (int) $row['id']; | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
private function searchByAddressBookIds(array $addressBookIds, | private function searchByAddressBookIds(array $addressBookIds, | ||||
string $pattern, | |||||
array $searchProperties, | |||||
array $options = []): array { | |||||
string $pattern, | |||||
array $searchProperties, | |||||
array $options = []): array { | |||||
if (empty($addressBookIds)) { | if (empty($addressBookIds)) { | ||||
return []; | return []; | ||||
} | } |
use Exception; | use Exception; | ||||
use OCP\Accounts\IAccountManager; | use OCP\Accounts\IAccountManager; | ||||
use OCP\IURLGenerator; | |||||
use OCP\IImage; | use OCP\IImage; | ||||
use OCP\IURLGenerator; | |||||
use OCP\IUser; | use OCP\IUser; | ||||
use OCP\IUserManager; | use OCP\IUserManager; | ||||
use Sabre\VObject\Component\VCard; | use Sabre\VObject\Component\VCard; |
use OCP\Files\NotPermittedException; | use OCP\Files\NotPermittedException; | ||||
use OCP\Files\SimpleFS\ISimpleFile; | use OCP\Files\SimpleFS\ISimpleFile; | ||||
use OCP\Files\SimpleFS\ISimpleFolder; | use OCP\Files\SimpleFS\ISimpleFolder; | ||||
use Psr\Log\LoggerInterface; | |||||
use Sabre\CardDAV\Card; | use Sabre\CardDAV\Card; | ||||
use Sabre\VObject\Document; | use Sabre\VObject\Document; | ||||
use Sabre\VObject\Parameter; | use Sabre\VObject\Parameter; | ||||
use Sabre\VObject\Property\Binary; | use Sabre\VObject\Property\Binary; | ||||
use Sabre\VObject\Reader; | use Sabre\VObject\Reader; | ||||
use Psr\Log\LoggerInterface; | |||||
class PhotoCache { | class PhotoCache { | ||||
*/ | */ | ||||
namespace OCA\DAV\CardDAV; | namespace OCA\DAV\CardDAV; | ||||
use OC\Accounts\AccountManager; | |||||
use OCP\AppFramework\Db\TTransactional; | use OCP\AppFramework\Db\TTransactional; | ||||
use OCP\AppFramework\Http; | use OCP\AppFramework\Http; | ||||
use OCP\IDBConnection; | use OCP\IDBConnection; | ||||
protected string $certPath; | protected string $certPath; | ||||
public function __construct(CardDavBackend $backend, | public function __construct(CardDavBackend $backend, | ||||
IUserManager $userManager, | |||||
IDBConnection $dbConnection, | |||||
LoggerInterface $logger, | |||||
Converter $converter) { | |||||
IUserManager $userManager, | |||||
IDBConnection $dbConnection, | |||||
LoggerInterface $logger, | |||||
Converter $converter) { | |||||
$this->backend = $backend; | $this->backend = $backend; | ||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
$this->logger = $logger; | $this->logger = $logger; | ||||
$cardUri = basename($resource); | $cardUri = basename($resource); | ||||
if (isset($status[200])) { | if (isset($status[200])) { | ||||
$vCard = $this->download($url, $userName, $sharedSecret, $resource); | $vCard = $this->download($url, $userName, $sharedSecret, $resource); | ||||
$this->atomic(function() use ($addressBookId, $cardUri, $vCard) { | |||||
$this->atomic(function () use ($addressBookId, $cardUri, $vCard) { | |||||
$existingCard = $this->backend->getCard($addressBookId, $cardUri); | $existingCard = $this->backend->getCard($addressBookId, $cardUri); | ||||
if ($existingCard === false) { | if ($existingCard === false) { | ||||
$this->backend->createCard($addressBookId, $cardUri, $vCard['body']); | $this->backend->createCard($addressBookId, $cardUri, $vCard['body']); | ||||
* @throws \Sabre\DAV\Exception\BadRequest | * @throws \Sabre\DAV\Exception\BadRequest | ||||
*/ | */ | ||||
public function ensureSystemAddressBookExists(string $principal, string $uri, array $properties): ?array { | public function ensureSystemAddressBookExists(string $principal, string $uri, array $properties): ?array { | ||||
return $this->atomic(function() use ($principal, $uri, $properties) { | |||||
return $this->atomic(function () use ($principal, $uri, $properties) { | |||||
$book = $this->backend->getAddressBooksByUri($principal, $uri); | $book = $this->backend->getAddressBooksByUri($principal, $uri); | ||||
if (!is_null($book)) { | if (!is_null($book)) { | ||||
return $book; | return $book; | ||||
$cardId = self::getCardUri($user); | $cardId = self::getCardUri($user); | ||||
if ($user->isEnabled()) { | if ($user->isEnabled()) { | ||||
$this->atomic(function() use ($addressBookId, $cardId, $user) { | |||||
$this->atomic(function () use ($addressBookId, $cardId, $user) { | |||||
$card = $this->backend->getCard($addressBookId, $cardId); | $card = $this->backend->getCard($addressBookId, $cardId); | ||||
if ($card === false) { | if ($card === false) { | ||||
$vCard = $this->converter->createCardFromUser($user); | $vCard = $this->converter->createCardFromUser($user); |
use OCP\IL10N; | use OCP\IL10N; | ||||
use OCP\IRequest; | use OCP\IRequest; | ||||
use OCP\IUserSession; | use OCP\IUserSession; | ||||
use Sabre\CardDAV\Backend\SyncSupport; | |||||
use Sabre\CardDAV\Backend\BackendInterface; | use Sabre\CardDAV\Backend\BackendInterface; | ||||
use Sabre\CardDAV\Backend\SyncSupport; | |||||
use Sabre\CardDAV\Card; | use Sabre\CardDAV\Card; | ||||
use Sabre\DAV\Exception\Forbidden; | use Sabre\DAV\Exception\Forbidden; | ||||
use Sabre\DAV\Exception\NotFound; | use Sabre\DAV\Exception\NotFound; |
namespace OCA\DAV\CardDAV; | namespace OCA\DAV\CardDAV; | ||||
use OCA\DAV\AppInfo\PluginManager; | use OCA\DAV\AppInfo\PluginManager; | ||||
use OCA\DAV\CardDAV\Integration\IAddressBookProvider; | |||||
use OCA\DAV\CardDAV\Integration\ExternalAddressBook; | use OCA\DAV\CardDAV\Integration\ExternalAddressBook; | ||||
use OCA\DAV\CardDAV\Integration\IAddressBookProvider; | |||||
use OCA\Federation\TrustedServers; | use OCA\Federation\TrustedServers; | ||||
use OCP\AppFramework\QueryException; | use OCP\AppFramework\QueryException; | ||||
use OCP\IConfig; | use OCP\IConfig; | ||||
use Psr\Container\ContainerExceptionInterface; | use Psr\Container\ContainerExceptionInterface; | ||||
use Psr\Container\NotFoundExceptionInterface; | use Psr\Container\NotFoundExceptionInterface; | ||||
use Sabre\CardDAV\Backend; | use Sabre\CardDAV\Backend; | ||||
use Sabre\DAV\Exception\MethodNotAllowed; | |||||
use Sabre\CardDAV\IAddressBook; | use Sabre\CardDAV\IAddressBook; | ||||
use function array_map; | |||||
use Sabre\DAV\Exception\MethodNotAllowed; | |||||
use Sabre\DAV\MkCol; | use Sabre\DAV\MkCol; | ||||
use function array_map; | |||||
class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { | class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { | ||||
/** @var IL10N */ | /** @var IL10N */ | ||||
private ?IGroupManager $groupManager; | private ?IGroupManager $groupManager; | ||||
public function __construct(Backend\BackendInterface $carddavBackend, | public function __construct(Backend\BackendInterface $carddavBackend, | ||||
string $principalUri, | |||||
PluginManager $pluginManager, | |||||
?IUser $user, | |||||
?IGroupManager $groupManager) { | |||||
string $principalUri, | |||||
PluginManager $pluginManager, | |||||
?IUser $user, | |||||
?IGroupManager $groupManager) { | |||||
parent::__construct($carddavBackend, $principalUri); | parent::__construct($carddavBackend, $principalUri); | ||||
$this->pluginManager = $pluginManager; | $this->pluginManager = $pluginManager; | ||||
$this->user = $user; | $this->user = $user; |
->setName('dav:create-addressbook') | ->setName('dav:create-addressbook') | ||||
->setDescription('Create a dav addressbook') | ->setDescription('Create a dav addressbook') | ||||
->addArgument('user', | ->addArgument('user', | ||||
InputArgument::REQUIRED, | |||||
'User for whom the addressbook will be created') | |||||
InputArgument::REQUIRED, | |||||
'User for whom the addressbook will be created') | |||||
->addArgument('name', | ->addArgument('name', | ||||
InputArgument::REQUIRED, | |||||
'Name of the addressbook'); | |||||
InputArgument::REQUIRED, | |||||
'Name of the addressbook'); | |||||
} | } | ||||
protected function execute(InputInterface $input, OutputInterface $output): int { | protected function execute(InputInterface $input, OutputInterface $output): int { |
throw new BadRequest('Invalid input values', 0, $e); | throw new BadRequest('Invalid input values', 0, $e); | ||||
} catch (\OCP\Comments\MessageTooLongException $e) { | } catch (\OCP\Comments\MessageTooLongException $e) { | ||||
$msg = 'Message exceeds allowed character limit of '; | $msg = 'Message exceeds allowed character limit of '; | ||||
throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e); | |||||
throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e); | |||||
} | } | ||||
} | } | ||||
} | } |
private IThrottler $throttler; | private IThrottler $throttler; | ||||
public function __construct(IRequest $request, | public function __construct(IRequest $request, | ||||
IManager $shareManager, | |||||
ISession $session, | |||||
IThrottler $throttler) { | |||||
IManager $shareManager, | |||||
ISession $session, | |||||
IThrottler $throttler) { | |||||
$this->request = $request; | $this->request = $request; | ||||
$this->shareManager = $shareManager; | $this->shareManager = $shareManager; | ||||
$this->session = $session; | $this->session = $session; |
private $isMacOSDavAgent = false; | private $isMacOSDavAgent = false; | ||||
/** | /** | ||||
* Sets up the plugin. | |||||
* | |||||
* This method is automatically called by the server class. | |||||
* Sets up the plugin. | |||||
* | |||||
* This method is automatically called by the server class. | |||||
* | * | ||||
* @return void | * @return void | ||||
*/ | |||||
public function initialize(Server $server) | |||||
{ | |||||
*/ | |||||
public function initialize(Server $server) { | |||||
$server->on('beforeMethod:REPORT', [$this, 'beforeReport'], 0); | $server->on('beforeMethod:REPORT', [$this, 'beforeReport'], 0); | ||||
$server->on('report', [$this, 'report'], 0); | $server->on('report', [$this, 'report'], 0); | ||||
} | } | ||||
/** | /** | ||||
* Triggered before any method is handled. | |||||
* Triggered before any method is handled. | |||||
* | * | ||||
* @return void | * @return void | ||||
*/ | |||||
public function beforeReport(RequestInterface $request, ResponseInterface $response) | |||||
{ | |||||
*/ | |||||
public function beforeReport(RequestInterface $request, ResponseInterface $response) { | |||||
$userAgent = $request->getRawServerValue('HTTP_USER_AGENT') ?? 'unknown'; | $userAgent = $request->getRawServerValue('HTTP_USER_AGENT') ?? 'unknown'; | ||||
$this->isMacOSDavAgent = $this->isMacOSUserAgent($userAgent); | $this->isMacOSDavAgent = $this->isMacOSUserAgent($userAgent); | ||||
} | } | ||||
/** | /** | ||||
* This method handles HTTP REPORT requests. | |||||
* | |||||
* @param string $reportName | |||||
* @param mixed $report | |||||
* @param mixed $path | |||||
* This method handles HTTP REPORT requests. | |||||
* | |||||
* @param string $reportName | |||||
* @param mixed $report | |||||
* @param mixed $path | |||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | |||||
public function report($reportName, $report, $path) | |||||
{ | |||||
*/ | |||||
public function report($reportName, $report, $path) { | |||||
if ($reportName == '{DAV:}principal-property-search' && $this->isMacOSDavAgent) { | if ($reportName == '{DAV:}principal-property-search' && $this->isMacOSDavAgent) { | ||||
/** @var \Sabre\DAVACL\Xml\Request\PrincipalPropertySearchReport $report */ | /** @var \Sabre\DAVACL\Xml\Request\PrincipalPropertySearchReport $report */ | ||||
$report->applyToPrincipalCollectionSet = true; | $report->applyToPrincipalCollectionSet = true; | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
protected function isMacOSUserAgent(string $userAgent):bool | |||||
{ | |||||
protected function isMacOSUserAgent(string $userAgent):bool { | |||||
return str_starts_with(self::OSX_AGENT_PREFIX, $userAgent); | return str_starts_with(self::OSX_AGENT_PREFIX, $userAgent); | ||||
} | } | ||||
* | * | ||||
* @return null|array | * @return null|array | ||||
*/ | */ | ||||
protected function decodeMacOSAgentString(string $userAgent):?array | |||||
{ | |||||
protected function decodeMacOSAgentString(string $userAgent):?array { | |||||
// OSX agent string is like: macOS/13.2.1 (22D68) dataaccessd/1.0 | // OSX agent string is like: macOS/13.2.1 (22D68) dataaccessd/1.0 | ||||
if (preg_match('|^' . self::OSX_AGENT_PREFIX . '/([0-9]+)\\.([0-9]+)\\.([0-9]+)\s+\((\w+)\)\s+([^/]+)/([0-9]+)(?:\\.([0-9]+))?(?:\\.([0-9]+))?$|i', $userAgent, $matches)) { | if (preg_match('|^' . self::OSX_AGENT_PREFIX . '/([0-9]+)\\.([0-9]+)\\.([0-9]+)\s+\((\w+)\)\s+([^/]+)/([0-9]+)(?:\\.([0-9]+))?(?:\\.([0-9]+))?$|i', $userAgent, $matches)) { | ||||
return [ | return [ |
private IThrottler $throttler; | private IThrottler $throttler; | ||||
public function __construct(ISession $session, | public function __construct(ISession $session, | ||||
Session $userSession, | |||||
IRequest $request, | |||||
Manager $twoFactorManager, | |||||
IThrottler $throttler, | |||||
string $principalPrefix = 'principals/users/') { | |||||
Session $userSession, | |||||
IRequest $request, | |||||
Manager $twoFactorManager, | |||||
IThrottler $throttler, | |||||
string $principalPrefix = 'principals/users/') { | |||||
$this->session = $session; | $this->session = $session; | ||||
$this->userSession = $userSession; | $this->userSession = $userSession; | ||||
$this->twoFactorManager = $twoFactorManager; | $this->twoFactorManager = $twoFactorManager; | ||||
if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) { | if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) { | ||||
// do not re-authenticate over ajax, use dummy auth name to prevent browser popup | // do not re-authenticate over ajax, use dummy auth name to prevent browser popup | ||||
$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"'); | |||||
$response->addHeader('WWW-Authenticate', 'DummyBasic realm="' . $this->realm . '"'); | |||||
$response->setStatus(401); | $response->setStatus(401); | ||||
throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls'); | throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls'); | ||||
} | } |
private string $principalPrefix; | private string $principalPrefix; | ||||
public function __construct(IUserSession $userSession, | public function __construct(IUserSession $userSession, | ||||
ISession $session, | |||||
IRequest $request, | |||||
$principalPrefix = 'principals/users/') { | |||||
ISession $session, | |||||
IRequest $request, | |||||
$principalPrefix = 'principals/users/') { | |||||
$this->userSession = $userSession; | $this->userSession = $userSession; | ||||
$this->session = $session; | $this->session = $session; | ||||
$this->request = $request; | $this->request = $request; |
use OCP\IConfig; | use OCP\IConfig; | ||||
use OCP\IRequest; | use OCP\IRequest; | ||||
use Sabre\DAV\Server; | |||||
use Sabre\DAV\ServerPlugin; | use Sabre\DAV\ServerPlugin; | ||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\DAV\Server; | |||||
/** | /** | ||||
* Class BlockLegacyClientPlugin is used to detect old legacy sync clients and | * Class BlockLegacyClientPlugin is used to detect old legacy sync clients and |
namespace OCA\DAV\Connector\Sabre; | namespace OCA\DAV\Connector\Sabre; | ||||
use Sabre\DAV\Server; | |||||
use Sabre\DAV\ServerPlugin; | use Sabre\DAV\ServerPlugin; | ||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\HTTP\ResponseInterface; | use Sabre\HTTP\ResponseInterface; | ||||
use Sabre\DAV\Server; | |||||
class ChecksumUpdatePlugin extends ServerPlugin { | class ChecksumUpdatePlugin extends ServerPlugin { | ||||
protected ?Server $server = null; | protected ?Server $server = null; |
<?php | <?php | ||||
declare(strict_types=1); | declare(strict_types=1); | ||||
/** | /** | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | * @copyright Copyright (c) 2016, ownCloud, Inc. | ||||
use OCP\Comments\ICommentsManager; | use OCP\Comments\ICommentsManager; | ||||
use OCP\IUserSession; | use OCP\IUserSession; | ||||
use Sabre\DAV\PropFind; | use Sabre\DAV\PropFind; | ||||
use Sabre\DAV\ServerPlugin; | |||||
use Sabre\DAV\Server; | use Sabre\DAV\Server; | ||||
use Sabre\DAV\ServerPlugin; | |||||
class CommentPropertiesPlugin extends ServerPlugin { | class CommentPropertiesPlugin extends ServerPlugin { | ||||
public const PROPERTY_NAME_HREF = '{http://owncloud.org/ns}comments-href'; | public const PROPERTY_NAME_HREF = '{http://owncloud.org/ns}comments-href'; |
namespace OCA\DAV\Connector\Sabre; | namespace OCA\DAV\Connector\Sabre; | ||||
use Sabre\DAV\Exception\NotFound; | use Sabre\DAV\Exception\NotFound; | ||||
use Sabre\DAV\Server; | |||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\HTTP\ResponseInterface; | use Sabre\HTTP\ResponseInterface; | ||||
use Sabre\DAV\Server; | |||||
/** | /** | ||||
* Copies the "Etag" header to "OC-Etag" after any request. | * Copies the "Etag" header to "OC-Etag" after any request. |
use OCP\L10N\IFactory; | use OCP\L10N\IFactory; | ||||
use OCP\Lock\ILockingProvider; | use OCP\Lock\ILockingProvider; | ||||
use OCP\Lock\LockedException; | use OCP\Lock\LockedException; | ||||
use OCP\Share\IManager as IShareManager; | |||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
use Sabre\DAV\Exception\BadRequest; | use Sabre\DAV\Exception\BadRequest; | ||||
use Sabre\DAV\Exception\Locked; | use Sabre\DAV\Exception\Locked; | ||||
use Sabre\DAV\Exception\ServiceUnavailable; | use Sabre\DAV\Exception\ServiceUnavailable; | ||||
use Sabre\DAV\IFile; | use Sabre\DAV\IFile; | ||||
use Sabre\DAV\INode; | use Sabre\DAV\INode; | ||||
use OCP\Share\IManager as IShareManager; | |||||
class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget { | class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget { | ||||
/** | /** |
*/ | */ | ||||
namespace OCA\DAV\Connector\Sabre; | namespace OCA\DAV\Connector\Sabre; | ||||
use Sabre\DAV\Server; | |||||
use Sabre\HTTP\RequestInterface; | use Sabre\HTTP\RequestInterface; | ||||
use Sabre\HTTP\ResponseInterface; | use Sabre\HTTP\ResponseInterface; | ||||
use Sabre\DAV\Server; | |||||
/** | /** | ||||
* Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented" | * Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented" | ||||
public function httpGet(RequestInterface $request, ResponseInterface $response) { | public function httpGet(RequestInterface $request, ResponseInterface $response) { | ||||
$string = 'This is the WebDAV interface. It can only be accessed by ' . | $string = 'This is the WebDAV interface. It can only be accessed by ' . | ||||
'WebDAV clients such as the Nextcloud desktop sync client.'; | 'WebDAV clients such as the Nextcloud desktop sync client.'; | ||||
$stream = fopen('php://memory','r+'); | |||||
$stream = fopen('php://memory', 'r+'); | |||||
fwrite($stream, $string); | fwrite($stream, $string); | ||||
rewind($stream); | rewind($stream); | ||||
* @param \DOMElement $errorNode | * @param \DOMElement $errorNode | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { | |||||
public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { | |||||
// set ownCloud namespace | // set ownCloud namespace | ||||
$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); | $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); | ||||
// adding the retry node | // adding the retry node | ||||
$error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); | |||||
$error = $errorNode->ownerDocument->createElementNS('o:', 'o:retry', var_export($this->retry, true)); | |||||
$errorNode->appendChild($error); | $errorNode->appendChild($error); | ||||
// adding the message node | // adding the message node | ||||
$error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); | |||||
$error = $errorNode->ownerDocument->createElementNS('o:', 'o:reason', $this->getMessage()); | |||||
$errorNode->appendChild($error); | $errorNode->appendChild($error); | ||||
} | } | ||||
} | } |
* @param \DOMElement $errorNode | * @param \DOMElement $errorNode | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { | |||||
public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { | |||||
// set ownCloud namespace | // set ownCloud namespace | ||||
$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); | $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); | ||||
// adding the retry node | // adding the retry node | ||||
$error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); | |||||
$error = $errorNode->ownerDocument->createElementNS('o:', 'o:retry', var_export($this->retry, true)); | |||||
$errorNode->appendChild($error); | $errorNode->appendChild($error); | ||||
// adding the message node | // adding the message node | ||||
$error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); | |||||
$error = $errorNode->ownerDocument->createElementNS('o:', 'o:reason', $this->getMessage()); | |||||
$errorNode->appendChild($error); | $errorNode->appendChild($error); | ||||
} | } | ||||
} | } |
use Sabre\DAV\Exception\NotImplemented; | use Sabre\DAV\Exception\NotImplemented; | ||||
use Sabre\DAV\Exception\PreconditionFailed; | use Sabre\DAV\Exception\PreconditionFailed; | ||||
use Sabre\DAV\Exception\RequestedRangeNotSatisfiable; | use Sabre\DAV\Exception\RequestedRangeNotSatisfiable; | ||||
use Sabre\DAV\Exception\ServiceUnavailable; | |||||
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { | class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { | ||||
protected $nonFatalExceptions = [ | protected $nonFatalExceptions = [ |
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function fakeLockProvider(RequestInterface $request, | public function fakeLockProvider(RequestInterface $request, | ||||
ResponseInterface $response) { | |||||
ResponseInterface $response) { | |||||
$lockInfo = new LockInfo(); | $lockInfo = new LockInfo(); | ||||
$lockInfo->token = md5($request->getPath()); | $lockInfo->token = md5($request->getPath()); | ||||
$lockInfo->uri = $request->getPath(); | $lockInfo->uri = $request->getPath(); | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function fakeUnlockProvider(RequestInterface $request, | public function fakeUnlockProvider(RequestInterface $request, | ||||
ResponseInterface $response) { | |||||
ResponseInterface $response) { | |||||
$response->setStatus(204); | $response->setStatus(204); | ||||
$response->setHeader('Content-Length', '0'); | $response->setHeader('Content-Length', '0'); | ||||
return false; | return false; |
private IPreview $previewManager; | private IPreview $previewManager; | ||||
public function __construct(Tree $tree, | public function __construct(Tree $tree, | ||||
IConfig $config, | |||||
IRequest $request, | |||||
IPreview $previewManager, | |||||
IUserSession $userSession, | |||||
bool $isPublic = false, | |||||
bool $downloadAttachment = true) { | |||||
IConfig $config, | |||||
IRequest $request, | |||||
IPreview $previewManager, | |||||
IUserSession $userSession, | |||||
bool $isPublic = false, | |||||
bool $downloadAttachment = true) { | |||||
$this->tree = $tree; | $this->tree = $tree; | ||||
$this->config = $config; | $this->config = $config; | ||||
$this->request = $request; | $this->request = $request; |
* @param IAppManager $appManager | * @param IAppManager $appManager | ||||
*/ | */ | ||||
public function __construct(Tree $tree, | public function __construct(Tree $tree, | ||||
View $view, | |||||
ISystemTagManager $tagManager, | |||||
ISystemTagObjectMapper $tagMapper, | |||||
ITagManager $fileTagger, | |||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
Folder $userFolder, | |||||
IAppManager $appManager | |||||
View $view, | |||||
ISystemTagManager $tagManager, | |||||
ISystemTagObjectMapper $tagMapper, | |||||
ITagManager $fileTagger, | |||||
IUserSession $userSession, | |||||
IGroupManager $groupManager, | |||||
Folder $userFolder, | |||||
IAppManager $appManager | |||||
) { | ) { | ||||
$this->tree = $tree; | $this->tree = $tree; | ||||
$this->fileView = $view; | $this->fileView = $view; |
private $languageFactory; | private $languageFactory; | ||||
public function __construct(IUserManager $userManager, | public function __construct(IUserManager $userManager, | ||||
IGroupManager $groupManager, | |||||
IAccountManager $accountManager, | |||||
IShareManager $shareManager, | |||||
IUserSession $userSession, | |||||
IAppManager $appManager, | |||||
ProxyMapper $proxyMapper, | |||||
KnownUserService $knownUserService, | |||||
IConfig $config, | |||||
IFactory $languageFactory, | |||||
string $principalPrefix = 'principals/users/') { | |||||
IGroupManager $groupManager, | |||||
IAccountManager $accountManager, | |||||
IShareManager $shareManager, | |||||
IUserSession $userSession, | |||||
IAppManager $appManager, | |||||
ProxyMapper $proxyMapper, | |||||
KnownUserService $knownUserService, | |||||
IConfig $config, | |||||
IFactory $languageFactory, | |||||
string $principalPrefix = 'principals/users/') { | |||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
$this->groupManager = $groupManager; | $this->groupManager = $groupManager; | ||||
$this->accountManager = $accountManager; | $this->accountManager = $accountManager; |
<?php declare(strict_types=1); | |||||
<?php | |||||
declare(strict_types=1); | |||||
/** | /** | ||||
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl> | * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl> | ||||
* | * |
*/ | */ | ||||
namespace OCA\DAV\Connector\Sabre; | namespace OCA\DAV\Connector\Sabre; | ||||
use OCP\EventDispatcher\IEventDispatcher; | |||||
use OCP\Files\Folder; | |||||
use OCA\DAV\AppInfo\PluginManager; | use OCA\DAV\AppInfo\PluginManager; | ||||
use OCA\DAV\DAV\ViewOnlyPlugin; | use OCA\DAV\DAV\ViewOnlyPlugin; | ||||
use OCA\DAV\Files\BrowserErrorPagePlugin; | use OCA\DAV\Files\BrowserErrorPagePlugin; | ||||
use OCP\EventDispatcher\IEventDispatcher; | |||||
use OCP\Files\Folder; | |||||
use OCP\Files\Mount\IMountManager; | use OCP\Files\Mount\IMountManager; | ||||
use OCP\IConfig; | use OCP\IConfig; | ||||
use OCP\IDBConnection; | use OCP\IDBConnection; | ||||
* @param callable $viewCallBack callback that should return the view for the dav endpoint | * @param callable $viewCallBack callback that should return the view for the dav endpoint | ||||
*/ | */ | ||||
public function createServer(string $baseUri, | public function createServer(string $baseUri, | ||||
string $requestUri, | |||||
Plugin $authPlugin, | |||||
callable $viewCallBack): Server { | |||||
string $requestUri, | |||||
Plugin $authPlugin, | |||||
callable $viewCallBack): Server { | |||||
// Fire up server | // Fire up server | ||||
$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree(); | $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree(); | ||||
$server = new \OCA\DAV\Connector\Sabre\Server($objectTree); | $server = new \OCA\DAV\Connector\Sabre\Server($objectTree); |
use OCP\Files\Node; | use OCP\Files\Node; | ||||
use OCP\Files\NotFoundException; | use OCP\Files\NotFoundException; | ||||
use OCP\IUserSession; | use OCP\IUserSession; | ||||
use OCP\Share\IShare; | |||||
use OCP\Share\IManager; | use OCP\Share\IManager; | ||||
use OCP\Share\IShare; | |||||
use Sabre\DAV\PropFind; | use Sabre\DAV\PropFind; | ||||
use Sabre\DAV\Tree; | |||||
use Sabre\DAV\Server; | use Sabre\DAV\Server; | ||||
use Sabre\DAV\Tree; | |||||
/** | /** | ||||
* Sabre Plugin to provide share-related properties | * Sabre Plugin to provide share-related properties |
&& $propFind->getDepth() !== 0 | && $propFind->getDepth() !== 0 | ||||
&& (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) | && (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) | ||||
|| !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)) | || !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)) | ||||
)) { | |||||
)) { | |||||
// note: pre-fetching only supported for depth <= 1 | // note: pre-fetching only supported for depth <= 1 | ||||
$folderContent = $node->getChildren(); | $folderContent = $node->getChildren(); | ||||
$fileIds[] = (int)$node->getId(); | $fileIds[] = (int)$node->getId(); |
* @param CalDavBackend $calDavBackend | * @param CalDavBackend $calDavBackend | ||||
*/ | */ | ||||
public function __construct($appName, IRequest $request, | public function __construct($appName, IRequest $request, | ||||
IDBConnection $db, IConfig $config, | |||||
IJobList $jobList, | |||||
IUserManager $userManager, | |||||
CalDavBackend $calDavBackend) { | |||||
IDBConnection $db, IConfig $config, | |||||
IJobList $jobList, | |||||
IUserManager $userManager, | |||||
CalDavBackend $calDavBackend) { | |||||
parent::__construct($appName, $request); | parent::__construct($appName, $request); | ||||
$this->db = $db; | $this->db = $db; | ||||
$this->config = $config; | $this->config = $config; |
use OCP\AppFramework\Http; | use OCP\AppFramework\Http; | ||||
use OCP\AppFramework\Http\DataResponse; | use OCP\AppFramework\Http\DataResponse; | ||||
use OCP\AppFramework\OCS\OCSBadRequestException; | use OCP\AppFramework\OCS\OCSBadRequestException; | ||||
use OCP\AppFramework\OCS\OCSNotFoundException; | |||||
use OCP\AppFramework\OCS\OCSForbiddenException; | use OCP\AppFramework\OCS\OCSForbiddenException; | ||||
use OCP\AppFramework\OCS\OCSNotFoundException; | |||||
use OCP\AppFramework\OCSController; | use OCP\AppFramework\OCSController; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | use OCP\AppFramework\Utility\ITimeFactory; | ||||
use OCP\EventDispatcher\GenericEvent; | |||||
use OCP\EventDispatcher\IEventDispatcher; | use OCP\EventDispatcher\IEventDispatcher; | ||||
use OCP\Files\Events\BeforeDirectFileDownloadEvent; | use OCP\Files\Events\BeforeDirectFileDownloadEvent; | ||||
use OCP\Files\File; | use OCP\Files\File; | ||||
private $eventDispatcher; | private $eventDispatcher; | ||||
public function __construct(string $appName, | public function __construct(string $appName, | ||||
IRequest $request, | |||||
IRootFolder $rootFolder, | |||||
string $userId, | |||||
DirectMapper $mapper, | |||||
ISecureRandom $random, | |||||
ITimeFactory $timeFactory, | |||||
IURLGenerator $urlGenerator, | |||||
IEventDispatcher $eventDispatcher) { | |||||
IRequest $request, | |||||
IRootFolder $rootFolder, | |||||
string $userId, | |||||
DirectMapper $mapper, | |||||
ISecureRandom $random, | |||||
ITimeFactory $timeFactory, | |||||
IURLGenerator $urlGenerator, | |||||
IEventDispatcher $eventDispatcher) { | |||||
parent::__construct($appName, $request); | parent::__construct($appName, $request); | ||||
$this->rootFolder = $rootFolder; | $this->rootFolder = $rootFolder; |
* @param InvitationResponseServer $responseServer | * @param InvitationResponseServer $responseServer | ||||
*/ | */ | ||||
public function __construct(string $appName, IRequest $request, | public function __construct(string $appName, IRequest $request, | ||||
IDBConnection $db, ITimeFactory $timeFactory, | |||||
InvitationResponseServer $responseServer) { | |||||
IDBConnection $db, ITimeFactory $timeFactory, | |||||
InvitationResponseServer $responseServer) { | |||||
parent::__construct($appName, $request); | parent::__construct($appName, $request); | ||||
$this->db = $db; | $this->db = $db; | ||||
$this->timeFactory = $timeFactory; | $this->timeFactory = $timeFactory; |
* @return array | * @return array | ||||
*/ | */ | ||||
public function getPrincipalByPath($path) { | public function getPrincipalByPath($path) { | ||||
$elements = explode('/', $path, 3); | |||||
$elements = explode('/', $path, 3); | |||||
if ($elements[0] !== 'principals') { | if ($elements[0] !== 'principals') { | ||||
return null; | return null; | ||||
} | } |
use OCA\DAV\Connector\Sabre\Principal; | use OCA\DAV\Connector\Sabre\Principal; | ||||
use OCP\AppFramework\Db\TTransactional; | use OCP\AppFramework\Db\TTransactional; | ||||
use OCP\Cache\CappedMemoryCache; | use OCP\Cache\CappedMemoryCache; | ||||
use OCP\DB\QueryBuilder\IQueryBuilder; | |||||
use OCP\IDBConnection; | use OCP\IDBConnection; | ||||
use OCP\IGroupManager; | use OCP\IGroupManager; | ||||
use OCP\IUserManager; | use OCP\IUserManager; | ||||
use OCP\DB\QueryBuilder\IQueryBuilder; | |||||
class Backend { | class Backend { | ||||
use TTransactional; | use TTransactional; | ||||
} | } | ||||
public function preloadShares(array $resourceIds): void { | public function preloadShares(array $resourceIds): void { | ||||
$resourceIds = array_filter($resourceIds, function(int $resourceId) { | |||||
$resourceIds = array_filter($resourceIds, function (int $resourceId) { | |||||
return !isset($this->shareCache[$resourceId]); | return !isset($this->shareCache[$resourceId]); | ||||
}); | }); | ||||
if (count($resourceIds) === 0) { | if (count($resourceIds) === 0) { |