Merge new-contacts-api

New interface
Contact storage move to plugin
This commit is contained in:
RainLoop Team 2013-12-07 02:07:29 +04:00
commit efdca7ef77
44 changed files with 3454 additions and 1012 deletions

View file

@ -1090,6 +1090,11 @@ class Utils
*/
public static function Utf8Clear($sUtfString, $sReplaceOn = '')
{
if ('' === $sUtfString)
{
return $sUtfString;
}
$sUtfString = @\iconv('UTF-8', 'UTF-8//IGNORE', $sUtfString);
$sUtfString = \preg_replace(

View file

@ -77,9 +77,9 @@ class Actions
private $oLoginProvider;
/**
* @var \RainLoop\Providers\Contacts
* @var \RainLoop\Providers\PersonalAddressBook
*/
private $oContactsProvider;
private $oPersonalAddressBookProvider;
/**
* @var \RainLoop\Providers\Suggestions
@ -121,6 +121,7 @@ class Actions
$this->oSettingsProvider = null;
$this->oDomainProvider = null;
$this->oLoginProvider = null;
$this->oPersonalAddressBookProvider = null;
$this->oSuggestionsProvider = null;
$this->oChangePasswordProvider = null;
@ -222,9 +223,8 @@ class Actions
// \RainLoop\Providers\Domain\DomainAdminInterface
$oResult = new \RainLoop\Providers\Domain\DefaultDomain(APP_PRIVATE_DATA.'domains');
break;
case 'contacts':
// \RainLoop\Providers\Contacts\ContactsInterface
$oResult = new \RainLoop\Providers\Contacts\DefaultContacts($this->Logger());
case 'personal-address-book':
// \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface
break;
case 'suggestions':
// \RainLoop\Providers\Suggestions\SuggestionsInterface
@ -529,18 +529,36 @@ class Actions
}
/**
* @return \RainLoop\Providers\Contacts
* @return \RainLoop\Providers\PersonalAddressBook
*/
public function ContactsProvider()
public function PersonalAddressBookProvider($oAccount = null)
{
if (null === $this->oContactsProvider)
if (null === $this->oPersonalAddressBookProvider)
{
$this->oContactsProvider = new \RainLoop\Providers\Contacts(
$this->Config()->Get('labs', 'allow_contacts', true) ?
$this->fabrica('contacts') : null);
$this->oPersonalAddressBookProvider = new \RainLoop\Providers\PersonalAddressBook(
$this->fabrica('personal-address-book', $oAccount));
$sPabVersion = $this->oPersonalAddressBookProvider->Version();
$sVersion = (string) $this->StorageProvider()->Get(null,
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'PersonalAddressBookVersion', '');
if ($sVersion !== $sPabVersion &&
$this->oPersonalAddressBookProvider->IsActive())
{
if ($this->oPersonalAddressBookProvider->SynchronizeStorage())
{
$this->StorageProvider()->Put(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
'PersonalAddressBookVersion', $sPabVersion);
}
}
}
return $this->oContactsProvider;
if ($oAccount)
{
$this->oPersonalAddressBookProvider->SetAccount($oAccount);
}
return $this->oPersonalAddressBookProvider;
}
/**
@ -877,9 +895,8 @@ class Actions
'AllowThemes' => (bool) $oConfig->Get('webmail', 'allow_themes', true),
'AllowCustomTheme' => (bool) $oConfig->Get('webmail', 'allow_custom_theme', true),
'SuggestionsLimit' => (int) $oConfig->Get('labs', 'suggestions_limit', 50),
'AllowChangePassword' => false,
'ContactsIsSupported' => (bool) $this->ContactsProvider()->IsSupported(),
'ContactsIsAllowed' => (bool) $this->ContactsProvider()->IsActive(),
'ChangePasswordIsAllowed' => false,
'ContactsIsAllowed' => false,
'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()),
'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false),
'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true),
@ -904,7 +921,8 @@ class Actions
$aResult['IncLogin'] = $oAccount->IncLogin();
$aResult['OutLogin'] = $oAccount->OutLogin();
$aResult['AccountHash'] = $oAccount->Hash();
$aResult['AllowChangePassword'] = $this->ChangePasswordProvider()->PasswordChangePossibility($oAccount);
$aResult['ChangePasswordIsAllowed'] = $this->ChangePasswordProvider()->PasswordChangePossibility($oAccount);
$aResult['ContactsIsAllowed'] = $this->PersonalAddressBookProvider($oAccount)->IsActive();
$oSettings = $this->SettingsProvider()->Load($oAccount);
}
@ -3745,10 +3763,10 @@ class Actions
$this->Plugins()->RunHook('filter.smtp-credentials', array($oAccount, &$aSmtpCredentials));
$bHookConnect = $bHookAuth = $bHookFrom = $bHookFrom = $bHookTo = $bHookData = false;
$bHookConnect = $bHookAuth = $bHookFrom = $bHookFrom = $bHookTo = $bHookData = $bHookLogoutAndDisconnect = false;
$this->Plugins()->RunHook('filter.smtp-connect', array($oAccount, $aSmtpCredentials,
&$oSmtpClient, $oMessage, &$oRcpt,
&$bHookConnect, &$bHookAuth, &$bHookFrom, &$bHookTo, &$bHookData));
&$bHookConnect, &$bHookAuth, &$bHookFrom, &$bHookTo, &$bHookData, &$bHookLogoutAndDisconnect));
if (!$bHookConnect)
{
@ -3794,7 +3812,10 @@ class Actions
$oSmtpClient->DataWithStream($rMessageStream);
}
$oSmtpClient->LogoutAndDisconnect();
if (!$bHookLogoutAndDisconnect)
{
$oSmtpClient->LogoutAndDisconnect();
}
}
catch (\MailSo\Net\Exceptions\ConnectionException $oException)
{
@ -3849,22 +3870,6 @@ class Actions
$rMessageStream, $iMessageStreamSize, $sSentFolder, array(
\MailSo\Imap\Enumerations\MessageFlag::SEEN
));
// TODO
// $rAppendMessageStream = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
//
// $iAppendMessageStreamSize = \MailSo\Base\Utils::MultipleStreamWriter(
// $oMessage->ToStream(false), array($rAppendMessageStream), 8192, true, true, true);
//
// $this->MailClient()->MessageAppendStream(
// $rAppendMessageStream, $iAppendMessageStreamSize, $sSentFolder, array(
// \MailSo\Imap\Enumerations\MessageFlag::SEEN
// ));
//
// if (\is_resource($rAppendMessageStream))
// {
// @\fclose($rAppendMessageStream);
// }
}
catch (\Exception $oException)
{
@ -3912,26 +3917,24 @@ class Actions
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantSendMessage);
}
// if ($oMessage && $this->ContactsProvider()->IsActive())
// {
// $oToCollection = $oMessage->GetTo();
// $oTo = $oToCollection->GetByIndex(0);
// if ($oTo)
// {
// $oContact = new \RainLoop\Providers\Contacts\Classes\Contact();
// /* @var $oTo \MailSo\Mime\Email */
// $oContact->Name = $oTo->GetDisplayName();
//
// $i = 30;
// while ($i > 0)
// {
// $i--;
// $oContact->Emails = array('u'.$i.'-'.$oTo->GetEmail());
// $this->ContactsProvider()->CreateContact($oAccount, $oContact);
// }
// }
//
// }
if ($oMessage && $this->PersonalAddressBookProvider($oAccount)->IsActive())
{
$aArrayToFrec = array();
$oToCollection = $oMessage->GetTo();
if ($oToCollection)
{
$aTo =& $oToCollection->GetAsArray();
foreach ($aTo as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{
$aArrayToFrec[$oEmail->GetEmail()] = $oEmail->ToString();
}
}
if (0 < \count($aArrayToFrec))
{
$this->PersonalAddressBookProvider($oAccount)->IncFrec($oAccount, \array_values($aArrayToFrec));
}
}
return $this->TrueResponse(__FUNCTION__);
}
@ -3961,30 +3964,27 @@ class Actions
public function DoContacts()
{
$oAccount = $this->getAccountFromToken();
$sSearch = \trim($this->GetActionParam('Search', ''));
$iOffset = (int) $this->GetActionParam('Offset', 0);
$iLimit = (int) $this->GetActionParam('Limit', 20);
$iOffset = 0 > $iOffset ? 0 : $iOffset;
$iLimit = 0 > $iLimit ? 20 : $iLimit;
$bMore = false;
$mResult = false;
if ($this->ContactsProvider()->IsActive())
if ($this->PersonalAddressBookProvider($oAccount)->IsActive())
{
$mResult = $this->ContactsProvider()->GetContacts($oAccount, 0, RL_CONTACTS_MAX + 1, $sSearch);
if (is_array($mResult))
{
$bMore = RL_CONTACTS_MAX < \count($mResult);
if ($bMore)
{
$mResult = \array_slice($mResult, 0, RL_CONTACTS_MAX);
}
}
$mResult = $this->PersonalAddressBookProvider($oAccount)->GetContacts($oAccount,
$iOffset, $iLimit, $sSearch, false);
}
return $this->DefaultResponse(__FUNCTION__, array(
'Limit' => RL_CONTACTS_MAX,
'More' => $bMore,
'Offset' => $iOffset,
'Limit' => $iLimit,
'Search' => $sSearch,
'List' => $mResult
));
}
/**
* @return array
*/
@ -3999,9 +3999,9 @@ class Actions
});
$bResult = false;
if ($this->ContactsProvider()->IsActive())
if (0 < \count($aFilteredUids) && $this->PersonalAddressBookProvider($oAccount)->IsActive())
{
$bResult = $this->ContactsProvider()->DeleteContacts($oAccount, $aFilteredUids);
$bResult = $this->PersonalAddressBookProvider($oAccount)->DeleteContacts($oAccount, $aFilteredUids);
}
return $this->DefaultResponse(__FUNCTION__, $bResult);
@ -4012,77 +4012,45 @@ class Actions
*/
public function DoContactSave()
{
sleep(1);
$oAccount = $this->getAccountFromToken();
$bResult = false;
$sResultID = '';
$oPab = $this->PersonalAddressBookProvider($oAccount);
$sRequestUid = \trim($this->GetActionParam('RequestUid', ''));
if ($this->ContactsProvider()->IsActive() && 0 < \strlen($sRequestUid))
if ($oPab && $oPab->IsActive() && 0 < \strlen($sRequestUid))
{
$sUid = \trim($this->GetActionParam('Uid', ''));
$sName = \trim($this->GetActionParam('Name', ''));
$sEmail = \trim($this->GetActionParam('Email', ''));
$sImageData = \trim($this->GetActionParam('ImageData', ''));
$oContact = null;
$oContact = new \RainLoop\Providers\PersonalAddressBook\Classes\Contact();
if (0 < \strlen($sUid))
{
if (\is_numeric($sUid))
{
$oContact = $this->ContactsProvider()->GetContactById($oAccount, (int) $sUid);
}
}
else
{
$oContact = new \RainLoop\Providers\Contacts\Classes\Contact();
$oContact->IdContact = $sUid;
}
if ($oContact)
$aProperties = $this->GetActionParam('Properties', array());
if (\is_array($aProperties))
{
$oContact->Name = $sName;
$oContact->Emails = array($sEmail);
if (0 < \strlen($sImageData) && 'data:image/' === substr($sImageData, 0, 11))
foreach ($aProperties as $aItem)
{
$oContact->ImageHash = \md5($sImageData);
}
if (0 < $oContact->IdContact)
{
$bResult = $this->ContactsProvider()->UpdateContact($oAccount, $oContact);
}
else
{
$bResult = $this->ContactsProvider()->CreateContact($oAccount, $oContact);
}
if ($bResult && 0 < $oContact->IdContact)
{
$sResultID = $oContact->IdContact;
$aMatches = array();
if ($bResult && $oContact && 0 < $oContact->IdContact && 0 < \strlen($oContact->ImageHash) &&
0 < \strlen($sImageData) &&
\preg_match('/^data:(image\/(jpeg|jpg|png|bmp));base64,(.+)$/i', $sImageData, $aMatches) &&
!empty($aMatches[1]) && !empty($aMatches[3]))
if ($aItem && isset($aItem[0], $aItem[1]) &&
\is_numeric($aItem[0]))
{
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::USER,
'contacts/'.$oContact->ImageHash, $aMatches[1].'|||'.$aMatches[3]);
$oProp = new \RainLoop\Providers\PersonalAddressBook\Classes\Property();
$oProp->Type = (int) $aItem[0];
$oProp->Value = $aItem[1];
$oContact->Properties[] = $oProp;
}
}
else
{
$bResult = false;
}
}
$bResult = $oPab->ContactSave($oAccount, $oContact);
}
return $this->DefaultResponse(__FUNCTION__, array(
'RequestUid' => $sRequestUid,
'ResultID' => $sResultID,
'ResultID' => $bResult ? $oContact->IdContact : '',
'Result' => $bResult
));
}
@ -4097,114 +4065,13 @@ class Actions
$sQuery = \trim($this->GetActionParam('Query', ''));
$aResult = array();
if (0 < \strlen($sQuery) && $this->ContactsProvider()->IsActive())
$oPab = $this->PersonalAddressBookProvider($oAccount);
if (0 < \strlen($sQuery) && $oPab->IsActive())
{
$mResult = $this->ContactsProvider()->GetContacts($oAccount, 0, RL_CONTACTS_PER_PAGE, $sQuery);
if (\is_array($mResult) && 0 < \count($mResult))
{
$mResult = \array_slice($mResult, 0, RL_CONTACTS_PER_PAGE);
foreach ($mResult as $oItem)
{
/* @var $oItem \RainLoop\Providers\Contacts\Classes\Contact */
$aEmails = $oItem->Emails;
if (0 < \count($aEmails))
{
foreach ($aEmails as $sEmail)
{
if (0 < \strlen($sEmail))
{
$aResult[] = array($sEmail, $oItem->Name);
}
}
}
}
}
$aResult = $oPab->GetSuggestions($oAccount, $sQuery);
}
return $this->DefaultResponse(__FUNCTION__, array(
'More' => false,
'List' => $aResult
));
// $oAccount = $this->getAccountFromToken();
//
// $aResult = array();
// $sQuery = \trim($this->GetActionParam('Query', ''));
// if (0 < \strlen($sQuery) && $oAccount)
// {
// $aResult = $this->SuggestionsProvider()->Process($oAccount, $sQuery);
//
// if (0 === count($aResult) && false !== \strpos(strtolower($oAccount->Email()), \strtolower($sQuery)))
// {
// $aResult[] = array($oAccount->Email(), $oAccount->Name());
// }
// }
//
// return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
* @return array
*/
public function DoSuggestionsDep()
{
$oAccount = $this->getAccountFromToken();
$sQuery = \trim($this->GetActionParam('Query', ''));
$iPage = (int) $this->GetActionParam('Page', 0);
$bMore = false;
$aResult = array();
if (0 < \strlen($sQuery) && 0 < $iPage && $this->ContactsProvider()->IsActive())
{
$mResult = $this->ContactsProvider()->GetContacts($oAccount, ($iPage - 1) * RL_CONTACTS_PER_PAGE, RL_CONTACTS_PER_PAGE + 1, $sQuery);
if (\is_array($mResult) && 0 < \count($mResult))
{
$bMore = RL_CONTACTS_PER_PAGE < \count($mResult);
if ($bMore)
{
$mResult = \array_slice($mResult, 0, RL_CONTACTS_PER_PAGE);
}
foreach ($mResult as $oItem)
{
/* @var $oItem \RainLoop\Providers\Contacts\Classes\Contact */
$aEmails = $oItem->Emails;
if (0 < \count($aEmails))
{
foreach ($aEmails as $sEmail)
{
if (0 < \strlen($sEmail))
{
$aResult[] = array($sEmail, $oItem->Name);
}
}
}
}
}
}
return $this->DefaultResponse(__FUNCTION__, array(
'More' => $bMore,
'List' => $aResult
));
// $oAccount = $this->getAccountFromToken();
//
// $aResult = array();
// $sQuery = \trim($this->GetActionParam('Query', ''));
// if (0 < \strlen($sQuery) && $oAccount)
// {
// $aResult = $this->SuggestionsProvider()->Process($oAccount, $sQuery);
//
// if (0 === count($aResult) && false !== \strpos(strtolower($oAccount->Email()), \strtolower($sQuery)))
// {
// $aResult[] = array($oAccount->Email(), $oAccount->Name());
// }
// }
//
// return $this->DefaultResponse(__FUNCTION__, $aResult);
return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
@ -4212,19 +4079,8 @@ class Actions
*/
public function DoEmailsPicsHashes()
{
$oAccount = $this->getAccountFromToken();
$aResult = array();
if ($this->ContactsProvider()->IsActive())
{
$mResult = $this->ContactsProvider()->GetContactsImageHashes($oAccount);
if (\is_array($mResult) && 0 < \count($mResult))
{
$aResult = $mResult;
}
}
return $this->DefaultResponse(__FUNCTION__, $aResult);
// $oAccount = $this->getAccountFromToken();
return $this->DefaultResponse(__FUNCTION__, array());
}
/**
@ -5686,7 +5542,7 @@ class Actions
if ($oAttachment)
{
$sContentLocation = $oAttachment->ContentLocation();
if ($sContentLocation && 0 < strlen($sContentLocation))
if ($sContentLocation && 0 < \strlen($sContentLocation))
{
$aContentLocationUrls[] = $oAttachment->ContentLocation();
}
@ -5746,6 +5602,25 @@ class Actions
'Emails' => $mResponse->Emails
));
}
else if ('RainLoop\Providers\PersonalAddressBook\Classes\Contact' === $sClassName)
{
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array(
/* @var $mResponse \RainLoop\Providers\PersonalAddressBook\Classes\Contact */
'IdContact' => $mResponse->IdContact,
'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display),
'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters)
));
}
else if ('RainLoop\Providers\PersonalAddressBook\Classes\Property' === $sClassName)
{
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array(
/* @var $mResponse \RainLoop\Providers\PersonalAddressBook\Classes\Property */
'Type' => $mResponse->Type,
'TypeCustom' => $mResponse->TypeCustom,
'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value),
'ValueClear' => \MailSo\Base\Utils::Utf8Clear($mResponse->ValueClear)
));
}
else if ('MailSo\Mail\Attachment' === $sClassName)
{
$oAccount = $this->getAccountFromToken(false);

View file

@ -0,0 +1,430 @@
<?php
namespace RainLoop\Common;
abstract class PdoAbstract
{
/**
* @var \PDO
*/
protected $oPDO = null;
/**
* @var \MailSo\Log\Logger
*/
protected $oLogger;
/**
* @var string
*/
protected $sDbType;
/**
* @return bool
*/
public function IsSupported()
{
return !!\class_exists('PDO');
}
/**
* @param \MailSo\Log\Logger $oLogger
*/
public function SetLogger($oLogger)
{
$this->oLogger = $oLogger instanceof \MailSo\Log\Logger ? $oLogger : null;
}
/**
* @return array
*/
protected function getPdoAccessData()
{
return array('', '', '', '');
}
/**
* @return \PDO
*
* @throws \Exception
*/
protected function getPDO()
{
if ($this->oPDO)
{
return $this->oPDO;
}
if (!\class_exists('PDO'))
{
throw new \Exception('Class PDO does not exist');
}
$sType = $sDsn = $sDbLogin = $sDbPassword = '';
list($sType, $sDsn, $sDbLogin, $sDbPassword) = $this->getPdoAccessData();
$this->sDbType = $sType;
$oPdo = false;
try
{
$oPdo = new \PDO($sDsn, $sDbLogin, $sDbPassword);
if ($oPdo)
{
$oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
if ('mysql' === $oPdo->getAttribute(\PDO::ATTR_DRIVER_NAME))
{
$oPdo->exec('SET NAMES utf8 COLLATE utf8_general_ci');
// $oPdo->exec('SET NAMES utf8');
}
}
}
catch (\Exception $oException)
{
throw $oException;
}
if ($oPdo)
{
$this->oPDO = $oPdo;
}
else
{
throw new \Exception('PDO = false');
}
return $oPdo;
}
/**
* @param string $sName = null
*
* @return string
*/
protected function lastInsertId($sName = null)
{
return $this->getPDO()->lastInsertId($sName);
}
/**
* @return nool
*/
protected function beginTransaction()
{
return $this->getPDO()->beginTransaction();
}
/**
* @return nool
*/
protected function commit()
{
return $this->getPDO()->commit();
}
/**
* @return nool
*/
protected function rollBack()
{
return $this->getPDO()->rollBack();
}
/**
* @param \RainLoop\Account $oAccount
* @param string $sSql
* @param array $aParams
* @param bool $bMultParams = false
*
* @return \PDOStatement|null
*/
protected function prepareAndExecute($sSql, $aParams = array(), $bMultParams = false)
{
$mResult = null;
$this->writeLog($sSql);
$oStmt = $this->getPDO()->prepare($sSql);
if ($oStmt)
{
$aRootParams = $bMultParams ? $aParams : array($aParams);
foreach ($aRootParams as $aSubParams)
{
foreach ($aSubParams as $sName => $aValue)
{
$oStmt->bindValue($sName, $aValue[0], $aValue[1]);
}
$mResult = $oStmt->execute() && !$bMultParams ? $oStmt : null;
}
}
return $mResult;
}
/**
* @param string $sSql
*/
protected function writeLog($sSql)
{
if ($this->oLogger)
{
$this->oLogger->Write($sSql, \MailSo\Log\Enumerations\Type::INFO, 'SQL');
}
}
/**
* @param string $sEmail
* @param bool $bSkipInsert = false
*
* @return int
*/
protected function getUserId($sEmail, $bSkipInsert = false)
{
$sEmail = \strtolower(\trim($sEmail));
if (empty($sEmail))
{
throw new \InvalidArgumentException('Empty Email argument');
}
$oStmt = $this->prepareAndExecute('SELECT id_user FROM rainloop_users WHERE rl_email = :rl_email',
array(':rl_email' => array($sEmail, \PDO::PARAM_STR)));
$mRow = $oStmt->fetch(\PDO::FETCH_ASSOC);
if ($mRow && isset($mRow['id_user']) && \is_numeric($mRow['id_user']))
{
return (int) $mRow['id_user'];
}
if (!$bSkipInsert)
{
$oStmt->closeCursor();
$oStmt = $this->prepareAndExecute('INSERT INTO rainloop_users (rl_email) VALUES (:rl_email)',
array(':rl_email' => array($sEmail, \PDO::PARAM_STR)));
return $this->getUserId($sEmail, true);
}
throw new \Exception('id_user = 0');
}
/**
* @param string $sValue
*
* @return string
*/
protected function quoteValue($sValue)
{
$oPdo = $this->getPDO();
return $oPdo ? $oPdo->quote((string) $sValue, \PDO::PARAM_STR) : '\'\'';
}
/**
* @param string $sType
* @param bool $bReturnIntValue = true
*
* @return int|string|bool
*/
protected function getSystemValue($sName, $bReturnIntValue = true)
{
$oPdo = $this->getPDO();
if ($oPdo)
{
$sQuery = 'SELECT * FROM rainloop_system WHERE sys_name = ?';
$this->writeLog($sQuery);
$oStmt = $oPdo->prepare($sQuery);
if ($oStmt->execute(array($sName)))
{
$mRow = $oStmt->fetchAll(\PDO::FETCH_ASSOC);
if ($mRow && isset($mRow[0]['sys_name'], $mRow[0]['value_int'], $mRow[0]['value_str']))
{
return $bReturnIntValue ? (int) $mRow[0]['value_int'] : (string) $mRow[0]['value_str'];
}
}
}
return false;
}
/**
* @param string $sType
* @param bool $bReturnIntValue = true
*
* @return int|string|bool
*/
protected function getVersion($sName)
{
return $this->getSystemValue($sName.'_version', true);
}
/**
* @param string $sType
* @param int $iVersion
*
* @return bool
*/
protected function setVersion($sName, $iVersion)
{
$bResult = false;
$oPdo = $this->getPDO();
if ($oPdo)
{
$oPdo->beginTransaction();
$sQuery = 'DELETE FROM rainloop_system WHERE sys_name = ? AND value_int <= ?;';
$this->writeLog($sQuery);
$oStmt = $oPdo->prepare($sQuery);
$bResult = !!$oStmt->execute(array($sName.'_version', $iVersion));
if ($bResult)
{
$sQuery = 'INSERT INTO rainloop_system (sys_name, value_int) VALUES (?, ?);';
$this->writeLog($sQuery);
$oStmt = $oPdo->prepare($sQuery);
if ($oStmt)
{
$bResult = !!$oStmt->execute(array($sName.'_version', $iVersion));
}
}
if ($bResult)
{
$oPdo->commit();
}
else
{
$oPdo->rollBack();
}
}
return $bResult;
}
/**
* @throws \Exception
*/
protected function initSystemTables()
{
$bResult = true;
$oPdo = $this->getPDO();
if ($oPdo)
{
$aQ = array();
if ('mysql' === $this->sDbType)
{
$aQ[] = 'CREATE TABLE IF NOT EXISTS `rainloop_system` (
`sys_name` varchar(50) NOT NULL,
`value_int` int(11) UNSIGNED NOT NULL DEFAULT \'0\',
`value_str` varchar(255) NOT NULL DEFAULT \'\'
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;';
$aQ[] = 'CREATE TABLE IF NOT EXISTS `rainloop_users` (
`id_user` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`rl_email` varchar(255) NOT NULL,
UNIQUE `email_unique` (`rl_email`),
PRIMARY KEY(`id_user`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ ;';
}
if (0 < \count($aQ))
{
try
{
$oPdo->beginTransaction();
foreach ($aQ as $sQuery)
{
if ($bResult)
{
$this->writeLog($sQuery);
$bResult = false !== $oPdo->exec($sQuery);
}
}
if ($bResult)
{
$oPdo->rollBack();
}
else
{
$oPdo->commit();
}
}
catch (\Exception $oException)
{
$oPdo->rollBack();
$this->oLogger->WriteException($oException);
throw $oException;
}
}
}
return $bResult;
}
/**
* @param string $sName
* @param array $aData = array()
*
* @return bool
*/
protected function dataBaseUpgrade($sName, $aData = array())
{
$this->initSystemTables();
$iFromVersion = $this->getVersion($sName);
$bResult = false;
$oPdo = $this->getPDO();
if ($oPdo)
{
$bResult = true;
foreach ($aData as $iVersion => $aQuery)
{
if ($iFromVersion < $iVersion)
{
try
{
$oPdo->beginTransaction();
foreach ($aQuery as $sQuery)
{
$this->writeLog($sQuery);
if (false === $oPdo->exec($sQuery))
{
$bResult = false;
break;
}
}
if ($bResult)
{
$oPdo->commit();
}
else
{
$oPdo->rollBack();
}
}
catch (\Exception $oException)
{
$oPdo->rollBack();
throw $oException;
}
if (!$bResult)
{
break;
}
$this->setVersion($sName, $iVersion);
}
}
}
return $bResult;
}
}

View file

@ -212,7 +212,6 @@ Enables caching in the system'),
'in_iframe' => array(false),
'custom_login_link' => array(''),
'custom_logout_link' => array(''),
'allow_contacts' => array(true),
'allow_external_login' => array(false),
'allow_admin_panel' => array(true),
'fast_cache_memcache_host' => array('127.0.0.1'),

View file

@ -1,14 +1,27 @@
<?php
namespace RainLoop\Providers;
abstract class AbstractProvider
{
/**
* @return bool
*/
public function IsActive()
{
return false;
}
}
<?php
namespace RainLoop\Providers;
abstract class AbstractProvider
{
/**
* @var \RainLoop\Account
*/
protected $oAccount;
/**
* @return bool
*/
public function IsActive()
{
return false;
}
/**
* @param \RainLoop\Account $oAccount
*/
public function SetAccount($oAccount)
{
$this->oAccount = $oAccount;
}
}

View file

@ -0,0 +1,115 @@
<?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;
}
}
/**
* @return string
*/
public function Version()
{
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface ?
$this->oDriver->Version() : 'null';
}
/**
* @return bool
*/
public function IsActive()
{
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface &&
$this->oDriver->IsSupported();
}
/**
* @param \RainLoop\Account $oAccount
* @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact
*
* @return bool
*/
public function ContactSave($oAccount, &$oContact)
{
return $this->IsActive() ? $this->oDriver->ContactSave($oAccount, $oContact) : false;
}
/**
* @param \RainLoop\Account $oAccount
* @param array $aContactIds
*
* @return bool
*/
public function DeleteContacts($oAccount, $aContactIds)
{
return $this->IsActive() ? $this->oDriver->DeleteContacts($oAccount, $aContactIds) : false;
}
/**
* @param \RainLoop\Account $oAccount
* @param int $iOffset = 0
* @param type $iLimit = 20
* @param string $sSearch = ''
* @param bool $bAutoOnly = false
*
* @return array
*/
public function GetContacts($oAccount,
$iOffset = 0, $iLimit = 20, $sSearch = '', $bAutoOnly = false)
{
return $this->IsActive() ? $this->oDriver->GetContacts($oAccount,
$iOffset, $iLimit, $sSearch, $bAutoOnly) : array();
}
/**
* @param \RainLoop\Account $oAccount
* @param string $sSearch
* @param int $iLimit = 20
*
* @return array
*
* @throws \InvalidArgumentException
*/
public function GetSuggestions($oAccount, $sSearch, $iLimit = 20)
{
return $this->IsActive() ? $this->oDriver->GetSuggestions($oAccount, $sSearch, $iLimit) : array();
}
/**
* @param \RainLoop\Account $oAccount
* @param array $aEmails
*
* @return bool
*/
public function IncFrec($oAccount, $aEmails)
{
return $this->IsActive() ? $this->oDriver->IncFrec($oAccount, $aEmails) : false;
}
/**
* @return bool
*/
public function SynchronizeStorage()
{
return $this->IsActive() && \method_exists($this->oDriver, 'SynchronizeStorage') &&
$this->oDriver->SynchronizeStorage();
}
}

