Contacts improvements (Added URL and Nickname fields)

This commit is contained in:
RainLoop Team 2014-05-01 04:01:31 +04:00
parent f36cb72b82
commit ef880319c6
42 changed files with 831 additions and 279 deletions

View file

@ -2465,6 +2465,15 @@ class Actions
$oImapClient->Disconnect();
$bImapResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);
$sImapErrorDesc = $oException->getSocketMessage();
if (empty($sImapErrorDesc))
{
$sImapErrorDesc = $oException->getMessage();
}
}
catch (\Exception $oException)
{
$this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);
@ -2482,6 +2491,15 @@ class Actions
$oSmtpClient->Disconnect();
$bSmtpResult = true;
}
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
{
$this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);
$sSmtpErrorDesc = $oException->getSocketMessage();
if (empty($sSmtpErrorDesc))
{
$sSmtpErrorDesc = $oException->getMessage();
}
}
catch (\Exception $oException)
{
$this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);

View file

@ -220,6 +220,9 @@ class Contact
case PropertyType::NICK_NAME:
$oVCard->NICKNAME = $oProperty->Value;
break;
case PropertyType::NOTE:
$oVCard->NOTE = $oProperty->Value;
break;
case PropertyType::FIRST_NAME:
$sFirstName = $oProperty->Value;
break;
@ -511,11 +514,11 @@ class Contact
$aProperties[] = new Property(PropertyType::NICK_NAME, $sValue);
}
// if (isset($oVCard->NOTE) && '' !== \trim($oVCard->NOTE))
// {
// $sValue = $this->getPropertyValueHelper($oVCard->NOTE, $bOldVersion);
// $aProperties[] = new Property(PropertyType::NOTE, $sValue);
// }
if (isset($oVCard->NOTE) && '' !== \trim($oVCard->NOTE))
{
$sValue = $this->getPropertyValueHelper($oVCard->NOTE, $bOldVersion);
$aProperties[] = new Property(PropertyType::NOTE, $sValue);
}
if (isset($oVCard->N))
{

View file

@ -21,6 +21,8 @@ class PropertyType
// const MOBILE = 32;
// const FAX = 33;
const WEB_PAGE = 32;
const BIRTHDAY = 40;
const FACEBOOK = 90;
const SKYPE = 91;

View file

@ -923,7 +923,7 @@ class PdoAddressBook
$iUserID = $this->getUserId($sEmail);
$sTypes = implode(',', array(
PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME
PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME, PropertyType::NICK_NAME
));
$sSql = 'SELECT id_contact, id_prop, prop_type, prop_value FROM rainloop_ab_properties '.
@ -961,9 +961,14 @@ class PdoAddressBook
$aIdContacts[$iIdContact] = $iIdContact;
$aIdProps[$iIdProp] = $iIdProp;
if (\in_array($iType, array(PropertyType::LAST_NAME, PropertyType::FIRST_NAME)))
if (\in_array($iType, array(PropertyType::LAST_NAME, PropertyType::FIRST_NAME, PropertyType::NICK_NAME)))
{
$aContactAllAccess[$iIdContact] = $iIdContact;
if (!isset($aContactAllAccess[$iIdContact]))
{
$aContactAllAccess[$iIdContact] = array();
}
$aContactAllAccess[$iIdContact][] = $iType;
}
}
}
@ -977,7 +982,7 @@ class PdoAddressBook
$oStmt->closeCursor();
$sTypes = \implode(',', array(
PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME
PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME, PropertyType::NICK_NAME
));
$sSql = 'SELECT id_prop, id_contact, prop_type, prop_value FROM rainloop_ab_properties '.
@ -990,6 +995,7 @@ class PdoAddressBook
if (\is_array($aFetch) && 0 < \count($aFetch))
{
$aNames = array();
$aNicks = array();
$aEmails = array();
foreach ($aFetch as $aItem)
@ -1000,7 +1006,11 @@ class PdoAddressBook
$iIdProp = (int) $aItem['id_prop'];
$iType = (int) $aItem['prop_type'];
if (\in_array($iType, array(PropertyType::LAST_NAME, PropertyType::FIRST_NAME)))
if (PropertyType::NICK_NAME === $iType)
{
$aNicks[$iIdContact] = $aItem['prop_value'];
}
else if (\in_array($iType, array(PropertyType::LAST_NAME, PropertyType::FIRST_NAME)))
{
if (!isset($aNames[$iIdContact]))
{
@ -1024,12 +1034,28 @@ class PdoAddressBook
foreach ($aEmails as $iId => $aItems)
{
$aNameItem = isset($aNames[$iId]) && \is_array($aNames[$iId]) ? $aNames[$iId] : array('', '');
$sNameItem = \trim($aNameItem[0].' '.$aNameItem[1]);
foreach ($aItems as $sEmail)
if (isset($aContactAllAccess[$iId]))
{
$aResult[] = array($sEmail, $sNameItem);
$bName = \in_array(PropertyType::FIRST_NAME, $aContactAllAccess[$iId]) || \in_array(PropertyType::LAST_NAME, $aContactAllAccess[$iId]);
$bNick = \in_array(PropertyType::NICK_NAME, $aContactAllAccess[$iId]);
$aNameItem = isset($aNames[$iId]) && \is_array($aNames[$iId]) ? $aNames[$iId] : array('', '');
$sNameItem = \trim($aNameItem[0].' '.$aNameItem[1]);
$sNickItem = isset($aNicks[$iId]) ? $aNicks[$iId] : '';
foreach ($aItems as $sEmail)
{
if ($bName)
{
$aResult[] = array($sEmail, $sNameItem);
}
if ($bNick)
{
$aResult[] = array($sEmail, $sNickItem);
}
}
}
}
}