function webform_civicrm_update_6101 in Webform CiviCRM Integration 6
Same name and namespace in other branches
- 6.2 webform_civicrm.install \webform_civicrm_update_6101()
- 7.5 webform_civicrm.install \webform_civicrm_update_6101()
- 7 webform_civicrm.install \webform_civicrm_update_6101()
- 7.2 webform_civicrm.install \webform_civicrm_update_6101()
- 7.3 webform_civicrm.install \webform_civicrm_update_6101()
- 7.4 webform_civicrm.install \webform_civicrm_update_6101()
Add missing activity targets.
File
- ./
webform_civicrm.install, line 133 - Webform CiviCRM module's install and uninstall code.
Code
function webform_civicrm_update_6101() {
civicrm_initialize();
$db = db_query('SELECT * FROM {webform_civicrm_submissions} WHERE contact_id <> 0 AND activity_id <> 0');
$sql = 'INSERT INTO civicrm_activity_target (activity_id, target_contact_id) VALUES (%1,%2)';
$n = 1;
$c = 0;
$params = array();
while ($row = db_fetch_array($db)) {
$params[$n] = array(
$row['activity_id'],
'Integer',
);
$params[$n + 1] = array(
$row['contact_id'],
'Integer',
);
if ($n > 1) {
$sql .= ',(%' . $n . ',%' . ($n + 1) . ')';
}
$n += 2;
++$c;
}
if ($n > 1) {
CRM_Core_DAO::executeQuery($sql, $params);
}
$ret = array(
array(
'success' => TRUE,
'query' => t('@num activity target contacts added.', array(
'@num' => $c,
)),
),
);
return $ret;
}