@@ -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 | } |
@@ -33,33 +33,33 @@ |
||
33 | 33 | */ |
34 | 34 | interface IAction extends JsonSerializable { |
35 | 35 | |
36 | - /** |
|
37 | - * @param string $icon absolute URI to an icon |
|
38 | - * @since 12.0 |
|
39 | - */ |
|
40 | - public function setIcon($icon); |
|
36 | + /** |
|
37 | + * @param string $icon absolute URI to an icon |
|
38 | + * @since 12.0 |
|
39 | + */ |
|
40 | + public function setIcon($icon); |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string localized action name, e.g. 'Call' |
|
44 | - * @since 12.0 |
|
45 | - */ |
|
46 | - public function getName(); |
|
42 | + /** |
|
43 | + * @return string localized action name, e.g. 'Call' |
|
44 | + * @since 12.0 |
|
45 | + */ |
|
46 | + public function getName(); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $name localized action name, e.g. 'Call' |
|
50 | - * @since 12.0 |
|
51 | - */ |
|
52 | - public function setName($name); |
|
48 | + /** |
|
49 | + * @param string $name localized action name, e.g. 'Call' |
|
50 | + * @since 12.0 |
|
51 | + */ |
|
52 | + public function setName($name); |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param int $priority priorize actions, high order ones are shown on top |
|
56 | - * @since 12.0 |
|
57 | - */ |
|
58 | - public function setPriority($priority); |
|
54 | + /** |
|
55 | + * @param int $priority priorize actions, high order ones are shown on top |
|
56 | + * @since 12.0 |
|
57 | + */ |
|
58 | + public function setPriority($priority); |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return int priority to priorize actions, high order ones are shown on top |
|
62 | - * @since 12.0 |
|
63 | - */ |
|
64 | - public function getPriority(); |
|
60 | + /** |
|
61 | + * @return int priority to priorize actions, high order ones are shown on top |
|
62 | + * @since 12.0 |
|
63 | + */ |
|
64 | + public function getPriority(); |
|
65 | 65 | } |
@@ -28,27 +28,27 @@ |
||
28 | 28 | */ |
29 | 29 | interface IActionFactory { |
30 | 30 | |
31 | - /** |
|
32 | - * Construct and return a new link action for the contacts menu |
|
33 | - * |
|
34 | - * @since 12.0 |
|
35 | - * |
|
36 | - * @param string $icon full path to the action's icon |
|
37 | - * @param string $name localized name of the action |
|
38 | - * @param string $href target URL |
|
39 | - * @return ILinkAction |
|
40 | - */ |
|
41 | - public function newLinkAction($icon, $name, $href); |
|
31 | + /** |
|
32 | + * Construct and return a new link action for the contacts menu |
|
33 | + * |
|
34 | + * @since 12.0 |
|
35 | + * |
|
36 | + * @param string $icon full path to the action's icon |
|
37 | + * @param string $name localized name of the action |
|
38 | + * @param string $href target URL |
|
39 | + * @return ILinkAction |
|
40 | + */ |
|
41 | + public function newLinkAction($icon, $name, $href); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Construct and return a new email action for the contacts menu |
|
45 | - * |
|
46 | - * @since 12.0 |
|
47 | - * |
|
48 | - * @param string $icon full path to the action's icon |
|
49 | - * @param string $name localized name of the action |
|
50 | - * @param string $email target e-mail address |
|
51 | - * @return ILinkAction |
|
52 | - */ |
|
53 | - public function newEMailAction($icon, $name, $email); |
|
43 | + /** |
|
44 | + * Construct and return a new email action for the contacts menu |
|
45 | + * |
|
46 | + * @since 12.0 |
|
47 | + * |
|
48 | + * @param string $icon full path to the action's icon |
|
49 | + * @param string $name localized name of the action |
|
50 | + * @param string $email target e-mail address |
|
51 | + * @return ILinkAction |
|
52 | + */ |
|
53 | + public function newEMailAction($icon, $name, $email); |
|
54 | 54 | } |
@@ -29,15 +29,15 @@ |
||
29 | 29 | */ |
30 | 30 | interface ILinkAction extends IAction { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 12.0 |
|
34 | - * @param string $href the target URL of the action |
|
35 | - */ |
|
36 | - public function setHref($href); |
|
32 | + /** |
|
33 | + * @since 12.0 |
|
34 | + * @param string $href the target URL of the action |
|
35 | + */ |
|
36 | + public function setHref($href); |
|
37 | 37 | |
38 | - /** |
|
39 | - * @since 12.0 |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getHref(); |
|
38 | + /** |
|
39 | + * @since 12.0 |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getHref(); |
|
43 | 43 | } |
@@ -29,141 +29,141 @@ |
||
29 | 29 | |
30 | 30 | class Entry implements IEntry { |
31 | 31 | |
32 | - /** @var string|int|null */ |
|
33 | - private $id = null; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $fullName = ''; |
|
37 | - |
|
38 | - /** @var string[] */ |
|
39 | - private $emailAddresses = []; |
|
40 | - |
|
41 | - /** @var string|null */ |
|
42 | - private $avatar; |
|
43 | - |
|
44 | - /** @var IAction[] */ |
|
45 | - private $actions = []; |
|
46 | - |
|
47 | - /** @var array */ |
|
48 | - private $properties = []; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $id |
|
52 | - */ |
|
53 | - public function setId($id) { |
|
54 | - $this->id = $id; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $displayName |
|
59 | - */ |
|
60 | - public function setFullName($displayName) { |
|
61 | - $this->fullName = $displayName; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getFullName() { |
|
68 | - return $this->fullName; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $address |
|
73 | - */ |
|
74 | - public function addEMailAddress($address) { |
|
75 | - $this->emailAddresses[] = $address; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getEMailAddresses() { |
|
82 | - return $this->emailAddresses; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $avatar |
|
87 | - */ |
|
88 | - public function setAvatar($avatar) { |
|
89 | - $this->avatar = $avatar; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function getAvatar() { |
|
96 | - return $this->avatar; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param IAction $action |
|
101 | - */ |
|
102 | - public function addAction(IAction $action) { |
|
103 | - $this->actions[] = $action; |
|
104 | - $this->sortActions(); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return IAction[] |
|
109 | - */ |
|
110 | - public function getActions() { |
|
111 | - return $this->actions; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * sort the actions by priority and name |
|
116 | - */ |
|
117 | - private function sortActions() { |
|
118 | - usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | - $prio1 = $action1->getPriority(); |
|
120 | - $prio2 = $action2->getPriority(); |
|
121 | - |
|
122 | - if ($prio1 === $prio2) { |
|
123 | - // Ascending order for same priority |
|
124 | - return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | - } |
|
126 | - |
|
127 | - // Descending order when priority differs |
|
128 | - return $prio2 - $prio1; |
|
129 | - }); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @param array $contact key-value array containing additional properties |
|
134 | - */ |
|
135 | - public function setProperties(array $contact) { |
|
136 | - $this->properties = $contact; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $key |
|
141 | - * @return mixed |
|
142 | - */ |
|
143 | - public function getProperty($key) { |
|
144 | - if (!isset($this->properties[$key])) { |
|
145 | - return null; |
|
146 | - } |
|
147 | - return $this->properties[$key]; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function jsonSerialize() { |
|
154 | - $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | - $otherActions = array_map(function(IAction $action) { |
|
156 | - return $action->jsonSerialize(); |
|
157 | - }, array_slice($this->actions, 1)); |
|
158 | - |
|
159 | - return [ |
|
160 | - 'id' => $this->id, |
|
161 | - 'fullName' => $this->fullName, |
|
162 | - 'avatar' => $this->getAvatar(), |
|
163 | - 'topAction' => $topAction, |
|
164 | - 'actions' => $otherActions, |
|
165 | - 'lastMessage' => '', |
|
166 | - ]; |
|
167 | - } |
|
32 | + /** @var string|int|null */ |
|
33 | + private $id = null; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $fullName = ''; |
|
37 | + |
|
38 | + /** @var string[] */ |
|
39 | + private $emailAddresses = []; |
|
40 | + |
|
41 | + /** @var string|null */ |
|
42 | + private $avatar; |
|
43 | + |
|
44 | + /** @var IAction[] */ |
|
45 | + private $actions = []; |
|
46 | + |
|
47 | + /** @var array */ |
|
48 | + private $properties = []; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $id |
|
52 | + */ |
|
53 | + public function setId($id) { |
|
54 | + $this->id = $id; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $displayName |
|
59 | + */ |
|
60 | + public function setFullName($displayName) { |
|
61 | + $this->fullName = $displayName; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getFullName() { |
|
68 | + return $this->fullName; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $address |
|
73 | + */ |
|
74 | + public function addEMailAddress($address) { |
|
75 | + $this->emailAddresses[] = $address; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getEMailAddresses() { |
|
82 | + return $this->emailAddresses; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $avatar |
|
87 | + */ |
|
88 | + public function setAvatar($avatar) { |
|
89 | + $this->avatar = $avatar; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function getAvatar() { |
|
96 | + return $this->avatar; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param IAction $action |
|
101 | + */ |
|
102 | + public function addAction(IAction $action) { |
|
103 | + $this->actions[] = $action; |
|
104 | + $this->sortActions(); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return IAction[] |
|
109 | + */ |
|
110 | + public function getActions() { |
|
111 | + return $this->actions; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * sort the actions by priority and name |
|
116 | + */ |
|
117 | + private function sortActions() { |
|
118 | + usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | + $prio1 = $action1->getPriority(); |
|
120 | + $prio2 = $action2->getPriority(); |
|
121 | + |
|
122 | + if ($prio1 === $prio2) { |
|
123 | + // Ascending order for same priority |
|
124 | + return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | + } |
|
126 | + |
|
127 | + // Descending order when priority differs |
|
128 | + return $prio2 - $prio1; |
|
129 | + }); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @param array $contact key-value array containing additional properties |
|
134 | + */ |
|
135 | + public function setProperties(array $contact) { |
|
136 | + $this->properties = $contact; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $key |
|
141 | + * @return mixed |
|
142 | + */ |
|
143 | + public function getProperty($key) { |
|
144 | + if (!isset($this->properties[$key])) { |
|
145 | + return null; |
|
146 | + } |
|
147 | + return $this->properties[$key]; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function jsonSerialize() { |
|
154 | + $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | + $otherActions = array_map(function(IAction $action) { |
|
156 | + return $action->jsonSerialize(); |
|
157 | + }, array_slice($this->actions, 1)); |
|
158 | + |
|
159 | + return [ |
|
160 | + 'id' => $this->id, |
|
161 | + 'fullName' => $this->fullName, |
|
162 | + 'avatar' => $this->getAvatar(), |
|
163 | + 'topAction' => $topAction, |
|
164 | + 'actions' => $otherActions, |
|
165 | + 'lastMessage' => '', |
|
166 | + ]; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | } |
@@ -31,36 +31,36 @@ |
||
31 | 31 | */ |
32 | 32 | interface IEntry extends JsonSerializable { |
33 | 33 | |
34 | - /** |
|
35 | - * @since 12.0 |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getFullName(); |
|
34 | + /** |
|
35 | + * @since 12.0 |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getFullName(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 12.0 |
|
42 | - * @return string[] |
|
43 | - */ |
|
44 | - public function getEMailAddresses(); |
|
40 | + /** |
|
41 | + * @since 12.0 |
|
42 | + * @return string[] |
|
43 | + */ |
|
44 | + public function getEMailAddresses(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 12.0 |
|
48 | - * @return string|null image URI |
|
49 | - */ |
|
50 | - public function getAvatar(); |
|
46 | + /** |
|
47 | + * @since 12.0 |
|
48 | + * @return string|null image URI |
|
49 | + */ |
|
50 | + public function getAvatar(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * @since 12.0 |
|
54 | - * @param IAction $action an action to show in the contacts menu |
|
55 | - */ |
|
56 | - public function addAction(IAction $action); |
|
52 | + /** |
|
53 | + * @since 12.0 |
|
54 | + * @param IAction $action an action to show in the contacts menu |
|
55 | + */ |
|
56 | + public function addAction(IAction $action); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Get an arbitrary property from the contact |
|
60 | - * |
|
61 | - * @since 12.0 |
|
62 | - * @param string $key |
|
63 | - * @return mixed the value of the property or null |
|
64 | - */ |
|
65 | - public function getProperty($key); |
|
58 | + /** |
|
59 | + * Get an arbitrary property from the contact |
|
60 | + * |
|
61 | + * @since 12.0 |
|
62 | + * @param string $key |
|
63 | + * @return mixed the value of the property or null |
|
64 | + */ |
|
65 | + public function getProperty($key); |
|
66 | 66 | } |
@@ -32,31 +32,31 @@ |
||
32 | 32 | |
33 | 33 | class ContactsMenuController extends Controller { |
34 | 34 | |
35 | - /** @var Manager */ |
|
36 | - private $manager; |
|
37 | - |
|
38 | - /** @var IUserSession */ |
|
39 | - private $userSession; |
|
40 | - |
|
41 | - /** |
|
42 | - * @param IRequest $request |
|
43 | - * @param IUserSession $userSession |
|
44 | - * @param Manager $manager |
|
45 | - */ |
|
46 | - public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) { |
|
47 | - parent::__construct('core', $request); |
|
48 | - $this->userSession = $userSession; |
|
49 | - $this->manager = $manager; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @NoAdminRequired |
|
54 | - * |
|
55 | - * @param string|null filter |
|
56 | - * @return JSONResponse |
|
57 | - */ |
|
58 | - public function index($filter = null) { |
|
59 | - return $this->manager->getEntries($this->userSession->getUser(), $filter); |
|
60 | - } |
|
35 | + /** @var Manager */ |
|
36 | + private $manager; |
|
37 | + |
|
38 | + /** @var IUserSession */ |
|
39 | + private $userSession; |
|
40 | + |
|
41 | + /** |
|
42 | + * @param IRequest $request |
|
43 | + * @param IUserSession $userSession |
|
44 | + * @param Manager $manager |
|
45 | + */ |
|
46 | + public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) { |
|
47 | + parent::__construct('core', $request); |
|
48 | + $this->userSession = $userSession; |
|
49 | + $this->manager = $manager; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @NoAdminRequired |
|
54 | + * |
|
55 | + * @param string|null filter |
|
56 | + * @return JSONResponse |
|
57 | + */ |
|
58 | + public function index($filter = null) { |
|
59 | + return $this->manager->getEntries($this->userSession->getUser(), $filter); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -35,80 +35,80 @@ |
||
35 | 35 | |
36 | 36 | class ActionProviderStore { |
37 | 37 | |
38 | - /** @var IServerContainer */ |
|
39 | - private $serverContainer; |
|
40 | - |
|
41 | - /** @var AppManager */ |
|
42 | - private $appManager; |
|
43 | - |
|
44 | - /** @var ILogger */ |
|
45 | - private $logger; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param IServerContainer $serverContainer |
|
49 | - * @param AppManager $appManager |
|
50 | - * @param ILogger $logger |
|
51 | - */ |
|
52 | - public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) { |
|
53 | - $this->serverContainer = $serverContainer; |
|
54 | - $this->appManager = $appManager; |
|
55 | - $this->logger = $logger; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param IUser $user |
|
60 | - * @return IProvider[] |
|
61 | - * @throws Exception |
|
62 | - */ |
|
63 | - public function getProviders(IUser $user) { |
|
64 | - $appClasses = $this->getAppProviderClasses($user); |
|
65 | - $providerClasses = $this->getServerProviderClasses(); |
|
66 | - $allClasses = array_merge($providerClasses, $appClasses); |
|
67 | - $providers = []; |
|
68 | - |
|
69 | - foreach ($allClasses as $class) { |
|
70 | - try { |
|
71 | - $providers[] = $this->serverContainer->query($class); |
|
72 | - } catch (QueryException $ex) { |
|
73 | - $this->logger->logException($ex, [ |
|
74 | - 'message' => "Could not load contacts menu action provider $class", |
|
75 | - 'app' => 'core', |
|
76 | - ]); |
|
77 | - throw new Exception("Could not load contacts menu action provider"); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - return $providers; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @return string[] |
|
86 | - */ |
|
87 | - private function getServerProviderClasses() { |
|
88 | - return [ |
|
89 | - EMailProvider::class, |
|
90 | - ]; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param IUser $user |
|
95 | - * @return string[] |
|
96 | - */ |
|
97 | - private function getAppProviderClasses(IUser $user) { |
|
98 | - return array_reduce($this->appManager->getEnabledAppsForUser($user), function($all, $appId) { |
|
99 | - $info = $this->appManager->getAppInfo($appId); |
|
100 | - |
|
101 | - if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) { |
|
102 | - // Nothing to add |
|
103 | - return $all; |
|
104 | - } |
|
105 | - |
|
106 | - $providers = array_reduce($info['contactsmenu'], function($all, $provider) { |
|
107 | - return array_merge($all, [$provider]); |
|
108 | - }, []); |
|
109 | - |
|
110 | - return array_merge($all, $providers); |
|
111 | - }, []); |
|
112 | - } |
|
38 | + /** @var IServerContainer */ |
|
39 | + private $serverContainer; |
|
40 | + |
|
41 | + /** @var AppManager */ |
|
42 | + private $appManager; |
|
43 | + |
|
44 | + /** @var ILogger */ |
|
45 | + private $logger; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param IServerContainer $serverContainer |
|
49 | + * @param AppManager $appManager |
|
50 | + * @param ILogger $logger |
|
51 | + */ |
|
52 | + public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) { |
|
53 | + $this->serverContainer = $serverContainer; |
|
54 | + $this->appManager = $appManager; |
|
55 | + $this->logger = $logger; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param IUser $user |
|
60 | + * @return IProvider[] |
|
61 | + * @throws Exception |
|
62 | + */ |
|
63 | + public function getProviders(IUser $user) { |
|
64 | + $appClasses = $this->getAppProviderClasses($user); |
|
65 | + $providerClasses = $this->getServerProviderClasses(); |
|
66 | + $allClasses = array_merge($providerClasses, $appClasses); |
|
67 | + $providers = []; |
|
68 | + |
|
69 | + foreach ($allClasses as $class) { |
|
70 | + try { |
|
71 | + $providers[] = $this->serverContainer->query($class); |
|
72 | + } catch (QueryException $ex) { |
|
73 | + $this->logger->logException($ex, [ |
|
74 | + 'message' => "Could not load contacts menu action provider $class", |
|
75 | + 'app' => 'core', |
|
76 | + ]); |
|
77 | + throw new Exception("Could not load contacts menu action provider"); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + return $providers; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @return string[] |
|
86 | + */ |
|
87 | + private function getServerProviderClasses() { |
|
88 | + return [ |
|
89 | + EMailProvider::class, |
|
90 | + ]; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param IUser $user |
|
95 | + * @return string[] |
|
96 | + */ |
|
97 | + private function getAppProviderClasses(IUser $user) { |
|
98 | + return array_reduce($this->appManager->getEnabledAppsForUser($user), function($all, $appId) { |
|
99 | + $info = $this->appManager->getAppInfo($appId); |
|
100 | + |
|
101 | + if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) { |
|
102 | + // Nothing to add |
|
103 | + return $all; |
|
104 | + } |
|
105 | + |
|
106 | + $providers = array_reduce($info['contactsmenu'], function($all, $provider) { |
|
107 | + return array_merge($all, [$provider]); |
|
108 | + }, []); |
|
109 | + |
|
110 | + return array_merge($all, $providers); |
|
111 | + }, []); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |