@@ -31,30 +31,30 @@ |
||
31 | 31 | |
32 | 32 | class ContactsMenuController extends Controller { |
33 | 33 | |
34 | - /** @var Manager */ |
|
35 | - private $manager; |
|
36 | - |
|
37 | - /** @var string */ |
|
38 | - private $userId; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param IRequest $request |
|
42 | - * @param string $UserId |
|
43 | - */ |
|
44 | - public function __construct(IRequest $request, $UserId, Manager $manager) { |
|
45 | - parent::__construct('core', $request); |
|
46 | - $this->userId = $UserId; |
|
47 | - $this->manager = $manager; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @NoAdminRequired |
|
52 | - * |
|
53 | - * @param string|null filter |
|
54 | - * @return JSONResponse |
|
55 | - */ |
|
56 | - public function index($filter = null) { |
|
57 | - return $this->manager->getEntries($this->userId, $filter); |
|
58 | - } |
|
34 | + /** @var Manager */ |
|
35 | + private $manager; |
|
36 | + |
|
37 | + /** @var string */ |
|
38 | + private $userId; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param IRequest $request |
|
42 | + * @param string $UserId |
|
43 | + */ |
|
44 | + public function __construct(IRequest $request, $UserId, Manager $manager) { |
|
45 | + parent::__construct('core', $request); |
|
46 | + $this->userId = $UserId; |
|
47 | + $this->manager = $manager; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @NoAdminRequired |
|
52 | + * |
|
53 | + * @param string|null filter |
|
54 | + * @return JSONResponse |
|
55 | + */ |
|
56 | + public function index($filter = null) { |
|
57 | + return $this->manager->getEntries($this->userId, $filter); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | |
36 | 36 | $application = new Application(); |
37 | 37 | $application->registerRoutes($this, [ |
38 | - 'routes' => [ |
|
39 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
60 | - ], |
|
61 | - 'ocs' => [ |
|
62 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | - ], |
|
38 | + 'routes' => [ |
|
39 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
60 | + ], |
|
61 | + 'ocs' => [ |
|
62 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | + ], |
|
67 | 67 | ]); |
68 | 68 | |
69 | 69 | // Post installation check |
@@ -72,36 +72,36 @@ discard block |
||
72 | 72 | // Core ajax actions |
73 | 73 | // Search |
74 | 74 | $this->create('search_ajax_search', '/core/search') |
75 | - ->actionInclude('core/search/ajax/search.php'); |
|
75 | + ->actionInclude('core/search/ajax/search.php'); |
|
76 | 76 | // Routing |
77 | 77 | $this->create('core_ajax_update', '/core/ajax/update.php') |
78 | - ->actionInclude('core/ajax/update.php'); |
|
78 | + ->actionInclude('core/ajax/update.php'); |
|
79 | 79 | |
80 | 80 | // File routes |
81 | 81 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
82 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | - $app->dispatch('ViewController', 'index'); |
|
82 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | + $app->dispatch('ViewController', 'index'); |
|
84 | 84 | }); |
85 | 85 | |
86 | 86 | // Sharing routes |
87 | 87 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
88 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | - $app->dispatch('ShareController', 'showShare'); |
|
88 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | + $app->dispatch('ShareController', 'showShare'); |
|
90 | 90 | }); |
91 | 91 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
92 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | - $app->dispatch('ShareController', 'authenticate'); |
|
92 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | + $app->dispatch('ShareController', 'authenticate'); |
|
94 | 94 | }); |
95 | 95 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
96 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
96 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
98 | 98 | }); |
99 | 99 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
100 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | - $app->dispatch('ShareController', 'downloadShare'); |
|
100 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | + $app->dispatch('ShareController', 'downloadShare'); |
|
102 | 102 | }); |
103 | 103 | |
104 | 104 | // used for heartbeat |
105 | 105 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
106 | - // do nothing |
|
106 | + // do nothing |
|
107 | 107 | }); |
@@ -33,52 +33,52 @@ |
||
33 | 33 | |
34 | 34 | class ActionProviderStore { |
35 | 35 | |
36 | - /** @var IServerContainer */ |
|
37 | - private $serverContainer; |
|
36 | + /** @var IServerContainer */ |
|
37 | + private $serverContainer; |
|
38 | 38 | |
39 | - /** @var ILogger */ |
|
40 | - private $logger; |
|
39 | + /** @var ILogger */ |
|
40 | + private $logger; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IServerContainer $serverContainer |
|
44 | - */ |
|
45 | - public function __construct(IServerContainer $serverContainer, ILogger $logger) { |
|
46 | - $this->serverContainer = $serverContainer; |
|
47 | - $this->logger = $logger; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @param IServerContainer $serverContainer |
|
44 | + */ |
|
45 | + public function __construct(IServerContainer $serverContainer, ILogger $logger) { |
|
46 | + $this->serverContainer = $serverContainer; |
|
47 | + $this->logger = $logger; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return IProvider[] |
|
52 | - * @throws Exception |
|
53 | - */ |
|
54 | - public function getProviders() { |
|
55 | - // TODO: include apps |
|
56 | - $providerClasses = $this->getServerProviderClasses(); |
|
57 | - $providers = []; |
|
50 | + /** |
|
51 | + * @return IProvider[] |
|
52 | + * @throws Exception |
|
53 | + */ |
|
54 | + public function getProviders() { |
|
55 | + // TODO: include apps |
|
56 | + $providerClasses = $this->getServerProviderClasses(); |
|
57 | + $providers = []; |
|
58 | 58 | |
59 | - foreach ($providerClasses as $class) { |
|
60 | - try { |
|
61 | - $providers[] = $this->serverContainer->query($class); |
|
62 | - } catch (QueryException $ex) { |
|
63 | - $this->logger->logException($ex, [ |
|
64 | - 'message' => "Could not load contacts menu action provider $class", |
|
65 | - 'app' => 'core', |
|
66 | - ]); |
|
67 | - throw new \Exception("Could not load contacts menu action provider"); |
|
68 | - } |
|
69 | - } |
|
59 | + foreach ($providerClasses as $class) { |
|
60 | + try { |
|
61 | + $providers[] = $this->serverContainer->query($class); |
|
62 | + } catch (QueryException $ex) { |
|
63 | + $this->logger->logException($ex, [ |
|
64 | + 'message' => "Could not load contacts menu action provider $class", |
|
65 | + 'app' => 'core', |
|
66 | + ]); |
|
67 | + throw new \Exception("Could not load contacts menu action provider"); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - return $providers; |
|
72 | - } |
|
71 | + return $providers; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string[] |
|
76 | - */ |
|
77 | - private function getServerProviderClasses() { |
|
78 | - return [ |
|
79 | - EMailProvider::class, |
|
80 | - DetailsProvider::class, |
|
81 | - ]; |
|
82 | - } |
|
74 | + /** |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | + private function getServerProviderClasses() { |
|
78 | + return [ |
|
79 | + EMailProvider::class, |
|
80 | + DetailsProvider::class, |
|
81 | + ]; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -29,56 +29,56 @@ |
||
29 | 29 | |
30 | 30 | class ContactsStore { |
31 | 31 | |
32 | - /** @var IManager */ |
|
33 | - private $contactsManager; |
|
32 | + /** @var IManager */ |
|
33 | + private $contactsManager; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param IManager $contactsManager |
|
37 | - */ |
|
38 | - public function __construct(IManager $contactsManager) { |
|
39 | - $this->contactsManager = $contactsManager; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @param IManager $contactsManager |
|
37 | + */ |
|
38 | + public function __construct(IManager $contactsManager) { |
|
39 | + $this->contactsManager = $contactsManager; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string|null $filter |
|
44 | - * @return IEntry[] |
|
45 | - */ |
|
46 | - public function getContacts($filter) { |
|
47 | - $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | - 'FN', |
|
49 | - ]); |
|
42 | + /** |
|
43 | + * @param string|null $filter |
|
44 | + * @return IEntry[] |
|
45 | + */ |
|
46 | + public function getContacts($filter) { |
|
47 | + $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | + 'FN', |
|
49 | + ]); |
|
50 | 50 | |
51 | - return array_map(function(array $contact) { |
|
52 | - return $this->contactArrayToEntry($contact); |
|
53 | - }, $allContacts); |
|
54 | - } |
|
51 | + return array_map(function(array $contact) { |
|
52 | + return $this->contactArrayToEntry($contact); |
|
53 | + }, $allContacts); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param array $contact |
|
58 | - * @return Entry |
|
59 | - */ |
|
60 | - private function contactArrayToEntry(array $contact) { |
|
61 | - $entry = new Entry(); |
|
56 | + /** |
|
57 | + * @param array $contact |
|
58 | + * @return Entry |
|
59 | + */ |
|
60 | + private function contactArrayToEntry(array $contact) { |
|
61 | + $entry = new Entry(); |
|
62 | 62 | |
63 | - if (isset($contact['id'])) { |
|
64 | - $entry->setId($contact['id']); |
|
65 | - } |
|
63 | + if (isset($contact['id'])) { |
|
64 | + $entry->setId($contact['id']); |
|
65 | + } |
|
66 | 66 | |
67 | - if (isset($contact['FN'])) { |
|
68 | - $entry->setFullName($contact['FN']); |
|
69 | - } |
|
67 | + if (isset($contact['FN'])) { |
|
68 | + $entry->setFullName($contact['FN']); |
|
69 | + } |
|
70 | 70 | |
71 | - if (isset($contact['EMAIL'])) { |
|
72 | - foreach ($contact['EMAIL'] as $email) { |
|
73 | - $entry->addEMailAddress($email); |
|
74 | - } |
|
75 | - } |
|
71 | + if (isset($contact['EMAIL'])) { |
|
72 | + foreach ($contact['EMAIL'] as $email) { |
|
73 | + $entry->addEMailAddress($email); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - // Attach all other properties to the entry too becuase some |
|
78 | - // providers might make use of it. |
|
79 | - $entry->setProperties($contact); |
|
77 | + // Attach all other properties to the entry too becuase some |
|
78 | + // providers might make use of it. |
|
79 | + $entry->setProperties($contact); |
|
80 | 80 | |
81 | - return $entry; |
|
82 | - } |
|
81 | + return $entry; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -30,28 +30,28 @@ |
||
30 | 30 | |
31 | 31 | class ActionFactory implements IActionFactory { |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $icon |
|
35 | - * @param string $name |
|
36 | - * @param string $href |
|
37 | - * @return ILinkAction |
|
38 | - */ |
|
39 | - public function newLinkAction($icon, $name, $href) { |
|
40 | - $action = new LinkAction(); |
|
41 | - $action->setName($name); |
|
42 | - $action->setIcon($icon); |
|
43 | - $action->setHref($href); |
|
44 | - return $action; |
|
45 | - } |
|
33 | + /** |
|
34 | + * @param string $icon |
|
35 | + * @param string $name |
|
36 | + * @param string $href |
|
37 | + * @return ILinkAction |
|
38 | + */ |
|
39 | + public function newLinkAction($icon, $name, $href) { |
|
40 | + $action = new LinkAction(); |
|
41 | + $action->setName($name); |
|
42 | + $action->setIcon($icon); |
|
43 | + $action->setHref($href); |
|
44 | + return $action; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $icon |
|
49 | - * @param string $name |
|
50 | - * @param string $email |
|
51 | - * @return ILinkAction |
|
52 | - */ |
|
53 | - public function newEMailAction($icon, $name, $email) { |
|
54 | - return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
55 | - } |
|
47 | + /** |
|
48 | + * @param string $icon |
|
49 | + * @param string $name |
|
50 | + * @param string $email |
|
51 | + * @return ILinkAction |
|
52 | + */ |
|
53 | + public function newEMailAction($icon, $name, $email) { |
|
54 | + return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | * @return ILinkAction |
52 | 52 | */ |
53 | 53 | public function newEMailAction($icon, $name, $email) { |
54 | - return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
54 | + return $this->newLinkAction($icon, $name, 'mailto:'.urlencode($email)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | } |
@@ -28,76 +28,76 @@ |
||
28 | 28 | |
29 | 29 | class LinkAction implements ILinkAction { |
30 | 30 | |
31 | - /** @var string */ |
|
32 | - private $icon; |
|
33 | - |
|
34 | - /** @var string */ |
|
35 | - private $name; |
|
36 | - |
|
37 | - /** @var string */ |
|
38 | - private $href; |
|
39 | - |
|
40 | - /** @var int */ |
|
41 | - private $priority = 10; |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $icon absolute URI to an icon |
|
45 | - */ |
|
46 | - public function setIcon($icon) { |
|
47 | - $this->icon = $icon; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $name |
|
52 | - */ |
|
53 | - public function setName($name) { |
|
54 | - $this->name = $name; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getName() { |
|
61 | - return $this->name; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param int $priority |
|
66 | - */ |
|
67 | - public function setPriority($priority) { |
|
68 | - $this->priority = $priority; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - public function getPriority() { |
|
75 | - return $this->priority; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $href |
|
80 | - */ |
|
81 | - public function setHref($href) { |
|
82 | - $this->href = $href; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function getHref() { |
|
89 | - return $this->href; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function jsonSerialize() { |
|
96 | - return [ |
|
97 | - 'title' => $this->name, |
|
98 | - 'icon' => $this->icon, |
|
99 | - 'hyperlink' => $this->href, |
|
100 | - ]; |
|
101 | - } |
|
31 | + /** @var string */ |
|
32 | + private $icon; |
|
33 | + |
|
34 | + /** @var string */ |
|
35 | + private $name; |
|
36 | + |
|
37 | + /** @var string */ |
|
38 | + private $href; |
|
39 | + |
|
40 | + /** @var int */ |
|
41 | + private $priority = 10; |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $icon absolute URI to an icon |
|
45 | + */ |
|
46 | + public function setIcon($icon) { |
|
47 | + $this->icon = $icon; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $name |
|
52 | + */ |
|
53 | + public function setName($name) { |
|
54 | + $this->name = $name; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getName() { |
|
61 | + return $this->name; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param int $priority |
|
66 | + */ |
|
67 | + public function setPriority($priority) { |
|
68 | + $this->priority = $priority; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @return int |
|
73 | + */ |
|
74 | + public function getPriority() { |
|
75 | + return $this->priority; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $href |
|
80 | + */ |
|
81 | + public function setHref($href) { |
|
82 | + $this->href = $href; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function getHref() { |
|
89 | + return $this->href; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function jsonSerialize() { |
|
96 | + return [ |
|
97 | + 'title' => $this->name, |
|
98 | + 'icon' => $this->icon, |
|
99 | + 'hyperlink' => $this->href, |
|
100 | + ]; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
@@ -30,27 +30,27 @@ |
||
30 | 30 | |
31 | 31 | class EMailProvider implements IProvider { |
32 | 32 | |
33 | - /** @var IActionFactory */ |
|
34 | - private $actionFactory; |
|
35 | - |
|
36 | - /** |
|
37 | - * @param IActionFactory $actionFactory |
|
38 | - */ |
|
39 | - public function __construct(IActionFactory $actionFactory) { |
|
40 | - $this->actionFactory = $actionFactory; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @param IEntry $entry |
|
45 | - */ |
|
46 | - public function process(IEntry $entry) { |
|
47 | - foreach ($entry->getEMailAddresses() as $address) { |
|
48 | - // TODO: absolute path |
|
49 | - // TODO: meaningful URL |
|
50 | - // TODO: l10n |
|
51 | - $action = $this->actionFactory->newEMailAction('icon-mail', 'Mail', $address); |
|
52 | - $entry->addAction($action); |
|
53 | - } |
|
54 | - } |
|
33 | + /** @var IActionFactory */ |
|
34 | + private $actionFactory; |
|
35 | + |
|
36 | + /** |
|
37 | + * @param IActionFactory $actionFactory |
|
38 | + */ |
|
39 | + public function __construct(IActionFactory $actionFactory) { |
|
40 | + $this->actionFactory = $actionFactory; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @param IEntry $entry |
|
45 | + */ |
|
46 | + public function process(IEntry $entry) { |
|
47 | + foreach ($entry->getEMailAddresses() as $address) { |
|
48 | + // TODO: absolute path |
|
49 | + // TODO: meaningful URL |
|
50 | + // TODO: l10n |
|
51 | + $action = $this->actionFactory->newEMailAction('icon-mail', 'Mail', $address); |
|
52 | + $entry->addAction($action); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -34,38 +34,38 @@ |
||
34 | 34 | */ |
35 | 35 | class DetailsProvider implements IProvider { |
36 | 36 | |
37 | - /** @var IURLGenerator */ |
|
38 | - private $urlGenerator; |
|
37 | + /** @var IURLGenerator */ |
|
38 | + private $urlGenerator; |
|
39 | 39 | |
40 | - /** @var IActionFactory */ |
|
41 | - private $actionFactory; |
|
40 | + /** @var IActionFactory */ |
|
41 | + private $actionFactory; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IURLGenerator $urlGenerator |
|
45 | - * @param IActionFactory $actionFactory |
|
46 | - */ |
|
47 | - public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { |
|
48 | - $this->actionFactory = $actionFactory; |
|
49 | - $this->urlGenerator = $urlGenerator; |
|
50 | - } |
|
43 | + /** |
|
44 | + * @param IURLGenerator $urlGenerator |
|
45 | + * @param IActionFactory $actionFactory |
|
46 | + */ |
|
47 | + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { |
|
48 | + $this->actionFactory = $actionFactory; |
|
49 | + $this->urlGenerator = $urlGenerator; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param IEntry $entry |
|
54 | - */ |
|
55 | - public function process(IEntry $entry) { |
|
56 | - $uid = $entry->getProperty('UID'); |
|
52 | + /** |
|
53 | + * @param IEntry $entry |
|
54 | + */ |
|
55 | + public function process(IEntry $entry) { |
|
56 | + $uid = $entry->getProperty('UID'); |
|
57 | 57 | |
58 | - if (is_null($uid)) { |
|
59 | - // Nothing to do |
|
60 | - return; |
|
61 | - } |
|
58 | + if (is_null($uid)) { |
|
59 | + // Nothing to do |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - // TODO: unique contact URL to the contacts app |
|
64 | - // TODO: l10n |
|
65 | - $contactsUrl = $this->urlGenerator->getAbsoluteURL('/apps/contacts'); |
|
66 | - $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); |
|
67 | - $action->setPriority(0); |
|
68 | - $entry->addAction($action); |
|
69 | - } |
|
63 | + // TODO: unique contact URL to the contacts app |
|
64 | + // TODO: l10n |
|
65 | + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/apps/contacts'); |
|
66 | + $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); |
|
67 | + $action->setPriority(0); |
|
68 | + $entry->addAction($action); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -30,72 +30,72 @@ |
||
30 | 30 | |
31 | 31 | class Manager { |
32 | 32 | |
33 | - /** @var ContactsStore */ |
|
34 | - private $store; |
|
33 | + /** @var ContactsStore */ |
|
34 | + private $store; |
|
35 | 35 | |
36 | - /** @var ActionProviderStore */ |
|
37 | - private $actionProviderStore; |
|
36 | + /** @var ActionProviderStore */ |
|
37 | + private $actionProviderStore; |
|
38 | 38 | |
39 | - /** @var IAppManager */ |
|
40 | - private $appManager; |
|
39 | + /** @var IAppManager */ |
|
40 | + private $appManager; |
|
41 | 41 | |
42 | - /** @var IURLGenerator */ |
|
43 | - private $urlGenerator; |
|
42 | + /** @var IURLGenerator */ |
|
43 | + private $urlGenerator; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param ContactsStore $store |
|
47 | - * @param ActionProviderStore $actionProviderStore |
|
48 | - * @param IAppManager $appManager |
|
49 | - */ |
|
50 | - public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IURLGenerator $urlGenerator) { |
|
51 | - $this->store = $store; |
|
52 | - $this->actionProviderStore = $actionProviderStore; |
|
53 | - $this->appManager = $appManager; |
|
54 | - $this->urlGenerator = $urlGenerator; |
|
55 | - } |
|
45 | + /** |
|
46 | + * @param ContactsStore $store |
|
47 | + * @param ActionProviderStore $actionProviderStore |
|
48 | + * @param IAppManager $appManager |
|
49 | + */ |
|
50 | + public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IURLGenerator $urlGenerator) { |
|
51 | + $this->store = $store; |
|
52 | + $this->actionProviderStore = $actionProviderStore; |
|
53 | + $this->appManager = $appManager; |
|
54 | + $this->urlGenerator = $urlGenerator; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $userId |
|
59 | - * @param string $filter |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function getEntries($userId, $filter) { |
|
63 | - $entries = $this->store->getContacts($filter); |
|
57 | + /** |
|
58 | + * @param string $userId |
|
59 | + * @param string $filter |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function getEntries($userId, $filter) { |
|
63 | + $entries = $this->store->getContacts($filter); |
|
64 | 64 | |
65 | - $sortedEntries = $this->sortEntries($entries); |
|
66 | - $topEntries = array_slice($sortedEntries, 0, 25); |
|
67 | - $this->processEntries($topEntries); |
|
65 | + $sortedEntries = $this->sortEntries($entries); |
|
66 | + $topEntries = array_slice($sortedEntries, 0, 25); |
|
67 | + $this->processEntries($topEntries); |
|
68 | 68 | |
69 | - $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $userId); |
|
70 | - $contactsURL = $this->urlGenerator->getAbsoluteURL('/apps/contacts'); |
|
71 | - return [ |
|
72 | - 'contacts' => $topEntries, |
|
73 | - 'contactsAppEnabled' => $contactsEnabled, |
|
74 | - 'contactsAppURL' => $contactsURL, |
|
75 | - ]; |
|
76 | - } |
|
69 | + $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $userId); |
|
70 | + $contactsURL = $this->urlGenerator->getAbsoluteURL('/apps/contacts'); |
|
71 | + return [ |
|
72 | + 'contacts' => $topEntries, |
|
73 | + 'contactsAppEnabled' => $contactsEnabled, |
|
74 | + 'contactsAppURL' => $contactsURL, |
|
75 | + ]; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IEntry[] $entries |
|
80 | - * @return IEntry[] |
|
81 | - */ |
|
82 | - private function sortEntries(array $entries) { |
|
83 | - usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
84 | - return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
85 | - }); |
|
86 | - return $entries; |
|
87 | - } |
|
78 | + /** |
|
79 | + * @param IEntry[] $entries |
|
80 | + * @return IEntry[] |
|
81 | + */ |
|
82 | + private function sortEntries(array $entries) { |
|
83 | + usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
84 | + return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
85 | + }); |
|
86 | + return $entries; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param IEntry[] $entries |
|
91 | - */ |
|
92 | - private function processEntries(array $entries) { |
|
93 | - $providers = $this->actionProviderStore->getProviders(); |
|
94 | - foreach ($entries as $entry) { |
|
95 | - foreach ($providers as $provider) { |
|
96 | - $provider->process($entry); |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
89 | + /** |
|
90 | + * @param IEntry[] $entries |
|
91 | + */ |
|
92 | + private function processEntries(array $entries) { |
|
93 | + $providers = $this->actionProviderStore->getProviders(); |
|
94 | + foreach ($entries as $entry) { |
|
95 | + foreach ($providers as $provider) { |
|
96 | + $provider->process($entry); |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |