--- node.module?rev=1.481 2005-03-29 17:43:33.000000000 +0200 +++ node.module 2005-03-30 00:12:32.000000000 +0200 @@ -566,7 +566,7 @@ function node_show($node, $cid) { * Implementation of hook_perm(). */ function node_perm() { - return array('administer nodes', 'access content'); + return array('administer nodes', 'administer unpublished nodes', 'access content'); } /** @@ -657,7 +657,7 @@ function node_menu($may_cache) { if ($may_cache) { $items[] = array('path' => 'admin/node', 'title' => t('content'), 'callback' => 'node_admin', - 'access' => user_access('administer nodes')); + 'access' => user_access('administer nodes') || user_access('administer unpublished nodes')); $items[] = array('path' => 'admin/node/action', 'title' => t('content'), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/node/overview', 'title' => t('list'), @@ -675,7 +675,7 @@ function node_menu($may_cache) { if (module_exist('search')) { $items[] = array('path' => 'admin/node/search', 'title' => t('search'), 'callback' => 'node_admin', - 'access' => user_access('administer nodes'), + 'access' => user_access('administer nodes') || user_access('administer unpublished nodes'), 'type' => MENU_LOCAL_TASK); } @@ -713,7 +713,7 @@ function node_menu($may_cache) { if ($node->revisions) { $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'), 'callback' => 'node_page', - 'access' => user_access('administer nodes'), + 'access' => user_access('administer nodes') || user_access('administer unpublished nodes'), 'weight' => 2, 'type' => MENU_LOCAL_TASK); } @@ -741,14 +741,24 @@ function node_admin_nodes() { /* ** Operations */ - $operations = array( - 'approve' => array(t('Approve the selected posts'), 'UPDATE {node} SET status = 1, moderate = 0 WHERE nid = %d'), - 'promote' => array(t('Promote the selected posts'), 'UPDATE {node} SET status = 1, promote = 1 WHERE nid = %d'), - 'sticky' => array(t('Make the selected posts sticky'), 'UPDATE {node} SET status = 1, sticky = 1 WHERE nid = %d'), - 'demote' => array(t('Demote the selected posts'), 'UPDATE {node} SET promote = 0 WHERE nid = %d'), - 'unpublish' => array(t('Unpublish the selected posts'), 'UPDATE {node} SET status = 0 WHERE nid = %d'), - 'delete' => array(t('Delete the selected posts'), '') - ); + if (user_access('administer nodes')) { + $operations = array( + 'approve' => array(t('Approve the selected posts'), 'UPDATE {node} SET status = 1, moderate = 0 WHERE nid = %d'), + 'promote' => array(t('Promote the selected posts'), 'UPDATE {node} SET status = 1, promote = 1 WHERE nid = %d'), + 'sticky' => array(t('Make the selected posts sticky'), 'UPDATE {node} SET status = 1, sticky = 1 WHERE nid = %d'), + 'demote' => array(t('Demote the selected posts'), 'UPDATE {node} SET promote = 0 WHERE nid = %d'), + 'unpublish' => array(t('Unpublish the selected posts'), 'UPDATE {node} SET status = 0 WHERE nid = %d'), + 'delete' => array(t('Delete the selected posts'), '') + ); + } + else { + $operations = array( + 'promote' => array(t('Promote the selected posts'), 'UPDATE {node} SET promote = 1 WHERE nid = %d'), + 'sticky' => array(t('Make the selected posts sticky'), 'UPDATE {node} SET sticky = 1 WHERE nid = %d'), + 'demote' => array(t('Demote the selected posts'), 'UPDATE {node} SET promote = 0 WHERE nid = %d'), + 'delete' => array(t('Delete the selected posts'), '') + ); + } // Handle operations $op = $_POST['op']; @@ -909,6 +919,10 @@ function node_admin_nodes() { $args[] = $value; $join .= $filters[$key]['join']; } + if (user_access('administer unpublished nodes') && !user_access('administer nodes')) { + $where[] = 'n.status = %d'; + $args[] = 0; + } $where = count($where) ? 'WHERE '. implode(' AND ', $where) : ''; $result = pager_query('SELECT n.*, u.name, u.uid FROM {node} n '. $join .' INNER JOIN {users} u ON n.uid = u.uid '. $where, 50, 0, NULL, $args); @@ -920,7 +934,15 @@ function node_admin_nodes() { $options[$key] = $value[0]; } - $form = form_select(NULL, 'operation', 'approve', $options, NULL, ($disabled ? 'disabled="disabled"' : '')); + if (user_access('administer nodes')) { + $default = 'approve'; + $description = NULL; + } + else { + $default = 'promote'; + $description = t('You do not have the right to publish nodes, so these operations will take effect only after a node administrator approves the nodes.'); + } + $form = form_select(NULL, 'operation', $default, $options, $description, ($disabled ? 'disabled="disabled"' : '')); $form .= form_submit(t('Update'), 'op', ($disabled ? array('disabled' => 'disabled') : array())); $output .= form_group(t('Update options'), "