View file

@ -0,0 +1,111 @@
<?php
namespace RainLoop\Providers\PersonalAddressBook\Classes;
class Contact
{
/**
* @var string
*/
public $IdContact;
/**
* @var string
*/
public $Display;
/**
* @var string
*/
public $DisplayName;
/**
* @var string
*/
public $DisplayEmail;
/**
* @var bool
*/
public $Auto;
/**
* @var int
*/
public $Changed;
/**
* @var array
*/
public $Tags;
/**
* @var array
*/
public $Properties;
public function __construct()
{
$this->Clear();
}
public function Clear()
{
$this->IdContact = '';
$this->IdUser = 0;
$this->Display = '';
$this->DisplayName = '';
$this->DisplayEmail = '';
$this->Auto = false;
$this->Changed = \time();
$this->Tags = array();
$this->Properties = array();
}
public function UpdateDependentValues()
{
$sDisplayName = '';
$sDisplayEmail = '';
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\PersonalAddressBook\Classes\Property */ &$oProperty)
{
if ($oProperty)
{
$oProperty->UpdateDependentValues();
if ('' === $sDisplayName && \RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType::FULLNAME === $oProperty->Type &&
0 < \strlen($oProperty->Value))
{
$sDisplayName = $oProperty->Value;
}
else if ('' === $sDisplayEmail && $oProperty->IsEmail() &&
0 < \strlen($oProperty->Value))
{
$sDisplayEmail = $oProperty->Value;
}
}
}
$this->DisplayName = $sDisplayName;
$this->DisplayEmail = $sDisplayEmail;
$this->Display = 0 < \strlen($sDisplayName) ? $sDisplayName : (!empty($sDisplayEmail) ? $sDisplayEmail : '');
}
/**
* @return array
*/
public function GetEmails()
{
$aResult = array();
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\PersonalAddressBook\Classes\Property */ &$oProperty)
{
if ($oProperty && $oProperty->IsEmail())
{
$aResult[] = $oProperty->Value;
}
}
return \array_unique($aResult);
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace RainLoop\Providers\PersonalAddressBook\Classes;
use RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType;
class Property
{
/**
* @var int
*/
public $Type;
/**
* @var string
*/
public $TypeCustom;
/**
* @var string
*/
public $Value;
/**
* @var string
*/
public $ValueClear;
/**
* @var int
*/
public $Frec;
public function __construct()
{
$this->Clear();
}
public function Clear()
{
$this->Type = PropertyType::UNKNOWN;
$this->TypeCustom = '';
$this->Value = '';
$this->ValueClear = '';
$this->Frec = 0;
}
/**
* @return bool
*/
public function IsEmail()
{
return \in_array($this->Type, array(
PropertyType::EMAIl_PERSONAL, PropertyType::EMAIl_BUSSINES, PropertyType::EMAIl_OTHER
));
}
/**
* @return bool
*/
public function IsPhone()
{
return \in_array($this->Type, array(
PropertyType::PHONE_PERSONAL, PropertyType::PHONE_BUSSINES, PropertyType::PHONE_OTHER,
PropertyType::MOBILE_PERSONAL, PropertyType::MOBILE_BUSSINES, PropertyType::MOBILE_OTHER,
PropertyType::FAX_BUSSINES, PropertyType::FAX_OTHER
));
}
public function UpdateDependentValues()
{
// trimer
$this->Value = \trim($this->Value);
$this->ValueClear = \trim($this->ValueClear);
$this->TypeCustom = \trim($this->TypeCustom);
if (0 < \strlen($this->Value))
{
// lower
if ($this->IsEmail())
{
$this->Value = \strtolower($this->Value);
}
// phones clear value for searching
if ($this->IsPhone())
{
$sPhone = $this->Value;
$sPhone = \preg_replace('/^[+]+/', '', $sPhone);
$sPhone = \preg_replace('/[^\d]/', '', $sPhone);
$this->ValueClear = $sPhone;
}
}
}
}

