You are here

function nopremium_form_alter in Node Option Premium 6

Same name and namespace in other branches
  1. 8 nopremium.module \nopremium_form_alter()

Implementation of hook_form_alter().

File

./nopremium.module, line 142
Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Code

function nopremium_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']->type) && $form['#node']->type . '_node_form' == $form_id) {
    $form['options']['premium'] = array(
      '#type' => 'checkbox',
      '#title' => t('Premium content'),
      '#default_value' => $form['#node']->premium,
    );

    // Allow or not to override the premium option.
    // See http://drupal.org/project/override_node_options
    if (!user_access('administer nodes') && user_access('override ' . $form['#node']->type . ' premium option')) {
      foreach (element_children($form['options']) as $key) {
        if (!isset($form['options'][$key]['#access'])) {
          $form['options'][$key]['#access'] = FALSE;
        }
        $form['options']['#access'] = $form['options']['premium']['#access'] = TRUE;
      }
    }
  }
}