- 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-14" => "update_116",
"2005-01-18" => "update_117",
"2005-01-19" => "update_118"
"2005-01-19" => "update_118",
"2005-01-20" => "update_119"
);
function update_32() {
@ -2110,6 +2111,37 @@ function update_118() {
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) {
$edit = $_POST["edit"];
$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])) {
$file = new stdClass();
$file = new StdClass();
$file->filename = trim(basename($_FILES["edit"]["name"][$source]), '.');
$file->filemime = $_FILES["edit"]["type"][$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) {
switch ($op) {
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 $output;
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.'));
case 'fields':
return array('comment');
case 'form admin':
if (user_access('administer comments')) {
$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);
}
break;
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));
case 'validate':
@ -251,9 +253,11 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$node->comment = variable_get("comment_$node->type", 2);
}
break;
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);
break;
case 'update':
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid);
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 {node_comment_statistics} WHERE nid = %d', $node->nid);
break;
case 'update index':
$text = '';
$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);
}
return $text;
case 'search result':
$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');

View File

@ -232,10 +232,11 @@ function comment_link($type, $node = 0, $main = 0) {
function comment_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
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 $output;
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.'));
case 'fields':
return array('comment');
case 'form admin':
if (user_access('administer comments')) {
$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);
}
break;
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));
case 'validate':
@ -251,9 +253,11 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$node->comment = variable_get("comment_$node->type", 2);
}
break;
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);
break;
case 'update':
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d AND cid = 0', $node->changed, $node->nid);
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 {node_comment_statistics} WHERE nid = %d', $node->nid);
break;
case 'update index':
$text = '';
$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);
}
return $text;
case 'search result':
$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');

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')));
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>');
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') {
@ -664,8 +662,8 @@ function node_menu($may_cache) {
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'),
'callback' => 'node_default_settings',
$items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_types',
'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK);
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;
@ -809,46 +814,27 @@ function node_admin_nodes() {
return form($output);
}
/**
* Menu callback; presents the interface for setting node defaults.
*/
function node_default_settings() {
$op = $_POST['op'];
$edit = $_POST['edit'];
function node_types() {
$header = array(t('Type'), t('Operations'));
if ($op == t('Save configuration')) {
// 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')));
$rows = array();
foreach (node_list() as $type) {
$node = new StdClass();
$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);
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
}
$output .= theme('table', $header, $rows);
print theme('page', theme('table', $header, $rows));
}
$output .= form_submit(t('Save configuration'));
$output .= form_submit(t('Reset to defaults'));
function node_types_configure($type = NULL) {
// 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:
$node->uid = $user->uid ? $user->uid : 0;
// Force defaults in case people modify the form:
$node->status = variable_get("node_status_$node->type", 1);
$node->promote = variable_get("node_promote_$node->type", 1);
$node->moderate = variable_get("node_moderate_$node->type", 0);
$node->sticky = variable_get("node_sticky_$node->type", 0);
$node->revision = variable_get("node_revision_$node->type", 0);
$node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$node->status = in_array('status', $node_options);
$node->moderate = in_array('moderate', $node_options);
$node->promote = in_array('promote', $node_options);
$node->sticky = in_array('sticky', $node_options);
$node->revision = in_array('revision', $node_options);
unset($node->created);
}
@ -1182,11 +1169,12 @@ function node_form($edit) {
$output .= form_group(t('Authoring information'), $author);
$output .= "</div>\n";
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : variable_get('node_status_'. $edit->type, 1));
$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('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : variable_get('node_promote_'. $edit->type, 1));
$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('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : variable_get('node_revision_'. $edit->type, 0));
$node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : in_array('status', $node_options));
$options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : in_array('moderate', $node_options));
$options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : in_array('promote', $node_options));
$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 .= form_group(t('Options'), $options);
@ -1611,12 +1599,8 @@ function node_update_index() {
function node_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'settings':
$output[t('publish')] = form_checkbox('', "node_status_$node->type", 1, variable_get("node_status_$node->type", 1));
$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;
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.'));
case 'fields':
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')));
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>');
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') {
@ -664,8 +662,8 @@ function node_menu($may_cache) {
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/node/configure/settings', 'title' => t('settings'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/node/configure/defaults', 'title' => t('default workflow'),
'callback' => 'node_default_settings',
$items[] = array('path' => 'admin/node/configure/types', 'title' => t('content types'),
'callback' => 'node_types',
'access' => user_access('administer nodes'),
'type' => MENU_LOCAL_TASK);
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;
@ -809,46 +814,27 @@ function node_admin_nodes() {
return form($output);
}
/**
* Menu callback; presents the interface for setting node defaults.
*/
function node_default_settings() {
$op = $_POST['op'];
$edit = $_POST['edit'];
function node_types() {
$header = array(t('Type'), t('Operations'));
if ($op == t('Save configuration')) {
// 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')));
$rows = array();
foreach (node_list() as $type) {
$node = new StdClass();
$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);
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/node/configure/types/'. $type));
}
$output .= theme('table', $header, $rows);
print theme('page', theme('table', $header, $rows));
}
$output .= form_submit(t('Save configuration'));
$output .= form_submit(t('Reset to defaults'));
function node_types_configure($type = NULL) {
// 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:
$node->uid = $user->uid ? $user->uid : 0;
// Force defaults in case people modify the form:
$node->status = variable_get("node_status_$node->type", 1);
$node->promote = variable_get("node_promote_$node->type", 1);
$node->moderate = variable_get("node_moderate_$node->type", 0);
$node->sticky = variable_get("node_sticky_$node->type", 0);
$node->revision = variable_get("node_revision_$node->type", 0);
$node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$node->status = in_array('status', $node_options);
$node->moderate = in_array('moderate', $node_options);
$node->promote = in_array('promote', $node_options);
$node->sticky = in_array('sticky', $node_options);
$node->revision = in_array('revision', $node_options);
unset($node->created);
}
@ -1182,11 +1169,12 @@ function node_form($edit) {
$output .= form_group(t('Authoring information'), $author);
$output .= "</div>\n";
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : variable_get('node_status_'. $edit->type, 1));
$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('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : variable_get('node_promote_'. $edit->type, 1));
$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('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : variable_get('node_revision_'. $edit->type, 0));
$node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
$options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : in_array('status', $node_options));
$options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : in_array('moderate', $node_options));
$options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : in_array('promote', $node_options));
$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 .= form_group(t('Options'), $options);
@ -1611,12 +1599,8 @@ function node_update_index() {
function node_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'settings':
$output[t('publish')] = form_checkbox('', "node_status_$node->type", 1, variable_get("node_status_$node->type", 1));
$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;
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.'));
case 'fields':
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.'));
}
if ($op == t('Save configuration')) {
else if ($op == t('Save configuration')) {
if (is_array($edit)) {
foreach ($edit as $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.'));
}
if ($op == t('Save configuration')) {
else if ($op == t('Save configuration')) {
if (is_array($edit)) {
foreach ($edit as $name => $value) {
variable_set($name, $value);

View File

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

View File

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