premium.inc in Node import 5
File
supported/premium.inc
View source
<?php
function premium_node_import_fields($type) {
if (user_access('administer nodes')) {
return array(
'premium' => t('Premium: Access restricted for non-premium users'),
);
}
}
function premium_node_import_prepare(&$node, $preview = FALSE) {
$errors = array();
$premium = in_array('premium', (array) variable_get('node_options_' . $node->type, array())) ? 1 : 0;
if (isset($node->node_import_premium)) {
$premium = $node->node_import_premium;
unset($node->node_import_premium);
}
if (isset($node->premium) && strlen($node->premium) > 0) {
$premium = $node->premium ? 1 : 0;
}
$node->premium = $premium;
return $errors;
}
function premium_node_import_global($type, $global_values) {
if (user_access('administer nodes')) {
if (!isset($global_values['node_import_premium'])) {
$defaults = variable_get('node_options_' . $type, array());
$premium = in_array('premium', $defaults) ? 1 : 0;
}
else {
$premium = $global_values['node_import_premium'];
}
$form = array();
$form['node_import_premium'] = array(
'#type' => 'checkbox',
'#default_value' => $premium,
'#title' => t('Access restricted for non-premium users'),
);
return $form;
}
}