コード例 #1
0
 public static function addMemberProperties($arrDetails)
 {
     $arrRecipientFields = array();
     \Controller::loadDataContainer('orm_avisota_recipient');
     foreach ($GLOBALS['TL_DCA']['orm_avisota_recipient']['metapalettes']['default'] as $strPalette => $arrFields) {
         $arrRecipientFields = array_merge($arrRecipientFields, $arrFields);
     }
     $objMember = \MemberModel::findByEmail($arrDetails['email']);
     foreach ($arrRecipientFields as $strName) {
         // ignore member data if a csv column is already there
         if ($arrDetails[$strName]) {
             continue;
         }
         // ignore salutations inserted in the backend
         if ($strName == 'salutation') {
             continue;
         }
         if ($strName != 'email') {
             $arrDetails[$strName] = '';
         }
         // enhance with member data if existing
         if ($objMember !== null) {
             if ($objMember->{$strName}) {
                 $arrDetails[$strName] = $objMember->{$strName};
             } else {
                 // try synonyms
                 $synonymizer = $GLOBALS['container']['avisota.recipient.synonymizer'];
                 $arrSynonyms = $synonymizer->findSynonyms($strName);
                 if ($arrSynonyms) {
                     foreach ($arrSynonyms as $strSynonym) {
                         if ($objMember->{$strSynonym}) {
                             $arrDetails[$strName] = $objMember->{$strSynonym};
                         }
                     }
                 }
             }
         }
     }
     return $arrDetails;
 }
 public static function addMemberProperties($arrProperties)
 {
     $arrResult = array();
     foreach ($arrProperties as $strName => $strValue) {
         // ignore salutations inserted in the backend
         if ($strName == 'salutation') {
             continue;
         }
         $objMember = \MemberModel::findByEmail($arrProperties['email']);
         if (!$strValue) {
             // first store the existing name-value pair
             $arrResult[$strName] = $strValue;
             // enhance member data if existing
             if ($objMember !== null) {
                 if ($objMember->{$strName}) {
                     $arrResult[$strName] = $objMember->{$strName};
                 } else {
                     // try synonyms
                     $synonymizer = $GLOBALS['container']['avisota.recipient.synonymizer'];
                     $arrSynonyms = $synonymizer->findSynonyms($strName);
                     if ($arrSynonyms) {
                         foreach ($arrSynonyms as $strSynonym) {
                             if ($objMember->{$strSynonym}) {
                                 $arrResult[$strName] = $objMember->{$strSynonym};
                             }
                         }
                     }
                 }
             }
         } else {
             $arrResult[$strName] = $strValue;
         }
     }
     return $arrResult;
 }