function makemeeting_pollpanel_form_submit in Make Meeting Scheduler 6
Same name and namespace in other branches
- 7 makemeeting.module \makemeeting_pollpanel_form_submit()
pollpanel_form submit function
File
- ./
makemeeting.module, line 637 - Make Meeting module
Code
function makemeeting_pollpanel_form_submit($form, &$form_state) {
$node = node_load($form_state['values']['node_id']);
if ($node->maybe_option == 1 || $node->multiple_allowed == 1) {
// we using $vote_value here
foreach ($form_state['values']['add_your_vote']['pollpanel']['alter_ids'] as $alter_id => $vote_value) {
db_query("INSERT INTO {makemeeting_poll_votes} (user_name, poll_id, answer_id, answer_value, dt) VALUES ('%s', %d, %d, %d, %d)", $form_state['values']['add_your_vote']['pollpanel']['name'], $node->nid, $alter_id, $vote_value, time());
}
}
else {
// $vote_value is 1 here -> checked is yes
foreach ($form_state['values']['add_your_vote']['pollpanel']['alter_ids'] as $alter_id) {
db_query("INSERT INTO {makemeeting_poll_votes} (user_name, poll_id, answer_id, answer_value, dt) VALUES ('%s', %d, %d, %d, %d)", $form_state['values']['add_your_vote']['pollpanel']['name'], $node->nid, $alter_id, 1, time());
}
}
// log
makemeeting_insert_log($node->nid, $form_state['values']['add_your_vote']['pollpanel']['name']);
// send notification email
if ($node->email_notification == 1) {
// if anonym and has valid email address
if ($node->uid == 0) {
if (valid_email_address($node->user_email)) {
$params = array(
'name' => $node->user_name == "" ? t("user") : $node->user_name,
'poll_url' => $node->poll_url,
);
drupal_mail('makemeeting', 'new_vote', $node->user_mail, language_default(), $params);
}
}
else {
// if registered and has valid email address
$account = user_load(array(
"uid" => $node->uid,
));
if (valid_email_address($account->mail)) {
$params = array(
'name' => $account->name,
'poll_url' => $node->poll_url,
);
drupal_mail('makemeeting', 'new_vote', $account->mail, user_preferred_language($account), $params);
}
}
}
drupal_set_message(t("Succesfull."));
return;
}