function nopremium_form_node_form_alter in Node Option Premium 7
Implementation of hook_form_BASE_FORM_ID_alter().
File
- ./
nopremium.module, line 154 - Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr
Code
function nopremium_form_node_form_alter(&$form, &$form_state, $form_id) {
$node = $form_state['node'];
$form['options']['premium'] = array(
'#type' => 'checkbox',
'#title' => t('Premium content'),
'#default_value' => $node->premium,
);
// Allow or not to override the premium option.
// See http://drupal.org/project/override_node_options
if (!user_access('administer nodes')) {
if (user_access('override premium option of any content type') || user_access('override ' . $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;
}
else {
$form['options']['premium']['#access'] = FALSE;
}
}
}