2013-11-28 02:57:38 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RainLoop\Providers;
|
|
|
|
|
|
|
|
class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface
|
|
|
|
*/
|
|
|
|
private $oDriver;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface $oDriver
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct($oDriver)
|
|
|
|
{
|
|
|
|
$this->oDriver = null;
|
|
|
|
if ($oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface)
|
|
|
|
{
|
|
|
|
$this->oDriver = $oDriver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-07 05:50:19 +08:00
|
|
|
/**
|
2013-12-10 08:40:21 +08:00
|
|
|
* @return bool
|
2013-12-07 05:50:19 +08:00
|
|
|
*/
|
2013-12-10 08:40:21 +08:00
|
|
|
public function Test()
|
2013-12-07 05:50:19 +08:00
|
|
|
{
|
2013-12-10 08:40:21 +08:00
|
|
|
\sleep(1);
|
2013-12-07 05:50:19 +08:00
|
|
|
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface ?
|
2013-12-10 08:40:21 +08:00
|
|
|
$this->oDriver->Test() : false;
|
2013-12-07 05:50:19 +08:00
|
|
|
}
|
|
|
|
|
2013-11-28 02:57:38 +08:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function IsActive()
|
|
|
|
{
|
|
|
|
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface &&
|
|
|
|
$this->oDriver->IsSupported();
|
|
|
|
}
|
|
|
|
|
2013-12-09 04:44:36 +08:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function IsSupported()
|
|
|
|
{
|
|
|
|
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface &&
|
|
|
|
$this->oDriver->IsSupported();
|
|
|
|
}
|
|
|
|
|
2013-11-28 02:57:38 +08:00
|
|
|
/**
|
2013-12-07 05:50:19 +08:00
|
|
|
* @param \RainLoop\Account $oAccount
|
|
|
|
* @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact
|
|
|
|
*
|
2013-11-28 02:57:38 +08:00
|
|
|
* @return bool
|
|
|
|
*/
|
2013-12-07 05:50:19 +08:00
|
|
|
public function ContactSave($oAccount, &$oContact)
|
2013-11-28 02:57:38 +08:00
|
|
|
{
|
2013-12-07 05:50:19 +08:00
|
|
|
return $this->IsActive() ? $this->oDriver->ContactSave($oAccount, $oContact) : false;
|
2013-11-28 02:57:38 +08:00
|
|
|
}
|
2013-12-03 08:08:42 +08:00
|
|
|
|
|
|
|
/**
|
2013-12-07 05:50:19 +08:00
|
|
|
* @param \RainLoop\Account $oAccount
|
|
|
|
* @param array $aContactIds
|
|
|
|
*
|
2013-12-03 08:08:42 +08:00
|
|
|
* @return bool
|
|
|
|
*/
|
2013-12-07 05:50:19 +08:00
|
|
|
public function DeleteContacts($oAccount, $aContactIds)
|
2013-12-03 08:08:42 +08:00
|
|
|
{
|
2013-12-07 05:50:19 +08:00
|
|
|
return $this->IsActive() ? $this->oDriver->DeleteContacts($oAccount, $aContactIds) : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \RainLoop\Account $oAccount
|
|
|
|
* @param int $iOffset = 0
|
|
|
|
* @param type $iLimit = 20
|
|
|
|
* @param string $sSearch = ''
|
2013-12-10 08:40:21 +08:00
|
|
|
* @param int $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_
|
2013-12-08 07:58:33 +08:00
|
|
|
* @param int $iResultCount = 0
|
2013-12-07 05:50:19 +08:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-12-10 08:40:21 +08:00
|
|
|
public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '',
|
|
|
|
$iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, &$iResultCount = 0)
|
2013-12-07 05:50:19 +08:00
|
|
|
{
|
|
|
|
return $this->IsActive() ? $this->oDriver->GetContacts($oAccount,
|
2013-12-10 08:40:21 +08:00
|
|
|
$iOffset, $iLimit, $sSearch, $iScopeType, $iResultCount) : array();
|
2013-12-03 08:08:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \RainLoop\Account $oAccount
|
|
|
|
* @param string $sSearch
|
2013-12-07 05:50:19 +08:00
|
|
|
* @param int $iLimit = 20
|
2013-12-03 08:08:42 +08:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
2013-12-07 05:50:19 +08:00
|
|
|
public function GetSuggestions($oAccount, $sSearch, $iLimit = 20)
|
2013-12-03 08:08:42 +08:00
|
|
|
{
|
2013-12-07 05:50:19 +08:00
|
|
|
return $this->IsActive() ? $this->oDriver->GetSuggestions($oAccount, $sSearch, $iLimit) : array();
|
2013-12-03 08:08:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \RainLoop\Account $oAccount
|
2013-12-07 05:50:19 +08:00
|
|
|
* @param array $aEmails
|
2013-12-08 07:58:33 +08:00
|
|
|
* @param bool $bCreateAuto = true
|
2013-12-03 08:08:42 +08:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2013-12-08 07:58:33 +08:00
|
|
|
public function IncFrec($oAccount, $aEmails, $bCreateAuto = true)
|
2013-12-07 05:50:19 +08:00
|
|
|
{
|
2013-12-08 07:58:33 +08:00
|
|
|
return $this->IsActive() ? $this->oDriver->IncFrec($oAccount, $aEmails, $bCreateAuto) : false;
|
2013-12-07 05:50:19 +08:00
|
|
|
}
|
2013-12-10 08:40:21 +08:00
|
|
|
}
|