View file

@ -0,0 +1,39 @@
<?php
namespace RainLoop\Providers\PersonalAddressBook\Enumerations;
class PropertyType
{
const UNKNOWN = 0;
const FULLNAME = 10;
const FIRST_NAME = 15;
const SUR_NAME = 16;
const MIDDLE_NAME = 17;
const NICK = 18;
const EMAIl_PERSONAL = 30;
const EMAIl_BUSSINES = 31;
const EMAIl_OTHER = 32;
const PHONE_PERSONAL = 50;
const PHONE_BUSSINES = 51;
const PHONE_OTHER = 52;
const MOBILE_PERSONAL = 60;
const MOBILE_BUSSINES = 61;
const MOBILE_OTHER = 62;
const FAX_PERSONAL = 70;
const FAX_BUSSINES = 71;
const FAX_OTHER = 72;
const FACEBOOK = 90;
const SKYPE = 91;
const GITHUB = 92;
const DESCRIPTION = 110;
const CUSTOM = 250;
}

View file

@ -0,0 +1,63 @@
<?php
namespace RainLoop\Providers\PersonalAddressBook;
interface PersonalAddressBookInterface
{
/**
* @return string
*/
public function Version();
/**
* @return bool
*/
public function IsSupported();
/**
* @param \RainLoop\Account $oAccount
* @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact
*
* @return bool
*/
public function ContactSave($oAccount, &$oContact);
/**
* @param \RainLoop\Account $oAccount
* @param array $aContactIds
*
* @return bool
*/
public function DeleteContacts($oAccount, $aContactIds);
/**
* @param \RainLoop\Account $oAccount
* @param int $iOffset = 0
* @param type $iLimit = 20
* @param string $sSearch = ''
* @param bool $bAutoOnly = false
*
* @return array
*/
public function GetContacts($oAccount,
$iOffset = 0, $iLimit = 20, $sSearch = '', $bAutoOnly = false);
/**
* @param \RainLoop\Account $oAccount
* @param string $sSearch
* @param int $iLimit = 20
*
* @return array
*
* @throws \InvalidArgumentException
*/
public function GetSuggestions($oAccount, $sSearch, $iLimit = 20);
/**
* @param \RainLoop\Account $oAccount
* @param array $aEmails
*
* @return bool
*/
public function IncFrec($oAccount, $aEmails);
}

