You are here

function makemeeting_update_poll in Make Meeting Scheduler 6

Same name and namespace in other branches
  1. 7 makemeeting.module \makemeeting_update_poll()

makemeeting_update_poll()

1 string reference to 'makemeeting_update_poll'
makemeeting_show_pollpage in ./makemeeting.pages.inc
Show the poll pages - scheduler and regular poll

File

./makemeeting.module, line 770
Make Meeting module

Code

function makemeeting_update_poll(&$form_state, $node) {
  $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_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    $form['body'] = array(
      '#type' => 'textarea',
      '#title' => check_plain($type->body_label),
      '#default_value' => $node->body,
      '#rows' => 5,
    );
  }
  if (isset($node->nid) && $node->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,
      '#default_value' => check_plain($node->anonym_name),
      '#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.'),
      '#default_value' => check_plain($node->anonym_email),
      '#maxlength' => 100,
    );
  }

  // translate the collected db datas into node data
  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 {
    $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.'),
    '#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 : 0,
  );
  $form['poll_admin_url'] = array(
    '#type' => 'value',
    '#value' => $node->poll_admin_url,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}