diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 9895b1f..9054c40 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1837,6 +1837,12 @@ function comment_action_info() { 'configurable' => FALSE, 'triggers' => array('comment_insert', 'comment_update'), ), + 'comment_delete_action' => array( + 'label' => t('Delete comment'), + 'type' => 'comment', + 'configurable' => FALSE, + 'triggers' => array('comment_delete'), + ), ); } @@ -1961,6 +1967,20 @@ function comment_save_action(Comment $comment) { } /** + * Deletes a comment. + * + * @param Drupal\comment\Comment $comment + * + * @ingroup actions + */ +function comment_delete_action(Comment $comment) { + $subject = $comment->subject->value; + comment_delete($comment->id()); + cache_invalidate_tags(array('content' => TRUE)); + watchdog('action', 'Deleted comment %subject.', array('%subject' => $subject)); +} + +/** * Implements hook_ranking(). */ function comment_ranking() { diff --git a/core/modules/comment/config/views.view.comments.yml b/core/modules/comment/config/views.view.comments.yml new file mode 100644 index 0000000..35beb4c --- /dev/null +++ b/core/modules/comment/config/views.view.comments.yml @@ -0,0 +1,1080 @@ +base_field: cid +base_table: comment +core: 8.x +description: '' +status: '1' +display: + default: + display_plugin: default + id: default + display_title: Master + position: '' + display_options: + access: + type: perm + options: + perm: 'administer comments' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: '0' + distinct: '0' + slave: '0' + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: '0' + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: '1' + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: full + options: + items_per_page: '50' + offset: '0' + id: '0' + total_pages: '' + expose: + items_per_page: '0' + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: '0' + items_per_page_options_all_label: '- All -' + offset: '0' + offset_label: Offset + tags: + previous: '‹ previous' + next: 'next ›' + first: '« first' + last: 'last »' + quantity: '9' + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: '1' + row_class_special: '1' + override: '1' + sticky: '0' + summary: '' + columns: + action_bulk_form: action_bulk_form + subject: subject + name: name + title: title + changed: changed + info: + action_bulk_form: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + subject: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + name: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + title: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + changed: + sortable: '1' + default_sort_order: desc + align: '' + separator: '' + empty_column: '0' + responsive: '' + default: changed + empty_table: '1' + row: + type: fields + relationships: + nid: + id: nid + table: comment + field: nid + required: '1' + relationship: none + group_type: group + admin_label: Content + fields: + action_bulk_form: + id: action_bulk_form + table: action + field: action_bulk_form + relationship: none + group_type: group + admin_label: '' + label: 'Bulk update' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + include_exclude: include + selected_actions: + comment_unpublish_action: comment_unpublish_action + plugin_id: action_bulk_form + subject: + id: subject + table: comment + field: subject + relationship: none + group_type: group + admin_label: '' + label: Subject + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '0' + ellipsis: '0' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_comment: '1' + link_to_node: '0' + name: + id: name + table: comment + field: name + relationship: none + group_type: group + admin_label: '' + label: Author + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_user: '1' + plugin_id: comment_username + title: + id: title + table: node_field_data + field: title + relationship: nid + group_type: group + admin_label: '' + label: 'Posted in' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_node: '1' + plugin_id: node + changed: + id: changed + table: comment + field: changed + relationship: none + group_type: group + admin_label: '' + label: Updated + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + date_format: short + custom_date_format: '' + timezone: '' + plugin_id: date + filters: + status: + id: status + table: comment + field: status + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: '0' + group: '1' + exposed: '0' + expose: + operator_id: '0' + label: '' + description: '' + use_operator: '0' + operator: '0' + identifier: '' + required: '0' + remember: '0' + multiple: '0' + remember_roles: + authenticated: authenticated + is_grouped: '0' + group_info: + label: '' + description: '' + identifier: '' + optional: '1' + widget: select + multiple: '0' + remember: '0' + default_group: All + default_group_multiple: { } + group_items: { } + sorts: + created: + id: created + table: comment + field: created + order: DESC + relationship: none + group_type: group + admin_label: '' + exposed: '0' + expose: + label: '' + granularity: second + title: Comments + header: { } + footer: { } + empty: + area: + id: area + table: views + field: area + relationship: none + group_type: group + admin_label: '' + empty: '1' + content: "

No comments available.

\n" + format: basic_html + tokenize: '0' + plugin_id: text + arguments: { } + page_2: + display_plugin: page + id: page_2 + display_title: 'Unapproved comments' + position: '' + display_options: + display_description: 'Comments pending to approval' + path: admin/content/comment/approval + menu: + type: tab + title: 'Unapproved comments' + description: '' + name: admin + weight: '0' + context: '0' + filters: + status: + id: status + table: comment + field: status + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: '0' + group: '1' + exposed: '0' + expose: + operator_id: '0' + label: '' + description: '' + use_operator: '0' + operator: '0' + identifier: '' + required: '0' + remember: '0' + multiple: '0' + remember_roles: + authenticated: authenticated + is_grouped: '0' + group_info: + label: '' + description: '' + identifier: '' + optional: '1' + widget: select + multiple: '0' + remember: '0' + default_group: All + default_group_multiple: { } + group_items: { } + defaults: + filters: '0' + filter_groups: '0' + fields: '0' + filter_groups: + operator: AND + groups: + 1: AND + fields: + action_bulk_form: + id: action_bulk_form + table: action + field: action_bulk_form + relationship: none + group_type: group + admin_label: '' + label: 'Bulk update' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + include_exclude: include + selected_actions: + comment_delete_action: comment_delete_action + comment_publish_action: comment_publish_action + plugin_id: action_bulk_form + subject: + id: subject + table: comment + field: subject + relationship: none + group_type: group + admin_label: '' + label: Subject + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '0' + ellipsis: '0' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_comment: '1' + link_to_node: '0' + name: + id: name + table: comment + field: name + relationship: none + group_type: group + admin_label: '' + label: Author + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_user: '1' + plugin_id: comment_username + title: + id: title + table: node_field_data + field: title + relationship: nid + group_type: group + admin_label: '' + label: 'Posted in' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_node: '1' + plugin_id: node + changed: + id: changed + table: comment + field: changed + relationship: none + group_type: group + admin_label: '' + label: Updated + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + date_format: short + custom_date_format: '' + timezone: '' + plugin_id: date + page_1: + display_plugin: page + id: page_1 + display_title: Comments + position: '' + display_options: + path: admin/content/comment/new + menu: + type: tab + title: 'Published comments' + description: 'Comments published' + name: admin + weight: '-10' + context: '0' + display_description: '' + filters: + status: + id: status + table: comment + field: status + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: '1' + group: '1' + exposed: '0' + expose: + operator_id: '0' + label: '' + description: '' + use_operator: '0' + operator: '0' + identifier: '' + required: '0' + remember: '0' + multiple: '0' + remember_roles: + authenticated: authenticated + is_grouped: '0' + group_info: + label: '' + description: '' + identifier: '' + optional: '1' + widget: select + multiple: '0' + remember: '0' + default_group: All + default_group_multiple: { } + group_items: { } + defaults: + filters: '0' + filter_groups: '0' + fields: '0' + filter_groups: + operator: AND + groups: + 1: AND + fields: + action_bulk_form: + id: action_bulk_form + table: action + field: action_bulk_form + relationship: none + group_type: group + admin_label: '' + label: 'Bulk update' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + include_exclude: include + selected_actions: + comment_delete_action: comment_delete_action + comment_unpublish_action: comment_unpublish_action + plugin_id: action_bulk_form + subject: + id: subject + table: comment + field: subject + relationship: none + group_type: group + admin_label: '' + label: Subject + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '0' + ellipsis: '0' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_comment: '1' + link_to_node: '0' + name: + id: name + table: comment + field: name + relationship: none + group_type: group + admin_label: '' + label: Author + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_user: '1' + plugin_id: comment_username + title: + id: title + table: node_field_data + field: title + relationship: nid + group_type: group + admin_label: '' + label: 'Posted in' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_node: '1' + plugin_id: node + changed: + id: changed + table: comment + field: changed + relationship: none + group_type: group + admin_label: '' + label: Updated + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + date_format: short + custom_date_format: '' + timezone: '' + plugin_id: date +label: Comments +module: views +id: comments +tag: '' +uuid: 5e610f28-4b1d-4310-b600-f079ab8d707c +langcode: en diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php index a942d7c..39f15be 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php @@ -83,6 +83,23 @@ function testCommentUnpublishByKeyword() { } /** + * Tests comment delete action. + */ + function testCommentDeleteAction() { + $this->drupalLogin($this->web_user); + $comment_text = $this->randomName(); + $subject = $this->randomName(); + $comment = $this->postComment($this->node, $comment_text, $subject); + + // Delete a comment. + comment_delete_action($comment); + $comment = comment_load($comment->id()); + $this->assertTrue(empty($comment), 'Comment was deleted'); + $this->assertWatchdogMessage('Deleted comment %subject.', array('%subject' => $subject), 'Found watchdog message'); + $this->clearWatchdog(); + } + + /** * Verifies that a watchdog message has been entered. * * @param $watchdog_message