mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
169 lines
4.1 KiB
PHP
169 lines
4.1 KiB
PHP
<?php
|
|
/************************************************************************
|
|
* This file is part of EspoCRM.
|
|
*
|
|
* EspoCRM - Open Source CRM application.
|
|
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
|
* Website: https://www.espocrm.com
|
|
*
|
|
* EspoCRM is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* EspoCRM 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 General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
|
*
|
|
* The interactive user interfaces in modified source and object code versions
|
|
* of this program must display Appropriate Legal Notices, as required under
|
|
* Section 5 of the GNU General Public License version 3.
|
|
*
|
|
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
|
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
|
************************************************************************/
|
|
|
|
namespace Espo\Entities;
|
|
|
|
use Espo\Core\ORM\Entity;
|
|
|
|
use Espo\Core\Field\Date;
|
|
use Espo\Core\Field\Link;
|
|
use Espo\Core\Field\LinkMultiple;
|
|
|
|
use stdClass;
|
|
|
|
class InboundEmail extends Entity
|
|
{
|
|
public const ENTITY_TYPE = 'InboundEmail';
|
|
|
|
public function isAvailableForFetching(): bool
|
|
{
|
|
return $this->get('status') === 'Active' && $this->get('useImap');
|
|
}
|
|
|
|
public function getEmailAddress(): ?string
|
|
{
|
|
return $this->get('emailAddress');
|
|
}
|
|
|
|
public function getAssignToUser(): ?Link
|
|
{
|
|
/** @var ?Link */
|
|
return $this->getValueObject('assignToUser');
|
|
}
|
|
|
|
public function getTeam(): ?Link
|
|
{
|
|
/** @var ?Link */
|
|
return $this->getValueObject('team');
|
|
}
|
|
|
|
public function getTeams(): LinkMultiple
|
|
{
|
|
/** @var LinkMultiple */
|
|
return $this->getValueObject('teams');
|
|
}
|
|
|
|
public function addAllTeamUsers(): bool
|
|
{
|
|
return (bool) $this->get('addAllTeamUsers');
|
|
}
|
|
|
|
public function keepFetchedEmailsUnread(): bool
|
|
{
|
|
return (bool) $this->get('keepFetchedEmailsUnread');
|
|
}
|
|
|
|
public function getFetchData(): stdClass
|
|
{
|
|
$data = $this->get('fetchData') ?? (object) [];
|
|
|
|
if (!property_exists($data, 'lastUID')) {
|
|
$data->lastUID = (object) [];
|
|
}
|
|
|
|
if (!property_exists($data, 'lastDate')) {
|
|
$data->lastDate = (object) [];
|
|
}
|
|
|
|
if (!property_exists($data, 'byDate')) {
|
|
$data->byDate = (object) [];
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getFetchSince(): ?Date
|
|
{
|
|
/** @var ?Date */
|
|
return $this->getValueObject('fetchSince');
|
|
}
|
|
|
|
public function getEmailFolder(): ?Link
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
public function getMonitoredFolderList(): array
|
|
{
|
|
return $this->get('monitoredFolders') ?? [];
|
|
}
|
|
|
|
public function getHost(): ?string
|
|
{
|
|
return $this->get('host');
|
|
}
|
|
|
|
public function getPort(): ?int
|
|
{
|
|
return $this->get('port');
|
|
}
|
|
|
|
public function getUsername(): ?string
|
|
{
|
|
return $this->get('username');
|
|
}
|
|
|
|
public function getPassword(): ?string
|
|
{
|
|
return $this->get('password');
|
|
}
|
|
|
|
public function getSecurity(): ?string
|
|
{
|
|
return $this->get('security');
|
|
}
|
|
|
|
/**
|
|
* @return ?class-string<object>
|
|
*/
|
|
public function getImapHandlerClassName(): ?string
|
|
{
|
|
/** @var ?class-string<object> */
|
|
return $this->get('imapHandler');
|
|
}
|
|
|
|
public function createCase(): bool
|
|
{
|
|
return (bool) $this->get('createCase');
|
|
}
|
|
|
|
public function autoReply(): bool
|
|
{
|
|
return (bool) $this->get('reply');
|
|
}
|
|
|
|
public function getSentFolder(): ?string
|
|
{
|
|
return $this->get('sentFolder');
|
|
}
|
|
}
|