Documentação ComusThumbz
Login de Admin

Messages Manager

Overview

The Admin Messages Manager provides a comprehensive moderation interface for the platform's private messaging system. Administrators can view all user conversations, handle reported messages, manage user blocks, and moderate content with a modern messenger-style interface.

Key capabilities include:

  • View all conversations between users in a messenger-style interface
  • Handle message reports with resolve/delete actions
  • View and manage blocked user relationships
  • Monitor messaging statistics (total, unread, reports, blocks)
  • Delete individual messages or entire conversations
  • Navigate between users and their conversations seamlessly

 


System Requirements

PHP Requirements

Requirement Minimum Recommended
PHP Version 7.4+ 8.0+
Memory Limit 64M 128M

PHP Extensions Required

  • mysqli - Database connectivity
  • json - JSON encoding for AJAX responses
  • session - Session management for CSRF protection
  • mbstring - Multi-byte string handling for message content

PHP Settings

session.autostart = Off
date.timezone = Your/Timezone

Features & UI Elements

Page Header

[Screenshot: messages-header]

The page header displays:

  • Title: "Messages Manager"
  • Icon: fa-envelope (envelope icon)
  • Breadcrumb: Dashboard / Messages

 

Statistics Dashboard

[Screenshot: messages-stats]

Six statistics cards show messaging overview:

Card Color Icon Description
Total Messages Green fa-envelope All messages in the system
Unread Messages Orange fa-envelope-open Messages not yet read by recipients
Pending Reports Red fa-flag Reports awaiting admin review
User Blocks Gray fa-ban Total blocked user relationships
Messages (24h) Blue fa-clock Messages sent in last 24 hours
Conversations Purple fa-comments Unique conversation threads

Navigation Tabs

[Screenshot: messages-tabs]

Three tabs for different views:

Tab Icon Description Badge
Conversations fa-comments View all user conversations Count of conversations
Reports fa-flag Handle reported messages Count of pending reports
Blocks fa-ban View blocked user relationships Count of blocks

Conversations View

[Screenshot: messages-conversations-view]

A two-panel messenger-style interface:

Left Panel - Conversation List:

  • Search input field for filtering conversations
  • Scrollable list of all conversations
  • Each conversation shows:
  • Profile image or initials
  • Both usernames (User A ↔ User B)
  • Last message preview (truncated to 50 chars)
  • Timestamp ("2 hours ago" format)
  • Unread count badge (if unread messages exist)
  • Click to load conversation

 

Right Panel - Conversation Detail:

  • Header showing both users with links to their profiles
  • Scrollable message history (chronological order)
  • Each message displays:
  • Sender name and avatar
  • Message content
  • Timestamp
  • "Read" indicator with read timestamp
  • Delete button (individual message)
  • Conversation actions:
  • Delete Conversation button (deletes all messages)

 

Reports View

[Screenshot: messages-reports-view]

A list of reported messages requiring attention:

Each Report Card Shows:

  • Reporter: Username of who filed the report
  • Report Reason: spam, harassment, inappropriate, scam, or other
  • Report Details: User-provided description
  • Reported Message: The actual message content
  • Sender: Who sent the reported message
  • Receiver: Who received it
  • Report Date: When the report was filed
  • Message Date: When the original message was sent

 

Available Actions:

Action Icon Description
Resolve fa-check Mark report as resolved (keep message)
Delete Message fa-trash Delete the reported message
View Conversation fa-comments Open full conversation in Conversations tab

Blocks View

 

[Screenshot: messages-blocks-view]

A table showing all blocked user relationships:

Column Description
Blocker User who initiated the block (link to profile)
Blocked User who is blocked (link to profile)
Reason Reason provided for blocking (if any)
Blocked Since Date and time of the block
Actions Unblock button to remove the block

Alert Messages

Success and error messages appear below the header:

  • Success (green): "Report resolved successfully", "Message deleted successfully"
  • Error (red): "Invalid security token", "Message not found"

 


Step-by-Step Usage

Viewing User Conversations

  1. Navigate to Admin Panel → Users → Messages
  2. Ensure the Conversations tab is selected
  3. Browse the conversation list on the left panel
  4. Click any conversation to load it in the right panel
  5. Scroll through messages chronologically
  6. Use the search box to filter conversations by username

 

Tip: Conversations with unread messages show a badge with the unread count. Click to view and messages will be marked as read.

 

Searching for Specific Users

  1. In the Conversations view, locate the search input
  2. Type a username (partial matches supported)
  3. The conversation list filters in real-time
  4. Click on a filtered result to view that conversation

Viewing a Full Conversation

  1. Click on any conversation in the left panel
  2. The right panel loads via AJAX (no page refresh)
  3. Messages appear in chronological order (oldest first)
  4. Each message shows:
  • Sender name and profile link
  • Message content
  • Sent timestamp
  • Read status with timestamp (if read)

