function makemeeting_pollpanel_form_submit in Make Meeting Scheduler 7
Same name and namespace in other branches
- 6 makemeeting.module \makemeeting_pollpanel_form_submit()
pollpanel_form submit function
File
- ./
makemeeting.module, line 731 - Make Meeting module
Code
function makemeeting_pollpanel_form_submit($form, &$form_state) {
$node = node_load($form_state['values']['node_id']);
$values = array(
'user_name' => $form_state['values']['add_your_vote']['pollpanel']['name'],
'poll_id' => $node->nid,
'dt' => REQUEST_TIME,
);
if ($node->maybe_option == 1 || $node->multiple_allowed == 1) {
// We are using $vote_value here
foreach ($form_state['values']['add_your_vote']['pollpanel']['alter_ids'] as $alter_id => $vote_value) {
$values['answer_id'] = $alter_id;
$values['answer_value'] = $vote_value;
db_insert('makemeeting_poll_votes')
->fields($values)
->execute();
}
}
else {
// $vote_value is 1 here -> checked is yes
$values['answer_value'] = 1;
foreach ($form_state['values']['add_your_vote']['pollpanel']['alter_ids'] as $alter_id) {
$values['answer_id'] = $alter_id;
db_insert('makemeeting_poll_votes')
->fields($values)
->execute();
}
}
// 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($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;
}