init
This commit is contained in:
69
include/SugarEmailAddress/SugarEmailAddress.js
Normal file
69
include/SugarEmailAddress/SugarEmailAddress.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
(function(){if(SUGAR.EmailAddressWidget)return;var Dom=YAHOO.util.Dom;SUGAR.EmailAddressWidget=function(module){if(!SUGAR.EmailAddressWidget.count[module])SUGAR.EmailAddressWidget.count[module]=0;this.count=SUGAR.EmailAddressWidget.count[module];SUGAR.EmailAddressWidget.count[module]++;this.module=module;this.id=this.module+this.count;if(document.getElementById(module+'_email_widget_id'))
|
||||
document.getElementById(module+'_email_widget_id').value=this.id;SUGAR.EmailAddressWidget.instances[this.id]=this;}
|
||||
SUGAR.EmailAddressWidget.instances={};SUGAR.EmailAddressWidget.count={};SUGAR.EmailAddressWidget.prototype={emailTemplate:'<tr id="emailAddressRow">'+'<td nowrap="NOWRAP"><input type="text" name="emailAddress{$index}" id="emailAddress0" size="30"/></td>'+'<td><span> </span><img id="removeButton0" name="0" src="index.php?entryPoint=getImage&themeName=Sugar&imageName=delete_inline.gif"/></td>'+'<td align="center"><input type="radio" name="emailAddressPrimaryFlag" id="emailAddressPrimaryFlag0" value="emailAddress0" enabled="true" checked="true"/></td>'+'<td align="center"><input type="checkbox" name="emailAddressOptOutFlag[]" id="emailAddressOptOutFlag0" value="emailAddress0" enabled="true"/></td>'+'<td align="center"><input type="checkbox" name="emailAddressInvalidFlag[]" id="emailAddressInvalidFlag0" value="emailAddress0" enabled="true"/></td>'+'<td><input type="hidden" name="emailAddressVerifiedFlag0" id="emailAddressVerifiedFlag0" value="true"/></td>'+'<td><input type="hidden" name="emailAddressVerifiedValue0" id="emailAddressVerifiedValue0" value=""/></td></tr>',numberEmailAddresses:0,replyToFlagObject:new Object(),verifying:false,enterPressed:false,tabPressed:false,emailView:"",emailIsRequired:false,prefillEmailAddresses:function(tableId,o){for(i=0;i<o.length;i++){o[i].email_address=o[i].email_address.replace(''',"'");this.addEmailAddress(tableId,o[i].email_address,o[i].primary_address,o[i].reply_to_address,o[i].opt_out,o[i].invalid_email);}},retrieveEmailAddress:function(event){var callbackFunction=function success(data){var vals=YAHOO.lang.JSON.parse(data.responseText);var target=vals.target;event=this.getEvent(event);if(vals.email){var email=vals.email;if(email!=''&&/\d+$/.test(target)){var matches=target.match(/\d+$/);var targetNumber=matches[0];var optOutEl=Dom.get(this.id+'emailAddressOptOutFlag'+targetNumber);if(optOutEl){optOutEl.checked=email['opt_out']==1?true:false;}
|
||||
var invalidEl=Dom.get(this.id+'emailAddressInvalidFlag'+targetNumber);if(invalidEl){invalidEl.checked=email['invalid_email']==1?true:false;}}}
|
||||
var index=/[a-z]*\d?emailAddress(\d+)/i.exec(target)[1];var verifyElementFlag=Dom.get(this.id+'emailAddressVerifiedFlag'+index);if(verifyElementFlag.parentNode.childNodes.length>1){verifyElementFlag.parentNode.removeChild(verifyElementFlag.parentNode.lastChild);}
|
||||
var verifiedTextNode=document.createElement('span');verifiedTextNode.innerHTML='';verifyElementFlag.parentNode.appendChild(verifiedTextNode);verifyElementFlag.value="true";this.verifyElementValue=Dom.get(this.id+'emailAddressVerifiedValue'+index);this.verifyElementValue.value=Dom.get(this.id+'emailAddress'+index).value;this.verifying=false;var savePressed=false;if(event){var elm=document.activeElement||event.explicitOriginalTarget;if(typeof elm.type!='undefined'&&/submit|button/.test(elm.type.toLowerCase())){savePressed=true;}}
|
||||
if(savePressed||this.enterPressed){setTimeout("SUGAR.EmailAddressWidget.instances."+this.id+".forceSubmit()",2100);}else if(this.tabPressed){Dom.get(this.id+'emailAddressPrimaryFlag'+index).focus();}}
|
||||
var event=this.getEvent(event);var targetEl=this.getEventElement(event);var index=/[a-z]*\d?emailAddress(\d+)/i.exec(targetEl.id)[1];var verifyElementFlag=Dom.get(this.id+'emailAddressVerifiedFlag'+index);this.verifyElementValue=Dom.get(this.id+'emailAddressVerifiedValue'+index);verifyElementFlag.value=(trim(targetEl.value)==''||targetEl.value==this.verifyElementValue.value)?"true":"false"
|
||||
if(verifyElementFlag.parentNode.childNodes.length>1){verifyElementFlag.parentNode.removeChild(verifyElementFlag.parentNode.lastChild);}
|
||||
if(/emailAddress\d+$/.test(targetEl.id)&&isValidEmail(targetEl.value)&&!this.verifying&&verifyElementFlag.value=="false"){verifiedTextNode=document.createElement('span');verifyElementFlag.parentNode.appendChild(verifiedTextNode);verifiedTextNode.innerHTML=SUGAR.language.get('app_strings','LBL_VERIFY_EMAIL_ADDRESS');this.verifying=true;var cObj=YAHOO.util.Connect.asyncRequest('GET','index.php?&module=Contacts&action=RetrieveEmail&target='+targetEl.id+'&email='+targetEl.value,{success:callbackFunction,failure:callbackFunction,scope:this});}},handleKeyDown:function(event){var e=this.getEvent(event);var eL=this.getEventElement(e);if((kc=e["keyCode"])){this.enterPressed=(kc==13)?true:false;this.tabPressed=(kc==9)?true:false;if(this.enterPressed||this.tabPressed){this.retrieveEmailAddress(e);if(this.enterPressed);this.freezeEvent(e);}}},getEvent:function(event){return(event?event:window.event);},getEventElement:function(e){return(e.srcElement?e.srcElement:(e.target?e.target:e.currentTarget));},freezeEvent:function(e){if(e.preventDefault)e.preventDefault();e.returnValue=false;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();return false;},addEmailAddress:function(tableId,address,primaryFlag,replyToFlag,optOutFlag,invalidFlag){if(this.addInProgress)
|
||||
return;this.addInProgress=true;if(!address)
|
||||
address="";var insertInto=Dom.get(tableId);var parentObj=insertInto.parentNode;var newContent=document.createElement("input");var nav=new String(navigator.appVersion);var newContentPrimaryFlag;if(SUGAR.isIE){newContentPrimaryFlag=document.createElement("<input name='emailAddressPrimaryFlag' />");}else{newContentPrimaryFlag=document.createElement("input");}
|
||||
var newContentReplyToFlag=document.createElement("input");var newContentOptOutFlag=document.createElement("input");var newContentInvalidFlag=document.createElement("input");var newContentVerifiedFlag=document.createElement("input");var newContentVerifiedValue=document.createElement("input");var removeButton=document.createElement("img");var tbody=document.createElement("tbody");var tr=document.createElement("tr");var td1=document.createElement("td");var td2=document.createElement("td");var td3=document.createElement("td");var td4=document.createElement("td");var td5=document.createElement("td");var td6=document.createElement("td");var td7=document.createElement("td");var td8=document.createElement("td");newContent.setAttribute("type","text");newContent.setAttribute("name",this.id+"emailAddress"+this.numberEmailAddresses);newContent.setAttribute("id",this.id+"emailAddress"+this.numberEmailAddresses);newContent.setAttribute("size","30");if(address!=''){newContent.setAttribute("value",address);}
|
||||
removeButton.setAttribute("id",this.id+"removeButton"+this.numberEmailAddresses);removeButton.setAttribute("class","id-ff-remove");removeButton.setAttribute("name",this.numberEmailAddresses);removeButton.eaw=this;removeButton.setAttribute("src","index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=id-ff-remove.png");removeButton.onclick=function(){this.eaw.removeEmailAddress(this.name);};newContentPrimaryFlag.setAttribute("type","radio");newContentPrimaryFlag.setAttribute("name",this.id+"emailAddressPrimaryFlag");newContentPrimaryFlag.setAttribute("id",this.id+"emailAddressPrimaryFlag"+this.numberEmailAddresses);newContentPrimaryFlag.setAttribute("value",this.id+"emailAddress"+this.numberEmailAddresses);newContentPrimaryFlag.setAttribute("enabled","true");newContentReplyToFlag.setAttribute("type","radio");newContentReplyToFlag.setAttribute("name",this.id+"emailAddressReplyToFlag");newContentReplyToFlag.setAttribute("id",this.id+"emailAddressReplyToFlag"+this.numberEmailAddresses);newContentReplyToFlag.setAttribute("value",this.id+"emailAddress"+this.numberEmailAddresses);newContentReplyToFlag.setAttribute("enabled","true");newContentReplyToFlag.eaw=this;newContentReplyToFlag['onclick']=function(){var form=document.forms[this.eaw.emailView];if(!form){form=document.forms['editContactForm'];}
|
||||
var nav=new String(navigator.appVersion);if(nav.match(/MSIE/gim)){for(i=0;i<form.elements.length;i++){var id=new String(form.elements[i].id);if(id.match(/emailAddressReplyToFlag/gim)&&form.elements[i].type=='radio'&&id!=this.eaw.id){form.elements[i].checked=false;}}}
|
||||
for(i=0;i<form.elements.length;i++){var id=new String(form.elements[i].id);if(id.match(/emailAddressReplyToFlag/gim)&&form.elements[i].type=='radio'&&id!=this.eaw.id){this.eaw.replyToFlagObject[this.eaw.id]=false;}}
|
||||
if(this.eaw.replyToFlagObject[this.id]){this.eaw.replyToFlagObject[this.id]=false;this.checked=false;}else{this.eaw.replyToFlagObject[this.id]=true;this.checked=true;}}
|
||||
newContentOptOutFlag.setAttribute("type","checkbox");newContentOptOutFlag.setAttribute("name",this.id+"emailAddressOptOutFlag[]");newContentOptOutFlag.setAttribute("id",this.id+"emailAddressOptOutFlag"+this.numberEmailAddresses);newContentOptOutFlag.setAttribute("value",this.id+"emailAddress"+this.numberEmailAddresses);newContentOptOutFlag.setAttribute("enabled","true");newContentOptOutFlag.eaw=this;newContentOptOutFlag['onClick']=function(){this.eaw.toggleCheckbox(this)};newContentInvalidFlag.setAttribute("type","checkbox");newContentInvalidFlag.setAttribute("name",this.id+"emailAddressInvalidFlag[]");newContentInvalidFlag.setAttribute("id",this.id+"emailAddressInvalidFlag"+this.numberEmailAddresses);newContentInvalidFlag.setAttribute("value",this.id+"emailAddress"+this.numberEmailAddresses);newContentInvalidFlag.setAttribute("enabled","true");newContentInvalidFlag.eaw=this;newContentInvalidFlag['onClick']=function(){this.eaw.toggleCheckbox(this)};newContentVerifiedFlag.setAttribute("type","hidden");newContentVerifiedFlag.setAttribute("name",this.id+"emailAddressVerifiedFlag"+this.numberEmailAddresses);newContentVerifiedFlag.setAttribute("id",this.id+"emailAddressVerifiedFlag"+this.numberEmailAddresses);newContentVerifiedFlag.setAttribute("value","true");newContentVerifiedValue.setAttribute("type","hidden");newContentVerifiedValue.setAttribute("name",this.id+"emailAddressVerifiedValue"+this.numberEmailAddresses);newContentVerifiedValue.setAttribute("id",this.id+"emailAddressVerifiedValue"+this.numberEmailAddresses);newContentVerifiedValue.setAttribute("value",address);this.emailView=(this.emailView=='')?'EditView':this.emailView;addToValidateVerified(this.emailView,this.id+"emailAddressVerifiedFlag"+this.numberEmailAddresses,'bool',false,SUGAR.language.get('app_strings','LBL_VERIFY_EMAIL_ADDRESS'));tr.setAttribute("id",this.id+"emailAddressRow"+this.numberEmailAddresses);td1.setAttribute("nowrap","NOWRAP");td3.setAttribute("align","center");td4.setAttribute("align","center");td5.setAttribute("align","center");td6.setAttribute("align","center");td1.appendChild(newContent);td1.appendChild(document.createTextNode(" "));spanNode=document.createElement('span');spanNode.innerHTML=' ';td2.appendChild(spanNode);if(this.numberEmailAddresses!=0||typeof(this.emailIsRequired)=="undefined"||!this.emailIsRequired)
|
||||
td2.appendChild(removeButton);td3.appendChild(newContentPrimaryFlag);td4.appendChild(newContentReplyToFlag);td5.appendChild(newContentOptOutFlag);td6.appendChild(newContentInvalidFlag);td7.appendChild(newContentVerifiedFlag);td8.appendChild(newContentVerifiedValue);tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);if(typeof(this.module)!='undefined'&&this.module=='Users'){tr.appendChild(td4);}else{tr.appendChild(td5);tr.appendChild(td6);}
|
||||
tr.appendChild(td7);tr.appendChild(td8);tbody.appendChild(tr);insertInto.appendChild(tbody);parentObj.insertBefore(Dom.get('targetBody'),insertInto);if(primaryFlag=='1'||(this.numberEmailAddresses==0)){newContentPrimaryFlag.setAttribute("checked",'true');}
|
||||
if(replyToFlag=='1'){newContentReplyToFlag.setAttribute("checked","true");}
|
||||
if(replyToFlag=='1'){this.replyToFlagObject[newContentReplyToFlag.id]=true;}else{this.replyToFlagObject[newContentReplyToFlag.id]=false;}
|
||||
if(optOutFlag=='1'){newContentOptOutFlag.setAttribute("checked",'true');}
|
||||
if(invalidFlag=='1'){newContentInvalidFlag.setAttribute("checked","true");}
|
||||
newContent.eaw=this;newContent.onblur=function(e){this.eaw.retrieveEmailAddress(e)};newContent.onkeydown=function(e){this.eaw.handleKeyDown(e)};addToValidate(this.emailView,this.id+'emailAddress'+this.numberEmailAddresses,'email',this.emailIsRequired,SUGAR.language.get('app_strings','LBL_EMAIL_ADDRESS_BOOK_EMAIL_ADDR'));this.numberEmailAddresses++;this.addInProgress=false;},removeEmailAddress:function(index){removeFromValidate(this.emailView,this.id+'emailAddress'+index);var oNodeToRemove=Dom.get(this.id+'emailAddressRow'+index);oNodeToRemove.parentNode.removeChild(oNodeToRemove);var removedIndex=parseInt(index);if(this.numberEmailAddresses!=removedIndex){for(var x=removedIndex+1;x<this.numberEmailAddresses;x++){Dom.get(this.id+'emailAddress'+x).setAttribute("name",this.id+"emailAddress"+(x-1));Dom.get(this.id+'emailAddress'+x).setAttribute("id",this.id+"emailAddress"+(x-1));if(Dom.get(this.id+'emailAddressInvalidFlag'+x)){Dom.get(this.id+'emailAddressInvalidFlag'+x).setAttribute("id",this.id+"emailAddressInvalidFlag"+(x-1));}
|
||||
if(Dom.get(this.id+'emailAddressOptOutFlag'+x)){Dom.get(this.id+'emailAddressOptOutFlag'+x).setAttribute("id",this.id+"emailAddressOptOutFlag"+(x-1));}
|
||||
if(Dom.get(this.id+'emailAddressPrimaryFlag'+x)){Dom.get(this.id+'emailAddressPrimaryFlag'+x).setAttribute("id",this.id+"emailAddressPrimaryFlag"+(x-1));}
|
||||
Dom.get(this.id+'emailAddressVerifiedValue'+x).setAttribute("id",this.id+"emailAddressVerifiedValue"+(x-1));Dom.get(this.id+'emailAddressVerifiedFlag'+x).setAttribute("id",this.id+"emailAddressVerifiedFlag"+(x-1));var rButton=Dom.get(this.id+'removeButton'+x);rButton.setAttribute("name",(x-1));rButton.setAttribute("id",this.id+"removeButton"+(x-1));Dom.get(this.id+'emailAddressRow'+x).setAttribute("id",this.id+'emailAddressRow'+(x-1));}}
|
||||
this.numberEmailAddresses--;if(this.numberEmailAddresses==0){return;}
|
||||
var primaryFound=false;for(x=0;x<this.numberEmailAddresses;x++){if(Dom.get(this.id+'emailAddressPrimaryFlag'+x).checked){primaryFound=true;}}
|
||||
if(!primaryFound){Dom.get(this.id+'emailAddressPrimaryFlag0').checked=true;Dom.get(this.id+'emailAddressPrimaryFlag0').value=this.id+'emailAddress0';}},toggleCheckbox:function(el)
|
||||
{var form=document.forms[this.emailView];if(!form){form=document.forms['editContactForm'];}
|
||||
if(SUGAR.isIE){for(i=0;i<form.elements.length;i++){var id=new String(form.elements[i].id);if(id.match(/emailAddressInvalidFlag/gim)&&form.elements[i].type=='checkbox'&&id!=el.id){form.elements[i].checked=false;}}
|
||||
el.checked=true;}},forceSubmit:function(){var theForm=Dom.get(this.emailView);if(theForm){theForm.action.value='Save';if(!check_form(this.emailView)){return false;}
|
||||
if(this.emailView=='EditView'){theForm.submit();}else if(this.emailView=='QuickCreate'){SUGAR.subpanelUtils.inlineSave(theForm.id,theForm.module.value.toLowerCase());}}}};emailAddressWidgetLoaded=true;})();
|
||||
979
include/SugarEmailAddress/SugarEmailAddress.php
Executable file
979
include/SugarEmailAddress/SugarEmailAddress.php
Executable file
@@ -0,0 +1,979 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description:
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
|
||||
* Reserved. Contributor(s): ______________________________________..
|
||||
*********************************************************************************/
|
||||
|
||||
|
||||
require_once("include/JSON.php");
|
||||
|
||||
|
||||
class SugarEmailAddress extends SugarBean {
|
||||
var $table_name = 'email_addresses';
|
||||
var $module_name = "EmailAddresses";
|
||||
var $module_dir = 'EmailAddresses';
|
||||
var $object_name = 'EmailAddress';
|
||||
var $regex = "/^\w+(['\.\-\+\/\w]+)*@((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\w+([\.-]?\w+)*(\.[\w-]{2,})+)\$/";
|
||||
|
||||
var $db;
|
||||
var $smarty;
|
||||
|
||||
var $addresses = array(); // array of emails
|
||||
var $view = '';
|
||||
|
||||
static $count = 0;
|
||||
|
||||
/**
|
||||
* Sole constructor
|
||||
*/
|
||||
function SugarEmailAddress() {
|
||||
parent::SugarBean();
|
||||
$this->index = self::$count;
|
||||
self::$count++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy email address handling. This is to allow support for SOAP or customizations
|
||||
* @param string $id
|
||||
* @param string $module
|
||||
*/
|
||||
function handleLegacySave($bean, $prefix = "") {
|
||||
if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) {
|
||||
if (empty($this->addresses) || !isset($_REQUEST['massupdate'])) {
|
||||
$this->addresses = array();
|
||||
$optOut = (isset($bean->email_opt_out) && $bean->email_opt_out == "1") ? true : false;
|
||||
$invalid = (isset($bean->invalid_email) && $bean->invalid_email == "1") ? true : false;
|
||||
|
||||
$isPrimary = true;
|
||||
for($i = 1; $i <= 10; $i++){
|
||||
$email = 'email'.$i;
|
||||
if(isset($bean->$email) && !empty($bean->$email)){
|
||||
$opt_out_field = $email.'_opt_out';
|
||||
$invalid_field = $email.'_invalid';
|
||||
$field_optOut = (isset($bean->$opt_out_field)) ? $bean->$opt_out_field : $optOut;
|
||||
$field_invalid = (isset($bean->$invalid_field)) ? $bean->$invalid_field : $invalid;
|
||||
$this->addAddress($bean->$email, $isPrimary, false, $field_invalid, $field_optOut);
|
||||
$isPrimary = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->populateAddresses($bean->id, $bean->module_dir, array(),'');
|
||||
if(isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) {
|
||||
$this->populateLegacyFields($bean);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills standard email1 legacy fields
|
||||
* @param string id
|
||||
* @param string module
|
||||
* @return object
|
||||
*/
|
||||
function handleLegacyRetrieve(&$bean) {
|
||||
$module_dir = $this->getCorrectedModule($bean->module_dir);
|
||||
$this->addresses = $this->getAddressesByGUID($bean->id, $module_dir);
|
||||
$this->populateLegacyFields($bean);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function populateLegacyFields(&$bean){
|
||||
$primary_found = false;
|
||||
$alternate_found = false;
|
||||
$alternate2_found = false;
|
||||
foreach($this->addresses as $k=>$address) {
|
||||
if ($primary_found && $alternate_found)
|
||||
break;
|
||||
if ($address['primary_address'] == 1 && !$primary_found) {
|
||||
$primary_index = $k;
|
||||
$primary_found = true;
|
||||
} elseif (!$alternate_found) {
|
||||
$alternate_index = $k;
|
||||
$alternate_found = true;
|
||||
} elseif (!$alternate2_found){
|
||||
$alternate2_index = $k;
|
||||
$alternate2_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($primary_found) {
|
||||
$bean->email1 = $this->addresses[$primary_index]['email_address'];
|
||||
$bean->email_opt_out = $this->addresses[$primary_index]['opt_out'];
|
||||
$bean->invalid_email = $this->addresses[$primary_index]['invalid_email'];
|
||||
if ($alternate_found) {
|
||||
$bean->email2 = $this->addresses[$alternate_index]['email_address'];
|
||||
}
|
||||
} elseif ($alternate_found) {
|
||||
// Use the first found alternate as email1.
|
||||
$bean->email1 = $this->addresses[$alternate_index]['email_address'];
|
||||
$bean->email_opt_out = $this->addresses[$alternate_index]['opt_out'];
|
||||
$bean->invalid_email = $this->addresses[$alternate_index]['invalid_email'];
|
||||
if ($alternate2_found) {
|
||||
$bean->email2 = $this->addresses[$alternate2_index]['email_address'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves email addresses for a parent bean
|
||||
* @param string $id Parent bean ID
|
||||
* @param string $module Parent bean's module
|
||||
* @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves
|
||||
* @param string $primary GUID of primary address
|
||||
* @param string $replyTo GUID of reply-to address
|
||||
* @param string $invalid GUID of invalid address
|
||||
*/
|
||||
function save($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='', $in_workflow=false) {
|
||||
if(empty($this->addresses) || $in_workflow){
|
||||
$this->populateAddresses($id, $module, $new_addrs,$primary);
|
||||
}
|
||||
|
||||
//find all email addresses..
|
||||
$current_links=array();
|
||||
// Need to correct this to handle the Employee/User split
|
||||
$module = $this->getCorrectedModule($module);
|
||||
$q2="select * from email_addr_bean_rel eabr WHERE eabr.bean_id = '{$id}' AND eabr.bean_module = '{$module}' and eabr.deleted=0";
|
||||
$r2 = $this->db->query($q2);
|
||||
while(($row2=$this->db->fetchByAssoc($r2)) != null ) {
|
||||
$current_links[$row2['email_address_id']]=$row2;
|
||||
}
|
||||
|
||||
if (!empty($this->addresses)) {
|
||||
// insert new relationships and create email address record, if they don't exist
|
||||
foreach($this->addresses as $address) {
|
||||
if(!empty($address['email_address'])) {
|
||||
$guid = create_guid();
|
||||
$emailId = $this->AddUpdateEmailAddress($address['email_address'],$address['invalid_email'],$address['opt_out']);// this will save the email address if not found
|
||||
|
||||
//verify linkage and flags.
|
||||
$upd_eabr="";
|
||||
if (isset($current_links[$emailId])) {
|
||||
if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address'] ) {
|
||||
$upd_eabr="UPDATE email_addr_bean_rel SET primary_address='{$address['primary_address']}', reply_to_address='{$address['reply_to_address']}' WHERE id='{$current_links[$emailId]['id']}'";
|
||||
}
|
||||
|
||||
unset($current_links[$emailId]);
|
||||
} else {
|
||||
$upd_eabr = "INSERT INTO email_addr_bean_rel (id, email_address_id,bean_id, bean_module,primary_address,reply_to_address,date_created,date_modified,deleted) VALUES('{$guid}', '{$emailId}', '{$id}', '{$module}', {$address['primary_address']}, {$address['reply_to_address']}, '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', 0)";
|
||||
}
|
||||
|
||||
if (!empty($upd_eabr)) {
|
||||
$r2 = $this->db->query($upd_eabr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//delete link to dropped email address.
|
||||
if (!empty($current_links)) {
|
||||
|
||||
$delete="";
|
||||
foreach ($current_links as $eabr) {
|
||||
|
||||
$delete.=empty($delete) ? "'".$eabr['id'] . "' " : ",'" . $eabr['id'] . "'";
|
||||
}
|
||||
|
||||
$eabr_unlink="update email_addr_bean_rel set deleted=1 where id in ({$delete})";
|
||||
$this->db->query($eabr_unlink);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of email addresses found for a specifed bean
|
||||
*
|
||||
* @param string $email Address to match
|
||||
* @param object $bean Bean to query against
|
||||
* @param string $addresstype Optional, pass a 1 to query against the primary address, 0 for the other addresses
|
||||
* @return int Count of records found
|
||||
*/
|
||||
function getCountEmailAddressByBean(
|
||||
$email,
|
||||
$bean,
|
||||
$addresstype
|
||||
)
|
||||
{
|
||||
$emailCaps = strtoupper(trim($email));
|
||||
if(empty($emailCaps))
|
||||
return 0;
|
||||
|
||||
$q = "SELECT *
|
||||
FROM email_addr_bean_rel eabl JOIN email_addresses ea
|
||||
ON (ea.id = eabl.email_address_id)
|
||||
JOIN {$bean->table_name} bean
|
||||
ON (eabl.bean_id = bean.id)
|
||||
WHERE ea.email_address_caps = '{$emailCaps}'
|
||||
and eabl.bean_module = '{$bean->module_dir}'
|
||||
and eabl.primary_address = '{$addresstype}'
|
||||
and eabl.deleted=0 ";
|
||||
|
||||
$r = $this->db->query($q);
|
||||
|
||||
// do it this way to make the count accurate in oracle
|
||||
$i = 0;
|
||||
while ($this->db->fetchByAssoc($r)) ++$i;
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a contact or user ID if a matching email is found
|
||||
* @param $email the email address to match
|
||||
* @param $table which table to query
|
||||
*/
|
||||
function getRelatedId($email, $module) {
|
||||
$email = trim(strtoupper($email));
|
||||
$module = ucfirst($module);
|
||||
|
||||
$q = "SELECT bean_id FROM email_addr_bean_rel eabr
|
||||
JOIN email_addresses ea ON (eabr.email_address_id = ea.id)
|
||||
WHERE bean_module = '{$module}' AND ea.email_address_caps = '{$email}' AND eabr.deleted=0";
|
||||
|
||||
$r = $this->db->query($q, true);
|
||||
|
||||
$retArr = array();
|
||||
while($a = $this->db->fetchByAssoc($r)) {
|
||||
$retArr[] = $a['bean_id'];
|
||||
}
|
||||
if(count($retArr) > 0) {
|
||||
return $retArr;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a collection of beans matching the email address
|
||||
* @param string $email Address to match
|
||||
* @return array
|
||||
*/
|
||||
function getBeansByEmailAddress($email) {
|
||||
global $beanList;
|
||||
global $beanFiles;
|
||||
|
||||
$ret = array();
|
||||
|
||||
$email = trim($email);
|
||||
|
||||
if(empty($email)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$emailCaps = strtoupper($email);
|
||||
$q = "SELECT * FROM email_addr_bean_rel eabl JOIN email_addresses ea ON (ea.id = eabl.email_address_id)
|
||||
WHERE ea.email_address_caps = '{$emailCaps}' and eabl.deleted=0 ";
|
||||
$r = $this->db->query($q);
|
||||
|
||||
while($a = $this->db->fetchByAssoc($r)) {
|
||||
if(isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) {
|
||||
$className = $beanList[$a['bean_module']];
|
||||
|
||||
if(isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
|
||||
if(!class_exists($className)) {
|
||||
require_once($beanFiles[$className]);
|
||||
}
|
||||
|
||||
$bean = new $className();
|
||||
$bean->retrieve($a['bean_id']);
|
||||
|
||||
$ret[] = $bean;
|
||||
} else {
|
||||
$GLOBALS['log']->fatal("SUGAREMAILADDRESS: could not find valid class file for [ {$className} ]");
|
||||
}
|
||||
} else {
|
||||
$GLOBALS['log']->fatal("SUGAREMAILADDRESS: could not find valid class [ {$a['bean_module']} ]");
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves email addresses for a parent bean
|
||||
* @param string $id Parent bean ID
|
||||
* @param string $module Parent bean's module
|
||||
* @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves
|
||||
* @param string $primary GUID of primary address
|
||||
* @param string $replyTo GUID of reply-to address
|
||||
* @param string $invalid GUID of invalid address
|
||||
*/
|
||||
function populateAddresses($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='') {
|
||||
$module = $this->getCorrectedModule($module);
|
||||
//One last check for the ConvertLead action in which case we need to change $module to 'Leads'
|
||||
$module = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? 'Leads' : $module;
|
||||
|
||||
$post_from_email_address_widget = (isset($_REQUEST) && isset($_REQUEST['emailAddressWidget'])) ? true : false;
|
||||
$primaryValue = $primary;
|
||||
$widgetCount = 0;
|
||||
$hasEmailValue = false;
|
||||
|
||||
if (isset($_REQUEST) && isset($_REQUEST[$module .'_email_widget_id'])) {
|
||||
|
||||
$fromRequest = false;
|
||||
// determine which array to process
|
||||
foreach($_REQUEST as $k => $v) {
|
||||
if(strpos($k, 'emailAddress') !== false) {
|
||||
$fromRequest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$widget_id = $_REQUEST[$module .'_email_widget_id'];
|
||||
|
||||
//Iterate over the widgets for this module, in case there are multiple email widgets for this module
|
||||
while(isset($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount]))
|
||||
{
|
||||
if (empty($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) {
|
||||
$widgetCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$hasEmailValue = true;
|
||||
|
||||
$eId = $module . $widget_id;
|
||||
if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) {
|
||||
$primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
|
||||
} else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) {
|
||||
$primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
|
||||
}
|
||||
|
||||
$optOutValues = array();
|
||||
if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) {
|
||||
$optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
|
||||
} else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) {
|
||||
$optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
|
||||
}
|
||||
|
||||
$invalidValues = array();
|
||||
if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) {
|
||||
$invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
|
||||
} else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) {
|
||||
$invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
|
||||
}
|
||||
|
||||
$deleteValues = array();
|
||||
if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) {
|
||||
$deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
|
||||
} else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) {
|
||||
$deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
|
||||
}
|
||||
|
||||
// prep from form save
|
||||
$primaryField = $primary;
|
||||
$replyToField = '';
|
||||
$invalidField = '';
|
||||
$optOutField = '';
|
||||
if($fromRequest && empty($primary) && isset($primaryValue)) {
|
||||
$primaryField = $primaryValue;
|
||||
}
|
||||
|
||||
if($fromRequest && empty($replyTo)) {
|
||||
if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) {
|
||||
$replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
|
||||
} else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) {
|
||||
$replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
|
||||
}
|
||||
}
|
||||
if($fromRequest && empty($new_addrs)) {
|
||||
foreach($_REQUEST as $k => $v) {
|
||||
if(preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) {
|
||||
$new_addrs[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($fromRequest && empty($new_addrs)) {
|
||||
foreach($_REQUEST as $k => $v) {
|
||||
if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
|
||||
$validateFlag = str_replace("Value", "Flag", $k);
|
||||
if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
|
||||
$new_addrs[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//empty the addresses array if the post happened from email address widget.
|
||||
if($post_from_email_address_widget) {
|
||||
$this->addresses=array(); //this gets populated during retrieve of the contact bean.
|
||||
} else {
|
||||
$optOutValues = array();
|
||||
$invalidValues = array();
|
||||
foreach($new_addrs as $k=>$email) {
|
||||
preg_match('/emailAddress([0-9])+$/', $k, $matches);
|
||||
$count = $matches[1];
|
||||
$result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . strtoupper($email) . "'");
|
||||
if(!empty($result)) {
|
||||
$row=$this->db->fetchByAssoc($result);
|
||||
if(!empty($row['opt_out'])) {
|
||||
$optOutValues[$k] = "emailAddress$count";
|
||||
}
|
||||
if(!empty($row['invalid_email'])) {
|
||||
$invalidValues[$k] = "emailAddress$count";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Re-populate the addresses class variable if we have new address(es).
|
||||
if (!empty($new_addrs)) {
|
||||
foreach($new_addrs as $k => $reqVar) {
|
||||
//$key = preg_match("/^$eId/s", $k) ? substr($k, strlen($eId)) : $k;
|
||||
$reqVar = trim($reqVar);
|
||||
if(strpos($k, 'emailAddress') !== false) {
|
||||
if(!empty($reqVar) && !in_array($k, $deleteValues)) {
|
||||
$primary = ($k == $primaryValue) ? true : false;
|
||||
$replyTo = ($k == $replyToField) ? true : false;
|
||||
$invalid = (in_array($k, $invalidValues)) ? true : false;
|
||||
$optOut = (in_array($k, $optOutValues)) ? true : false;
|
||||
$this->addAddress(trim($new_addrs[$k]), $primary, $replyTo, $invalid, $optOut);
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
}
|
||||
|
||||
$widgetCount++;
|
||||
}//End of Widget for loop
|
||||
}
|
||||
|
||||
//If no widgets, set addresses array to empty
|
||||
if($post_from_email_address_widget && !$hasEmailValue) {
|
||||
$this->addresses = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preps internal array structure for email addresses
|
||||
* @param string $addr Email address
|
||||
* @param bool $primary Default false
|
||||
* @param bool $replyTo Default false
|
||||
*/
|
||||
function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false) {
|
||||
$addr = html_entity_decode($addr, ENT_QUOTES);
|
||||
if(preg_match($this->regex, $addr)) {
|
||||
$primaryFlag = ($primary) ? '1' : '0';
|
||||
$replyToFlag = ($replyTo) ? '1' : '0';
|
||||
$invalidFlag = ($invalid) ? '1' : '0';
|
||||
$optOutFlag = ($optOut) ? '1' : '0';
|
||||
|
||||
$addr = trim($addr);
|
||||
|
||||
// If we have such address already, remove it and add new one in.
|
||||
foreach ($this->addresses as $k=>$address) {
|
||||
if ($address['email_address'] == $addr) {
|
||||
unset($this->addresses[$k]);
|
||||
} elseif ($primary && $address['primary_address'] == '1') {
|
||||
// We should only have one primary. If we are adding a primary but
|
||||
// we find an existing primary, reset this one's primary flag.
|
||||
$address['primary_address'] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$this->addresses[] = array(
|
||||
'email_address' => $addr,
|
||||
'primary_address' => $primaryFlag,
|
||||
'reply_to_address' => $replyToFlag,
|
||||
'invalid_email' => $invalidFlag,
|
||||
'opt_out' => $optOutFlag,
|
||||
);
|
||||
} else {
|
||||
$GLOBALS['log']->fatal("SUGAREMAILADDRESS: address did not validate [ {$addr} ]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates invalid_email and opt_out flags for each address
|
||||
*/
|
||||
function updateFlags() {
|
||||
if(!empty($this->addresses)) {
|
||||
foreach($this->addresses as $addressMeta) {
|
||||
if(isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) {
|
||||
$address = $this->_cleanAddress($addressMeta['email_address']);
|
||||
|
||||
$q = "SELECT * FROM email_addresses WHERE email_address = '{$address}'";
|
||||
$r = $this->db->query($q);
|
||||
$a = $this->db->fetchByAssoc($r);
|
||||
|
||||
if(!empty($a)) {
|
||||
if(isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) {
|
||||
$qUpdate = "UPDATE email_addresses SET invalid_email = {$addressMeta['invalid_email']}, opt_out = {$addressMeta['opt_out']}, date_modified = '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."' WHERE id = '{$a['id']}'";
|
||||
$rUpdate = $this->db->query($qUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function splitEmailAddress($addr)
|
||||
{
|
||||
$email = $this->_cleanAddress($addr);
|
||||
if(!preg_match($this->regex, $email)) {
|
||||
$email = ''; // remove bad email addr
|
||||
}
|
||||
$name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr));
|
||||
return array("name" => $name, "email" => strtolower($email));
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE UTIL
|
||||
* Normalizes an RFC-clean email address, returns a string that is the email address only
|
||||
* @param string $addr Dirty email address
|
||||
* @return string clean email address
|
||||
*/
|
||||
function _cleanAddress($addr) {
|
||||
$addr = trim(from_html($addr));
|
||||
|
||||
if(strpos($addr, "<") !== false && strpos($addr, ">") !== false) {
|
||||
$address = trim(substr($addr, strrpos($addr, "<") +1, strrpos($addr, ">") - strrpos($addr, "<") -1));
|
||||
} else {
|
||||
$address = trim($addr);
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* preps a passed email address for email address storage
|
||||
* @param array $addr Address in focus, must be RFC compliant
|
||||
* @return string $id email_addresses ID
|
||||
*/
|
||||
function getEmailGUID($addr) {
|
||||
$address = $this->_cleanAddress($addr);
|
||||
$addressCaps = strtoupper($address);
|
||||
|
||||
$q = "SELECT id FROM email_addresses WHERE email_address_caps = '{$addressCaps}'";
|
||||
$r = $this->db->query($q);
|
||||
$a = $this->db->fetchByAssoc($r);
|
||||
|
||||
if(!empty($a) && !empty($a['id'])) {
|
||||
return $a['id'];
|
||||
} else {
|
||||
$guid = '';
|
||||
if(!empty($address)){
|
||||
$guid = create_guid();
|
||||
$address = $GLOBALS['db']->quote($address);
|
||||
$addressCaps = $GLOBALS['db']->quote($addressCaps);
|
||||
$qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted)
|
||||
VALUES('{$guid}', '{$address}', '{$addressCaps}', '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', 0)";
|
||||
$ra = $this->db->query($qa);
|
||||
}
|
||||
return $guid;
|
||||
}
|
||||
}
|
||||
|
||||
function AddUpdateEmailAddress($addr,$invalid=0,$opt_out=0) {
|
||||
|
||||
$address = $this->_cleanAddress($addr);
|
||||
$addressCaps = strtoupper($this->db->quoteForEmail($address));
|
||||
|
||||
$q = "SELECT * FROM email_addresses WHERE email_address_caps = '{$addressCaps}' and deleted=0";
|
||||
$r = $this->db->query($q);
|
||||
$a = $this->db->fetchByAssoc($r);
|
||||
if(!empty($a) && !empty($a['id'])) {
|
||||
//verify the opt out and invalid flags.
|
||||
if ($a['invalid_email'] != $invalid or $a['opt_out'] != $opt_out) {
|
||||
$upd_q="update email_addresses set invalid_email={$invalid}, opt_out={$opt_out},date_modified = '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."' where id='{$a['id']}'";
|
||||
$upd_r= $this->db->query($upd_q);
|
||||
}
|
||||
return $a['id'];
|
||||
} else {
|
||||
$guid = '';
|
||||
if(!empty($address)){
|
||||
$guid = create_guid();
|
||||
$address = $GLOBALS['db']->quote($address);
|
||||
$addressCaps = $GLOBALS['db']->quote($addressCaps);
|
||||
$qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted, invalid_email, opt_out)
|
||||
VALUES('{$guid}', '{$address}', '{$addressCaps}', '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', '".gmdate($GLOBALS['timedate']->get_db_date_time_format())."', 0 , $invalid, $opt_out)";
|
||||
$this->db->query($qa);
|
||||
}
|
||||
return $guid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Primary or newest email address
|
||||
* @param object $focus Object in focus
|
||||
* @return string email
|
||||
*/
|
||||
function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) {
|
||||
|
||||
$parent_type=empty($parent_type) ? $focus->module_dir : $parent_type;
|
||||
$parent_id=empty($parent_id) ? $focus->id : $parent_id;
|
||||
|
||||
$q = "SELECT ea.email_address FROM email_addresses ea
|
||||
LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
|
||||
WHERE ear.bean_module = '{$parent_type}'
|
||||
AND ear.bean_id = '{$parent_id}'
|
||||
AND ear.deleted = 0
|
||||
ORDER BY ear.primary_address DESC";
|
||||
$r = $this->db->limitQuery($q, 0, 1);
|
||||
$a = $this->db->fetchByAssoc($r);
|
||||
|
||||
if(isset($a['email_address'])) {
|
||||
return $a['email_address'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getReplyToAddress($focus) {
|
||||
$q = "SELECT ea.email_address FROM email_addresses ea
|
||||
LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
|
||||
WHERE ear.bean_module = '{$focus->module_dir}'
|
||||
AND ear.bean_id = '{$focus->id}'
|
||||
AND ear.deleted = 0
|
||||
ORDER BY ear.reply_to_address DESC";
|
||||
$r = $this->db->query($q);
|
||||
$a = $this->db->fetchByAssoc($r);
|
||||
|
||||
if(isset($a['email_address'])) {
|
||||
return $a['email_address'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all email addresses by parent's GUID
|
||||
* @param string $id Parent's GUID
|
||||
* @param string $module Parent's module
|
||||
* @return array
|
||||
*/
|
||||
function getAddressesByGUID($id, $module) {
|
||||
$return = array();
|
||||
$module = $this->getCorrectedModule($module);
|
||||
|
||||
$q = "SELECT ea.*, ear.* FROM email_addresses ea
|
||||
LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
|
||||
WHERE ear.bean_module = '{$module}'
|
||||
AND ear.bean_id = '{$id}'
|
||||
AND ear.deleted = 0
|
||||
ORDER BY ear.reply_to_address, ear.primary_address DESC";
|
||||
$r = $this->db->query($q);
|
||||
|
||||
while($a = $this->db->fetchByAssoc($r)) {
|
||||
$return[] = $a;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML/JS for the EmailAddress widget
|
||||
* @param string $parent_id ID of parent bean, generally $focus
|
||||
* @param string $module $focus' module
|
||||
* @param bool asMetadata Default false
|
||||
* @return string HTML/JS for widget
|
||||
*/
|
||||
function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='')
|
||||
{
|
||||
if ( !($this->smarty instanceOf Sugar_Smarty ) )
|
||||
$this->smarty = new Sugar_Smarty();
|
||||
|
||||
global $app_strings, $dictionary, $beanList;
|
||||
|
||||
$prefill = 'false';
|
||||
$prefillData = 'new Object()';
|
||||
$passedModule = $module;
|
||||
$module = $this->getCorrectedModule($module);
|
||||
$saveModule = $module;
|
||||
if(isset($_POST['is_converted']) && $_POST['is_converted']==true){
|
||||
$id=$_POST['return_id'];
|
||||
$module=$_POST['return_module'];
|
||||
}
|
||||
$prefillDataArr = array();
|
||||
if(!empty($id)) {
|
||||
$prefillDataArr = $this->getAddressesByGUID($id, $module);
|
||||
//When coming from convert leads, sometimes module is Contacts while the id is for a lead.
|
||||
if (empty($prefillDataArr) && $module == "Contacts")
|
||||
$prefillDataArr = $this->getAddressesByGUID($id, "Leads");
|
||||
} else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
|
||||
$widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
|
||||
$count = 0;
|
||||
$key = $module . $widget_id . 'emailAddress'.$count;
|
||||
while(isset($_REQUEST[$key])) {
|
||||
$email = $_REQUEST[$key];
|
||||
$prefillDataArr[] = array('email_address'=>$email,
|
||||
'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
|
||||
'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
|
||||
'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
|
||||
'reply_to_address'=>false
|
||||
);
|
||||
$key = $module . $widget_id . 'emailAddress' . ++$count;
|
||||
} //while
|
||||
}
|
||||
|
||||
if(!empty($prefillDataArr)) {
|
||||
$json = new JSON(JSON_LOOSE_TYPE);
|
||||
$prefillData = $json->encode($prefillDataArr);
|
||||
$prefill = !empty($prefillDataArr) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$required = false;
|
||||
$vardefs = $dictionary[$beanList[$passedModule]]['fields'];
|
||||
if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required'])
|
||||
$required = true;
|
||||
$this->smarty->assign('required', $required);
|
||||
|
||||
$this->smarty->assign('module', $saveModule);
|
||||
$this->smarty->assign('index', $this->index);
|
||||
$this->smarty->assign('app_strings', $app_strings);
|
||||
$this->smarty->assign('prefillEmailAddresses', $prefill);
|
||||
$this->smarty->assign('prefillData', $prefillData);
|
||||
//Set addDefaultAddress flag (do not add if it's from the Email module)
|
||||
$this->smarty->assign('addDefaultAddress', (isset($_REQUEST['module']) && $_REQUEST['module'] == 'Emails') ? 'false' : 'true');
|
||||
$form = $this->view;
|
||||
if ($this->view == "QuickCreate")
|
||||
$form = 'form_'.$this->view .'_'.$module;
|
||||
$this->smarty->assign('emailView', $form);
|
||||
|
||||
|
||||
if($module == 'Users') {
|
||||
$this->smarty->assign('useReplyTo', true);
|
||||
} else {
|
||||
$this->smarty->assign('useOptOut', true);
|
||||
$this->smarty->assign('useInvalid', true);
|
||||
}
|
||||
|
||||
$template = empty($tpl) ? "include/SugarEmailAddress/templates/forEditView.tpl" : $tpl;
|
||||
$newEmail = $this->smarty->fetch($template);
|
||||
|
||||
|
||||
if($asMetadata) {
|
||||
// used by Email 2.0
|
||||
$ret = array();
|
||||
$ret['prefillData'] = $prefillDataArr;
|
||||
$ret['html'] = $newEmail;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return $newEmail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the HTML/JS for the EmailAddress widget
|
||||
* @param object $focus Bean in focus
|
||||
* @return string HTML/JS for widget
|
||||
*/
|
||||
function getEmailAddressWidgetDetailView($focus, $tpl='')
|
||||
{
|
||||
if ( !($this->smarty instanceOf Sugar_Smarty ) )
|
||||
$this->smarty = new Sugar_Smarty();
|
||||
|
||||
global $app_strings;
|
||||
global $current_user;
|
||||
$assign = array();
|
||||
if(empty($focus->id))return '';
|
||||
$prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
|
||||
|
||||
foreach($prefillData as $addressItem) {
|
||||
$key = ($addressItem['primary_address'] == 1) ? 'primary' : "";
|
||||
$key = ($addressItem['reply_to_address'] == 1) ? 'reply_to' : $key;
|
||||
$key = ($addressItem['opt_out'] == 1) ? 'opt_out' : $key;
|
||||
$key = ($addressItem['invalid_email'] == 1) ? 'invalid' : $key;
|
||||
|
||||
$assign[] = array('key' => $key, 'address' => $current_user->getEmailLink2($addressItem['email_address'], $focus).$addressItem['email_address']."</a>");
|
||||
}
|
||||
|
||||
|
||||
$this->smarty->assign('app_strings', $app_strings);
|
||||
$this->smarty->assign('emailAddresses', $assign);
|
||||
$templateFile = empty($tpl) ? "include/SugarEmailAddress/templates/forDetailView.tpl" : $tpl;
|
||||
$return = $this->smarty->fetch($templateFile);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getEmailAddressWidgetDuplicatesView($focus)
|
||||
* @param object $focus Bean in focus
|
||||
* @return string HTML that contains hidden input values based off of HTML request
|
||||
*/
|
||||
function getEmailAddressWidgetDuplicatesView($focus)
|
||||
{
|
||||
if ( !($this->smarty instanceOf Sugar_Smarty ) )
|
||||
$this->smarty = new Sugar_Smarty();
|
||||
|
||||
$count = 0;
|
||||
$emails = array();
|
||||
$primary = null;
|
||||
$optOut = array();
|
||||
$invalid = array();
|
||||
$mod = isset($focus) ? $focus->module_dir : "";
|
||||
|
||||
$widget_id = $_POST[$mod .'_email_widget_id'];
|
||||
$this->smarty->assign('email_widget_id',$widget_id);
|
||||
$this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']);
|
||||
|
||||
if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) {
|
||||
$primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
|
||||
}
|
||||
|
||||
while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) {
|
||||
$emails[] = $_POST[$mod . $widget_id . 'emailAddress' . $count];
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($count == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) {
|
||||
foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
|
||||
$optOut[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) {
|
||||
foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
|
||||
$invalid[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) {
|
||||
foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
|
||||
$replyTo[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) {
|
||||
foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
|
||||
$delete[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) {
|
||||
$verified[] = $_POST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count];
|
||||
$count++;
|
||||
}
|
||||
|
||||
$this->smarty->assign('emails', $emails);
|
||||
$this->smarty->assign('primary', $primary);
|
||||
$this->smarty->assign('optOut', $optOut);
|
||||
$this->smarty->assign('invalid', $invalid);
|
||||
$this->smarty->assign('replyTo', $invalid);
|
||||
$this->smarty->assign('delete', $invalid);
|
||||
$this->smarty->assign('verified', $invalid);
|
||||
$this->smarty->assign('moduleDir', $mod);
|
||||
|
||||
return $this->smarty->fetch("include/SugarEmailAddress/templates/forDuplicatesView.tpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* getFormBaseURL
|
||||
*
|
||||
*/
|
||||
function getFormBaseURL($focus) {
|
||||
$get = "";
|
||||
$count = 0;
|
||||
$mod = isset($focus) ? $focus->module_dir : "";
|
||||
|
||||
$widget_id = $_POST[$mod .'_email_widget_id'];
|
||||
$get .= '&' . $mod . '_email_widget_id='. $widget_id;
|
||||
$get .= '&emailAddressWidget='.$_POST['emailAddressWidget'];
|
||||
|
||||
while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) {
|
||||
$get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
|
||||
$count++;
|
||||
} //while
|
||||
|
||||
while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) {
|
||||
$get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
|
||||
$count++;
|
||||
} //while
|
||||
|
||||
$options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag');
|
||||
|
||||
foreach($options as $option) {
|
||||
$count = 0;
|
||||
$optionIdentifier = $mod.$widget_id.$option;
|
||||
if(isset($_REQUEST[$optionIdentifier])) {
|
||||
if(is_array($_REQUEST[$optionIdentifier])) {
|
||||
foreach($_REQUEST[$optionIdentifier] as $optOut) {
|
||||
$get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
|
||||
$count++;
|
||||
} //foreach
|
||||
} else {
|
||||
$get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
|
||||
}
|
||||
} //if
|
||||
} //foreach
|
||||
return $get;
|
||||
|
||||
}
|
||||
|
||||
function setView($view) {
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is here so the Employees/Users division can be handled cleanly in one place
|
||||
* @param object $focus SugarBean
|
||||
* @return string The value for the bean_module column in the email_addr_bean_rel table
|
||||
*/
|
||||
function getCorrectedModule(&$module) {
|
||||
return ($module == "Employees")? "Users" : $module;
|
||||
}
|
||||
} // end class def
|
||||
|
||||
|
||||
/**
|
||||
* Convenience function for MVC (Mystique)
|
||||
* @param object $focus SugarBean
|
||||
* @param string $field unused
|
||||
* @param string $value unused
|
||||
* @param string $view DetailView or EditView
|
||||
* @return string
|
||||
*/
|
||||
function getEmailAddressWidget($focus, $field, $value, $view) {
|
||||
$sea = new SugarEmailAddress();
|
||||
$sea->setView($view);
|
||||
|
||||
if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
|
||||
$module = $focus->module_dir;
|
||||
if ($view == 'ConvertLead' && $module == "Contacts") $module = "Leads";
|
||||
|
||||
return $sea->getEmailAddressWidgetEditView($focus->id, $module, false);
|
||||
}
|
||||
|
||||
return $sea->getEmailAddressWidgetDetailView($focus);
|
||||
}
|
||||
|
||||
?>
|
||||
70
include/SugarEmailAddress/templates/forDetailView.tpl
Executable file
70
include/SugarEmailAddress/templates/forDetailView.tpl
Executable file
@@ -0,0 +1,70 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
{foreach from=$emailAddresses item=address}
|
||||
<tr>
|
||||
<td style="border:none;">
|
||||
{if $address.key === 'opt_out'}
|
||||
<span style="text-decoration: line-through;">
|
||||
{elseif $address.key === 'primary'}
|
||||
<b>
|
||||
{elseif $address.key === 'reply_to' && $item.key != 0}
|
||||
<i>
|
||||
{/if}
|
||||
|
||||
{$address.address}
|
||||
|
||||
{if $address.key === 'primary'}
|
||||
</b> <i>({$app_strings.LBL_EMAIL_PRIMARY})</i>
|
||||
{elseif $address.key === 'reply_to'}
|
||||
<i>({$app_strings.LBL_EMAIL_REPLY_TO})</i>
|
||||
{elseif $address.key === 'opt_out'}
|
||||
</span> <i class='error'>({$app_strings.LBL_EMAIL_OPT_OUT})</i>
|
||||
{elseif $address.key === 'invalid'}
|
||||
<i>({$app_strings.LBL_EMAIL_INVALID})</i>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{foreachelse}
|
||||
<tr>
|
||||
<td>
|
||||
<i>{$app_strings.LBL_NONE}</i>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
62
include/SugarEmailAddress/templates/forDuplicatesView.tpl
Executable file
62
include/SugarEmailAddress/templates/forDuplicatesView.tpl
Executable file
@@ -0,0 +1,62 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
<input type="hidden" name="{$moduleDir}_email_widget_id" value="{$email_widget_id}">
|
||||
<input type="hidden" name="emailAddressWidget" value="{$emailAddressWidget}">
|
||||
{counter assign="count" start=-1 print=false}
|
||||
{foreach from=$emails item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddress{counter print=true}" value="{$email}">
|
||||
{/foreach}
|
||||
{counter assign="count" start=-1 print=false}
|
||||
{foreach from=$verified item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressVerifiedValue{counter print=true}" value="{$email}">
|
||||
{/foreach}
|
||||
{if isset($primary)}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressPrimaryFlag" value="{$primary}">
|
||||
{/if}
|
||||
{foreach from=$optOut item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressOptOutFlag[]" value="{$email}">
|
||||
{/foreach}
|
||||
{foreach from=$invalid item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressInvalidFlag[]" value="{$email}">
|
||||
{/foreach}
|
||||
{foreach from=$replyTo item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressReplyToFlag[]" value="{$email}">
|
||||
{/foreach}
|
||||
{foreach from=$delete item=email}
|
||||
<input type="hidden" name="{$moduleDir}{$email_widget_id}emailAddressDeleteFlag[]" value="{$email}">
|
||||
{/foreach}
|
||||
<input type="hidden" name="useEmailWidget" value="true">
|
||||
120
include/SugarEmailAddress/templates/forEditView.tpl
Executable file
120
include/SugarEmailAddress/templates/forEditView.tpl
Executable file
@@ -0,0 +1,120 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
{php}
|
||||
global $emailInstances;
|
||||
if (empty($emailInstances))
|
||||
$emailInstances = array();
|
||||
if (!isset($emailInstances[$this->_tpl_vars['module']]))
|
||||
$emailInstances[$this->_tpl_vars['module']] = 0;
|
||||
$this->_tpl_vars['index'] = $emailInstances[$this->_tpl_vars['module']];
|
||||
$emailInstances['module']++;
|
||||
{/php}
|
||||
<script type="text/javascript" language="javascript">
|
||||
var emailAddressWidgetLoaded = false;
|
||||
</script>
|
||||
<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>
|
||||
<script type="text/javascript">
|
||||
var module = '{$module}';
|
||||
</script>
|
||||
<table style="border-spacing: 0pt;">
|
||||
<tr>
|
||||
<td valign="top" NOWRAP>
|
||||
<table id="{$module}emailAddressesTable{$index}" class="emailaddresses">
|
||||
<tbody id="targetBody"></tbody>
|
||||
<tr>
|
||||
<td scope="row" NOWRAP>
|
||||
<input type=hidden id="{$module}_email_widget_id" name="{$module}_email_widget_id" value="">
|
||||
<input type=hidden id='emailAddressWidget' name='emailAddressWidget' value='1'>
|
||||
<span class="id-ff multiple ownline">
|
||||
<button class='button' type='button'
|
||||
onClick="javascript:SUGAR.EmailAddressWidget.instances.{$module}{$index}.addEmailAddress('{$module}emailAddressesTable{$index}','','');"
|
||||
value='{$app_strings.LBL_ADD_BUTTON}'><img src="{sugar_getimagepath file="id-ff-add.png"}"></button>
|
||||
</span>
|
||||
</td>
|
||||
<td scope="row" NOWRAP>
|
||||
|
||||
</td>
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_PRIMARY}
|
||||
</td>
|
||||
{if $useReplyTo == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_REPLY_TO}
|
||||
</td>
|
||||
{/if}
|
||||
{if $useOptOut == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_OPT_OUT}
|
||||
</td>
|
||||
{/if}
|
||||
{if $useInvalid == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_INVALID}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="useEmailWidget" value="true">
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
function init(){ldelim}
|
||||
if(emailAddressWidgetLoaded || SUGAR.EmailAddressWidget){ldelim}
|
||||
var table = YAHOO.util.Dom.get("{$module}emailAddressesTable{$index}");
|
||||
var eaw = SUGAR.EmailAddressWidget.instances.{$module}{$index} = new SUGAR.EmailAddressWidget("{$module}");
|
||||
eaw.emailView = '{$emailView}';
|
||||
eaw.emailIsRequired = "{$required}";
|
||||
var addDefaultAddress = '{$addDefaultAddress}';
|
||||
var prefillEmailAddress = '{$prefillEmailAddresses}';
|
||||
var prefillData = {$prefillData};
|
||||
if(prefillEmailAddress == 'true') {ldelim}
|
||||
eaw.prefillEmailAddresses('{$module}emailAddressesTable{$index}', prefillData);
|
||||
{rdelim} else if(addDefaultAddress == 'true') {ldelim}
|
||||
eaw.addEmailAddress('{$module}emailAddressesTable{$index}');
|
||||
{rdelim}
|
||||
if('{$module}_email_widget_id') {ldelim}
|
||||
document.getElementById('{$module}_email_widget_id').value = eaw.count;
|
||||
{rdelim}
|
||||
{rdelim}else{ldelim}
|
||||
setTimeout("init();", 500);
|
||||
{rdelim}
|
||||
{rdelim}
|
||||
|
||||
YAHOO.util.Event.onDOMReady(init);
|
||||
</script>
|
||||
104
include/SugarEmailAddress/templates/forWideFormBodyView.tpl
Executable file
104
include/SugarEmailAddress/templates/forWideFormBodyView.tpl
Executable file
@@ -0,0 +1,104 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
<tr>
|
||||
<td scope="row">{$app_strings.LBL_EMAIL_ADDRESSES}: </td>
|
||||
</tr>
|
||||
|
||||
<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>
|
||||
<script type="text/javascript">
|
||||
var module = '{$module}';
|
||||
</script>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<table style="border-spacing: 0pt;">
|
||||
<tr>
|
||||
<td valign="top" NOWRAP>
|
||||
<table cellpadding="0" cellspacing="0" border="0" id="{$module}emailAddressesTable{$index}" class="emailaddresses">
|
||||
<tbody id="targetBody"></tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<input type=hidden name='emailAddressWidget' value=1>
|
||||
<span class="id-ff multiple ownline">
|
||||
<button class='button' type='button'
|
||||
onClick="javascript:SUGAR.EmailAddressWidget.instances.{$module}{$index}.addEmailAddress('{$module}emailAddressesTable{$index}','','');"
|
||||
value='{$app_strings.LBL_ADD_BUTTON}'><img src="{sugar_getimagepath file="id-ff-add.png"}"></button>
|
||||
</span>
|
||||
</td>
|
||||
<td scope="row" NOWRAP>
|
||||
|
||||
</td>
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_PRIMARY}
|
||||
</td>
|
||||
{if $useReplyTo == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_REPLY_TO}
|
||||
</td>
|
||||
{/if}
|
||||
{if $useOptOut == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_OPT_OUT}
|
||||
</td>
|
||||
{/if}
|
||||
{if $useInvalid == true}
|
||||
<td scope="row" NOWRAP>
|
||||
{$app_strings.LBL_EMAIL_INVALID}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="useEmailWidget" value="true">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
var table = YAHOO.util.Dom.get("{$module}emailAddressesTable{$index}");
|
||||
var eaw = SUGAR.EmailAddressWidget.instances.{$module}{$index} = new SUGAR.EmailAddressWidget("{$module}");
|
||||
eaw.emailView = '{$emailView}';
|
||||
eaw.emailIsRequired = "{$required}";
|
||||
var addDefaultAddress = '{$addDefaultAddress}';
|
||||
var prefillEmailAddress = '{$prefillEmailAddresses}';
|
||||
var prefillData = {$prefillData};
|
||||
if(prefillEmailAddress == 'true') {ldelim}
|
||||
eaw.prefillEmailAddresses('{$module}emailAddressesTable{$index}', prefillData);
|
||||
{rdelim} else if(addDefaultAddress == 'true') {ldelim}
|
||||
eaw.addEmailAddress('{$module}emailAddressesTable{$index}');
|
||||
{rdelim}
|
||||
</script>
|
||||
Reference in New Issue
Block a user