View file

@ -9,15 +9,6 @@
password to something else now.
</div>
</div>
<div class="row" data-bind="visible: !contactsSupported">
<div class="alert span8">
<h4>Notice!</h4>
<br />
<strong>Contacts</strong> functions are not supported.
<br />
You need to install or enable <strong>PDO (sqlite)</strong> exstenstion on your server.
</div>
</div>
<div class="form-horizontal">
<div class="legend">
General

View file

@ -1,104 +1,121 @@
<div class="popups">
<div class="modal hide b-contacts-content" data-bind="modal: modalVisibility">
<div class="modal-header b-header-toolbar g-ui-user-select-none">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<a class="btn button-create-contact" data-bind="command: newCommand">
<i class="icon-plus"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_ADD_CONTACT"></span>
</a>
<a class="btn btn-success button-new-message" data-bind="command: newMessageCommand">
<i class="icon-envelope icon-white"></i>
</a>
<a class="btn btn-danger button-delete" data-bind="command: deleteCommand">
<i class="icon-trash icon-white"></i>
<span data-bind="text: 1 < contactsCheckedOrSelected().length ? ' (' + contactsCheckedOrSelected().length + ')' : ''"></span>
</a>
</div>
<div class="modal-body" style="position: relative">
<div class="b-list-toopbar">
<input class="i18n span3 e-search" type="text" placeholder="Search" data-18n-placeholder="CONTACS/SEARCH_INPUT_PLACEHOLDER" data-bind="value: search" />
</div>
<div class="b-list-content g-ui-user-select-none" data-bind="nano: true, css: {'hideContactListCheckbox': !useCheckboxesInList()}">
<div class="content g-scrollbox">
<div class="content-wrapper">
<div class="listClear" data-bind="visible: viewClearSearch() && '' !== search()">
<span class="g-ui-link i18n" data-i18n-text="CONTACTS/CLEAR_SEARCH" data-bind="command: clearCommand"></span>
</div>
<div class="listEmptyList" data-bind="visible: 0 === contacts().length && '' === search() && !contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/EMPTY_LIST"></span>
</div>
<div class="listEmptyListLoading" data-bind="visible: 0 === contacts().length && '' === search() && contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/LIST_LOADING"></span><span class="textLoadingAnimationD1">.</span><span class="textLoadingAnimationD2">.</span><span class="textLoadingAnimationD3">.</span>
</div>
<div class="listEmptySearchList" data-bind="visible: 0 === contacts().length && '' !== search() && !contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/EMPTY_SEARCH"></span>
</div>
<div class="e-contact-foreach" data-bind="foreach: contacts, visible: 0 < contacts().length">
<div class="e-contact-item g-ui-user-select-none" data-bind="css: lineAsCcc()">
<div class="sidebarParent">
&nbsp;
</div>
<div class="delimiter"></div>
<div class="wrapper">
<div class="checkedParent">
<i class="checkboxItem" data-bind="css: checked() || selected() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>
</div>
<div class="nameParent actionHandle">
<span class="listName" data-bind="text: listName"></span>
&nbsp;
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="b-view-content" data-bind="nano: true">
<div class="content g-scrollbox">
<div class="content-wrapper">
<div class="b-contact-view-desc" data-bind="visible: emptySelection">
<span class="i18n" data-i18n-text="CONTACTS/CONTACT_VIEW_DESC"></span>
</div>
<div data-bind="visible: !emptySelection()">
<div class="form-horizontal top-part">
<div class="control-group">
<div class="control-label" data-bind="initDom: imageUploader">
<div class="image-wrapper" style="width: 100px; height: 100px;">
<img data-bind="initDom: imageDom" style="width: 100px; height: 100px;" />
</div>
</div>
<div class="controls">
<div class="top-row">
<span class="contactEmptyValueClick" data-bind="visible: !viewName.focused() && '' === viewName(), click: function() { viewName.focused(true); }">display name</span>
<span class="contactValueClick" data-bind="visible: !viewName.focused() && '' !== viewName(), click: function() { viewName.focused(true); }, text: viewName"></span>
<input class="contactValueInput span5" type="text" placeholder="display name" data-bind="value: viewName, visible: viewName.focused, hasfocus: viewName.focused, onEnter: function () { viewName.focused(false); }">
</div>
<div class="top-row" data-bind="css: { hasError: viewEmail.hasError() }">
<span class="contactEmptyValueClick" data-bind="visible: !viewEmail.focused() && '' === viewEmail(), click: function() { viewEmail.focused(true); }">email</span>
<span class="contactValueClick" data-bind="visible: !viewEmail.focused() && !viewEmail.hasError() && '' !== viewEmail(), click: function() { viewEmail.focused(true); }, text: viewEmail"></span>
<input class="contactValueInput span5" type="text" placeholder="email" data-bind="value: viewEmail, visible: viewEmail.hasError() || viewEmail.focused(), hasfocus: viewEmail.focused, onEnter: function () { viewEmail.focused(false); }">
</div>
</div>
</div>
<div class="control-group">
<div class="control-label">
</div>
<div class="controls">
</div>
</div>
</div>
<button class="btn button-save-contact" data-bind="command: saveCommand">
<i data-bind="css: {'icon-ok': !viewSaving(), 'icon-spinner-2 animated': viewSaving()}"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_CREATE_CONTACT" data-bind="visible: '' === viewID()"></span>
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_UPDATE_CONTACT" data-bind="visible: '' !== viewID()"></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="popups">
<div class="modal hide b-contacts-content" data-bind="modal: modalVisibility">
<div class="modal-header b-header-toolbar g-ui-user-select-none">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<a class="btn button-create-contact" data-bind="command: newCommand">
<i class="icon-plus"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_ADD_CONTACT"></span>
</a>
<a class="btn btn-success button-new-message" data-bind="command: newMessageCommand">
<i class="icon-envelope icon-white"></i>
</a>
<a class="btn btn-danger button-delete" data-bind="command: deleteCommand">
<i class="icon-trash icon-white"></i>
<span data-bind="text: 1 < contactsCheckedOrSelected().length ? ' (' + contactsCheckedOrSelected().length + ')' : ''"></span>
</a>
</div>
<div class="modal-body" style="position: relative">
<div class="b-list-toopbar">
<input class="i18n span3 e-search" type="text" placeholder="Search" data-18n-placeholder="CONTACS/SEARCH_INPUT_PLACEHOLDER" data-bind="value: search" />
</div>
<div class="b-list-content g-ui-user-select-none" data-bind="nano: true, css: {'hideContactListCheckbox': !useCheckboxesInList()}">
<div class="content g-scrollbox">
<div class="content-wrapper">
<div class="listClear" data-bind="visible: viewClearSearch() && '' !== search()">
<span class="g-ui-link i18n" data-i18n-text="CONTACTS/CLEAR_SEARCH" data-bind="command: clearCommand"></span>
</div>
<div class="listEmptyList" data-bind="visible: 0 === contacts().length && '' === search() && !contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/EMPTY_LIST"></span>
</div>
<div class="listEmptyListLoading" data-bind="visible: 0 === contacts().length && '' === search() && contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/LIST_LOADING"></span><span class="textLoadingAnimationD1">.</span><span class="textLoadingAnimationD2">.</span><span class="textLoadingAnimationD3">.</span>
</div>
<div class="listEmptySearchList" data-bind="visible: 0 === contacts().length && '' !== search() && !contacts.loading()">
<span class="i18n" data-i18n-text="CONTACTS/EMPTY_SEARCH"></span>
</div>
<div class="e-contact-foreach" data-bind="foreach: contacts, visible: 0 < contacts().length">
<div class="e-contact-item g-ui-user-select-none" data-bind="css: lineAsCcc()">
<div class="sidebarParent">
&nbsp;
</div>
<div class="delimiter"></div>
<div class="wrapper">
<div class="checkedParent">
<i class="checkboxItem" data-bind="css: checked() || selected() ? 'checkboxMessage icon-checkbox-checked' : 'checkboxMessage icon-checkbox-unchecked'"></i>
</div>
<div class="nameParent actionHandle">
<span class="listName" data-bind="text: display"></span>
&nbsp;
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="b-view-content" data-bind="nano: true">
<div class="content g-scrollbox">
<div class="content-wrapper">
<div class="b-contact-view-desc" data-bind="visible: emptySelection">
<span class="i18n" data-i18n-text="CONTACTS/CONTACT_VIEW_DESC"></span>
</div>
<div data-bind="visible: !emptySelection()">
<div class="form-horizontal top-part">
<div class="control-group">
<label class="control-label">
<span class="i18n">Display name</span>
</label>
<div class="controls" data-bind="foreach: viewPropertiesNames">
<div class="property-line">
<input type="text" class="contactValueInput" data-bind="value: value, valueUpdate: 'keyup'" />
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">
<span class="i18n">Emails</span>
</label>
<div class="controls">
<div data-bind="foreach: viewPropertiesEmails">
<div class="property-line">
<input type="email" class="contactValueInput" data-bind="value: value, hasFocus: focused, valueUpdate: 'keyup'" />
</div>
</div>
<div class="g-ui-link add-link" data-bind="click: addNewEmail">Add an email address</div>
</div>
</div>
<div class="control-group">
<label class="control-label">
<span class="i18n">Phones</span>
</label>
<div class="controls">
<div data-bind="foreach: viewPropertiesPhones">
<div class="property-line">
<input type="email" class="contactValueInput" data-bind="value: value, hasFocus: focused, valueUpdate: 'keyup'" />
</div>
</div>
<div class="g-ui-link add-link" data-bind="click: addNewPhone">Add a phone</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<br />
<br />
</div>
</div>
</div>
<button class="btn button-save-contact" data-bind="command: saveCommand">
<i data-bind="css: {'icon-ok': !viewSaving(), 'icon-spinner-2 animated': viewSaving()}"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_CREATE_CONTACT" data-bind="visible: '' === viewID()"></span>
<span class="i18n" data-i18n-text="CONTACTS/BUTTON_UPDATE_CONTACT" data-bind="visible: '' !== viewID()"></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>