You are here

function sms_sendtophone_form in SMS Framework 7

Same name and namespace in other branches
  1. 5 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_form()
  2. 6.2 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_form()
  3. 6 modules/sms_sendtophone/sms_sendtophone.module \sms_sendtophone_form()

Form constructor for sms_sendtophone_form.

Parameters

string $type: The type of form to be displayed - 'cck', 'inline' or 'node'.

See also

sms_sendtophone_form_validate()

sms_sendtophone_form_submit()

1 string reference to 'sms_sendtophone_form'
sms_sendtophone_page in modules/sms_sendtophone/sms_sendtophone.module
Menu callback: displays the Send To Phone confirmation form for content.

File

modules/sms_sendtophone/sms_sendtophone.module, line 373
Provides various tools for sending bits of information via SMS.

Code

function sms_sendtophone_form($form, $form_state, $type) {
  global $user;
  switch ($type) {
    case 'cck':
    case 'field':
    case 'inline':
      $form['message'] = array(
        '#type' => 'value',
        '#value' => $_GET['text'],
      );
      $form['message_preview'] = array(
        '#type' => 'item',
        '#markup' => '<p class="message-preview">' . check_plain($_GET['text']) . '</p>',
        '#title' => t('Message preview'),
      );
      break;
    case 'node':
      if (is_numeric(arg(3))) {
        $node = node_load(arg(3));
        $form['message_display'] = array(
          '#type' => 'textarea',
          '#title' => t('Message preview'),
          '#description' => t('This URL will be sent to the phone.'),
          '#cols' => 35,
          '#rows' => 2,
          '#attributes' => array(
            'disabled' => TRUE,
          ),
          '#default_value' => url('node/' . $node->nid, array(
            'absolute' => TRUE,
          )),
        );
        $form['message'] = array(
          '#type' => 'value',
          '#value' => url('node/' . $node->nid, array(
            'absolute' => TRUE,
          )),
        );
      }
      break;
  }
  $form = array_merge(sms_send_form(), $form);
  if (!empty($user->sms_user)) {
    $form['number']['#default_value'] = $user->sms_user['number'];
    if (is_array($user->sms_user['gateway'])) {
      foreach ($user->sms_user['gateway'] as $option => $value) {
        $form['gateway'][$option]['#default_value'] = $value;
      }
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
    '#weight' => 20,
  );

  // Add css.
  drupal_add_css(drupal_get_path('module', 'sms_sendtophone') . '/sms_sendtophone.css');
  return $form;
}