diff --git a/dev/App/App.js b/dev/App/App.js index 9f0a8ddbb..d41da725c 100644 --- a/dev/App/App.js +++ b/dev/App/App.js @@ -839,17 +839,6 @@ }, sQuery); }; - /** - * @param {string} sQuery - * @param {Function} fCallback - */ - AppApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback) - { - fCallback(_.filter(Data.contactTags(), function (oContactTag) { - return oContactTag && oContactTag.filterHelper(sQuery); - })); - }; - AppApp.prototype.setMessageList = function (oData, bCached) { if (oData && oData.Result && 'Collection/MessageCollection' === oData.Result['@Object'] && diff --git a/dev/External/ko.js b/dev/External/ko.js index a549085e2..064f72d2a 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -636,80 +636,6 @@ } }; - ko.bindingHandlers.contactTags = { - 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { - - var - Utils = require('Common/Utils'), - ContactTagModel = require('Model/ContactTag'), - - $oEl = $(oElement), - fValue = fValueAccessor(), - fAllBindings = fAllBindingsAccessor(), - fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, - fFocusCallback = function (bValue) { - if (fValue && fValue.focusTrigger) - { - fValue.focusTrigger(bValue); - } - } - ; - - $oEl.inputosaurus({ - 'parseOnBlur': true, - 'allowDragAndDrop': false, - 'focusCallback': fFocusCallback, - 'inputDelimiters': [',', ';'], - 'outputDelimiter': ',', - 'autoCompleteSource': fAutoCompleteSource, - 'parseHook': function (aInput) { - return _.map(aInput, function (sInputValue) { - - var - sValue = Utils.trim(sInputValue), - oTag = null - ; - - if ('' !== sValue) - { - oTag = new ContactTagModel(); - oTag.name(sValue); - return [oTag.toLine(false), oTag]; - } - - return [sValue, null]; - - }); - }, - 'change': _.bind(function (oEvent) { - $oEl.data('ContactTagsValue', oEvent.target.value); - fValue(oEvent.target.value); - }, this) - }); - }, - 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { - - var - $oEl = $(oElement), - fAllValueFunc = fAllBindingsAccessor(), - fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null, - sValue = ko.utils.unwrapObservable(fValueAccessor()) - ; - - if ($oEl.data('ContactTagsValue') !== sValue) - { - $oEl.val(sValue); - $oEl.data('ContactTagsValue', sValue); - $oEl.inputosaurus('refresh'); - } - - if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter)) - { - $oEl.inputosaurus('focus'); - } - } - }; - ko.bindingHandlers.command = { 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { var diff --git a/dev/Model/Contact.js b/dev/Model/Contact.js index bf79f5ac3..47bd489c4 100644 --- a/dev/Model/Contact.js +++ b/dev/Model/Contact.js @@ -20,7 +20,6 @@ this.idContact = 0; this.display = ''; this.properties = []; - this.tags = ''; this.readOnly = false; this.focused = ko.observable(false); @@ -71,7 +70,6 @@ this.idContact = Utils.pInt(oItem['IdContact']); this.display = Utils.pString(oItem['Display']); this.readOnly = !!oItem['ReadOnly']; - this.tags = ''; if (Utils.isNonEmptyArray(oItem['Properties'])) { @@ -83,11 +81,6 @@ }, this); } - if (Utils.isNonEmptyArray(oItem['Tags'])) - { - this.tags = oItem['Tags'].join(','); - } - bResult = true; } diff --git a/dev/Model/ContactTag.js b/dev/Model/ContactTag.js deleted file mode 100644 index 0531b1b78..000000000 --- a/dev/Model/ContactTag.js +++ /dev/null @@ -1,58 +0,0 @@ - -(function () { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Common/Utils') - ; - - /** - * @constructor - */ - function ContactTagModel() - { - this.idContactTag = 0; - this.name = ko.observable(''); - this.readOnly = false; - } - - ContactTagModel.prototype.parse = function (oItem) - { - var bResult = false; - if (oItem && 'Object/Tag' === oItem['@Object']) - { - this.idContact = Utils.pInt(oItem['IdContactTag']); - this.name(Utils.pString(oItem['Name'])); - this.readOnly = !!oItem['ReadOnly']; - - bResult = true; - } - - return bResult; - }; - - /** - * @param {string} sSearch - * @return {boolean} - */ - ContactTagModel.prototype.filterHelper = function (sSearch) - { - return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1; - }; - - /** - * @param {boolean=} bEncodeHtml = false - * @return {string} - */ - ContactTagModel.prototype.toLine = function (bEncodeHtml) - { - return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ? - Utils.encodeHtml(this.name()) : this.name(); - }; - - module.exports = ContactTagModel; - -}()); \ No newline at end of file diff --git a/dev/Model/Email.js b/dev/Model/Email.js index bb26edb39..07858b8ba 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -335,14 +335,6 @@ return true; }; - /** - * @return {string} - */ - EmailModel.prototype.inputoTagLine = function () - { - return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email; - }; - module.exports = EmailModel; }()); \ No newline at end of file diff --git a/dev/Storage/App/Data.js b/dev/Storage/App/Data.js index 90b660a9e..391ea8200 100644 --- a/dev/Storage/App/Data.js +++ b/dev/Storage/App/Data.js @@ -111,7 +111,6 @@ this.identitiesLoading = ko.observable(false).extend({'throttle': 100}); // contacts - this.contactTags = ko.observableArray([]); this.contacts = ko.observableArray([]); this.contacts.loading = ko.observable(false).extend({'throttle': 200}); this.contacts.importing = ko.observable(false).extend({'throttle': 200}); diff --git a/dev/Storage/App/Remote.js b/dev/Storage/App/Remote.js index 92be01fea..d70336ddb 100644 --- a/dev/Storage/App/Remote.js +++ b/dev/Storage/App/Remote.js @@ -715,12 +715,11 @@ /** * @param {?Function} fCallback */ - RemoteAppStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties) + RemoteAppStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties) { this.defaultRequest(fCallback, 'ContactSave', { 'RequestUid': sRequestUid, 'Uid': Utils.trim(sUid), - 'Tags': Utils.trim(sTags), 'Properties': aProperties }); }; diff --git a/dev/Styles/Contacts.less b/dev/Styles/Contacts.less index aa3a31e23..c5d1176b1 100644 --- a/dev/Styles/Contacts.less +++ b/dev/Styles/Contacts.less @@ -271,27 +271,6 @@ -webkit-overflow-scrolling: touch; } - .tags-property-container { - font-size: 18px; - width: 400px; - - .inputosaurus-container { - border-width: 1px; - border-color: transparent; - box-shadow: none; - - &:hover { - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - border-color: #ccc; - } - - &.inputosaurus-focused { - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - border-color: #999; - } - } - } - .contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic { height: 20px; line-height: 20px; diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 7d26e03ce..22bf9b9d0 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -22,7 +22,6 @@ EmailModel = require('Model/Email'), ContactModel = require('Model/Contact'), - ContactTagModel = require('Model/ContactTag'), ContactPropertyModel = require('Model/ContactProperty'), kn = require('Knoin/Knoin'), @@ -53,7 +52,6 @@ this.search = ko.observable(''); this.contactsCount = ko.observable(0); this.contacts = Data.contacts; - this.contactTags = Data.contactTags; this.currentContact = ko.observable(null); @@ -74,21 +72,6 @@ this.viewReadOnly = ko.observable(false); this.viewProperties = ko.observableArray([]); - this.viewTags = ko.observable(''); - this.viewTags.visibility = ko.observable(false); - this.viewTags.focusTrigger = ko.observable(false); - - this.viewTags.focusTrigger.subscribe(function (bValue) { - if (!bValue && '' === this.viewTags()) - { - this.viewTags.visibility(false); - } - else if (bValue) - { - this.viewTags.visibility(true); - } - }, this); - this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { @@ -336,7 +319,7 @@ }, 1000); } - }, sRequestUid, this.viewID(), this.viewTags(), aProperties); + }, sRequestUid, this.viewID(), aProperties); }, function () { var @@ -369,7 +352,7 @@ this.watchHash = ko.observable(false); this.viewHash = ko.computed(function () { - return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) { + return '' + _.map(self.viewProperties(), function (oItem) { return oItem.value(); }).join(''); }); @@ -385,23 +368,12 @@ this.sDefaultKeyScope = Enums.KeyState.ContactList; - this.contactTagsSource = _.bind(this.contactTagsSource, this); - kn.constructorEnd(this); } kn.extendAsViewModel(['View/Popup/Contacts', 'PopupsContactsViewModel'], ContactsPopupView); _.extend(ContactsPopupView.prototype, AbstractView.prototype); - ContactsPopupView.prototype.contactTagsSource = function (oData, fResponse) - { - require('App/App').getContactTagsAutocomplete(oData.term, function (aData) { - fResponse(_.map(aData, function (oTagItem) { - return oTagItem.toLine(false); - })); - }); - }; - ContactsPopupView.prototype.getPropertyPlceholder = function (sType) { var sResult = ''; @@ -442,12 +414,6 @@ } }; - ContactsPopupView.prototype.addNewTag = function () - { - this.viewTags.visibility(true); - this.viewTags.focusTrigger(true); - }; - ContactsPopupView.prototype.addNewEmail = function () { this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); @@ -621,7 +587,6 @@ this.emptySelection(false); this.viewReadOnly(false); - this.viewTags(''); if (oContact) { @@ -647,14 +612,9 @@ }); } - this.viewTags(oContact.tags); - this.viewReadOnly(!!oContact.readOnly); } - this.viewTags.focusTrigger.valueHasMutated(); - this.viewTags.visibility('' !== this.viewTags()); - aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false, this.getPropertyPlceholder(Enums.ContactPropertyType.LastName))); @@ -689,10 +649,10 @@ this.contacts.loading(true); Remote.contacts(function (sResult, oData) { + var iCount = 0, - aList = [], - aTagsList = [] + aList = [] ; if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List) @@ -709,23 +669,12 @@ iCount = Utils.pInt(oData.Result.Count); iCount = 0 < iCount ? iCount : 0; } - - if (Utils.isNonEmptyArray(oData.Result.Tags)) - { - aTagsList = _.map(oData.Result.Tags, function (oItem) { - var oContactTag = new ContactTagModel(); - return oContactTag.parse(oItem) ? oContactTag : null; - }); - - aTagsList = _.compact(aTagsList); - } } self.contactsCount(iCount); self.contacts(aList); self.contacts.loading(false); - self.contactTags(aTagsList); self.viewClearSearch('' !== self.search()); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 5b5748540..48e613591 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -5390,7 +5390,6 @@ class Actions $iResultCount = 0; $mResult = array(); - $aTags = array(); $oAbp = $this->AddressBookProvider($oAccount); if ($oAbp->IsActive()) @@ -5398,8 +5397,6 @@ class Actions $iResultCount = 0; $mResult = $oAbp->GetContacts($oAccount->ParentEmailHelper(), $iOffset, $iLimit, $sSearch, $iResultCount); - - $aTags = $oAbp->GetContactTags($oAccount->ParentEmailHelper()); } return $this->DefaultResponse(__FUNCTION__, array( @@ -5407,8 +5404,7 @@ class Actions 'Limit' => $iLimit, 'Count' => $iResultCount, 'Search' => $sSearch, - 'List' => $mResult, - 'Tags' => $aTags + 'List' => $mResult )); } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php index d32e0e418..eb67256a4 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php @@ -163,7 +163,7 @@ class Api if (\RainLoop\Api::Actions()->AddressBookProvider() && \RainLoop\Api::Actions()->AddressBookProvider()->IsActive()) { - \RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContactsAndTags($sEmail); + \RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContacts($sEmail); } return true; diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php index b62a2b356..44838dffb 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php @@ -113,9 +113,9 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider * * @return bool */ - public function DeleteAllContactsAndTags($sEmail) + public function DeleteAllContacts($sEmail) { - return $this->IsActive() ? $this->oDriver->DeleteAllContactsAndTags($sEmail) : false; + return $this->IsActive() ? $this->oDriver->DeleteAllContacts($sEmail) : false; } /** @@ -133,17 +133,6 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider $iOffset, $iLimit, $sSearch, $iResultCount) : array(); } - /** - * @param string $sEmail - * @param bool $bCache = true - * - * @return array - */ - public function GetContactTags($sEmail, $bCache = true) - { - return $this->IsActive() ? $this->oDriver->GetContactTags($sEmail, $bCache) : array(); - } - /** * @param string $sEmail * @param string $mID diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php index fe9ec1590..60daf2410 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php @@ -34,11 +34,6 @@ class Contact */ public $Properties; - /** - * @var array - */ - public $Tags; - /** * @var bool */ @@ -66,7 +61,6 @@ class Contact $this->Display = ''; $this->Changed = \time(); $this->Properties = array(); - $this->Tags = array(); $this->ReadOnly = false; $this->IdPropertyFromSearch = 0; $this->Etag = ''; @@ -149,8 +143,6 @@ class Contact { $this->Properties[] = new \RainLoop\Providers\AddressBook\Classes\Property(PropertyType::FULLNAME, $this->Display); } - - $this->Tags = \array_map('trim', $this->Tags); } /** @@ -211,7 +203,7 @@ class Contact $oVCard->VERSION = '3.0'; $oVCard->PRODID = '-//RainLoop//'.APP_VERSION.'//EN'; - unset($oVCard->FN, $oVCard->EMAIL, $oVCard->TEL, $oVCard->URL, $oVCard->NICKNAME, $oVCard->CATEGORIES, $oVCard->{'X-RL-TAGS'}); + unset($oVCard->FN, $oVCard->EMAIL, $oVCard->TEL, $oVCard->URL, $oVCard->NICKNAME); $sFirstName = $sLastName = $sMiddleName = $sSuffix = $sPrefix = ''; foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) @@ -272,11 +264,6 @@ class Contact $oVCard->N = array($sLastName, $sFirstName, $sMiddleName, $sPrefix, $sSuffix); $oVCard->REV = \gmdate('Ymd', $this->Changed).'T'.\gmdate('His', $this->Changed).'Z'; - if (0 < \count($this->Tags)) - { - $oVCard->CATEGORIES = $this->Tags; - } - return (string) $oVCard->serialize(); } @@ -589,13 +576,6 @@ class Contact } $this->Properties = $aProperties; - - if (isset($oVCard->CATEGORIES)) - { - $this->Tags = (array) $oVCard->CATEGORIES->getParts(); - $this->Tags = \is_array($this->Tags) ? $this->Tags : array(); - $this->Tags = \array_map('trim', $this->Tags); - } } $this->UpdateDependentValues(); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php index 5614b15f4..6c0469283 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php @@ -28,11 +28,6 @@ class PdoAddressBook */ private $sPassword; - /** - * @var array - */ - private $aTagsCache; - public function __construct($sDsn, $sUser = '', $sPassword = '', $sDsnType = 'mysql') { $this->sDsn = $sDsn; @@ -41,7 +36,6 @@ class PdoAddressBook $this->sDsnType = $sDsnType; $this->bExplain = false; // debug - $this->aTagsCache = array(); // debug } /** @@ -470,14 +464,6 @@ class PdoAddressBook ':id_contact' => array($iIdContact, \PDO::PARAM_INT) ) ); - - // clear previos tags - $this->prepareAndExecute( - 'DELETE FROM rainloop_ab_tags_contacts WHERE id_contact = :id_contact', - array( - ':id_contact' => array($iIdContact, \PDO::PARAM_INT) - ) - ); } else { @@ -533,47 +519,6 @@ class PdoAddressBook $this->prepareAndExecute($sSql, $aParams, true); } - - $aTags = array(); - $aContactTags = $this->GetContactTags($sEmail); - - $fFindFunc = function ($sName) use ($aContactTags) { - - $iResult = 0; - foreach ($aContactTags as $oItem) - { - if ($oItem && $oItem->Name === $sName) - { - $iResult = (int) $oItem->IdContactTag; - break; - } - } - - return $iResult; - }; - - foreach ($oContact->Tags as $sTagName) - { - $iTagID = $fFindFunc($sTagName); - if (0 >= $iTagID) - { - $iTagID = $this->CreateTag($sEmail, $sTagName, false); - } - - if (\is_int($iTagID) && 0 < $iTagID) - { - $aTags[] = array( - ':id_tag' => array($iTagID, \PDO::PARAM_INT), - ':id_contact' => array($iIdContact, \PDO::PARAM_INT) - ); - } - } - - if (0 < \count($aTags)) - { - $sSql = 'INSERT INTO rainloop_ab_tags_contacts (id_tag, id_contact) VALUES (:id_tag, :id_contact)'; - $this->prepareAndExecute($sSql, $aTags, true); - } } } catch (\Exception $oException) @@ -584,51 +529,6 @@ class PdoAddressBook return 0 < $iIdContact; } - /** - * @param string $sEmail - * @param string $sName - * @param bool $bSyncDb = true - * - * @return bool|int - */ - public function CreateTag($sEmail, $sName, $bSyncDb = true) - { - if ($bSyncDb) - { - $this->SyncDatabase(); - } - - $iUserID = $this->getUserId($sEmail); - - $this->aTagsCache = array(); - - $mResult = false; - try - { - $sSql = 'INSERT INTO rainloop_ab_tags '. - '(id_user, tag_name) VALUES (:id_user, :tag_name)'; - - $this->prepareAndExecute($sSql, - array( - ':id_user' => array($iUserID, \PDO::PARAM_INT), - ':tag_name' => array($sName, \PDO::PARAM_STR) - ) - ); - - $sLast = $this->lastInsertId('rainloop_ab_tags', 'id_tag'); - if (\is_numeric($sLast) && 0 < (int) $sLast) - { - $mResult = (int) $sLast; - } - } - catch (\Exception $oException) - { - throw $oException; - } - - return $mResult; - } - /** * @param string $sEmail * @param array $aContactIds @@ -677,7 +577,7 @@ class PdoAddressBook * * @return bool */ - public function DeleteAllContactsAndTags($sEmail, $bSyncDb = true) + public function DeleteAllContacts($sEmail, $bSyncDb = true) { if ($bSyncDb) { @@ -690,136 +590,10 @@ class PdoAddressBook $this->prepareAndExecute('DELETE FROM rainloop_ab_properties WHERE id_user = :id_user', $aParams); $this->prepareAndExecute('DELETE FROM rainloop_ab_contacts WHERE id_user = :id_user', $aParams); - $this->prepareAndExecute('DELETE FROM rainloop_ab_tags WHERE id_user = :id_user', $aParams); return true; } - /** - * @param string $sEmail - * @param array $aTagsIds - * - * @return bool - */ - public function DeleteTags($sEmail, $aTagsIds) - { - $this->SyncDatabase(); - $iUserID = $this->getUserId($sEmail); - - $aTagsIds = \array_filter($aTagsIds, function (&$mItem) { - $mItem = (int) \trim($mItem); - return 0 < $mItem; - }); - - if (0 === \count($aTagsIds)) - { - return false; - } - - $this->aTagsCache = array(); - - $sIDs = \implode(',', $aTagsIds); - $aParams = array(':id_user' => array($iUserID, \PDO::PARAM_INT)); - - $this->prepareAndExecute('DELETE FROM rainloop_pab_tags_contacts WHERE id_tag IN ('.$sIDs.')'); - $this->prepareAndExecute('DELETE FROM rainloop_pab_tags WHERE id_user = :id_user AND id_tag IN ('.$sIDs.')', $aParams); - - return true; - } - - /** - * @param string $sEmail - * @param array|\RainLoop\Providers\AddressBook\Classes\Contact $mContactOrContacts - */ - private function populateContactsByTags($sEmail, &$mContactOrContacts) - { - $aContacts = array(); - if ($mContactOrContacts) - { - $aContacts = is_array($mContactOrContacts) ? $mContactOrContacts : array(&$mContactOrContacts); - } - - if (\is_array($aContacts) && 0 < \count($aContacts)) - { - $aIdContacts = array(); - $aIdTagsContacts = array(); - - $aTags = $this->GetContactTags($sEmail); - - if (\is_array($aTags) && 0 < \count($aTags)) - { - foreach ($aContacts as $oItem) - { - $aIdContacts[$oItem->IdContact] = true; - } - - if (0 < \count($aIdContacts)) - { - $sSql = 'SELECT id_tag, id_contact FROM rainloop_ab_tags_contacts WHERE id_contact IN ('.\implode(',', \array_keys($aIdContacts)).')'; - $oStmt = $this->prepareAndExecute($sSql); - - if ($oStmt) - { - $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); - if (\is_array($aFetch) && 0 < \count($aFetch)) - { - foreach ($aFetch as $aItem) - { - if ($aItem && isset($aItem['id_tag'], $aItem['id_contact'])) - { - $sID = (string) $aItem['id_contact']; - if (!isset($aIdTagsContacts[$sID])) - { - $aIdTagsContacts[$sID] = array(); - } - - $aIdTagsContacts[$sID][] = (string) $aItem['id_tag']; - } - } - } - - unset($aFetch); - } - - if (0 < \count($aIdTagsContacts)) - { - $fFindFunc = function ($sID) use ($aTags) { - - foreach ($aTags as $oItem) - { - if ($oItem && (string) $oItem->IdContactTag === $sID) - { - return\trim($oItem->Name); - } - } - - return ''; - }; - - foreach ($aContacts as &$oItem) - { - $sID = $oItem ? (string) $oItem->IdContact : ''; - if (0 < \strlen($sID) && isset($aIdTagsContacts[$sID]) && \is_array($aIdTagsContacts[$sID])) - { - $aNames = array(); - foreach ($aIdTagsContacts[$sID] as $sSubID) - { - $sName = $fFindFunc($sSubID); - if (0 < \strlen($sName)) - { - $aNames[] = $sName; - } - } - - $oItem->Tags = $aNames; - } - } - } - } - } - } - } - /** * @param string $sEmail * @param int $iOffset = 0 @@ -1012,62 +786,6 @@ class PdoAddressBook } } - $this->populateContactsByTags($sEmail, $aResult); - return $aResult; - } - - /** - * @param string $sEmail - * @param bool $bCache = true - * - * @return array - */ - public function GetContactTags($sEmail, $bCache = true) - { - if ($bCache && isset($this->aTagsCache[$sEmail])) - { - return $this->aTagsCache[$sEmail]; - } - - $this->SyncDatabase(); - - $iUserID = $this->getUserId($sEmail); - - $sSql = 'SELECT id_tag, id_user, tag_name FROM rainloop_ab_tags WHERE id_user = :id_user ORDER BY tag_name ASC'; - - $aParams = array( - ':id_user' => array($iUserID, \PDO::PARAM_INT) - ); - - $aResult = array(); - $oStmt = $this->prepareAndExecute($sSql, $aParams); - if ($oStmt) - { - $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); - if (\is_array($aFetch) && 0 < \count($aFetch)) - { - foreach ($aFetch as $aItem) - { - $iIdContactTag = $aItem && isset($aItem['id_tag']) ? (int) $aItem['id_tag'] : 0; - if (0 < $iIdContactTag) - { - $oContactTag = new \RainLoop\Providers\AddressBook\Classes\Tag(); - - $oContactTag->IdContactTag = (string) $iIdContactTag; - $oContactTag->Name = isset($aItem['tag_name']) ? (string) $aItem['tag_name'] : ''; - $oContactTag->ReadOnly = $iUserID !== (isset($aItem['id_user']) ? (int) $aItem['id_user'] : 0); - - $aResult[] = $oContactTag; - } - } - } - } - - if ($bCache) - { - $this->aTagsCache[$sEmail] = $aResult; - } - return $aResult; } @@ -1171,11 +889,6 @@ class PdoAddressBook } } - if ($oContact) - { - $this->populateContactsByTags($sEmail, $oContact); - } - return $oContact; } @@ -1609,27 +1322,6 @@ CREATE TABLE IF NOT EXISTS rainloop_ab_properties ( )/*!40000 ENGINE=INNODB *//*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; -CREATE TABLE IF NOT EXISTS rainloop_ab_tags ( - - id_tag int UNSIGNED NOT NULL AUTO_INCREMENT, - id_user int UNSIGNED NOT NULL, - tag_name varchar(255) NOT NULL, - - PRIMARY KEY(id_tag), - INDEX id_user_rainloop_ab_tags_index (id_user), - INDEX id_user_name_rainloop_ab_tags_index (id_user, tag_name) - -)/*!40000 ENGINE=INNODB *//*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */; - -CREATE TABLE IF NOT EXISTS rainloop_ab_tags_contacts ( - - id_tag int UNSIGNED NOT NULL, - id_contact bigint UNSIGNED NOT NULL, - - INDEX id_tag_rainloop_ab_tags_contacts_index (id_tag), - INDEX id_contact_rainloop_ab_tags_contacts_index (id_contact) - -)/*!40000 ENGINE=INNODB */; MYSQLINITIAL; break; @@ -1662,23 +1354,6 @@ CREATE TABLE rainloop_ab_properties ( CREATE INDEX id_user_rainloop_ab_properties_index ON rainloop_ab_properties (id_user); CREATE INDEX id_user_id_contact_rainloop_ab_properties_index ON rainloop_ab_properties (id_user, id_contact); -CREATE TABLE rainloop_ab_tags ( - id_tag serial PRIMARY KEY, - id_user integer NOT NULL, - tag_name varchar(255) NOT NULL -); - -CREATE INDEX id_user_rainloop_ab_tags_index ON rainloop_ab_tags (id_user); -CREATE INDEX id_user_name_rainloop_ab_tags_index ON rainloop_ab_tags (id_user, tag_name); - -CREATE TABLE rainloop_ab_tags_contacts ( - id_tag integer NOT NULL, - id_contact integer NOT NULL -); - -CREATE INDEX id_tag_rainloop_ab_tags_index ON rainloop_ab_tags_contacts (id_tag); -CREATE INDEX id_contact_rainloop_ab_tags_index ON rainloop_ab_tags_contacts (id_contact); - POSTGRESINITIAL; break; @@ -1711,23 +1386,6 @@ CREATE TABLE rainloop_ab_properties ( CREATE INDEX id_user_rainloop_ab_properties_index ON rainloop_ab_properties (id_user); CREATE INDEX id_user_id_contact_rainloop_ab_properties_index ON rainloop_ab_properties (id_user, id_contact); -CREATE TABLE rainloop_ab_tags ( - id_tag integer NOT NULL PRIMARY KEY, - id_user integer NOT NULL, - tag_name text NOT NULL -); - -CREATE INDEX id_user_rainloop_ab_tags_index ON rainloop_ab_tags (id_user); -CREATE INDEX id_user_name_rainloop_ab_tags_index ON rainloop_ab_tags (id_user, tag_name); - -CREATE TABLE rainloop_ab_tags_contacts ( - id_tag integer NOT NULL, - id_contact integer NOT NULL -); - -CREATE INDEX id_tag_rainloop_ab_tags_index ON rainloop_ab_tags_contacts (id_tag); -CREATE INDEX id_contact_rainloop_ab_tags_index ON rainloop_ab_tags_contacts (id_contact); - SQLITEINITIAL; break; } diff --git a/rainloop/v/0.0.0/app/templates/Views/App/PopupsContacts.html b/rainloop/v/0.0.0/app/templates/Views/App/PopupsContacts.html index b7f0121ae..497a53675 100644 --- a/rainloop/v/0.0.0/app/templates/Views/App/PopupsContacts.html +++ b/rainloop/v/0.0.0/app/templates/Views/App/PopupsContacts.html @@ -153,14 +153,6 @@ -
-