0011992: Selected e-mail-address is unusable
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 4 Nov 2016 09:13:15 +0000 (10:13 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 4 Nov 2016 11:17:54 +0000 (12:17 +0100)
* fixes getPreferredEmail for private addresses
* fixes typo: prefered -> preferred

https://forge.tine20.org/view.php?id=11992

Change-Id: Ic5b4da35ce5c4f7ad85a392ae24bb90ef0e92378
Reviewed-on: http://gerrit.tine20.com/customers/3729
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
13 files changed:
tine20/Addressbook/Model/Contact.php
tine20/Addressbook/js/Model.js
tine20/Calendar/Controller.php
tine20/Calendar/Controller/EventNotifications.php
tine20/Calendar/Export/Ical.php
tine20/Calendar/Frontend/ActiveSync.php
tine20/Calendar/Model/Attender.php
tine20/Calendar/js/AttendeeGridPanel.js
tine20/Expressomail/js/AddressbookGridPanelHook.js
tine20/Expressomail/js/Expressomail.js
tine20/Felamimail/js/Felamimail.js
tine20/Felamimail/js/GridPanel.js
tine20/Felamimail/js/GridPanelHook.js

index 2bb5a02..971f510 100644 (file)
@@ -264,7 +264,7 @@ class Addressbook_Model_Contact extends Tinebase_Record_Abstract
      * 
      * @return string
      */
-    public function getPreferedEmailAddress()
+    public function getPreferredEmailAddress()
     {
         // prefer work mail over private mail till we have prefs for this
         return $this->email ? $this->email : $this->email_home;
index ad89ea0..39730be 100644 (file)
@@ -112,10 +112,8 @@ Tine.Addressbook.Model.Contact = Tine.Tinebase.data.Record.create(Tine.Addressbo
     /**
      * returns true preferred email if available
      * @return {String}
-     *
-     * TODO fix typo (prefered -> preferred)
      */
-    getPreferedEmail: function(preferred) {
+    getPreferredEmail: function(preferred) {
         var preferred = preferred || 'email',
             other = preferred == 'email' ? 'email_home' : 'email';
             
@@ -129,7 +127,7 @@ Tine.Addressbook.Model.Contact = Tine.Tinebase.data.Record.create(Tine.Addressbo
             appName: 'Tinebase'
         });
         if (tinebaseApp.featureEnabled('featureShowAccountEmail')) {
-            var email = this.getPreferedEmail();
+            var email = this.getPreferredEmail();
             if (email !== '') {
                 result += ' (' + email + ')';
             }
@@ -287,10 +285,10 @@ Tine.Addressbook.Model.EmailAddress = Tine.Tinebase.data.Record.create([
     containersName: 'Addressbooks',
     copyOmitFields: ['group_id'],
 
-    getPreferedEmail: function(preferred) {
+    getPreferredEmail: function(preferred) {
         var emails = this.get("emails");
-        if (!this.get("email")) {
-            return  this.get("emails");
+        if (! this.get("email") && ! this.get("email_home")) {
+            return this.get("emails");
         } else {
             var preferred = preferred || 'email',
             other = preferred == 'email' ? 'email_home' : 'email';
index 6452f32..85fd26f 100644 (file)
@@ -119,7 +119,7 @@ class Calendar_Controller extends Tinebase_Controller_Event implements Tinebase_
         if ($_eventObject->keepAsContact()) {
             try {
                 $contact = Addressbook_Controller_Contact::getInstance()->get($contactId);
-                $contactEmail = $contact->getPreferedEmailAddress();
+                $contactEmail = $contact->getPreferredEmailAddress();
             } catch (Tinebase_Exception_NotFound $tenf) {
                 // ignore
                 $contactEmail = $_eventObject->account->accountEmailAddress;
@@ -232,7 +232,7 @@ class Calendar_Controller extends Tinebase_Controller_Event implements Tinebase_
     public function getInvitationContainer($organizer, $emailAddress = null)
     {
         if (null!==$organizer) {
-            $containerName = $organizer->getPreferedEmailAddress();
+            $containerName = $organizer->getPreferredEmailAddress();
         } else {
             $containerName = $emailAddress;
         }
index 6f3a1ae..0b0f83a 100644 (file)
             // external (non account) notification
             if (! $attendeeAccountId) {
                 // external organizer needs status updates
-                $sendLevel = is_object($organizer) && $_attender->getEmail() == $organizer->getPreferedEmailAddress() ? 40 : 30;
+                $sendLevel = is_object($organizer) && $_attender->getEmail() == $organizer->getPreferredEmailAddress() ? 40 : 30;
                 $sendOnOwnActions = false;
                 $sendAlarms = false;
             }
             // NOTE prefUser is organizer for external notifications
             if (($attendeeAccountId == $_updater->getId() && ! $sendOnOwnActions) 
                 || ($sendLevel < $_notificationLevel && (
-                        ((is_object($organizer) && method_exists($attendee, 'getPreferedEmailAddress') && $attendee->getPreferedEmailAddress() != $organizer->getPreferedEmailAddress())
-                        || (is_object($organizer) && !method_exists($attendee, 'getPreferedEmailAddress') && $attendee->email != $organizer->getPreferedEmailAddress()))
+                        ((is_object($organizer) && method_exists($attendee, 'getPreferredEmailAddress') && $attendee->getPreferredEmailAddress() != $organizer->getPreferredEmailAddress())
+                        || (is_object($organizer) && !method_exists($attendee, 'getPreferredEmailAddress') && $attendee->email != $organizer->getPreferredEmailAddress()))
                         || $sendLevel == self::NOTIFICATION_LEVEL_NONE)
                    )
                 ) {
index 403049f..7b1ea4c 100644 (file)
@@ -130,7 +130,7 @@ class Calendar_Export_Ical
         // organizer
         $organizerId = $_event->organizer instanceof Addressbook_Model_Contact ? array($_event->organizer->getId()) : array($_event->organizer);
         $organizer = Addressbook_Controller_Contact::getInstance()->getMultiple($organizerId, TRUE)->getFirstRecord();
-        if ($organizer && $organizerEmail = $organizer->getPreferedEmailAddress()) {
+        if ($organizer && $organizerEmail = $organizer->getPreferredEmailAddress()) {
             $vevent->addProperty(new qCal_Property_Organizer("mailto:$organizerEmail", array('CN' => $organizer->n_fileas)));
         }
         
index eea9321..34f6dbe 100644 (file)
@@ -866,7 +866,7 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
     
         if ($organizer instanceof Addressbook_Model_Contact) {
             $organizerName = $organizer->n_fileas;
-            $organizerEmail = $organizer->getPreferedEmailAddress();
+            $organizerEmail = $organizer->getPreferredEmailAddress();
         } else {
             // set the current account as organizer
             // if organizer is not set, you can not edit the event on the Motorola Milestone
index 2eb6c81..d9bb0bd 100644 (file)
@@ -147,7 +147,7 @@ class Calendar_Model_Attender extends Tinebase_Record_Abstract
         switch ($this->user_type) {
             case self::USERTYPE_USER:
             case self::USERTYPE_GROUPMEMBER:
-                return $resolvedUser->getPreferedEmailAddress();
+                return $resolvedUser->getPreferredEmailAddress();
                 break;
             case self::USERTYPE_GROUP:
                 return $resolvedUser->getId();
index 242f693..b998662 100644 (file)
@@ -583,8 +583,8 @@ Tine.Calendar.AttendeeGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
             appName: 'Tinebase'
         });
         if (tinebaseApp.featureEnabled('featureShowAccountEmail')) {
-            if (typeof name.getPreferedEmail == 'function') {
-                email = name.getPreferedEmail();
+            if (typeof name.getPreferredEmail == 'function') {
+                email = name.getPreferredEmail();
             } else if (name.email) {
                 email = name.email;
             } else if (name.accountEmailAddress) {
index 0387673..eec6207 100644 (file)
@@ -109,7 +109,7 @@ Ext.apply(Tine.Expressomail.AddressbookGridPanelHook.prototype, {
                 contact = new Tine.Addressbook.Model.Contact(contact);
             }
             
-            var mailAddress = contact.getPreferedEmail();
+            var mailAddress = contact.getPreferredEmail();
             if (mailAddress) {
                 mailAddresses.push(mailAddress);
             }
index 1a3c9f7..6206447 100644 (file)
@@ -972,7 +972,7 @@ Tine.Expressomail.getEmailStringFromContact = function(contact) {
     Tine.log.debug(contact);
 
     var result = contact.get('n_fn') + ' <';
-    result += contact.getPreferedEmail();
+    result += contact.getPreferredEmail();
     result += '>';
 
    if (contact.get('org_unit') != '' && contact.get('org_unit') != null ) {
index e27d148..54bb929 100644 (file)
@@ -871,7 +871,7 @@ Tine.Felamimail.getEmailStringFromContact = function(contact) {
     Tine.log.debug(contact);
     
     var result = contact.get('n_fileas') + ' <';
-    result += contact.getPreferedEmail();
+    result += contact.getPreferredEmail();
     result += '>';
     
     return result;
index 2e504c8..cf2f65c 100644 (file)
@@ -239,6 +239,7 @@ Tine.Felamimail.GridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
             actionType: 'add',
             text: this.app.i18n._('Compose'),
             handler: this.onMessageCompose.createDelegate(this),
+            // TODO reactivate when account becomes available as sometimes this stays deactivated
             disabled: ! this.app.getActiveAccount(),
             iconCls: this.app.appName + 'IconCls'
         });
index 5ac087a..5897724 100644 (file)
@@ -217,7 +217,7 @@ Ext.apply(Tine.Felamimail.GridPanelHook.prototype, {
         }
         
         if (!contact.get("members")) {
-            var mailAddress = (contact.getPreferedEmail()) ? Tine.Felamimail.getEmailStringFromContact(contact) : null;
+            var mailAddress = (contact.getPreferredEmail()) ? Tine.Felamimail.getEmailStringFromContact(contact) : null;
             if (mailAddress)
                 mailAddresses.push(mailAddress);
         } else {