function sharethis_form_submit in ShareThis 7
This is the submit function for sharethis_form
File
- ./
sharethis.module, line 164 - A module that adds one of the ShareThis widget to your website.
Code
function sharethis_form_submit($form, &$form_state) {
// Record the widget option.
if (isset($form_state['input']['widget_option'])) {
$record = (object) NULL;
$record->st_option = "widget";
$record->st_value = $form_state['input']['widget_option'];
drupal_write_record('st_table', $record, 'st_option');
}
// Record the buttons option.
if (isset($form_state['input']['button_option'])) {
$record = (object) NULL;
$record->st_option = "buttons";
$record->st_value = $form_state['input']['button_option'];
drupal_write_record('st_table', $record, 'st_option');
}
// Record the services option.
if (isset($form_state['input']['service_option'])) {
$record = (object) NULL;
$record->st_option = "services";
$sanitized = $form_state['input']['service_option'];
$sanitized = str_replace(";", "", $sanitized);
$sanitized = str_replace("\\", "", $sanitized);
$sanitized = str_replace("/", "", $sanitized);
$sanitized = str_replace("(", "", $sanitized);
$sanitized = str_replace(")", "", $sanitized);
$record->st_value = $sanitized;
drupal_write_record('st_table', $record, 'st_option');
}
// Record the NodeType option.
if (isset($form_state['input']['node_option'])) {
$record = (object) NULL;
$record->st_option = "nodeType";
$node_string = "";
foreach ($form_state['input']['node_option'] as $k => $v) {
$node_string .= $v . ",";
}
$record->st_value = substr($node_string, 0, -1);
drupal_write_record('st_table', $record, 'st_option');
}
// Record the teaser option.
if (isset($form_state['input']['teaser_option'])) {
$record = (object) NULL;
$record->st_option = "viewMode";
$record->st_value = $form_state['input']['teaser_option'];
drupal_write_record('st_table', $record, 'st_option');
}
else {
$record = (object) NULL;
$record->st_option = "viewMode";
$record->st_value = "0";
drupal_write_record('st_table', $record, 'st_option');
}
// Record the publisher ID option. Since it's a text field, remove anything that resembles code
if (isset($form_state['input']['publisherID'])) {
$record = (object) NULL;
$record->st_option = "publisherID";
$sanitized = $form_state['input']['publisherID'];
$sanitized = str_replace(";", "", $sanitized);
$sanitized = str_replace(":", "", $sanitized);
$sanitized = str_replace("\\", "", $sanitized);
$sanitized = str_replace("/", "", $sanitized);
$sanitized = str_replace("(", "", $sanitized);
$sanitized = str_replace(")", "", $sanitized);
$record->st_value = $sanitized;
drupal_write_record('st_table', $record, 'st_option');
}
drupal_set_message(t("Thank you! Your preferences have been saved."));
}