- Modified patch #14170 by Neil: improved default workflow (default node type) configuration page.

Modified the patch to remove some redundant code, to translate strings, and to better use the menu system.
4.6.x
Dries Buytaert 2005-01-24 21:20:16 +00:00
parent cdc4ca816d
commit 173f528f59
10 changed files with 144 additions and 120 deletions

View File

@ -94,7 +94,8 @@ $sql_updates = array(
"2005-01-07" => "update_115", "2005-01-07" => "update_115",
"2005-01-14" => "update_116", "2005-01-14" => "update_116",
"2005-01-18" => "update_117", "2005-01-18" => "update_117",
"2005-01-19" => "update_118" "2005-01-19" => "update_118",
"2005-01-20" => "update_119"
); );
function update_32() { function update_32() {
@ -2110,6 +2111,37 @@ function update_118() {
return $ret; return $ret;
} }
function update_119() {
$ret = array();
foreach (node_list() as $type) {
$node_options = array();
if (variable_get('node_status_'. $type, 1)) {
$node_options[] = 'status';
}
if (variable_get('node_moderate_'. $type, 0)) {
$node_options[] = 'moderate';
}
if (variable_get('node_promote_'. $type, 1)) {
$node_options[] = 'promote';
}
if (variable_get('node_sticky_'. $type, 0)) {
$node_options[] = 'sticky';
}
if (variable_get('node_revision_'. $type, 0)) {
$node_options[] = 'revision';
}
variable_set('node_options_'. $type, $node_options);
variable_del('node_status_'. $type);
variable_del('node_moderate_'. $type);
variable_del('node_promote_'. $type);
variable_del('node_sticky_'. $type);
variable_del('node_revision_'. $type);
}
return $ret;
}
function update_sql($sql) { function update_sql($sql) {
$edit = $_POST["edit"]; $edit = $_POST["edit"];
$result = db_query($sql); $result = db_query($sql);

View File

@ -133,7 +133,7 @@ function file_check_upload($source) {
} }
} }
elseif ($_FILES["edit"]["name"][$source] && is_uploaded_file($_FILES["edit"]["tmp_name"][$source])) { elseif ($_FILES["edit"]["name"][$source] && is_uploaded_file($_FILES["edit"]["tmp_name"][$source])) {
$file = new stdClass(); $file = new StdClass();
$file->filename = trim(basename($_FILES["edit"]["name"][$source]), '.'); $file->filename = trim(basename($_FILES["edit"]["name"][$source]), '.');
$file->filemime = $_FILES["edit"]["type"][$source]; $file->filemime = $_FILES["edit"]["type"][$source];
$file->filepath = $_FILES["edit"]["tmp_name"][$source]; $file->filepath = $_FILES["edit"]["tmp_name"][$source];

View File

@ -232,10 +232,11 @@ function comment_link($type, $node = 0, $main = 0) {
function comment_nodeapi(&$node, $op, $arg = 0) { function comment_nodeapi(&$node, $op, $arg = 0) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('comment')] = form_select('', "comment_$node->type", variable_get("comment_$node->type", 2), array(t('Disabled'), t('Read only'), t('Read/Write'))); return form_radios(t('Default comment setting'), 'comment_'. $node->type, variable_get('comment_'. $node->type, 2), array(t('Disabled'), t('Read only'), t('Read/Write')), t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
return $output;
case 'fields': case 'fields':
return array('comment'); return array('comment');
case 'form admin': case 'form admin':
if (user_access('administer comments')) { if (user_access('administer comments')) {
$selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2); $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2);
@ -243,6 +244,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
return form_group(t('User comments'), $output); return form_group(t('User comments'), $output);
} }
break; break;
case 'load': case 'load':
return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, last_comment_name, comment_count, cid as last_comment_cid FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, last_comment_name, comment_count, cid as last_comment_cid FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
case 'validate': case 'validate':
@ -251,9 +253,11 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$node->comment = variable_get("comment_$node->type", 2); $node->comment = variable_get("comment_$node->type", 2);
} }
break; break;
case 'insert': case 'insert':
db_query('INSERT INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, 0, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid); db_query('INSERT INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, 0, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid);
break; break;
case 'update': case 'update':
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid); db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid);
break; break;
@ -261,6 +265,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
break; break;
case 'update index': case 'update index':
$text = ''; $text = '';
$comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = 0', $node->nid); $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = 0', $node->nid);
@ -268,6 +273,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$text .= '<h2>'. $comment->subject .'</h2>'. check_output($comment->comment, $comment->format); $text .= '<h2>'. $comment->subject .'</h2>'. check_output($comment->comment, $comment->format);
} }
return $text; return $text;
case 'search result': case 'search result':
$comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid));
return format_plural($comments, '1 comment', '%count comments'); return format_plural($comments, '1 comment', '%count comments');