Deleting a Single Message

  1. Load the conversation containing the message
  2. Locate the message to delete
  3. Click the trash icon button on that message
  4. Confirm the deletion when prompted
  5. Message is removed from the conversation

 

Warning: Deleting a message is permanent. The message cannot be recovered.

 

Deleting an Entire Conversation

  1. Load the conversation you want to delete
  2. Click the Delete Conversation button in the header
  3. Confirm the deletion when prompted
  4. All messages between both users are deleted

 

Warning: This action is irreversible! All messages in the conversation will be permanently deleted.

 

Handling Message Reports

  1. Click the Reports tab
  2. Review pending reports (sorted by date, newest first)
  3. For each report, read:
  • The reason for the report
  • Any details provided by the reporter
  • The actual message content
  1. Choose an action:

Option A - Resolve (Keep Message):

  1. Click the green Resolve button
  2. Report is marked as resolved
  3. Message remains in place
  4. Good for false reports or minor issues

 

Option B - Delete Message:

  1. Click the red Delete Message button
  2. Confirm the deletion
  3. Message is removed from the system
  4. Report is automatically resolved

 

Option C - View Full Context:

  1. Click View Conversation to see surrounding messages
  2. This helps understand the context
  3. Return to Reports tab to take action

 

 

Tip: Always view the full conversation before deciding on a report. Context matters!

 

Managing User Blocks

  1. Click the Blocks tab
  2. View all blocked user relationships
  3. To unblock a user:
  • Find the block entry
  • Click the Unblock button
  • Confirm the action
  • Users can message each other again

 

Note: Blocks are one-directional. User A blocking User B doesn't prevent B from blocking A. Both appear as separate entries.

 

Navigating to User Profiles

From any view, you can click on usernames to:

  • Open the user's admin profile page (userdetails.php)
  • View full user information
  • Take additional moderation actions

 


AJAX Endpoints

Load Conversation

The page includes an AJAX endpoint for loading conversations without page refresh:

Request:

GET messages.admin.php?ajax=loadconversation&user1={userid}&user2={userid}

 

Response (JSON):

{

    "success": true,

    "messages": [

        {

            "messageid": 123,

            "senderid": 1,

            "senderusername": "johndoe",

            "receiverid": 2,

            "receiverusername": "janesmith",

            "message": "Hello, how are you?",

            "isread": 1,

            "readat": "2025-01-02 10:30:00",

            "createdat": "2025-01-02 10:25:00"

        }

    ]

}

 

Error Response:

{

    "success": false,

    "error": "Conversation not found"

}

 


Best Practices

Report Handling Guidelines

 

Tip: Consistent report handling builds user trust in the platform:

 

  1. Response Time:
  • Handle pending reports within 24 hours
  • Prioritize harassment and scam reports
  • Batch process spam reports
  1. Context Review:
  • Always view the full conversation before acting
  • Consider user history and patterns
  • Look for provocation or context
  1. Action Selection:
  • Resolve (no action): False reports, misunderstandings, minor issues
  • Delete message: Clear policy violations, explicit content, harassment
  • Escalate: Illegal content, threats, repeat offenders (ban user)

Common Report Types

Report Type Typical Action Notes
Spam Delete message Consider banning repeat spammers
Harassment Delete + review history May require user ban
Inappropriate Context-dependent Often false reports
Scam Delete + ban user Protect other users
Other Review carefully May need more details
Warning: Document severe violations. Keep notes for potential legal issues or user appeals.

Performance Tips

  1. Large Datasets:
  • Use search to narrow results
  • Handle reports promptly to reduce pending count
  • Archive old conversations periodically
  1. AJAX Loading:
  • Wait for conversation to load before taking actions
  • Don't rapidly click between conversations

Troubleshooting

Common Issues

Conversation Not Loading (AJAX Error)

Cause: JavaScript error or network issue

Solutions:

  1. Check browser console for JavaScript errors
  2. Verify CSRF token is valid (refresh page)
  3. Check network tab for failed requests
  4. Clear browser cache and retry
  5. Verify both user IDs exist in database

 

Reports Not Showing

Cause: No pending reports or filter issue

Solutions:

  1. Check if reports exist with status='pending'
  2. Verify tblMessageReports table exists
  3. Check foreign key constraints (messages may be deleted)
  4. Query database: SELECT COUNT() FROM tblMessageReports WHERE status = 'pending'

 

Delete Action Fails

Cause: CSRF token expired or database constraint

Solutions:

  1. Refresh page to get new CSRF token
  2. Check if message still exists
  3. Verify admin session is active
  4. Check PHP error logs for constraint violations

 

Search Not Filtering

Cause: JavaScript not loaded or input issue

