#46549, more robust node_submit, patch by chx

4.7.x
Gerhard Killesreiter 2006-04-20 16:38:22 +00:00
parent b354396b69
commit 45785f9610
2 changed files with 12 additions and 10 deletions

View File

@ -1488,7 +1488,8 @@ function node_submit($node) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : ''; $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. // Populate the "authored by" field.
if ($account = user_load(array('name' => $node->name))) { if ($account = user_load(array('name' => $node->name))) {
$node->uid = $account->uid; $node->uid = $account->uid;
@ -1499,10 +1500,10 @@ function node_submit($node) {
$node->created = $node->date ? strtotime($node->date) : NULL; $node->created = $node->date ? strtotime($node->date) : NULL;
} }
else { // Force defaults in case people modify the form:
// Force defaults in case people modify the form: $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) { if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options); $node->$key = in_array($key, $node_options);
} }
} }

View File

@ -1488,7 +1488,8 @@ function node_submit($node) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : ''; $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. // Populate the "authored by" field.
if ($account = user_load(array('name' => $node->name))) { if ($account = user_load(array('name' => $node->name))) {
$node->uid = $account->uid; $node->uid = $account->uid;
@ -1499,10 +1500,10 @@ function node_submit($node) {
$node->created = $node->date ? strtotime($node->date) : NULL; $node->created = $node->date ? strtotime($node->date) : NULL;
} }
else { // Force defaults in case people modify the form:
// Force defaults in case people modify the form: $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) { if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options); $node->$key = in_array($key, $node_options);
} }
} }