You are here

function _vkxp_process_node_form in VK CrossPoster 7.2

Same name and namespace in other branches
  1. 6.3 vkxp.forms.inc \_vkxp_process_node_form()
  2. 6 vkxp.module \_vkxp_process_node_form()
  3. 6.2 vkxp.module \_vkxp_process_node_form()
  4. 7 vkxp.module \_vkxp_process_node_form()

Add vkxp fieldset to node add/edit form.

Parameters

$form: Node add/edit form.

1 call to _vkxp_process_node_form()
vkxp_form_node_form_alter in ./vkxp.module
Implements hook_form_FORM_ID_alter(). Alters node add/edit form.

File

./vkxp.forms.inc, line 195
vkxp.forms.inc Contains node form alters.

Code

function _vkxp_process_node_form(&$form) {
  $form['vkxp'] = array(
    '#type' => 'fieldset',
    '#title' => t('VKontakte CrossPoster'),
    '#group' => 'additional_settings',
    '#weight' => -10,
  );
  $vkxp_node_enabled_default_checkbox = variable_get('vkxp_node_enabled_default_' . $form['#node']->type);
  $vkxp_node_prevent_doublepost = variable_get('vkxp_node_enabled_prevent_double_post_' . $form['#node']->type);

  // If default checkbox for node is enabled but prevent variable is false and this post
  // has already pushed to VK, making checkbox unchecked.
  if ($vkxp_node_enabled_default_checkbox) {
    if ($vkxp_node_prevent_doublepost) {
      $post_this_node = empty($form['#node']->vkxp_sent);
    }
    else {
      $post_this_node = TRUE;
    }
  }
  else {
    $post_this_node = FALSE;
  }
  $form['vkxp']['vkxp_post_this_node'] = array(
    '#type' => 'checkbox',
    '#title' => t('Post this node to VK'),
    '#default_value' => $post_this_node,
    '#description' => t('After you submit this node it will be posted to VK.'),
  );

  // Disable crosspost if cURL library is not installed on a server.
  if (!function_exists('curl_init')) {
    $form['vkxp']['vkxp_post_this_node']['#disabled'] = TRUE;
    $form['vkxp']['vkxp_post_this_node']['#value'] = 0;
    $form['vkxp']['vkxp_post_this_node']['#description'] = t("You can't crosspost nodes until cURL library is not installed on your server.");
  }

  // Disable crosspost if no access token recieved.
  if (!variable_get('vkxp_access_token')) {
    $form['vkxp']['vkxp_post_this_node']['#disabled'] = TRUE;
    $form['vkxp']['vkxp_post_this_node']['#value'] = 0;
    $form['vkxp']['vkxp_post_this_node']['#description'] = t("You can't crosspost nodes until access token not recieved from VK.");
  }
}