You are here

admin_audit_trail_comment.module in Admin Audit Trail 1.0.x

Logs comment CUD commands in the admin_audit_trail module.

File

admin_audit_trail_comment/admin_audit_trail_comment.module
View source
<?php

/**
 * @file
 * Logs comment CUD commands in the admin_audit_trail module.
 */

/**
 * Implements hook_admin_audit_trail_handlers().
 */
function admin_audit_trail_comment_admin_audit_trail_handlers() {

  // Comment event log handler.
  $handlers = [];
  $handlers['comment'] = [
    'title' => t('Comment'),
  ];
  return $handlers;
}

/**
 * Implements hook_comment_insert().
 */
function admin_audit_trail_comment_insert($comment) {
  $log = [
    'type' => 'comment',
    'operation' => 'insert',
    'description' => t('%type: %title', [
      '%type' => $comment
        ->getTypeId(),
      '%title' => $comment
        ->getSubject(),
    ]),
    'ref_numeric' => $comment
      ->id(),
    'ref_char' => $comment
      ->getSubject(),
  ];
  admin_audit_trail_insert($log);
}

/**
 * Implements hook_comment_update().
 */
function admin_audit_trail_comment_update($comment) {
  $log = [
    'type' => 'comment',
    'operation' => 'update',
    'description' => t('%type: %title', [
      '%type' => $comment
        ->getTypeId(),
      '%title' => $comment
        ->getSubject(),
    ]),
    'ref_numeric' => $comment
      ->id(),
    'ref_char' => $comment
      ->getSubject(),
  ];
  admin_audit_trail_insert($log);
}

/**
 * Implements hook_comment_delete().
 */
function admin_audit_trail_comment_delete($comment) {
  $log = [
    'type' => 'comment',
    'operation' => 'delete',
    'description' => t('%type: %title', [
      '%type' => $comment
        ->getTypeId(),
      '%title' => $comment
        ->getSubject(),
    ]),
    'ref_numeric' => $comment
      ->id(),
    'ref_char' => $comment
      ->getSubject(),
  ];
  admin_audit_trail_insert($log);
}

Functions

Namesort descending Description
admin_audit_trail_comment_admin_audit_trail_handlers Implements hook_admin_audit_trail_handlers().
admin_audit_trail_comment_delete Implements hook_comment_delete().
admin_audit_trail_comment_insert Implements hook_comment_insert().
admin_audit_trail_comment_update Implements hook_comment_update().