Created
May 5, 2014 04:48
-
-
Save xurizaemon/11528943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 86c913f1f0bb9ccf2a36938778675e29976459da | |
Author: Torrance <torrance@fuzion.co.nz> | |
Date: Wed Feb 20 13:08:50 2013 +1300 | |
Ensure drupal_write_record sets NULL values for contact_b when it is empty. | |
diff --git a/civicrm_relationship_og.module b/civicrm_relationship_og.module | |
index f495317..4921119 100644 | |
--- a/civicrm_relationship_og.module | |
+++ b/civicrm_relationship_og.module | |
@@ -197,17 +197,20 @@ function civicrm_relationship_og_settings_form_validate($form, &$form_state) { | |
} | |
function civicrm_relationship_og_settings_form_submit($form, &$form_state) { | |
- // If contact_b is empty, we want to insert a NULL value into the field. | |
- $contact_b = empty($form_state['values']['contact_b']) ? NULL : (int) $form_state['values']['contact_b']; | |
- | |
$record = array( | |
'gid' => (int) $form_state['values']['group'], | |
'relationship_id' => (int) $form_state['values']['relationship'], | |
- 'contact_b' => $contact_b, | |
); | |
+ | |
+ // If contact_b is empty, omit it so that we default to a NULL record in the database field. | |
+ $contact_b = (int) $form_state['values']['contact_b']; | |
+ if (!empty($contact_b)) { | |
+ $record['contact_b'] = $contact_b; | |
+ } | |
+ | |
try { | |
drupal_write_record('og_civicrm_relationship', $record); | |
- _civicrm_relationship_og_populate_group($record['gid'], $record['relationship_id'], $record['contact_b']); | |
+ _civicrm_relationship_og_populate_group($record['gid'], $record['relationship_id'], $contact_b); | |
} | |
catch (PDOException $e) { | |
# Do nothing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment