aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Contacts/ContactsMenu/Entry.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Contacts/ContactsMenu/Entry.php')
-rw-r--r--lib/private/Contacts/ContactsMenu/Entry.php123
1 files changed, 49 insertions, 74 deletions
diff --git a/lib/private/Contacts/ContactsMenu/Entry.php b/lib/private/Contacts/ContactsMenu/Entry.php
index 915a0434cc8..d4f2dc7bf90 100644
--- a/lib/private/Contacts/ContactsMenu/Entry.php
+++ b/lib/private/Contacts/ContactsMenu/Entry.php
@@ -3,83 +3,55 @@
declare(strict_types=1);
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Contacts\ContactsMenu;
use OCP\Contacts\ContactsMenu\IAction;
use OCP\Contacts\ContactsMenu\IEntry;
+use function array_merge;
class Entry implements IEntry {
+ public const PROPERTY_STATUS_MESSAGE_TIMESTAMP = 'statusMessageTimestamp';
/** @var string|int|null */
private $id = null;
- /** @var string */
- private $fullName = '';
+ private string $fullName = '';
/** @var string[] */
- private $emailAddresses = [];
+ private array $emailAddresses = [];
- /** @var string|null */
- private $avatar;
+ private ?string $avatar = null;
- /** @var string|null */
- private $profileTitle;
+ private ?string $profileTitle = null;
- /** @var string|null */
- private $profileUrl;
+ private ?string $profileUrl = null;
/** @var IAction[] */
- private $actions = [];
+ private array $actions = [];
- /** @var array */
- private $properties = [];
+ private array $properties = [];
+
+ private ?string $status = null;
+ private ?string $statusMessage = null;
+ private ?int $statusMessageTimestamp = null;
+ private ?string $statusIcon = null;
- /**
- * @param string $id
- */
public function setId(string $id): void {
$this->id = $id;
}
- /**
- * @param string $displayName
- */
public function setFullName(string $displayName): void {
$this->fullName = $displayName;
}
- /**
- * @return string
- */
public function getFullName(): string {
return $this->fullName;
}
- /**
- * @param string $address
- */
public function addEMailAddress(string $address): void {
$this->emailAddresses[] = $address;
}
@@ -91,56 +63,45 @@ class Entry implements IEntry {
return $this->emailAddresses;
}
- /**
- * @param string $avatar
- */
public function setAvatar(string $avatar): void {
$this->avatar = $avatar;
}
- /**
- * @return string
- */
public function getAvatar(): ?string {
return $this->avatar;
}
- /**
- * @param string $profileTitle
- */
public function setProfileTitle(string $profileTitle): void {
$this->profileTitle = $profileTitle;
}
- /**
- * @return string
- */
public function getProfileTitle(): ?string {
return $this->profileTitle;
}
- /**
- * @param string $profileUrl
- */
public function setProfileUrl(string $profileUrl): void {
$this->profileUrl = $profileUrl;
}
- /**
- * @return string
- */
public function getProfileUrl(): ?string {
return $this->profileUrl;
}
- /**
- * @param IAction $action
- */
public function addAction(IAction $action): void {
$this->actions[] = $action;
$this->sortActions();
}
+ public function setStatus(string $status,
+ ?string $statusMessage = null,
+ ?int $statusMessageTimestamp = null,
+ ?string $icon = null): void {
+ $this->status = $status;
+ $this->statusMessage = $statusMessage;
+ $this->statusMessageTimestamp = $statusMessageTimestamp;
+ $this->statusIcon = $icon;
+ }
+
/**
* @return IAction[]
*/
@@ -166,18 +127,18 @@ class Entry implements IEntry {
});
}
- /**
- * @param array $contact key-value array containing additional properties
- */
- public function setProperties(array $contact): void {
- $this->properties = $contact;
+ public function setProperty(string $propertyName, mixed $value) {
+ $this->properties[$propertyName] = $value;
}
/**
- * @param string $key
- * @return mixed
+ * @param array $properties key-value array containing additional properties
*/
- public function getProperty(string $key) {
+ public function setProperties(array $properties): void {
+ $this->properties = array_merge($this->properties, $properties);
+ }
+
+ public function getProperty(string $key): mixed {
if (!isset($this->properties[$key])) {
return null;
}
@@ -185,7 +146,7 @@ class Entry implements IEntry {
}
/**
- * @return array
+ * @return array{id: int|string|null, fullName: string, avatar: string|null, topAction: mixed, actions: array, lastMessage: '', emailAddresses: string[], profileTitle: string|null, profileUrl: string|null, status: string|null, statusMessage: null|string, statusMessageTimestamp: null|int, statusIcon: null|string, isUser: bool, uid: mixed}
*/
public function jsonSerialize(): array {
$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
@@ -203,6 +164,20 @@ class Entry implements IEntry {
'emailAddresses' => $this->getEMailAddresses(),
'profileTitle' => $this->profileTitle,
'profileUrl' => $this->profileUrl,
+ 'status' => $this->status,
+ 'statusMessage' => $this->statusMessage,
+ 'statusMessageTimestamp' => $this->statusMessageTimestamp,
+ 'statusIcon' => $this->statusIcon,
+ 'isUser' => $this->getProperty('isUser') === true,
+ 'uid' => $this->getProperty('UID'),
];
}
+
+ public function getStatusMessage(): ?string {
+ return $this->statusMessage;
+ }
+
+ public function getStatusMessageTimestamp(): ?int {
+ return $this->statusMessageTimestamp;
+ }
}