Solutions:

  1. Verify JavaScript is enabled
  2. Check for console errors
  3. Try typing slowly (debounce may be active)
  4. Refresh page and retry

 

Database Issues

Missing Tables

Cause: Tables not created during installation

Solutions:

  1. Run CREATE TABLE statements from Installation Requirements
  2. Verify foreign key references (tblCMSUsers must exist first)
  3. Check MySQL character set compatibility

 

Orphaned Records

Cause: Users deleted without proper cascade

Solutions:

-- Find orphaned messages (sender doesn't exist)

SELECT m. FROM tblMessages m

LEFT JOIN tblCMSUsers u ON m.senderid = u.id

WHERE u.id IS NULL;

 


-- Find orphaned reports
SELECT r.* FROM tblMessageReports r
LEFT JOIN tblMessages m ON r.messageid = m.messageid
WHERE m.messageid IS NULL;


-- Clean up orphaned data
DELETE r FROM tblMessageReports r
LEFT JOIN tblMessages m ON r.message
id = m.messageid
WHERE m.message
id IS NULL;

 


Security Considerations

CSRF Protection

All POST actions include CSRF token validation:

if ($POST['csrftoken'] !== $SESSION['admincsrftoken']) {

    die('Invalid security token');

}

 

Input Sanitization

  • Usernames are escaped for HTML output
  • Message content is sanitized to prevent XSS
  • SQL queries use prepared statements

Access Control

  • Only administrators can access this page
  • Session validation occurs on page load
  • User actions are logged (if logging enabled)

Translatable Strings

{
    "messagestitle": "Messages Manager",
    "messagesbreadcrumb": "Dashboard / Messages",
    "messagesstattotal": "Total Messages",
    "messagesstatunread": "Unread Messages",
    "messagesstatreports": "Pending Reports",
    "messagesstatblocks": "User Blocks",
    "messagesstat24h": "Messages (24h)",
    "messagesstatconversations": "Conversations",
    "messagestabconversations": "Conversations",
    "messagestabreports": "Reports",
    "messagestabblocks": "Blocks",
    "messagessearchplaceholder": "Search by username...",
    "messagesconversationbetween": "Conversation between",
    "messagesnoconversations": "No conversations found",
    "messagesnomessages": "Select a conversation to view messages",
    "messagesloaderror": "Failed to load conversation",
    "messagesdeletesingle": "Delete Message",
    "messagesdeleteconversation": "Delete Conversation",
    "messagesconfirmdeletesingle": "Are you sure you want to delete this message?",
    "messagesconfirmdeleteconversation": "Are you sure you want to delete this entire conversation? This cannot be undone.",
    "messagesdeletedsuccess": "Message deleted successfully",
    "messagesconversationdeleted": "Conversation deleted successfully",
    "messagesreporttitle": "Message Reports",
    "messagesreportby": "Reported by",
    "messagesreportreason": "Reason",
    "messagesreportdetails": "Details",
    "messagesreportmessage": "Reported Message",
    "messagesreportsender": "Sender",
    "messagesreportreceiver": "Receiver",
    "messagesreportdate": "Report Date",
    "messagesmessagedate": "Message Date",
    "messagesresolve": "Resolve",
    "messagesdelete": "Delete Message",
    "messagesviewconversation": "View Conversation",
    "messagesresolvedsuccess": "Report resolved successfully",
    "messagesnoreports": "No pending reports",
    "messagesblockstitle": "Blocked Users",
    "messagesblocker": "Blocker",
    "messagesblocked": "Blocked User",
    "messagesblockreason": "Reason",
    "messagesblockedsince": "Blocked Since",
    "messagesunblock": "Unblock",
    "messagesunblockconfirm": "Are you sure you want to unblock this user?",
    "messagesunblockedsuccess": "User unblocked successfully",
    "messagesnoblocks": "No blocked users",
    "messagesreadat": "Read at",
    "messagesunread": "Unread",
    "messagessentby": "Sent by",
    "messagesagominutes": "minutes ago",
    "messagesagohours": "hours ago",
    "messagesagodays": "days ago",
    "messagesreasonspam": "Spam",
    "messagesreasonharassment": "Harassment",
    "messagesreasoninappropriate": "Inappropriate Content",
    "messagesreasonscam": "Scam",
    "messagesreasonother": "Other",
    "messageserrorcsrf": "Invalid security token",
    "messageserrornotfound": "Message not found",
    "messageserroractionfailed": "Action failed. Please try again."
}


Version History

Version Date Changes
1.0.0 2025-10-20 Initial messages admin page
1.1.0 2025-11-01 Added messenger-style interface
1.2.0 2025-11-15 Added reports management
1.3.0 2025-12-01 Added blocks view
1.4.0 2025-12-15 Modern UI with green theme
1.5.0 2025-01-02 AJAX conversation loading, statistics dashboard