function makemeeting_simplepoll_pollpanel_form_submit in Make Meeting Scheduler 6
makemeeting_simplepoll_pollpanel_form_submit()
Making the vote
_state
Parameters
mixed $form:
File
- ./
makemeeting_simplepoll.module, line 552 - Make Meeting Simple Poll module
Code
function makemeeting_simplepoll_pollpanel_form_submit($form, &$form_state) {
$node = node_load($form_state['values']['node_id']);
// submit the vote (or votes, if multiple answers are allowed)
foreach ($form_state['values']['add_your_vote']['pollpanel']['vote'] as $k => $v) {
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, $k, 1, time());
}
// log
makemeeting_insert_log($node->nid, $form['#post']['your_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_email, 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;
}