View File

@ -232,10 +232,11 @@ function comment_link($type, $node = 0, $main = 0) {
function comment_nodeapi(&$node, $op, $arg = 0) { function comment_nodeapi(&$node, $op, $arg = 0) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('comment')] = form_select('', "comment_$node->type", variable_get("comment_$node->type", 2), array(t('Disabled'), t('Read only'), t('Read/Write'))); return form_radios(t('Default comment setting'), 'comment_'. $node->type, variable_get('comment_'. $node->type, 2), array(t('Disabled'), t('Read only'), t('Read/Write')), t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
return $output;
case 'fields': case 'fields':
return array('comment'); return array('comment');
case 'form admin': case 'form admin':
if (user_access('administer comments')) { if (user_access('administer comments')) {
$selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2); $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2);
@ -243,6 +244,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
return form_group(t('User comments'), $output); return form_group(t('User comments'), $output);
} }
break; break;
case 'load': case 'load':
return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, last_comment_name, comment_count, cid as last_comment_cid FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, last_comment_name, comment_count, cid as last_comment_cid FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
case 'validate': case 'validate':
@ -251,9 +253,11 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$node->comment = variable_get("comment_$node->type", 2); $node->comment = variable_get("comment_$node->type", 2);
} }
break; break;
case 'insert': case 'insert':
db_query('INSERT INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, 0, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid); db_query('INSERT INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, 0, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid);
break; break;
case 'update': case 'update':
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid); db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid);
break; break;
@ -261,6 +265,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
break; break;
case 'update index': case 'update index':
$text = ''; $text = '';
$comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = 0', $node->nid); $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = 0', $node->nid);
@ -268,6 +273,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$text .= '<h2>'. $comment->subject .'</h2>'. check_output($comment->comment, $comment->format); $text .= '<h2>'. $comment->subject .'</h2>'. check_output($comment->comment, $comment->format);
} }
return $text; return $text;
case 'search result': case 'search result':
$comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid));
return format_plural($comments, '1 comment', '%count comments'); return format_plural($comments, '1 comment', '%count comments');

View File

