Index: hidden.action-pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hidden/hidden.action-pages.inc,v retrieving revision 1.4.2.1 diff -u -p -r1.4.2.1 hidden.action-pages.inc --- hidden.action-pages.inc 13 Mar 2009 11:44:09 -0000 1.4.2.1 +++ hidden.action-pages.inc 13 Mar 2009 17:37:03 -0000 @@ -29,6 +29,9 @@ function hidden_hide(&$form_state, $type if (! $item = _hidden_hide_form_item_get($type, $id)) { drupal_goto(); } + if ($item->type != 'comment' && ! hidden_content_type($item->type)) { + drupal_not_found(); + } drupal_set_title(t('Hide @title', array('@title' => $item->title))); $form = _hidden_hide_form($user, $hidden); @@ -127,6 +130,9 @@ function hidden_report(&$form_state, $ty if (! $item = _hidden_hide_form_item_get($type, $id)) { drupal_goto(); } + if ($item->type != 'comment' && ! hidden_content_type($item->type)) { + drupal_not_found(); + } drupal_set_title(t('Report @title', array('@title' => $item->title))); @@ -188,6 +194,7 @@ function _hidden_hide_form_item_get($typ return FALSE; } $item->title = $item->subject; + $item->type = 'comment'; } else { if (! $item = node_load($id)) { @@ -197,7 +204,6 @@ function _hidden_hide_form_item_get($typ $item->cid = 0; } - $item->type = $type; $item->id = $id; return $item; @@ -227,6 +233,15 @@ function hidden_hide_submit($form, &$for } $type = (string) $form['#content_type']; + if ($type != 'comment') { + if(! hidden_content_type($type)) { + _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_hide_submit() passed invalid parameters.'); + drupal_goto('hidden'); + } + else { + $type = 'node'; + } + } $id = (int) $form['#content_id']; if (! _hidden_check_param($type, $id)) { _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_hide_submit() passed invalid parameters.'); @@ -281,6 +296,15 @@ function hidden_report_submit($form, &$f } $type = (string) $form['#content_type']; + if ($type != 'comment') { + if(! hidden_content_type($type)) { + _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_report_submit() passed invalid parameters.'); + drupal_goto('hidden'); + } + else { + $type = 'node'; + } + } $id = (int) $form['#content_id']; if (! _hidden_check_param($type, $id)) { _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_report_submit() passed invalid parameters.'); Index: hidden.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hidden/hidden.admin.inc,v retrieving revision 1.2.2.1 diff -u -p -r1.2.2.1 hidden.admin.inc --- hidden.admin.inc 13 Mar 2009 11:44:09 -0000 1.2.2.1 +++ hidden.admin.inc 13 Mar 2009 17:37:03 -0000 @@ -13,11 +13,27 @@ * @see theme_hidden_admin_settings() */ function hidden_admin_settings(&$form_state) { - $form['hidden_logging'] = array( - '#tree' => 'TRUE', + $types = node_get_types('names'); + $form['hidden_content_types'] = array( + '#type' => 'checkboxes', + '#title' => t('Content types'), + '#description' => t('Which content types can be hidden and reported'), + '#default_value' => _hidden_settings_types(), ); - $form['hidden_logging']['header'] = array( - '#value' => array(t('Type'), t('Logged')), + foreach ($types as $type => $name) { + $form['hidden_content_types']['#options'][$type] = t($name); + } + $form['hidden_public_notes'] = array( + '#title' => t('Allow public notes'), + '#type' => 'checkbox', + '#default_value' => variable_get('hidden_public_notes', TRUE), + '#description' => t('If unchecked, the form for public notes about hidden content will be disabled, only predefined reasons are available.') + ); + $form['hidden_logging'] = array( + '#title' => t('Logging'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => FALSE, ); $logging = _hidden_settings_logging(); $logform = array( @@ -35,12 +51,9 @@ function hidden_admin_settings(&$form_st ), ); foreach ($logform as $row => $content) { - $form['hidden_logging'][$row]['name'] = array( - '#type' => 'item', - '#value' => $content['title'], - '#description' => $content['description'] - ); - $form['hidden_logging'][$row]['enabled'] = array( + $form['hidden_logging'][$row] = array( + '#title' => $content['title'], + '#description' => $content['description'], '#type' => 'checkbox', '#default_value' => $logging[$row]['enabled'], ); @@ -49,7 +62,10 @@ function hidden_admin_settings(&$form_st $email = _hidden_settings_mail(); $frequency = drupal_map_assoc(array(21600, 43200, 64800, 86400, 172800), 'format_interval'); $form['hidden_email'] = array( - '#tree' => 'TRUE', + '#title' => t('e-mail notifications'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => FALSE, ); $form['hidden_email']['domail'] = array( '#type' => 'checkbox', @@ -72,9 +88,6 @@ function hidden_admin_settings(&$form_st '#default_value' => $email['frequency'], '#description' => t('How often any periodic e-mails should be sent out'), ); - $form['hidden_email']['header'] = array( - '#value' => array(t('Log message'), t('e-mail')), - ); $emailform = array( HIDDEN_LOG_DELETE => array( 'title' => t('Delete hidden content'), @@ -121,12 +134,6 @@ function hidden_admin_settings(&$form_st ); } } - $form['hidden_public_notes'] = array( - '#title' => t('Allow public notes'), - '#type' => 'checkbox', - '#default_value' => variable_get('hidden_public_notes', TRUE), - '#description' => t('If unchecked, the form for public notes about hidden content will be disabled, only predefined reasons are available.') - ); return system_settings_form($form); } Index: hidden.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hidden/hidden.module,v retrieving revision 1.8.2.1 diff -u -p -r1.8.2.1 hidden.module --- hidden.module 13 Mar 2009 11:44:09 -0000 1.8.2.1 +++ hidden.module 13 Mar 2009 17:37:04 -0000 @@ -335,7 +335,7 @@ function hidden_menu() { ); $items['hidden/%/%/hide'] = array( - 'title' => 'Report post', + 'title' => 'Hide post', 'page callback' => 'drupal_get_form', 'page arguments' => array('hidden_hide', 1, 2), 'access arguments' => $hide, @@ -495,6 +495,10 @@ function hidden_comment(&$comment, $acti * removes deleted node from the records. */ function hidden_nodeapi(&$node, $action, $arg=0) { + if (! hidden_content_type($node->type)) { + return; + } + switch ($action) { case 'alter': if (! $node->status) { @@ -576,6 +580,10 @@ function hidden_link($type, $item = NULL $iscomment = TRUE; } elseif ($type == 'node') { + if (! hidden_content_type($item->type)) { + // not a hidable content type + return $links; + } $target = $item->nid; $iscomment = FALSE; } @@ -1986,6 +1994,37 @@ function _hidden_settings_mail() { } /** + * Check if a type is enbled. + * + * @param + * string content type name. + * @return + * bool true if enabled. + */ +function hidden_content_type($type) { + $types = _hidden_settings_types(); + return (array_key_exists($type, $types) && $types[$type]) ? TRUE : FALSE; +} + +/** + * variable_get('hidden_content_types') or defaults. + * + * Defaults to all content types, partly historically, partly as + * opt-out makes sense. + * + * @return + * array present settings. + */ +function _hidden_settings_types() { + $content_types = variable_get('hidden_content_types', NULL); + if (! is_array($content_types)) { + $content_types = node_get_types('names'); + } + + return $content_types; +} + +/** * Find which node a comment is attached to. * * @param $cid Index: hidden.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hidden/hidden.test,v retrieving revision 1.3.2.1 diff -u -p -r1.3.2.1 hidden.test --- hidden.test 13 Mar 2009 11:44:09 -0000 1.3.2.1 +++ hidden.test 13 Mar 2009 17:37:05 -0000 @@ -550,7 +550,7 @@ class HiddenHideTestCase extends HiddenH $this->drupalLogin($this->hide_user); // make node to hide - $node = $this->drupalCreateNode(array('type' => 'article')); + $node = $this->drupalCreateNode(array('type' => 'story')); // Submit hide form $hide = array( @@ -593,7 +593,7 @@ class HiddenHideTestCase extends HiddenH function testHiddenReport() { $this->drupalLogin($this->report_user); - $node = $this->drupalCreateNode(array('type' => 'article')); + $node = $this->drupalCreateNode(array('type' => 'story')); // Submit report form $report = array(