Skip to content

Commit

Permalink
add support for contact image
Browse files Browse the repository at this point in the history
  • Loading branch information
mecachisenros committed Oct 14, 2018
1 parent d7fec86 commit 057102f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/class-civicrm-caldera-forms-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CiviCRM_Caldera_Forms_Helper {
* @access public
* @var aray $contact_fields The contact fields
*/
public $contact_fields = [ 'prefix_id', 'first_name', 'last_name', 'middle_name', 'suffix_id', 'is_opt_out', 'nick_name', 'source', 'formal_title', 'job_title', 'gender_id', 'birth_date', 'email', 'current_employer', 'do_not_phone', 'do_not_email', 'do_not_mail', 'do_not_sms', 'do_not_trade', 'legal_identifier', 'legal_name', 'preferred_communication_method', 'preferred_language', 'preferred_mail_format', 'communication_style_id', 'household_name', 'organization_name', 'sic_code' ];
public $contact_fields = [ 'prefix_id', 'first_name', 'last_name', 'middle_name', 'suffix_id', 'is_opt_out', 'nick_name', 'source', 'formal_title', 'job_title', 'gender_id', 'birth_date', 'email', 'current_employer', 'do_not_phone', 'do_not_email', 'do_not_mail', 'do_not_sms', 'do_not_trade', 'legal_identifier', 'legal_name', 'preferred_communication_method', 'preferred_language', 'preferred_mail_format', 'communication_style_id', 'household_name', 'organization_name', 'sic_code', 'image_URL' ];

/**
* Activity fields.
Expand Down
12 changes: 12 additions & 0 deletions processors/contact/class-contact-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ public function pre_processor( $config, $form, $processid ) {
}
}

// handle contact image url
if ( ! empty( $config['civicrm_contact']['image_URL'] ) && ! empty( $form_values['civicrm_contact']['image_URL'] ) ) {
try {
$file = civicrm_api3( 'File', 'getsingle', [ 'id' => $form_values['civicrm_contact']['image_URL'] ] );
} catch ( CiviCRM_API3_Exception $e ) {

}

if ( is_array( $file ) && ! $file['is_error'] )
$form_values['civicrm_contact']['image_URL'] = CRM_Utils_System::url( 'civicrm/contact/imagefile', ['photo' => $file['uri']], true );
}

try {
$create_contact = civicrm_api3( 'Contact', 'create', $form_values['civicrm_contact'] );
} catch ( CiviCRM_API3_Exception $e ) {
Expand Down
2 changes: 1 addition & 1 deletion processors/contact/contact_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<div class="caldera-config-field">
<select class="block-input field-config required" name="{{_name}}[civicrm_contact][dedupe_rule]">
<option value="" {{#is dedupe_rule value=""}}selected="selected"{{/is}}></option>
<?php foreach( CiviCRM_Caldera_Forms_Helper::get_dedupe_rules() as $type => $rule ) {
<?php foreach( caldera_forms_civicrm()->helper->get_dedupe_rules() as $type => $rule ) {
foreach ( $rule as $key => $value ) { ?>
<option value="<?php echo esc_attr( $key ); ?>" data-crm-type="<?php echo esc_attr( $type ); ?>" {{#is civicrm_contact/dedupe_rule value=<?php echo $key; ?>}}selected="selected"{{/is}}><?php echo esc_html( "[{$type}] - {$value}" ); ?></option>
<?php } } ?>
Expand Down

0 comments on commit 057102f

Please sign in to comment.