@ -48,8 +48,6 @@ function node_help($section) {
return t('<p>Below is a list of all of the posts on your site. Other forms of content are listed elsewhere (e.g. <a href="%comments">comments</a>).<br />Clicking a title views the post, while clicking an author\'s name edits their user information.<br />Other post-related tasks are available from the menu.</p>', array('%comments' => url('admin/comment'))); return t('<p>Below is a list of all of the posts on your site. Other forms of content are listed elsewhere (e.g. <a href="%comments">comments</a>).<br />Clicking a title views the post, while clicking an author\'s name edits their user information.<br />Other post-related tasks are available from the menu.</p>', array('%comments' => url('admin/comment')));
case 'admin/node/search': case 'admin/node/search':
return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>'); return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>');
case 'admin/node/configure/defaults':
return t('<p>This page lets you set the defaults used during creation of nodes for all the different node types.<br /><em>comment:</em> Read/write setting for comments.<br /><em>publish:</em> Is this post publicly viewable, has it been published?<br /><em>promote:</em> Is this post to be promoted to the front page?<br /><em>moderate:</em> Does this post need approval before it can be viewed?<br /><em>sticky:</em> Is this post always visible at the top of lists?<br /><em>revision:</em> Will this post go into the revision system allowing multiple versions to be saved?</p>');
} }
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') { if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') {
@ -664,8 +662,8 @@ function node_menu($may_cache) {
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'), $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'), $items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_default_settings', 'callback' => 'node_types',
'access' => user_access('administer nodes'), 'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
if (module_exist('search')) { if (module_exist('search')) {
@ -710,6 +708,13 @@ function node_menu($may_cache) {
} }
} }
} }
else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) {
$items[] = array('path' => 'admin/node/configure/types/'. arg(4),
'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))),
'callback' => 'node_types_configure',
'access' => user_access('administer nodes'),
'type' => MENU_CALLBACK);
}
} }
return $items; return $items;
@ -809,46 +814,27 @@ function node_admin_nodes() {
return form($output); return form($output);
} }
/** function node_types() {
* Menu callback; presents the interface for setting node defaults. $header = array(t('Type'), t('Operations'));
*/
function node_default_settings() {
$op = $_POST['op'];
$edit = $_POST['edit'];
if ($op == t('Save configuration')) { $rows = array();
// Save the configuration options:
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
drupal_set_message(t('The content settings have been saved.'));
}
if ($op == t('Reset to defaults')) {
// Reset the configuration options to their default value:
foreach ($edit as $name => $value) {
variable_del($name);
}
drupal_set_message(t('The content settings have been reset to their default values.'));
}
$header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings')));
foreach (node_list() as $type) { foreach (node_list() as $type) {
$node = new StdClass(); $rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
$node->type = $type;
$cols = array();
foreach (node_invoke_nodeapi($node, 'settings') as $setting) {
$cols[] = array('data' => $setting, 'align' => 'center', 'width' => 55);
}
$rows[] = array_merge(array(node_invoke($node, 'node_name')), $cols);
} }
$output .= theme('table', $header, $rows); print theme('page', theme('table', $header, $rows));
}
$output .= form_submit(t('Save configuration')); function node_types_configure($type = NULL) {
$output .= form_submit(t('Reset to defaults')); // Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
}
system_settings_save();
print theme('page', form($output)); $output .= implode('', node_invoke_nodeapi($type, 'settings'));
print theme('page', system_settings_form($output));
} }
/** /**
@ -1121,11 +1107,12 @@ function node_validate($node) {
// Validate for normal users: // Validate for normal users:
$node->uid = $user->uid ? $user->uid : 0; $node->uid = $user->uid ? $user->uid : 0;
// Force defaults in case people modify the form: // Force defaults in case people modify the form:
$node->status = variable_get("node_status_$node->type", 1); $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$node->promote = variable_get("node_promote_$node->type", 1); $node->status = in_array('status', $node_options);
$node->moderate = variable_get("node_moderate_$node->type", 0); $node->moderate = in_array('moderate', $node_options);
$node->sticky = variable_get("node_sticky_$node->type", 0); $node->promote = in_array('promote', $node_options);
$node->revision = variable_get("node_revision_$node->type", 0); $node->sticky = in_array('sticky', $node_options);
$node->revision = in_array('revision', $node_options);
unset($node->created); unset($node->created);
} }
@ -1182,11 +1169,12 @@ function node_form($edit) {
$output .= form_group(t('Authoring information'), $author); $output .= form_group(t('Authoring information'), $author);
$output .= "</div>\n"; $output .= "</div>\n";
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : variable_get('node_status_'. $edit->type, 1)); $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : variable_get('node_moderate_'. $edit->type, 0)); $options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : in_array('status', $node_options));
$options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : variable_get('node_promote_'. $edit->type, 1)); $options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : in_array('moderate', $node_options));
$options .= form_checkbox(t('Sticky at top of lists'), 'sticky', 1, isset($edit->sticky) ? $edit->sticky : variable_get('node_sticky_'. $edit->type, 0)); $options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : in_array('promote', $node_options));
$options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : variable_get('node_revision_'. $edit->type, 0)); $options .= form_checkbox(t('Sticky at top of lists'), 'sticky', 1, isset($edit->sticky) ? $edit->sticky : in_array('sticky', $node_options));
$options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : in_array('revision', $node_options));
$output .= '<div class="options">'; $output .= '<div class="options">';
$output .= form_group(t('Options'), $options); $output .= form_group(t('Options'), $options);
@ -1611,12 +1599,8 @@ function node_update_index() {
function node_nodeapi(&$node, $op, $arg = 0) { function node_nodeapi(&$node, $op, $arg = 0) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('publish')] = form_checkbox('', "node_status_$node->type", 1, variable_get("node_status_$node->type", 1)); return form_checkboxes(t('Default options'), 'node_options_'. $node->type, variable_get('node_options_'. $node->type, array('status', 'promote')), array('status' => t('Published'), 'moderate' => t('In moderation queue'), 'promote' => t('Promoted to front page'), 'sticky' => t('Sticky at top of lists'), 'revision' => t('Create new revision')), t('Users with the <em>administer nodes</em> permission will be able to override these options.'));
$output[t('promote')] = form_checkbox('', "node_promote_$node->type", 1, variable_get("node_promote_$node->type", 1));
$output[t('moderate')] = form_checkbox('', "node_moderate_$node->type", 1, variable_get("node_moderate_$node->type", 0));
$output[t('sticky')] = form_checkbox('', "node_sticky_$node->type", 1, variable_get("node_sticky_$node->type", 0));
$output[t('revision')] = form_checkbox('', "node_revision_$node->type", 1, variable_get("node_revision_$node->type", 0));
return $output;
case 'fields': case 'fields':
return array('nid', 'uid', 'type', 'title', 'teaser', 'body', 'revisions', 'status', 'promote', 'moderate', 'sticky', 'created', 'changed', 'format'); return array('nid', 'uid', 'type', 'title', 'teaser', 'body', 'revisions', 'status', 'promote', 'moderate', 'sticky', 'created', 'changed', 'format');
} }

View File

@ -48,8 +48,6 @@ function node_help($section) {
return t('<p>Below is a list of all of the posts on your site. Other forms of content are listed elsewhere (e.g. <a href="%comments">comments</a>).<br />Clicking a title views the post, while clicking an author\'s name edits their user information.<br />Other post-related tasks are available from the menu.</p>', array('%comments' => url('admin/comment'))); return t('<p>Below is a list of all of the posts on your site. Other forms of content are listed elsewhere (e.g. <a href="%comments">comments</a>).<br />Clicking a title views the post, while clicking an author\'s name edits their user information.<br />Other post-related tasks are available from the menu.</p>', array('%comments' => url('admin/comment')));
case 'admin/node/search': case 'admin/node/search':
return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>'); return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>');
case 'admin/node/configure/defaults':
return t('<p>This page lets you set the defaults used during creation of nodes for all the different node types.<br /><em>comment:</em> Read/write setting for comments.<br /><em>publish:</em> Is this post publicly viewable, has it been published?<br /><em>promote:</em> Is this post to be promoted to the front page?<br /><em>moderate:</em> Does this post need approval before it can be viewed?<br /><em>sticky:</em> Is this post always visible at the top of lists?<br /><em>revision:</em> Will this post go into the revision system allowing multiple versions to be saved?</p>');
} }
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') { if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') {
@ -664,8 +662,8 @@ function node_menu($may_cache) {
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'), $items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'), $items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_default_settings', 'callback' => 'node_types',
'access' => user_access('administer nodes'), 'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK); 'type' => MENU_LOCAL_TASK);
if (module_exist('search')) { if (module_exist('search')) {
@ -710,6 +708,13 @@ function node_menu($may_cache) {
} }
} }
} }
else if (arg(0) == 'admin' && arg(1) == 'node' && arg(2) == 'configure' && arg(3) == 'types' && is_string(arg(4))) {
$items[] = array('path' => 'admin/node/configure/types/'. arg(4),
'title' => t("'%name' content type", array('%name' => node_invoke(arg(4), 'node_name'))),
'callback' => 'node_types_configure',
'access' => user_access('administer nodes'),
'type' => MENU_CALLBACK);
}
} }
return $items; return $items;
@ -809,46 +814,27 @@ function node_admin_nodes() {
return form($output); return form($output);
} }
/** function node_types() {
* Menu callback; presents the interface for setting node defaults. $header = array(t('Type'), t('Operations'));
*/
function node_default_settings() {
$op = $_POST['op'];
$edit = $_POST['edit'];
if ($op == t('Save configuration')) { $rows = array();
// Save the configuration options:
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
drupal_set_message(t('The content settings have been saved.'));
}
if ($op == t('Reset to defaults')) {
// Reset the configuration options to their default value:
foreach ($edit as $name => $value) {
variable_del($name);
}
drupal_set_message(t('The content settings have been reset to their default values.'));
}
$header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings')));
foreach (node_list() as $type) { foreach (node_list() as $type) {
$node = new StdClass(); $rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
$node->type = $type;
$cols = array();
foreach (node_invoke_nodeapi($node, 'settings') as $setting) {
$cols[] = array('data' => $setting, 'align' => 'center', 'width' => 55);
}
$rows[] = array_merge(array(node_invoke($node, 'node_name')), $cols);
} }
$output .= theme('table', $header, $rows); print theme('page', theme('table', $header, $rows));
}
$output .= form_submit(t('Save configuration')); function node_types_configure($type = NULL) {
$output .= form_submit(t('Reset to defaults')); // Go to the listing page when we submit this form, system_settings_save() calls drupal_goto().
if ($_POST['op']) {
$_GET['q'] = 'admin/node/configure/types';
}
system_settings_save();
print theme('page', form($output)); $output .= implode('', node_invoke_nodeapi($type, 'settings'));
print theme('page', system_settings_form($output));
} }
/** /**
@ -1121,11 +1107,12 @@ function node_validate($node) {
// Validate for normal users: // Validate for normal users:
$node->uid = $user->uid ? $user->uid : 0; $node->uid = $user->uid ? $user->uid : 0;
// Force defaults in case people modify the form: // Force defaults in case people modify the form:
$node->status = variable_get("node_status_$node->type", 1); $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$node->promote = variable_get("node_promote_$node->type", 1); $node->status = in_array('status', $node_options);
$node->moderate = variable_get("node_moderate_$node->type", 0); $node->moderate = in_array('moderate', $node_options);
$node->sticky = variable_get("node_sticky_$node->type", 0); $node->promote = in_array('promote', $node_options);
$node->revision = variable_get("node_revision_$node->type", 0); $node->sticky = in_array('sticky', $node_options);
$node->revision = in_array('revision', $node_options);
unset($node->created); unset($node->created);
} }
@ -1182,11 +1169,12 @@ function node_form($edit) {
$output .= form_group(t('Authoring information'), $author); $output .= form_group(t('Authoring information'), $author);
$output .= "</div>\n"; $output .= "</div>\n";
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : variable_get('node_status_'. $edit->type, 1)); $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : variable_get('node_moderate_'. $edit->type, 0)); $options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : in_array('status', $node_options));
$options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : variable_get('node_promote_'. $edit->type, 1)); $options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : in_array('moderate', $node_options));
$options .= form_checkbox(t('Sticky at top of lists'), 'sticky', 1, isset($edit->sticky) ? $edit->sticky : variable_get('node_sticky_'. $edit->type, 0)); $options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : in_array('promote', $node_options));
$options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : variable_get('node_revision_'. $edit->type, 0)); $options .= form_checkbox(t('Sticky at top of lists'), 'sticky', 1, isset($edit->sticky) ? $edit->sticky : in_array('sticky', $node_options));
$options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : in_array('revision', $node_options));
$output .= '<div class="options">'; $output .= '<div class="options">';
$output .= form_group(t('Options'), $options); $output .= form_group(t('Options'), $options);
@ -1611,12 +1599,8 @@ function node_update_index() {
function node_nodeapi(&$node, $op, $arg = 0) { function node_nodeapi(&$node, $op, $arg = 0) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('publish')] = form_checkbox('', "node_status_$node->type", 1, variable_get("node_status_$node->type", 1)); return form_checkboxes(t('Default options'), 'node_options_'. $node->type, variable_get('node_options_'. $node->type, array('status', 'promote')), array('status' => t('Published'), 'moderate' => t('In moderation queue'), 'promote' => t('Promoted to front page'), 'sticky' => t('Sticky at top of lists'), 'revision' => t('Create new revision')), t('Users with the <em>administer nodes</em> permission will be able to override these options.'));
$output[t('promote')] = form_checkbox('', "node_promote_$node->type", 1, variable_get("node_promote_$node->type", 1));
$output[t('moderate')] = form_checkbox('', "node_moderate_$node->type", 1, variable_get("node_moderate_$node->type", 0));
$output[t('sticky')] = form_checkbox('', "node_sticky_$node->type", 1, variable_get("node_sticky_$node->type", 0));
$output[t('revision')] = form_checkbox('', "node_revision_$node->type", 1, variable_get("node_revision_$node->type", 0));
return $output;
case 'fields': case 'fields':
return array('nid', 'uid', 'type', 'title', 'teaser', 'body', 'revisions', 'status', 'promote', 'moderate', 'sticky', 'created', 'changed', 'format'); return array('nid', 'uid', 'type', 'title', 'teaser', 'body', 'revisions', 'status', 'promote', 'moderate', 'sticky', 'created', 'changed', 'format');
} }

View File

@ -539,7 +539,7 @@ function system_settings_save() {
} }
drupal_set_message(t('The configuration options have been reset to their default values.')); drupal_set_message(t('The configuration options have been reset to their default values.'));
} }
if ($op == t('Save configuration')) { else if ($op == t('Save configuration')) {
if (is_array($edit)) { if (is_array($edit)) {
foreach ($edit as $name => $value) { foreach ($edit as $name => $value) {
variable_set($name, $value); variable_set($name, $value);

View File

@ -539,7 +539,7 @@ function system_settings_save() {
} }
drupal_set_message(t('The configuration options have been reset to their default values.')); drupal_set_message(t('The configuration options have been reset to their default values.'));
} }
if ($op == t('Save configuration')) { else if ($op == t('Save configuration')) {
if (is_array($edit)) { if (is_array($edit)) {
foreach ($edit as $name => $value) { foreach ($edit as $name => $value) {
variable_set($name, $value); variable_set($name, $value);

View File

@ -105,13 +105,14 @@ function upload_file_download($file) {
function upload_nodeapi(&$node, $op, $arg) { function upload_nodeapi(&$node, $op, $arg) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('attachments')] = form_checkbox(NULL, "upload_$node->type", 1, variable_get("upload_$node->type", 1)); return form_radios(t('Attachments'), 'upload_'. $node->type, variable_get('upload_'. $node->type, 1), array(t('Disabled'), t('Enabled')));
break;
case 'form param': case 'form param':
if (variable_get("upload_$node->type", 1) && user_access('upload files')) { if (variable_get("upload_$node->type", 1) && user_access('upload files')) {
$output['options'] = array('enctype' => 'multipart/form-data'); $output['options'] = array('enctype' => 'multipart/form-data');
} }
break; break;
case 'validate': case 'validate':
$node->files = upload_load($node); $node->files = upload_load($node);
@ -197,16 +198,19 @@ function upload_nodeapi(&$node, $op, $arg) {
} }
} }
break; break;
case 'form post': case 'form post':
if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) { if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
$output = upload_form($node); $output = upload_form($node);
} }
break; break;
case 'load': case 'load':
if (variable_get("upload_$node->type", 1) == 1) { if (variable_get("upload_$node->type", 1) == 1) {
$output['files'] = upload_load($node); $output['files'] = upload_load($node);
} }
break; break;
case 'view': case 'view':
if ($node->files && user_access('view uploaded files')) { if ($node->files && user_access('view uploaded files')) {
$header = array(t('Attachment'), t('Size')); $header = array(t('Attachment'), t('Size'));
@ -248,12 +252,14 @@ function upload_nodeapi(&$node, $op, $arg) {
} }
} }
break; break;
case 'insert': case 'insert':
case 'update': case 'update':
if (user_access('upload files')) { if (user_access('upload files')) {
upload_save($node); upload_save($node);
} }
break; break;
case 'delete': case 'delete':
upload_delete($node); upload_delete($node);
break; break;

View File

@ -105,13 +105,14 @@ function upload_file_download($file) {
function upload_nodeapi(&$node, $op, $arg) { function upload_nodeapi(&$node, $op, $arg) {
switch ($op) { switch ($op) {
case 'settings': case 'settings':
$output[t('attachments')] = form_checkbox(NULL, "upload_$node->type", 1, variable_get("upload_$node->type", 1)); return form_radios(t('Attachments'), 'upload_'. $node->type, variable_get('upload_'. $node->type, 1), array(t('Disabled'), t('Enabled')));
break;
case 'form param': case 'form param':
if (variable_get("upload_$node->type", 1) && user_access('upload files')) { if (variable_get("upload_$node->type", 1) && user_access('upload files')) {
$output['options'] = array('enctype' => 'multipart/form-data'); $output['options'] = array('enctype' => 'multipart/form-data');
} }
break; break;
case 'validate': case 'validate':
$node->files = upload_load($node); $node->files = upload_load($node);
@ -197,16 +198,19 @@ function upload_nodeapi(&$node, $op, $arg) {
} }
} }
break; break;
case 'form post': case 'form post':
if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) { if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
$output = upload_form($node); $output = upload_form($node);
} }
break; break;
case 'load': case 'load':
if (variable_get("upload_$node->type", 1) == 1) { if (variable_get("upload_$node->type", 1) == 1) {
$output['files'] = upload_load($node); $output['files'] = upload_load($node);
} }
break; break;
case 'view': case 'view':
if ($node->files && user_access('view uploaded files')) { if ($node->files && user_access('view uploaded files')) {
$header = array(t('Attachment'), t('Size')); $header = array(t('Attachment'), t('Size'));
@ -248,12 +252,14 @@ function upload_nodeapi(&$node, $op, $arg) {
} }
} }
break; break;
case 'insert': case 'insert':
case 'update': case 'update':
if (user_access('upload files')) { if (user_access('upload files')) {
upload_save($node); upload_save($node);
} }
break; break;
case 'delete': case 'delete':
upload_delete($node); upload_delete($node);
break; break;