#46549, more robust node_submit, patch by chx
parent
b354396b69
commit
45785f9610
|
@ -1488,7 +1488,8 @@ function node_submit($node) {
|
|||
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
|
||||
}
|
||||
|
||||
if (user_access('administer nodes')) {
|
||||
$access = user_access('administer nodes');
|
||||
if ($access) {
|
||||
// Populate the "authored by" field.
|
||||
if ($account = user_load(array('name' => $node->name))) {
|
||||
$node->uid = $account->uid;
|
||||
|
@ -1499,10 +1500,10 @@ function node_submit($node) {
|
|||
|
||||
$node->created = $node->date ? strtotime($node->date) : NULL;
|
||||
}
|
||||
else {
|
||||
// Force defaults in case people modify the form:
|
||||
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
|
||||
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
|
||||
// Force defaults in case people modify the form:
|
||||
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
|
||||
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
|
||||
if (!$access || !isset($node->$key)) {
|
||||
$node->$key = in_array($key, $node_options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1488,7 +1488,8 @@ function node_submit($node) {
|
|||
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
|
||||
}
|
||||
|
||||
if (user_access('administer nodes')) {
|
||||
$access = user_access('administer nodes');
|
||||
if ($access) {
|
||||
// Populate the "authored by" field.
|
||||
if ($account = user_load(array('name' => $node->name))) {
|
||||
$node->uid = $account->uid;
|
||||
|
@ -1499,10 +1500,10 @@ function node_submit($node) {
|
|||
|
||||
$node->created = $node->date ? strtotime($node->date) : NULL;
|
||||
}
|
||||
else {
|
||||
// Force defaults in case people modify the form:
|
||||
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
|
||||
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
|
||||
// Force defaults in case people modify the form:
|
||||
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
|
||||
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
|
||||
if (!$access || !isset($node->$key)) {
|
||||
$node->$key = in_array($key, $node_options);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue