@@ -32,37 +32,37 @@ |
||
32 | 32 | |
33 | 33 | class RegisterRegenerateBirthdayCalendars extends QueuedJob { |
34 | 34 | |
35 | - /** @var IUserManager */ |
|
36 | - private $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + private $userManager; |
|
37 | 37 | |
38 | - /** @var IJobList */ |
|
39 | - private $jobList; |
|
38 | + /** @var IJobList */ |
|
39 | + private $jobList; |
|
40 | 40 | |
41 | - /** |
|
42 | - * RegisterRegenerateBirthdayCalendars constructor. |
|
43 | - * |
|
44 | - * @param ITimeFactory $time |
|
45 | - * @param IUserManager $userManager |
|
46 | - * @param IJobList $jobList |
|
47 | - */ |
|
48 | - public function __construct(ITimeFactory $time, |
|
49 | - IUserManager $userManager, |
|
50 | - IJobList $jobList) { |
|
51 | - parent::__construct($time); |
|
52 | - $this->userManager = $userManager; |
|
53 | - $this->jobList = $jobList; |
|
54 | - } |
|
41 | + /** |
|
42 | + * RegisterRegenerateBirthdayCalendars constructor. |
|
43 | + * |
|
44 | + * @param ITimeFactory $time |
|
45 | + * @param IUserManager $userManager |
|
46 | + * @param IJobList $jobList |
|
47 | + */ |
|
48 | + public function __construct(ITimeFactory $time, |
|
49 | + IUserManager $userManager, |
|
50 | + IJobList $jobList) { |
|
51 | + parent::__construct($time); |
|
52 | + $this->userManager = $userManager; |
|
53 | + $this->jobList = $jobList; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @inheritDoc |
|
58 | - */ |
|
59 | - public function run($argument) { |
|
60 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
61 | - $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
62 | - 'userId' => $user->getUID(), |
|
63 | - 'purgeBeforeGenerating' => true |
|
64 | - ]); |
|
65 | - }); |
|
66 | - } |
|
56 | + /** |
|
57 | + * @inheritDoc |
|
58 | + */ |
|
59 | + public function run($argument) { |
|
60 | + $this->userManager->callForSeenUsers(function (IUser $user) { |
|
61 | + $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
62 | + 'userId' => $user->getUID(), |
|
63 | + 'purgeBeforeGenerating' => true |
|
64 | + ]); |
|
65 | + }); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * @inheritDoc |
58 | 58 | */ |
59 | 59 | public function run($argument) { |
60 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
60 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
61 | 61 | $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
62 | 62 | 'userId' => $user->getUID(), |
63 | 63 | 'purgeBeforeGenerating' => true |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); |
74 | 74 | /** @var IAddressBook[] $objects */ |
75 | - $objects = array_map(function (array $addressBook) { |
|
75 | + $objects = array_map(function(array $addressBook) { |
|
76 | 76 | if ($addressBook['principaluri'] === 'principals/system/system') { |
77 | 77 | return new SystemAddressbook($this->carddavBackend, $addressBook, $this->l10n, $this->config); |
78 | 78 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return new AddressBook($this->carddavBackend, $addressBook, $this->l10n); |
81 | 81 | }, $addressBooks); |
82 | 82 | /** @var IAddressBook[][] $objectsFromPlugins */ |
83 | - $objectsFromPlugins = array_map(function (IAddressBookProvider $plugin): array { |
|
83 | + $objectsFromPlugins = array_map(function(IAddressBookProvider $plugin): array { |
|
84 | 84 | return $plugin->fetchAllForAddressBookHome($this->principalUri); |
85 | 85 | }, $this->pluginManager->getAddressBookPlugins()); |
86 | 86 |
@@ -41,82 +41,82 @@ |
||
41 | 41 | |
42 | 42 | class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { |
43 | 43 | |
44 | - /** @var IL10N */ |
|
45 | - protected $l10n; |
|
46 | - |
|
47 | - /** @var IConfig */ |
|
48 | - protected $config; |
|
49 | - |
|
50 | - /** @var PluginManager */ |
|
51 | - private $pluginManager; |
|
52 | - |
|
53 | - public function __construct(Backend\BackendInterface $carddavBackend, |
|
54 | - string $principalUri, |
|
55 | - PluginManager $pluginManager) { |
|
56 | - parent::__construct($carddavBackend, $principalUri); |
|
57 | - $this->pluginManager = $pluginManager; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Returns a list of address books |
|
62 | - * |
|
63 | - * @return IAddressBook[] |
|
64 | - */ |
|
65 | - public function getChildren() { |
|
66 | - if ($this->l10n === null) { |
|
67 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
68 | - } |
|
69 | - if ($this->config === null) { |
|
70 | - $this->config = \OC::$server->getConfig(); |
|
71 | - } |
|
72 | - |
|
73 | - $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); |
|
74 | - /** @var IAddressBook[] $objects */ |
|
75 | - $objects = array_map(function (array $addressBook) { |
|
76 | - if ($addressBook['principaluri'] === 'principals/system/system') { |
|
77 | - return new SystemAddressbook($this->carddavBackend, $addressBook, $this->l10n, $this->config); |
|
78 | - } |
|
79 | - |
|
80 | - return new AddressBook($this->carddavBackend, $addressBook, $this->l10n); |
|
81 | - }, $addressBooks); |
|
82 | - /** @var IAddressBook[][] $objectsFromPlugins */ |
|
83 | - $objectsFromPlugins = array_map(function (IAddressBookProvider $plugin): array { |
|
84 | - return $plugin->fetchAllForAddressBookHome($this->principalUri); |
|
85 | - }, $this->pluginManager->getAddressBookPlugins()); |
|
86 | - |
|
87 | - return array_merge($objects, ...$objectsFromPlugins); |
|
88 | - } |
|
89 | - |
|
90 | - public function createExtendedCollection($name, MkCol $mkCol) { |
|
91 | - if (ExternalAddressBook::doesViolateReservedName($name)) { |
|
92 | - throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
93 | - } |
|
94 | - |
|
95 | - parent::createExtendedCollection($name, $mkCol); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns a list of ACE's for this node. |
|
100 | - * |
|
101 | - * Each ACE has the following properties: |
|
102 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
103 | - * currently the only supported privileges |
|
104 | - * * 'principal', a url to the principal who owns the node |
|
105 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
106 | - * be updated. |
|
107 | - * |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function getACL() { |
|
111 | - $acl = parent::getACL(); |
|
112 | - if ($this->principalUri === 'principals/system/system') { |
|
113 | - $acl[] = [ |
|
114 | - 'privilege' => '{DAV:}read', |
|
115 | - 'principal' => '{DAV:}authenticated', |
|
116 | - 'protected' => true, |
|
117 | - ]; |
|
118 | - } |
|
119 | - |
|
120 | - return $acl; |
|
121 | - } |
|
44 | + /** @var IL10N */ |
|
45 | + protected $l10n; |
|
46 | + |
|
47 | + /** @var IConfig */ |
|
48 | + protected $config; |
|
49 | + |
|
50 | + /** @var PluginManager */ |
|
51 | + private $pluginManager; |
|
52 | + |
|
53 | + public function __construct(Backend\BackendInterface $carddavBackend, |
|
54 | + string $principalUri, |
|
55 | + PluginManager $pluginManager) { |
|
56 | + parent::__construct($carddavBackend, $principalUri); |
|
57 | + $this->pluginManager = $pluginManager; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Returns a list of address books |
|
62 | + * |
|
63 | + * @return IAddressBook[] |
|
64 | + */ |
|
65 | + public function getChildren() { |
|
66 | + if ($this->l10n === null) { |
|
67 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
68 | + } |
|
69 | + if ($this->config === null) { |
|
70 | + $this->config = \OC::$server->getConfig(); |
|
71 | + } |
|
72 | + |
|
73 | + $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); |
|
74 | + /** @var IAddressBook[] $objects */ |
|
75 | + $objects = array_map(function (array $addressBook) { |
|
76 | + if ($addressBook['principaluri'] === 'principals/system/system') { |
|
77 | + return new SystemAddressbook($this->carddavBackend, $addressBook, $this->l10n, $this->config); |
|
78 | + } |
|
79 | + |
|
80 | + return new AddressBook($this->carddavBackend, $addressBook, $this->l10n); |
|
81 | + }, $addressBooks); |
|
82 | + /** @var IAddressBook[][] $objectsFromPlugins */ |
|
83 | + $objectsFromPlugins = array_map(function (IAddressBookProvider $plugin): array { |
|
84 | + return $plugin->fetchAllForAddressBookHome($this->principalUri); |
|
85 | + }, $this->pluginManager->getAddressBookPlugins()); |
|
86 | + |
|
87 | + return array_merge($objects, ...$objectsFromPlugins); |
|
88 | + } |
|
89 | + |
|
90 | + public function createExtendedCollection($name, MkCol $mkCol) { |
|
91 | + if (ExternalAddressBook::doesViolateReservedName($name)) { |
|
92 | + throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
93 | + } |
|
94 | + |
|
95 | + parent::createExtendedCollection($name, $mkCol); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns a list of ACE's for this node. |
|
100 | + * |
|
101 | + * Each ACE has the following properties: |
|
102 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
103 | + * currently the only supported privileges |
|
104 | + * * 'principal', a url to the principal who owns the node |
|
105 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
106 | + * be updated. |
|
107 | + * |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function getACL() { |
|
111 | + $acl = parent::getACL(); |
|
112 | + if ($this->principalUri === 'principals/system/system') { |
|
113 | + $acl[] = [ |
|
114 | + 'privilege' => '{DAV:}read', |
|
115 | + 'principal' => '{DAV:}authenticated', |
|
116 | + 'protected' => true, |
|
117 | + ]; |
|
118 | + } |
|
119 | + |
|
120 | + return $acl; |
|
121 | + } |
|
122 | 122 | } |
@@ -60,8 +60,8 @@ |
||
60 | 60 | $tagMapper, |
61 | 61 | $userSession, |
62 | 62 | $groupManager, |
63 | - function ($name) { |
|
64 | - $nodes = \OC::$server->getUserFolder()->getById((int)$name); |
|
63 | + function($name) { |
|
64 | + $nodes = \OC::$server->getUserFolder()->getById((int) $name); |
|
65 | 65 | return !empty($nodes); |
66 | 66 | } |
67 | 67 | ), |
@@ -37,58 +37,58 @@ |
||
37 | 37 | |
38 | 38 | class SystemTagsRelationsCollection extends SimpleCollection { |
39 | 39 | |
40 | - /** |
|
41 | - * SystemTagsRelationsCollection constructor. |
|
42 | - * |
|
43 | - * @param ISystemTagManager $tagManager |
|
44 | - * @param ISystemTagObjectMapper $tagMapper |
|
45 | - * @param IUserSession $userSession |
|
46 | - * @param IGroupManager $groupManager |
|
47 | - * @param EventDispatcherInterface $dispatcher |
|
48 | - */ |
|
49 | - public function __construct( |
|
50 | - ISystemTagManager $tagManager, |
|
51 | - ISystemTagObjectMapper $tagMapper, |
|
52 | - IUserSession $userSession, |
|
53 | - IGroupManager $groupManager, |
|
54 | - EventDispatcherInterface $dispatcher |
|
55 | - ) { |
|
56 | - $children = [ |
|
57 | - new SystemTagsObjectTypeCollection( |
|
58 | - 'files', |
|
59 | - $tagManager, |
|
60 | - $tagMapper, |
|
61 | - $userSession, |
|
62 | - $groupManager, |
|
63 | - function ($name) { |
|
64 | - $nodes = \OC::$server->getUserFolder()->getById((int)$name); |
|
65 | - return !empty($nodes); |
|
66 | - } |
|
67 | - ), |
|
68 | - ]; |
|
40 | + /** |
|
41 | + * SystemTagsRelationsCollection constructor. |
|
42 | + * |
|
43 | + * @param ISystemTagManager $tagManager |
|
44 | + * @param ISystemTagObjectMapper $tagMapper |
|
45 | + * @param IUserSession $userSession |
|
46 | + * @param IGroupManager $groupManager |
|
47 | + * @param EventDispatcherInterface $dispatcher |
|
48 | + */ |
|
49 | + public function __construct( |
|
50 | + ISystemTagManager $tagManager, |
|
51 | + ISystemTagObjectMapper $tagMapper, |
|
52 | + IUserSession $userSession, |
|
53 | + IGroupManager $groupManager, |
|
54 | + EventDispatcherInterface $dispatcher |
|
55 | + ) { |
|
56 | + $children = [ |
|
57 | + new SystemTagsObjectTypeCollection( |
|
58 | + 'files', |
|
59 | + $tagManager, |
|
60 | + $tagMapper, |
|
61 | + $userSession, |
|
62 | + $groupManager, |
|
63 | + function ($name) { |
|
64 | + $nodes = \OC::$server->getUserFolder()->getById((int)$name); |
|
65 | + return !empty($nodes); |
|
66 | + } |
|
67 | + ), |
|
68 | + ]; |
|
69 | 69 | |
70 | - $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
71 | - $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
70 | + $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
71 | + $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
72 | 72 | |
73 | - foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
74 | - $children[] = new SystemTagsObjectTypeCollection( |
|
75 | - $entity, |
|
76 | - $tagManager, |
|
77 | - $tagMapper, |
|
78 | - $userSession, |
|
79 | - $groupManager, |
|
80 | - $entityExistsFunction |
|
81 | - ); |
|
82 | - } |
|
73 | + foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
74 | + $children[] = new SystemTagsObjectTypeCollection( |
|
75 | + $entity, |
|
76 | + $tagManager, |
|
77 | + $tagMapper, |
|
78 | + $userSession, |
|
79 | + $groupManager, |
|
80 | + $entityExistsFunction |
|
81 | + ); |
|
82 | + } |
|
83 | 83 | |
84 | - parent::__construct('root', $children); |
|
85 | - } |
|
84 | + parent::__construct('root', $children); |
|
85 | + } |
|
86 | 86 | |
87 | - public function getName() { |
|
88 | - return 'systemtags-relations'; |
|
89 | - } |
|
87 | + public function getName() { |
|
88 | + return 'systemtags-relations'; |
|
89 | + } |
|
90 | 90 | |
91 | - public function setName($name) { |
|
92 | - throw new Forbidden('Permission denied to rename this collection'); |
|
93 | - } |
|
91 | + public function setName($name) { |
|
92 | + throw new Forbidden('Permission denied to rename this collection'); |
|
93 | + } |
|
94 | 94 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); |
95 | 95 | |
96 | 96 | // add background job for each user |
97 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
97 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
98 | 98 | $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
99 | 99 | 'userId' => $user->getUID(), |
100 | 100 | ]); |
@@ -37,82 +37,82 @@ |
||
37 | 37 | |
38 | 38 | class BirthdayCalendarController extends Controller { |
39 | 39 | |
40 | - /** |
|
41 | - * @var IDBConnection |
|
42 | - */ |
|
43 | - protected $db; |
|
40 | + /** |
|
41 | + * @var IDBConnection |
|
42 | + */ |
|
43 | + protected $db; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var IConfig |
|
47 | - */ |
|
48 | - protected $config; |
|
45 | + /** |
|
46 | + * @var IConfig |
|
47 | + */ |
|
48 | + protected $config; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var IUserManager |
|
52 | - */ |
|
53 | - protected $userManager; |
|
50 | + /** |
|
51 | + * @var IUserManager |
|
52 | + */ |
|
53 | + protected $userManager; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var CalDavBackend |
|
57 | - */ |
|
58 | - protected $caldavBackend; |
|
55 | + /** |
|
56 | + * @var CalDavBackend |
|
57 | + */ |
|
58 | + protected $caldavBackend; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var IJobList |
|
62 | - */ |
|
63 | - protected $jobList; |
|
60 | + /** |
|
61 | + * @var IJobList |
|
62 | + */ |
|
63 | + protected $jobList; |
|
64 | 64 | |
65 | - /** |
|
66 | - * BirthdayCalendar constructor. |
|
67 | - * |
|
68 | - * @param string $appName |
|
69 | - * @param IRequest $request |
|
70 | - * @param IDBConnection $db |
|
71 | - * @param IConfig $config |
|
72 | - * @param IJobList $jobList |
|
73 | - * @param IUserManager $userManager |
|
74 | - * @param CalDavBackend $calDavBackend |
|
75 | - */ |
|
76 | - public function __construct($appName, IRequest $request, |
|
77 | - IDBConnection $db, IConfig $config, |
|
78 | - IJobList $jobList, |
|
79 | - IUserManager $userManager, |
|
80 | - CalDavBackend $calDavBackend) { |
|
81 | - parent::__construct($appName, $request); |
|
82 | - $this->db = $db; |
|
83 | - $this->config = $config; |
|
84 | - $this->userManager = $userManager; |
|
85 | - $this->jobList = $jobList; |
|
86 | - $this->caldavBackend = $calDavBackend; |
|
87 | - } |
|
65 | + /** |
|
66 | + * BirthdayCalendar constructor. |
|
67 | + * |
|
68 | + * @param string $appName |
|
69 | + * @param IRequest $request |
|
70 | + * @param IDBConnection $db |
|
71 | + * @param IConfig $config |
|
72 | + * @param IJobList $jobList |
|
73 | + * @param IUserManager $userManager |
|
74 | + * @param CalDavBackend $calDavBackend |
|
75 | + */ |
|
76 | + public function __construct($appName, IRequest $request, |
|
77 | + IDBConnection $db, IConfig $config, |
|
78 | + IJobList $jobList, |
|
79 | + IUserManager $userManager, |
|
80 | + CalDavBackend $calDavBackend) { |
|
81 | + parent::__construct($appName, $request); |
|
82 | + $this->db = $db; |
|
83 | + $this->config = $config; |
|
84 | + $this->userManager = $userManager; |
|
85 | + $this->jobList = $jobList; |
|
86 | + $this->caldavBackend = $calDavBackend; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return Response |
|
91 | - * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) |
|
92 | - */ |
|
93 | - public function enable() { |
|
94 | - $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); |
|
89 | + /** |
|
90 | + * @return Response |
|
91 | + * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) |
|
92 | + */ |
|
93 | + public function enable() { |
|
94 | + $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); |
|
95 | 95 | |
96 | - // add background job for each user |
|
97 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
98 | - $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
99 | - 'userId' => $user->getUID(), |
|
100 | - ]); |
|
101 | - }); |
|
96 | + // add background job for each user |
|
97 | + $this->userManager->callForSeenUsers(function (IUser $user) { |
|
98 | + $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
99 | + 'userId' => $user->getUID(), |
|
100 | + ]); |
|
101 | + }); |
|
102 | 102 | |
103 | - return new JSONResponse([]); |
|
104 | - } |
|
103 | + return new JSONResponse([]); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @return Response |
|
108 | - * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) |
|
109 | - */ |
|
110 | - public function disable() { |
|
111 | - $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); |
|
106 | + /** |
|
107 | + * @return Response |
|
108 | + * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) |
|
109 | + */ |
|
110 | + public function disable() { |
|
111 | + $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); |
|
112 | 112 | |
113 | - $this->jobList->remove(GenerateBirthdayCalendarBackgroundJob::class); |
|
114 | - $this->caldavBackend->deleteAllBirthdayCalendars(); |
|
113 | + $this->jobList->remove(GenerateBirthdayCalendarBackgroundJob::class); |
|
114 | + $this->caldavBackend->deleteAllBirthdayCalendars(); |
|
115 | 115 | |
116 | - return new JSONResponse([]); |
|
117 | - } |
|
116 | + return new JSONResponse([]); |
|
117 | + } |
|
118 | 118 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | $this->server = $server; |
114 | 114 | |
115 | 115 | $this->server->on('method:POST', [$this, 'httpPost']); |
116 | - $this->server->on('propFind', [$this, 'propFind']); |
|
116 | + $this->server->on('propFind', [$this, 'propFind']); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function propFind(PropFind $propFind, INode $node) { |
120 | 120 | if ($node instanceof Calendar) { |
121 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
121 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function() use ($node) { |
|
122 | 122 | if ($node->getPublishStatus()) { |
123 | 123 | // We return the publish-url only if the calendar is published. |
124 | 124 | $token = $node->getPublishStatus(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | }); |
130 | 130 | |
131 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
131 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function() use ($node) { |
|
132 | 132 | $canShare = (!$node->isSubscription() && $node->canWrite()); |
133 | 133 | $canPublish = (!$node->isSubscription() && $node->canWrite()); |
134 | 134 |
@@ -41,216 +41,216 @@ |
||
41 | 41 | use Sabre\HTTP\ResponseInterface; |
42 | 42 | |
43 | 43 | class PublishPlugin extends ServerPlugin { |
44 | - public const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; |
|
45 | - |
|
46 | - /** |
|
47 | - * Reference to SabreDAV server object. |
|
48 | - * |
|
49 | - * @var \Sabre\DAV\Server |
|
50 | - */ |
|
51 | - protected $server; |
|
52 | - |
|
53 | - /** |
|
54 | - * Config instance to get instance secret. |
|
55 | - * |
|
56 | - * @var IConfig |
|
57 | - */ |
|
58 | - protected $config; |
|
59 | - |
|
60 | - /** |
|
61 | - * URL Generator for absolute URLs. |
|
62 | - * |
|
63 | - * @var IURLGenerator |
|
64 | - */ |
|
65 | - protected $urlGenerator; |
|
66 | - |
|
67 | - /** |
|
68 | - * PublishPlugin constructor. |
|
69 | - * |
|
70 | - * @param IConfig $config |
|
71 | - * @param IURLGenerator $urlGenerator |
|
72 | - */ |
|
73 | - public function __construct(IConfig $config, IURLGenerator $urlGenerator) { |
|
74 | - $this->config = $config; |
|
75 | - $this->urlGenerator = $urlGenerator; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * This method should return a list of server-features. |
|
80 | - * |
|
81 | - * This is for example 'versioning' and is added to the DAV: header |
|
82 | - * in an OPTIONS response. |
|
83 | - * |
|
84 | - * @return string[] |
|
85 | - */ |
|
86 | - public function getFeatures() { |
|
87 | - // May have to be changed to be detected |
|
88 | - return ['oc-calendar-publishing', 'calendarserver-sharing']; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Returns a plugin name. |
|
93 | - * |
|
94 | - * Using this name other plugins will be able to access other plugins |
|
95 | - * using Sabre\DAV\Server::getPlugin |
|
96 | - * |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function getPluginName() { |
|
100 | - return 'oc-calendar-publishing'; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * This initializes the plugin. |
|
105 | - * |
|
106 | - * This function is called by Sabre\DAV\Server, after |
|
107 | - * addPlugin is called. |
|
108 | - * |
|
109 | - * This method should set up the required event subscriptions. |
|
110 | - * |
|
111 | - * @param Server $server |
|
112 | - */ |
|
113 | - public function initialize(Server $server) { |
|
114 | - $this->server = $server; |
|
115 | - |
|
116 | - $this->server->on('method:POST', [$this, 'httpPost']); |
|
117 | - $this->server->on('propFind', [$this, 'propFind']); |
|
118 | - } |
|
119 | - |
|
120 | - public function propFind(PropFind $propFind, INode $node) { |
|
121 | - if ($node instanceof Calendar) { |
|
122 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
123 | - if ($node->getPublishStatus()) { |
|
124 | - // We return the publish-url only if the calendar is published. |
|
125 | - $token = $node->getPublishStatus(); |
|
126 | - $publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token; |
|
127 | - |
|
128 | - return new Publisher($publishUrl, true); |
|
129 | - } |
|
130 | - }); |
|
131 | - |
|
132 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
133 | - $canShare = (!$node->isSubscription() && $node->canWrite()); |
|
134 | - $canPublish = (!$node->isSubscription() && $node->canWrite()); |
|
135 | - |
|
136 | - if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { |
|
137 | - $canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI()); |
|
138 | - $canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI()); |
|
139 | - } |
|
140 | - |
|
141 | - return new AllowedSharingModes($canShare, $canPublish); |
|
142 | - }); |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * We intercept this to handle POST requests on calendars. |
|
148 | - * |
|
149 | - * @param RequestInterface $request |
|
150 | - * @param ResponseInterface $response |
|
151 | - * |
|
152 | - * @return void|bool |
|
153 | - */ |
|
154 | - public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
155 | - $path = $request->getPath(); |
|
156 | - |
|
157 | - // Only handling xml |
|
158 | - $contentType = $request->getHeader('Content-Type'); |
|
159 | - if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) { |
|
160 | - return; |
|
161 | - } |
|
162 | - |
|
163 | - // Making sure the node exists |
|
164 | - try { |
|
165 | - $node = $this->server->tree->getNodeForPath($path); |
|
166 | - } catch (NotFound $e) { |
|
167 | - return; |
|
168 | - } |
|
169 | - |
|
170 | - $requestBody = $request->getBodyAsString(); |
|
171 | - |
|
172 | - // If this request handler could not deal with this POST request, it |
|
173 | - // will return 'null' and other plugins get a chance to handle the |
|
174 | - // request. |
|
175 | - // |
|
176 | - // However, we already requested the full body. This is a problem, |
|
177 | - // because a body can only be read once. This is why we preemptively |
|
178 | - // re-populated the request body with the existing data. |
|
179 | - $request->setBody($requestBody); |
|
180 | - |
|
181 | - $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
182 | - |
|
183 | - switch ($documentType) { |
|
184 | - |
|
185 | - case '{'.self::NS_CALENDARSERVER.'}publish-calendar': |
|
186 | - |
|
187 | - // We can only deal with IShareableCalendar objects |
|
188 | - if (!$node instanceof Calendar) { |
|
189 | - return; |
|
190 | - } |
|
191 | - $this->server->transactionType = 'post-publish-calendar'; |
|
192 | - |
|
193 | - // Getting ACL info |
|
194 | - $acl = $this->server->getPlugin('acl'); |
|
195 | - |
|
196 | - // If there's no ACL support, we allow everything |
|
197 | - if ($acl) { |
|
198 | - /** @var \Sabre\DAVACL\Plugin $acl */ |
|
199 | - $acl->checkPrivileges($path, '{DAV:}write'); |
|
200 | - |
|
201 | - $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
202 | - $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
203 | - if ($limitSharingToOwner && !$isOwner) { |
|
204 | - return; |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - $node->setPublishStatus(true); |
|
209 | - |
|
210 | - // iCloud sends back the 202, so we will too. |
|
211 | - $response->setStatus(202); |
|
212 | - |
|
213 | - // Adding this because sending a response body may cause issues, |
|
214 | - // and I wanted some type of indicator the response was handled. |
|
215 | - $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
216 | - |
|
217 | - // Breaking the event chain |
|
218 | - return false; |
|
219 | - |
|
220 | - case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': |
|
221 | - |
|
222 | - // We can only deal with IShareableCalendar objects |
|
223 | - if (!$node instanceof Calendar) { |
|
224 | - return; |
|
225 | - } |
|
226 | - $this->server->transactionType = 'post-unpublish-calendar'; |
|
227 | - |
|
228 | - // Getting ACL info |
|
229 | - $acl = $this->server->getPlugin('acl'); |
|
230 | - |
|
231 | - // If there's no ACL support, we allow everything |
|
232 | - if ($acl) { |
|
233 | - /** @var \Sabre\DAVACL\Plugin $acl */ |
|
234 | - $acl->checkPrivileges($path, '{DAV:}write'); |
|
235 | - |
|
236 | - $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
237 | - $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
238 | - if ($limitSharingToOwner && !$isOwner) { |
|
239 | - return; |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - $node->setPublishStatus(false); |
|
244 | - |
|
245 | - $response->setStatus(200); |
|
246 | - |
|
247 | - // Adding this because sending a response body may cause issues, |
|
248 | - // and I wanted some type of indicator the response was handled. |
|
249 | - $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
250 | - |
|
251 | - // Breaking the event chain |
|
252 | - return false; |
|
44 | + public const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; |
|
45 | + |
|
46 | + /** |
|
47 | + * Reference to SabreDAV server object. |
|
48 | + * |
|
49 | + * @var \Sabre\DAV\Server |
|
50 | + */ |
|
51 | + protected $server; |
|
52 | + |
|
53 | + /** |
|
54 | + * Config instance to get instance secret. |
|
55 | + * |
|
56 | + * @var IConfig |
|
57 | + */ |
|
58 | + protected $config; |
|
59 | + |
|
60 | + /** |
|
61 | + * URL Generator for absolute URLs. |
|
62 | + * |
|
63 | + * @var IURLGenerator |
|
64 | + */ |
|
65 | + protected $urlGenerator; |
|
66 | + |
|
67 | + /** |
|
68 | + * PublishPlugin constructor. |
|
69 | + * |
|
70 | + * @param IConfig $config |
|
71 | + * @param IURLGenerator $urlGenerator |
|
72 | + */ |
|
73 | + public function __construct(IConfig $config, IURLGenerator $urlGenerator) { |
|
74 | + $this->config = $config; |
|
75 | + $this->urlGenerator = $urlGenerator; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * This method should return a list of server-features. |
|
80 | + * |
|
81 | + * This is for example 'versioning' and is added to the DAV: header |
|
82 | + * in an OPTIONS response. |
|
83 | + * |
|
84 | + * @return string[] |
|
85 | + */ |
|
86 | + public function getFeatures() { |
|
87 | + // May have to be changed to be detected |
|
88 | + return ['oc-calendar-publishing', 'calendarserver-sharing']; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Returns a plugin name. |
|
93 | + * |
|
94 | + * Using this name other plugins will be able to access other plugins |
|
95 | + * using Sabre\DAV\Server::getPlugin |
|
96 | + * |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function getPluginName() { |
|
100 | + return 'oc-calendar-publishing'; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * This initializes the plugin. |
|
105 | + * |
|
106 | + * This function is called by Sabre\DAV\Server, after |
|
107 | + * addPlugin is called. |
|
108 | + * |
|
109 | + * This method should set up the required event subscriptions. |
|
110 | + * |
|
111 | + * @param Server $server |
|
112 | + */ |
|
113 | + public function initialize(Server $server) { |
|
114 | + $this->server = $server; |
|
115 | + |
|
116 | + $this->server->on('method:POST', [$this, 'httpPost']); |
|
117 | + $this->server->on('propFind', [$this, 'propFind']); |
|
118 | + } |
|
119 | + |
|
120 | + public function propFind(PropFind $propFind, INode $node) { |
|
121 | + if ($node instanceof Calendar) { |
|
122 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
123 | + if ($node->getPublishStatus()) { |
|
124 | + // We return the publish-url only if the calendar is published. |
|
125 | + $token = $node->getPublishStatus(); |
|
126 | + $publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token; |
|
127 | + |
|
128 | + return new Publisher($publishUrl, true); |
|
129 | + } |
|
130 | + }); |
|
131 | + |
|
132 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
133 | + $canShare = (!$node->isSubscription() && $node->canWrite()); |
|
134 | + $canPublish = (!$node->isSubscription() && $node->canWrite()); |
|
135 | + |
|
136 | + if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { |
|
137 | + $canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI()); |
|
138 | + $canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI()); |
|
139 | + } |
|
140 | + |
|
141 | + return new AllowedSharingModes($canShare, $canPublish); |
|
142 | + }); |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * We intercept this to handle POST requests on calendars. |
|
148 | + * |
|
149 | + * @param RequestInterface $request |
|
150 | + * @param ResponseInterface $response |
|
151 | + * |
|
152 | + * @return void|bool |
|
153 | + */ |
|
154 | + public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
155 | + $path = $request->getPath(); |
|
156 | + |
|
157 | + // Only handling xml |
|
158 | + $contentType = $request->getHeader('Content-Type'); |
|
159 | + if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) { |
|
160 | + return; |
|
161 | + } |
|
162 | + |
|
163 | + // Making sure the node exists |
|
164 | + try { |
|
165 | + $node = $this->server->tree->getNodeForPath($path); |
|
166 | + } catch (NotFound $e) { |
|
167 | + return; |
|
168 | + } |
|
169 | + |
|
170 | + $requestBody = $request->getBodyAsString(); |
|
171 | + |
|
172 | + // If this request handler could not deal with this POST request, it |
|
173 | + // will return 'null' and other plugins get a chance to handle the |
|
174 | + // request. |
|
175 | + // |
|
176 | + // However, we already requested the full body. This is a problem, |
|
177 | + // because a body can only be read once. This is why we preemptively |
|
178 | + // re-populated the request body with the existing data. |
|
179 | + $request->setBody($requestBody); |
|
180 | + |
|
181 | + $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
182 | + |
|
183 | + switch ($documentType) { |
|
184 | + |
|
185 | + case '{'.self::NS_CALENDARSERVER.'}publish-calendar': |
|
186 | + |
|
187 | + // We can only deal with IShareableCalendar objects |
|
188 | + if (!$node instanceof Calendar) { |
|
189 | + return; |
|
190 | + } |
|
191 | + $this->server->transactionType = 'post-publish-calendar'; |
|
192 | + |
|
193 | + // Getting ACL info |
|
194 | + $acl = $this->server->getPlugin('acl'); |
|
195 | + |
|
196 | + // If there's no ACL support, we allow everything |
|
197 | + if ($acl) { |
|
198 | + /** @var \Sabre\DAVACL\Plugin $acl */ |
|
199 | + $acl->checkPrivileges($path, '{DAV:}write'); |
|
200 | + |
|
201 | + $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
202 | + $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
203 | + if ($limitSharingToOwner && !$isOwner) { |
|
204 | + return; |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + $node->setPublishStatus(true); |
|
209 | + |
|
210 | + // iCloud sends back the 202, so we will too. |
|
211 | + $response->setStatus(202); |
|
212 | + |
|
213 | + // Adding this because sending a response body may cause issues, |
|
214 | + // and I wanted some type of indicator the response was handled. |
|
215 | + $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
216 | + |
|
217 | + // Breaking the event chain |
|
218 | + return false; |
|
219 | + |
|
220 | + case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': |
|
221 | + |
|
222 | + // We can only deal with IShareableCalendar objects |
|
223 | + if (!$node instanceof Calendar) { |
|
224 | + return; |
|
225 | + } |
|
226 | + $this->server->transactionType = 'post-unpublish-calendar'; |
|
227 | + |
|
228 | + // Getting ACL info |
|
229 | + $acl = $this->server->getPlugin('acl'); |
|
230 | + |
|
231 | + // If there's no ACL support, we allow everything |
|
232 | + if ($acl) { |
|
233 | + /** @var \Sabre\DAVACL\Plugin $acl */ |
|
234 | + $acl->checkPrivileges($path, '{DAV:}write'); |
|
235 | + |
|
236 | + $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
237 | + $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
238 | + if ($limitSharingToOwner && !$isOwner) { |
|
239 | + return; |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + $node->setPublishStatus(false); |
|
244 | + |
|
245 | + $response->setStatus(200); |
|
246 | + |
|
247 | + // Adding this because sending a response body may cause issues, |
|
248 | + // and I wanted some type of indicator the response was handled. |
|
249 | + $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
250 | + |
|
251 | + // Breaking the event chain |
|
252 | + return false; |
|
253 | 253 | |
254 | - } |
|
255 | - } |
|
254 | + } |
|
255 | + } |
|
256 | 256 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public function createFile($name, $data = null) { |
47 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
47 | + throw new Forbidden('Permission denied to create file (filename '.$name.')'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function createDirectory($name) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getChildren(): array { |
62 | - return array_map(function ($node) { |
|
62 | + return array_map(function($node) { |
|
63 | 63 | return new UploadFolder($node, $this->cleanupService); |
64 | 64 | }, $this->impl()->getChildren()); |
65 | 65 | } |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | $rootView = new View(); |
93 | 93 | $user = \OC::$server->getUserSession()->getUser(); |
94 | 94 | Filesystem::initMountPoints($user->getUID()); |
95 | - if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
96 | - $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
95 | + if (!$rootView->file_exists('/'.$user->getUID().'/uploads')) { |
|
96 | + $rootView->mkdir('/'.$user->getUID().'/uploads'); |
|
97 | 97 | } |
98 | - $view = new View('/' . $user->getUID() . '/uploads'); |
|
98 | + $view = new View('/'.$user->getUID().'/uploads'); |
|
99 | 99 | $rootInfo = $view->getFileInfo(''); |
100 | 100 | return new Directory($view, $rootInfo); |
101 | 101 | } |
@@ -33,70 +33,70 @@ |
||
33 | 33 | |
34 | 34 | class UploadHome implements ICollection { |
35 | 35 | |
36 | - /** @var array */ |
|
37 | - private $principalInfo; |
|
38 | - /** @var CleanupService */ |
|
39 | - private $cleanupService; |
|
36 | + /** @var array */ |
|
37 | + private $principalInfo; |
|
38 | + /** @var CleanupService */ |
|
39 | + private $cleanupService; |
|
40 | 40 | |
41 | - public function __construct(array $principalInfo, CleanupService $cleanupService) { |
|
42 | - $this->principalInfo = $principalInfo; |
|
43 | - $this->cleanupService = $cleanupService; |
|
44 | - } |
|
41 | + public function __construct(array $principalInfo, CleanupService $cleanupService) { |
|
42 | + $this->principalInfo = $principalInfo; |
|
43 | + $this->cleanupService = $cleanupService; |
|
44 | + } |
|
45 | 45 | |
46 | - public function createFile($name, $data = null) { |
|
47 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
48 | - } |
|
46 | + public function createFile($name, $data = null) { |
|
47 | + throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
48 | + } |
|
49 | 49 | |
50 | - public function createDirectory($name) { |
|
51 | - $this->impl()->createDirectory($name); |
|
50 | + public function createDirectory($name) { |
|
51 | + $this->impl()->createDirectory($name); |
|
52 | 52 | |
53 | - // Add a cleanup job |
|
54 | - $this->cleanupService->addJob($name); |
|
55 | - } |
|
53 | + // Add a cleanup job |
|
54 | + $this->cleanupService->addJob($name); |
|
55 | + } |
|
56 | 56 | |
57 | - public function getChild($name): UploadFolder { |
|
58 | - return new UploadFolder($this->impl()->getChild($name), $this->cleanupService); |
|
59 | - } |
|
57 | + public function getChild($name): UploadFolder { |
|
58 | + return new UploadFolder($this->impl()->getChild($name), $this->cleanupService); |
|
59 | + } |
|
60 | 60 | |
61 | - public function getChildren(): array { |
|
62 | - return array_map(function ($node) { |
|
63 | - return new UploadFolder($node, $this->cleanupService); |
|
64 | - }, $this->impl()->getChildren()); |
|
65 | - } |
|
61 | + public function getChildren(): array { |
|
62 | + return array_map(function ($node) { |
|
63 | + return new UploadFolder($node, $this->cleanupService); |
|
64 | + }, $this->impl()->getChildren()); |
|
65 | + } |
|
66 | 66 | |
67 | - public function childExists($name): bool { |
|
68 | - return !is_null($this->getChild($name)); |
|
69 | - } |
|
67 | + public function childExists($name): bool { |
|
68 | + return !is_null($this->getChild($name)); |
|
69 | + } |
|
70 | 70 | |
71 | - public function delete() { |
|
72 | - $this->impl()->delete(); |
|
73 | - } |
|
71 | + public function delete() { |
|
72 | + $this->impl()->delete(); |
|
73 | + } |
|
74 | 74 | |
75 | - public function getName() { |
|
76 | - [,$name] = \Sabre\Uri\split($this->principalInfo['uri']); |
|
77 | - return $name; |
|
78 | - } |
|
75 | + public function getName() { |
|
76 | + [,$name] = \Sabre\Uri\split($this->principalInfo['uri']); |
|
77 | + return $name; |
|
78 | + } |
|
79 | 79 | |
80 | - public function setName($name) { |
|
81 | - throw new Forbidden('Permission denied to rename this folder'); |
|
82 | - } |
|
80 | + public function setName($name) { |
|
81 | + throw new Forbidden('Permission denied to rename this folder'); |
|
82 | + } |
|
83 | 83 | |
84 | - public function getLastModified() { |
|
85 | - return $this->impl()->getLastModified(); |
|
86 | - } |
|
84 | + public function getLastModified() { |
|
85 | + return $this->impl()->getLastModified(); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return Directory |
|
90 | - */ |
|
91 | - private function impl() { |
|
92 | - $rootView = new View(); |
|
93 | - $user = \OC::$server->getUserSession()->getUser(); |
|
94 | - Filesystem::initMountPoints($user->getUID()); |
|
95 | - if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
96 | - $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
97 | - } |
|
98 | - $view = new View('/' . $user->getUID() . '/uploads'); |
|
99 | - $rootInfo = $view->getFileInfo(''); |
|
100 | - return new Directory($view, $rootInfo); |
|
101 | - } |
|
88 | + /** |
|
89 | + * @return Directory |
|
90 | + */ |
|
91 | + private function impl() { |
|
92 | + $rootView = new View(); |
|
93 | + $user = \OC::$server->getUserSession()->getUser(); |
|
94 | + Filesystem::initMountPoints($user->getUID()); |
|
95 | + if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
96 | + $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
97 | + } |
|
98 | + $view = new View('/' . $user->getUID() . '/uploads'); |
|
99 | + $rootInfo = $view->getFileInfo(''); |
|
100 | + return new Directory($view, $rootInfo); |
|
101 | + } |
|
102 | 102 | } |
@@ -33,33 +33,33 @@ |
||
33 | 33 | * Verify that the public link share is valid |
34 | 34 | */ |
35 | 35 | class PublicLinkCheckPlugin extends ServerPlugin { |
36 | - /** |
|
37 | - * @var FileInfo |
|
38 | - */ |
|
39 | - private $fileInfo; |
|
36 | + /** |
|
37 | + * @var FileInfo |
|
38 | + */ |
|
39 | + private $fileInfo; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param FileInfo $fileInfo |
|
43 | - */ |
|
44 | - public function setFileInfo($fileInfo) { |
|
45 | - $this->fileInfo = $fileInfo; |
|
46 | - } |
|
41 | + /** |
|
42 | + * @param FileInfo $fileInfo |
|
43 | + */ |
|
44 | + public function setFileInfo($fileInfo) { |
|
45 | + $this->fileInfo = $fileInfo; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * This initializes the plugin. |
|
50 | - * |
|
51 | - * @param \Sabre\DAV\Server $server Sabre server |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initialize(\Sabre\DAV\Server $server) { |
|
56 | - $server->on('beforeMethod:*', [$this, 'beforeMethod']); |
|
57 | - } |
|
48 | + /** |
|
49 | + * This initializes the plugin. |
|
50 | + * |
|
51 | + * @param \Sabre\DAV\Server $server Sabre server |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initialize(\Sabre\DAV\Server $server) { |
|
56 | + $server->on('beforeMethod:*', [$this, 'beforeMethod']); |
|
57 | + } |
|
58 | 58 | |
59 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
60 | - // verify that the owner didn't have his share permissions revoked |
|
61 | - if ($this->fileInfo && !$this->fileInfo->isShareable()) { |
|
62 | - throw new NotFound(); |
|
63 | - } |
|
64 | - } |
|
59 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
60 | + // verify that the owner didn't have his share permissions revoked |
|
61 | + if ($this->fileInfo && !$this->fileInfo->isShareable()) { |
|
62 | + throw new NotFound(); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | $output->writeln("Start birthday calendar sync for all users ..."); |
97 | 97 | $p = new ProgressBar($output); |
98 | 98 | $p->start(); |
99 | - $this->userManager->callForSeenUsers(function ($user) use ($p) { |
|
99 | + $this->userManager->callForSeenUsers(function($user) use ($p) { |
|
100 | 100 | $p->advance(); |
101 | 101 | |
102 | 102 | $userId = $user->getUID(); |
@@ -38,87 +38,87 @@ |
||
38 | 38 | |
39 | 39 | class SyncBirthdayCalendar extends Command { |
40 | 40 | |
41 | - /** @var BirthdayService */ |
|
42 | - private $birthdayService; |
|
43 | - |
|
44 | - /** @var IConfig */ |
|
45 | - private $config; |
|
46 | - |
|
47 | - /** @var IUserManager */ |
|
48 | - private $userManager; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IUserManager $userManager |
|
52 | - * @param IConfig $config |
|
53 | - * @param BirthdayService $birthdayService |
|
54 | - */ |
|
55 | - public function __construct(IUserManager $userManager, IConfig $config, |
|
56 | - BirthdayService $birthdayService) { |
|
57 | - parent::__construct(); |
|
58 | - $this->birthdayService = $birthdayService; |
|
59 | - $this->config = $config; |
|
60 | - $this->userManager = $userManager; |
|
61 | - } |
|
62 | - |
|
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('dav:sync-birthday-calendar') |
|
66 | - ->setDescription('Synchronizes the birthday calendar') |
|
67 | - ->addArgument('user', |
|
68 | - InputArgument::OPTIONAL, |
|
69 | - 'User for whom the birthday calendar will be synchronized'); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param InputInterface $input |
|
74 | - * @param OutputInterface $output |
|
75 | - */ |
|
76 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
77 | - $this->verifyEnabled(); |
|
78 | - |
|
79 | - $user = $input->getArgument('user'); |
|
80 | - if (!is_null($user)) { |
|
81 | - if (!$this->userManager->userExists($user)) { |
|
82 | - throw new \InvalidArgumentException("User <$user> in unknown."); |
|
83 | - } |
|
84 | - |
|
85 | - // re-enable the birthday calendar in case it's called directly with a user name |
|
86 | - $isEnabled = $this->config->getUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
87 | - if ($isEnabled !== 'yes') { |
|
88 | - $this->config->setUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
89 | - $output->writeln("Re-enabling birthday calendar for $user"); |
|
90 | - } |
|
91 | - |
|
92 | - $output->writeln("Start birthday calendar sync for $user"); |
|
93 | - $this->birthdayService->syncUser($user); |
|
94 | - return 0; |
|
95 | - } |
|
96 | - $output->writeln("Start birthday calendar sync for all users ..."); |
|
97 | - $p = new ProgressBar($output); |
|
98 | - $p->start(); |
|
99 | - $this->userManager->callForSeenUsers(function ($user) use ($p) { |
|
100 | - $p->advance(); |
|
101 | - |
|
102 | - $userId = $user->getUID(); |
|
103 | - $isEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
104 | - if ($isEnabled !== 'yes') { |
|
105 | - return; |
|
106 | - } |
|
107 | - |
|
108 | - /** @var IUser $user */ |
|
109 | - $this->birthdayService->syncUser($user->getUID()); |
|
110 | - }); |
|
111 | - |
|
112 | - $p->finish(); |
|
113 | - $output->writeln(''); |
|
114 | - return 0; |
|
115 | - } |
|
116 | - |
|
117 | - protected function verifyEnabled() { |
|
118 | - $isEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
119 | - |
|
120 | - if ($isEnabled !== 'yes') { |
|
121 | - throw new \InvalidArgumentException('Birthday calendars are disabled'); |
|
122 | - } |
|
123 | - } |
|
41 | + /** @var BirthdayService */ |
|
42 | + private $birthdayService; |
|
43 | + |
|
44 | + /** @var IConfig */ |
|
45 | + private $config; |
|
46 | + |
|
47 | + /** @var IUserManager */ |
|
48 | + private $userManager; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IUserManager $userManager |
|
52 | + * @param IConfig $config |
|
53 | + * @param BirthdayService $birthdayService |
|
54 | + */ |
|
55 | + public function __construct(IUserManager $userManager, IConfig $config, |
|
56 | + BirthdayService $birthdayService) { |
|
57 | + parent::__construct(); |
|
58 | + $this->birthdayService = $birthdayService; |
|
59 | + $this->config = $config; |
|
60 | + $this->userManager = $userManager; |
|
61 | + } |
|
62 | + |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('dav:sync-birthday-calendar') |
|
66 | + ->setDescription('Synchronizes the birthday calendar') |
|
67 | + ->addArgument('user', |
|
68 | + InputArgument::OPTIONAL, |
|
69 | + 'User for whom the birthday calendar will be synchronized'); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param InputInterface $input |
|
74 | + * @param OutputInterface $output |
|
75 | + */ |
|
76 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
77 | + $this->verifyEnabled(); |
|
78 | + |
|
79 | + $user = $input->getArgument('user'); |
|
80 | + if (!is_null($user)) { |
|
81 | + if (!$this->userManager->userExists($user)) { |
|
82 | + throw new \InvalidArgumentException("User <$user> in unknown."); |
|
83 | + } |
|
84 | + |
|
85 | + // re-enable the birthday calendar in case it's called directly with a user name |
|
86 | + $isEnabled = $this->config->getUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
87 | + if ($isEnabled !== 'yes') { |
|
88 | + $this->config->setUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
89 | + $output->writeln("Re-enabling birthday calendar for $user"); |
|
90 | + } |
|
91 | + |
|
92 | + $output->writeln("Start birthday calendar sync for $user"); |
|
93 | + $this->birthdayService->syncUser($user); |
|
94 | + return 0; |
|
95 | + } |
|
96 | + $output->writeln("Start birthday calendar sync for all users ..."); |
|
97 | + $p = new ProgressBar($output); |
|
98 | + $p->start(); |
|
99 | + $this->userManager->callForSeenUsers(function ($user) use ($p) { |
|
100 | + $p->advance(); |
|
101 | + |
|
102 | + $userId = $user->getUID(); |
|
103 | + $isEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
104 | + if ($isEnabled !== 'yes') { |
|
105 | + return; |
|
106 | + } |
|
107 | + |
|
108 | + /** @var IUser $user */ |
|
109 | + $this->birthdayService->syncUser($user->getUID()); |
|
110 | + }); |
|
111 | + |
|
112 | + $p->finish(); |
|
113 | + $output->writeln(''); |
|
114 | + return 0; |
|
115 | + } |
|
116 | + |
|
117 | + protected function verifyEnabled() { |
|
118 | + $isEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
119 | + |
|
120 | + if ($isEnabled !== 'yes') { |
|
121 | + throw new \InvalidArgumentException('Birthday calendars are disabled'); |
|
122 | + } |
|
123 | + } |
|
124 | 124 | } |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | private function entitiesToArray(array $entities) { |
149 | - return array_map(function (IEntity $entity) { |
|
150 | - $events = array_map(function (IEntityEvent $entityEvent) { |
|
149 | + return array_map(function(IEntity $entity) { |
|
150 | + $events = array_map(function(IEntityEvent $entityEvent) { |
|
151 | 151 | return [ |
152 | 152 | 'eventName' => $entityEvent->getEventName(), |
153 | 153 | 'displayName' => $entityEvent->getDisplayName() |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | private function operatorsToArray(array $operators) { |
167 | - $operators = array_filter($operators, function (IOperation $operator) { |
|
167 | + $operators = array_filter($operators, function(IOperation $operator) { |
|
168 | 168 | return $operator->isAvailableForScope($this->getScope()); |
169 | 169 | }); |
170 | 170 | |
171 | - return array_map(function (IOperation $operator) { |
|
171 | + return array_map(function(IOperation $operator) { |
|
172 | 172 | return [ |
173 | 173 | 'id' => get_class($operator), |
174 | 174 | 'icon' => $operator->getIcon(), |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | private function checksToArray(array $checks) { |
185 | - $checks = array_filter($checks, function (ICheck $check) { |
|
185 | + $checks = array_filter($checks, function(ICheck $check) { |
|
186 | 186 | return $check->isAvailableForScope($this->getScope()); |
187 | 187 | }); |
188 | 188 | |
189 | - return array_map(function (ICheck $check) { |
|
189 | + return array_map(function(ICheck $check) { |
|
190 | 190 | return [ |
191 | 191 | 'id' => get_class($check), |
192 | 192 | 'supportedEntities' => $check->supportedEntities(), |
@@ -48,145 +48,145 @@ |
||
48 | 48 | use OCP\WorkflowEngine\ISpecificOperation; |
49 | 49 | |
50 | 50 | abstract class ASettings implements ISettings { |
51 | - private IL10N $l10n; |
|
52 | - private string $appName; |
|
53 | - private IEventDispatcher $eventDispatcher; |
|
54 | - protected Manager $manager; |
|
55 | - private IInitialState $initialStateService; |
|
56 | - private IConfig $config; |
|
57 | - private IURLGenerator $urlGenerator; |
|
58 | - |
|
59 | - public function __construct( |
|
60 | - string $appName, |
|
61 | - IL10N $l, |
|
62 | - IEventDispatcher $eventDispatcher, |
|
63 | - Manager $manager, |
|
64 | - IInitialState $initialStateService, |
|
65 | - IConfig $config, |
|
66 | - IURLGenerator $urlGenerator |
|
67 | - ) { |
|
68 | - $this->appName = $appName; |
|
69 | - $this->l10n = $l; |
|
70 | - $this->eventDispatcher = $eventDispatcher; |
|
71 | - $this->manager = $manager; |
|
72 | - $this->initialStateService = $initialStateService; |
|
73 | - $this->config = $config; |
|
74 | - $this->urlGenerator = $urlGenerator; |
|
75 | - } |
|
76 | - |
|
77 | - abstract public function getScope(): int; |
|
78 | - |
|
79 | - /** |
|
80 | - * @return TemplateResponse |
|
81 | - */ |
|
82 | - public function getForm(): TemplateResponse { |
|
83 | - // @deprecated in 20.0.0: retire this one in favor of the typed event |
|
84 | - $this->eventDispatcher->dispatch( |
|
85 | - 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
86 | - new LoadSettingsScriptsEvent() |
|
87 | - ); |
|
88 | - $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent()); |
|
89 | - |
|
90 | - $entities = $this->manager->getEntitiesList(); |
|
91 | - $this->initialStateService->provideInitialState( |
|
92 | - 'entities', |
|
93 | - $this->entitiesToArray($entities) |
|
94 | - ); |
|
95 | - |
|
96 | - $operators = $this->manager->getOperatorList(); |
|
97 | - $this->initialStateService->provideInitialState( |
|
98 | - 'operators', |
|
99 | - $this->operatorsToArray($operators) |
|
100 | - ); |
|
101 | - |
|
102 | - $checks = $this->manager->getCheckList(); |
|
103 | - $this->initialStateService->provideInitialState( |
|
104 | - 'checks', |
|
105 | - $this->checksToArray($checks) |
|
106 | - ); |
|
107 | - |
|
108 | - $this->initialStateService->provideInitialState( |
|
109 | - 'scope', |
|
110 | - $this->getScope() |
|
111 | - ); |
|
112 | - |
|
113 | - $this->initialStateService->provideInitialState( |
|
114 | - 'appstoreenabled', |
|
115 | - $this->config->getSystemValueBool('appstoreenabled', true) |
|
116 | - ); |
|
117 | - |
|
118 | - $this->initialStateService->provideInitialState( |
|
119 | - 'doc-url', |
|
120 | - $this->urlGenerator->linkToDocs('admin-workflowengine') |
|
121 | - ); |
|
122 | - |
|
123 | - return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank'); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @return string the section ID, e.g. 'sharing' |
|
128 | - */ |
|
129 | - public function getSection(): ?string { |
|
130 | - return 'workflow'; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @return int whether the form should be rather on the top or bottom of |
|
135 | - * the admin section. The forms are arranged in ascending order of the |
|
136 | - * priority values. It is required to return a value between 0 and 100. |
|
137 | - * |
|
138 | - * E.g.: 70 |
|
139 | - */ |
|
140 | - public function getPriority(): int { |
|
141 | - return 0; |
|
142 | - } |
|
143 | - |
|
144 | - private function entitiesToArray(array $entities) { |
|
145 | - return array_map(function (IEntity $entity) { |
|
146 | - $events = array_map(function (IEntityEvent $entityEvent) { |
|
147 | - return [ |
|
148 | - 'eventName' => $entityEvent->getEventName(), |
|
149 | - 'displayName' => $entityEvent->getDisplayName() |
|
150 | - ]; |
|
151 | - }, $entity->getEvents()); |
|
152 | - |
|
153 | - return [ |
|
154 | - 'id' => get_class($entity), |
|
155 | - 'icon' => $entity->getIcon(), |
|
156 | - 'name' => $entity->getName(), |
|
157 | - 'events' => $events, |
|
158 | - ]; |
|
159 | - }, $entities); |
|
160 | - } |
|
161 | - |
|
162 | - private function operatorsToArray(array $operators) { |
|
163 | - $operators = array_filter($operators, function (IOperation $operator) { |
|
164 | - return $operator->isAvailableForScope($this->getScope()); |
|
165 | - }); |
|
166 | - |
|
167 | - return array_map(function (IOperation $operator) { |
|
168 | - return [ |
|
169 | - 'id' => get_class($operator), |
|
170 | - 'icon' => $operator->getIcon(), |
|
171 | - 'name' => $operator->getDisplayName(), |
|
172 | - 'description' => $operator->getDescription(), |
|
173 | - 'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '', |
|
174 | - 'isComplex' => $operator instanceof IComplexOperation, |
|
175 | - 'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '', |
|
176 | - ]; |
|
177 | - }, $operators); |
|
178 | - } |
|
179 | - |
|
180 | - private function checksToArray(array $checks) { |
|
181 | - $checks = array_filter($checks, function (ICheck $check) { |
|
182 | - return $check->isAvailableForScope($this->getScope()); |
|
183 | - }); |
|
184 | - |
|
185 | - return array_map(function (ICheck $check) { |
|
186 | - return [ |
|
187 | - 'id' => get_class($check), |
|
188 | - 'supportedEntities' => $check->supportedEntities(), |
|
189 | - ]; |
|
190 | - }, $checks); |
|
191 | - } |
|
51 | + private IL10N $l10n; |
|
52 | + private string $appName; |
|
53 | + private IEventDispatcher $eventDispatcher; |
|
54 | + protected Manager $manager; |
|
55 | + private IInitialState $initialStateService; |
|
56 | + private IConfig $config; |
|
57 | + private IURLGenerator $urlGenerator; |
|
58 | + |
|
59 | + public function __construct( |
|
60 | + string $appName, |
|
61 | + IL10N $l, |
|
62 | + IEventDispatcher $eventDispatcher, |
|
63 | + Manager $manager, |
|
64 | + IInitialState $initialStateService, |
|
65 | + IConfig $config, |
|
66 | + IURLGenerator $urlGenerator |
|
67 | + ) { |
|
68 | + $this->appName = $appName; |
|
69 | + $this->l10n = $l; |
|
70 | + $this->eventDispatcher = $eventDispatcher; |
|
71 | + $this->manager = $manager; |
|
72 | + $this->initialStateService = $initialStateService; |
|
73 | + $this->config = $config; |
|
74 | + $this->urlGenerator = $urlGenerator; |
|
75 | + } |
|
76 | + |
|
77 | + abstract public function getScope(): int; |
|
78 | + |
|
79 | + /** |
|
80 | + * @return TemplateResponse |
|
81 | + */ |
|
82 | + public function getForm(): TemplateResponse { |
|
83 | + // @deprecated in 20.0.0: retire this one in favor of the typed event |
|
84 | + $this->eventDispatcher->dispatch( |
|
85 | + 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
86 | + new LoadSettingsScriptsEvent() |
|
87 | + ); |
|
88 | + $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent()); |
|
89 | + |
|
90 | + $entities = $this->manager->getEntitiesList(); |
|
91 | + $this->initialStateService->provideInitialState( |
|
92 | + 'entities', |
|
93 | + $this->entitiesToArray($entities) |
|
94 | + ); |
|
95 | + |
|
96 | + $operators = $this->manager->getOperatorList(); |
|
97 | + $this->initialStateService->provideInitialState( |
|
98 | + 'operators', |
|
99 | + $this->operatorsToArray($operators) |
|
100 | + ); |
|
101 | + |
|
102 | + $checks = $this->manager->getCheckList(); |
|
103 | + $this->initialStateService->provideInitialState( |
|
104 | + 'checks', |
|
105 | + $this->checksToArray($checks) |
|
106 | + ); |
|
107 | + |
|
108 | + $this->initialStateService->provideInitialState( |
|
109 | + 'scope', |
|
110 | + $this->getScope() |
|
111 | + ); |
|
112 | + |
|
113 | + $this->initialStateService->provideInitialState( |
|
114 | + 'appstoreenabled', |
|
115 | + $this->config->getSystemValueBool('appstoreenabled', true) |
|
116 | + ); |
|
117 | + |
|
118 | + $this->initialStateService->provideInitialState( |
|
119 | + 'doc-url', |
|
120 | + $this->urlGenerator->linkToDocs('admin-workflowengine') |
|
121 | + ); |
|
122 | + |
|
123 | + return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank'); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @return string the section ID, e.g. 'sharing' |
|
128 | + */ |
|
129 | + public function getSection(): ?string { |
|
130 | + return 'workflow'; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @return int whether the form should be rather on the top or bottom of |
|
135 | + * the admin section. The forms are arranged in ascending order of the |
|
136 | + * priority values. It is required to return a value between 0 and 100. |
|
137 | + * |
|
138 | + * E.g.: 70 |
|
139 | + */ |
|
140 | + public function getPriority(): int { |
|
141 | + return 0; |
|
142 | + } |
|
143 | + |
|
144 | + private function entitiesToArray(array $entities) { |
|
145 | + return array_map(function (IEntity $entity) { |
|
146 | + $events = array_map(function (IEntityEvent $entityEvent) { |
|
147 | + return [ |
|
148 | + 'eventName' => $entityEvent->getEventName(), |
|
149 | + 'displayName' => $entityEvent->getDisplayName() |
|
150 | + ]; |
|
151 | + }, $entity->getEvents()); |
|
152 | + |
|
153 | + return [ |
|
154 | + 'id' => get_class($entity), |
|
155 | + 'icon' => $entity->getIcon(), |
|
156 | + 'name' => $entity->getName(), |
|
157 | + 'events' => $events, |
|
158 | + ]; |
|
159 | + }, $entities); |
|
160 | + } |
|
161 | + |
|
162 | + private function operatorsToArray(array $operators) { |
|
163 | + $operators = array_filter($operators, function (IOperation $operator) { |
|
164 | + return $operator->isAvailableForScope($this->getScope()); |
|
165 | + }); |
|
166 | + |
|
167 | + return array_map(function (IOperation $operator) { |
|
168 | + return [ |
|
169 | + 'id' => get_class($operator), |
|
170 | + 'icon' => $operator->getIcon(), |
|
171 | + 'name' => $operator->getDisplayName(), |
|
172 | + 'description' => $operator->getDescription(), |
|
173 | + 'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '', |
|
174 | + 'isComplex' => $operator instanceof IComplexOperation, |
|
175 | + 'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '', |
|
176 | + ]; |
|
177 | + }, $operators); |
|
178 | + } |
|
179 | + |
|
180 | + private function checksToArray(array $checks) { |
|
181 | + $checks = array_filter($checks, function (ICheck $check) { |
|
182 | + return $check->isAvailableForScope($this->getScope()); |
|
183 | + }); |
|
184 | + |
|
185 | + return array_map(function (ICheck $check) { |
|
186 | + return [ |
|
187 | + 'id' => get_class($check), |
|
188 | + 'supportedEntities' => $check->supportedEntities(), |
|
189 | + ]; |
|
190 | + }, $checks); |
|
191 | + } |
|
192 | 192 | } |