Skip to content

Commit

Permalink
No blank form submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
stefancrain committed Jan 23, 2013
1 parent f667b59 commit 7afe650
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
33 changes: 15 additions & 18 deletions civicrm/custom/php/CRM/IMAP/AJAX.php
Expand Up @@ -563,14 +563,6 @@ public static function assignMessage() {
$results[] = $row;
}

// On match add email to user
// Important
$params = array(
'contact_id' => $contactId,
'email' => $fromEmail,
'version' => 3,
);

if ($debug){
echo "<h1>Contact ".$contactId." has the following emails </h1>";
var_dump($results);
Expand All @@ -590,7 +582,13 @@ public static function assignMessage() {
}
}
}


// Prams to add email to user
$params = array(
'contact_id' => $contactId,
'email' => $fromEmail,
'version' => 3,
);
if(($emailsCount-$matches) == 0){
if ($debug) echo "<p> added ".$fromEmail."</p><hr/>";
$result = civicrm_api( 'email','create',$params );
Expand Down Expand Up @@ -857,7 +855,6 @@ public static function getActivityDetails() {
'details' => $activity_node['details'],
'match_type' => $activity_node['is_auto'],
'original_id' => $activity_node['original_id'],

'date' => $date);

echo json_encode($returnMessage);
Expand Down Expand Up @@ -1066,14 +1063,14 @@ public static function createNewContact() {
//http://skelos/civicrm/imap/ajax/createNewContact?first_name=dan&last_name=pozzi&email=dpozzie@gmail.com&street_address=26%20Riverwalk%20Way&city=Cohoes&debug=true
// http://skelos/civicrm/imap/ajax/createNewContact?messageId=52&imap_id=0&first_name=Fakie&last_name=McTesterson&email_address=Test%40aol.com&phone=5185185555&street_address=1241+fake+street&street_address_2=floor+2&postal_code=12202&city=albany&debug=true

$first_name = (strtolower(self::get('first_name')) == 'first name') ? '' : self::get('first_name');
$last_name = (strtolower(self::get('last_name')) == 'last name') ? '' : self::get('last_name');
$email = (strtolower(self::get('email_address')) == 'email address') ? '' : self::get('email_address');
$phone = (strtolower(self::get('phone')) == 'phone number') ? '' : self::get('phone');
$street_address = (strtolower(self::get('street_address')) == 'street address') ? '' : self::get('street_address');
$street_address_2 = (strtolower(self::get('street_address_2')) == 'street address') ? '' : self::get('street_address_2');
$postal_code = (strtolower(self::get('postal_code')) == 'zip code') ? '' : self::get('postal_code');
$city = (strtolower(self::get('city')) == 'city') ? '' : self::get('city');
$first_name = (strtolower(self::get('first_name')) == 'first name' || trim(self::get('first_name')) =='') ? '' : self::get('first_name');
$last_name = (strtolower(self::get('last_name')) == 'last name'|| trim(self::get('last_name')) =='') ? '' : self::get('last_name');
$email = (strtolower(self::get('email_address')) == 'email address')|| trim(self::get('email_address')) =='' ? '' : self::get('email_address');
$phone = (strtolower(self::get('phone')) == 'phone number'|| trim(self::get('phone')) =='') ? '' : self::get('phone');
$street_address = (strtolower(self::get('street_address')) == 'street address'|| trim(self::get('street_address')) =='') ? '' : self::get('street_address');
$street_address_2 = (strtolower(self::get('street_address_2')) == 'street address'|| trim(self::get('street_address_2')) =='') ? '' : self::get('street_address_2');
$postal_code = (strtolower(self::get('postal_code')) == 'zip code'|| trim(self::get('postal_code')) =='') ? '' : self::get('postal_code');
$city = (strtolower(self::get('city')) == 'city'|| trim(self::get('city')) =='') ? '' : self::get('city');

if ($debug){
echo "<h1>inputs</h1>";
Expand Down
18 changes: 11 additions & 7 deletions modules/nyss_imapper/nyss_imapper.js
Expand Up @@ -123,7 +123,6 @@ cj(document).ready(function(){
cj("#find-match-popup").dialog('close');
help_message('Message assigned to contact');
}

}
});
return false;
Expand Down Expand Up @@ -207,12 +206,17 @@ cj(document).ready(function(){
contactId: contactData.contact
},
success: function(data, status) {
cj("#find-match-popup").dialog('close');
cj(".imapper-message-box[data-id='"+create_messageId+"']").remove();
help_message('Contact created and message Assigned');
var old_total = parseInt(cj("#total_number").html(),10);
help_message('Activity Deleted');
cj("#total_number").html(old_total-1);
if (data.code == 'ERROR'){
alert('failure'+data.message);
return false;
}else{
cj("#find-match-popup").dialog('close');
cj(".imapper-message-box[data-id='"+create_messageId+"']").remove();
help_message('Contact created and message Assigned');
var old_total = parseInt(cj("#total_number").html(),10);
help_message('Message Assigned');
cj("#total_number").html(old_total-1);
}
},
error: function(){
alert('failure');
Expand Down

0 comments on commit 7afe650

Please sign in to comment.