function create_custom_activity_types($domain_id = 1) {
db_set_active('civicrm');
$activity_type_group_id = db_result(db_query("SELECT id FROM civicrm_option_group WHERE domain_id = %d AND name = 'activity_type'", $domain_id));
$activity_type_value = db_result(db_query('SELECT MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = %d', $activity_type_group_id));
$activity_type_value ++;
$activity_type_weight = db_result(db_query('SELECT MAX(weight) FROM civicrm_option_value WHERE option_group_id = %d', $activity_type_group_id));
$activity_type_weight ++;
$result = db_query('SELECT DISTINCT activity_type FROM civicrm_activity_history WHERE activity_type IS NOT NULL');
while ($activity = db_fetch_object($result)) {
db_query("INSERT INTO civicrm_option_value (option_group_id, label, value, name, grouping, filter, is_default, weight, description, is_optgroup, is_reserved, is_active)
VALUES ($activity_type_group_id, '$activity->activity_type', '$activity_type_value', '$activity->activity_type', NULL, 1, NULL, $activity_type_weight, '$activity->activity_type', 0, 1, 1);");
$activity_type_value ++;
$activity_type_weight ++;
}
db_set_active();
}
Earlier versions used the label "Email Sent" in this table. The upgrade script expects this to be "Email" and reports this to be 3rd party data. The following mysql statement prepared those records for input without an error message: