function node_makemeeting_form in Make Meeting Scheduler 6
Same name and namespace in other branches
- 7 makemeeting.module \node_makemeeting_form()
Implements node_form().
File
- ./
makemeeting.module, line 285 - Make Meeting module
Code
function node_makemeeting_form(&$node) {
global $user;
$type = node_get_types('type', $node);
if ($type->has_title) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
}
if ($type->has_body) {
$form['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#rows' => 5,
);
}
if (isset($node->nid) && $node->uid == 0 || $user->uid == 0) {
$form['anonym'] = array(
'#type' => 'fieldset',
'#title' => t('Add your name and email'),
'#tree' => TRUE,
);
$form['anonym']['user_name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
'#maxlength' => 100,
'#description' => t('This is optional.'),
);
$form['anonym']['user_email'] = array(
'#type' => 'textfield',
'#title' => t('Your e-mail'),
'#description' => t('This is optional, too. But if you add, we can send e-mail notification after every valid vote.'),
'#maxlength' => 100,
);
}
// transform the days_and_options array to the structure required by the theme funcion
if (is_array($node->days_and_options)) {
$attributes = array();
$i = 1;
foreach ($node->days_and_options as $days => $options_array) {
$start_day = strpos($days, "_");
$day_str = substr($days, $start_day + 1);
$day_id = substr($days, 0, $start_day);
$attributes['date_' . $i] = $day_str;
foreach ($options_array as $k => $option) {
$start_option = strpos($option, "_");
$option_id = substr($option, 0, $start_option);
$option_str = substr($option, $start_option + 1);
$attributes['option_' . $i][] = $option_str;
}
$i++;
}
}
else {
// initializing data for dates and options (options are empty)
$attributes = array(
'date_1' => date("Y-m-d"),
'option_1' => array(
"",
"",
),
);
}
$form['calendar'] = array(
'#type' => 'makemeeting_calendarselector',
'#title' => t('Calendar test'),
'#description' => t('Use the calendar above to select the days, then add the options for the days. For example select the day of tomorrow and add "AM", "PM" as options. You can use only upcoming days.'),
'#default_value' => $attributes,
'#attributes' => array(
'selected_dates_and_options' => $attributes,
),
);
$form['poll_options'] = array(
'#type' => 'fieldset',
'#title' => t('Scheduler options'),
'#tree' => TRUE,
);
$form['poll_options']['secure'] = array(
'#type' => 'radios',
'#title' => t('Show previous votes'),
'#description' => t("Deny new voters to see the previous votes."),
'#options' => array(
'0' => t('Yes'),
'1' => t('No'),
),
'#default_value' => isset($node->secure) ? $node->secure : 0,
);
$form['poll_options']['maybe_option'] = array(
'#type' => 'radios',
'#title' => t('Maybe option'),
'#description' => t("Voters can select maybe as answer too."),
'#options' => array(
'0' => t('Disabled'),
'1' => t('Enabled'),
),
'#default_value' => isset($node->maybe_option) ? $node->maybe_option : 0,
);
$form['poll_options']['multiple_allowed'] = array(
'#type' => 'radios',
'#title' => t('Multiple option is selectable per answers.'),
'#options' => array(
'0' => t('Disabled'),
'1' => t('Enabled'),
),
'#default_value' => isset($node->multiple_allowed) ? $node->multiple_allowed : 0,
);
$form['email'] = array(
'#type' => 'fieldset',
'#title' => t('E-mail notification'),
);
$form['email']['email_notification'] = array(
'#type' => 'radios',
'#title' => t('Send me an e-mail after every valid vote'),
'#options' => array(
'1' => t('Yes'),
'0' => t('No'),
),
'#default_value' => isset($node->email_notification) ? $node->email_notification : 1,
);
return $form;
}