You are here

function makemeeting_simplepoll_update_poll in Make Meeting Scheduler 6

makemeeting_simplepoll_update_poll()

The following two functions are the custom update form, we using this instead of node_update() hook, because we can't use the node/%d/edit page, only the makemeeting/admin_string url

Parameters

mixed $form_state:

mixed $node:

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

File

./makemeeting_simplepoll.module, line 607
Make Meeting Simple Poll module

Code

function makemeeting_simplepoll_update_poll(&$form_state, $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,
      '#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,
    );
  }
  $form['ans'] = array(
    '#type' => 'fieldset',
    '#title' => t('Answers'),
    '#tree' => TRUE,
    '#description' => t('You can add extra field with the link at the bottom of the form fields.'),
  );
  $form['ans']['answers'] = array(
    '#type' => 'makemeeting_simplepoll_form',
    '#title' => t('Poll answers'),
    '#attributes' => array(
      'answers' => $node->answers,
    ),
  );
  $form['poll_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Poll 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']['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;
}