<?php

//var_dump($_REQUEST);
$path = '../../';
require_once $path . 'core/includes/header.inc.php';
//require_once $path . 'core/admin/templates/adminheader.html.php';
//var_dump("test");
use Mtc\Modules\Members\Classes\Auth;
use Mtc\Plugins\ContentReports\Classes\Reports;
use Mtc\Plugins\MembersMessaging\Classes\Message;
use Mtc\Plugins\MembersMessaging\Classes\Thread;


if (!Auth::isLoggedIn()) {
    header("Location: " . route('members-login'));
    exit();
}

if($_REQUEST['action']=="send_message"){
    $thread = Thread::whereUrl($url)->first();

    $message            = new Message;
    $message->member_id = $member->id;
    $message->thread_id = $thread->id;
    $message->text      = $_REQUEST['message'];
    $message->save();

    header('Location: ' . $_SERVER['PHP_SELF'] . '?id='.$_REQUEST['id'].'&url='.$_REQUEST['url'].'&lesson='.$_REQUEST['lesson']);
    exit;
}



if (count($errors) > 0) {
    showerrors($errors);
}



?>

<!--<script>
    window.onload = function(){
        var objDiv = document.getElementById("admin-chat-log");
        objDiv.scrollTop = objDiv.scrollHeight;
    }
</script>

<div class="admin-chat-log-container">
    <div class="member">
        <?php //var_dump($thread)?>
        <?php //var_dump($thread->participants)?>
        <strong><?=$myName($thread->participants); ?></strong>
    </div>
    <ul id="admin-chat-log" class="admin-chat-log">
        <?php
        foreach($messages as $message) {
            echo $messageBubbleHtml($message);
        }
        ?>
    </ul>
    <div class="member">
        <strong><?=$myName($thread->participants, true); ?></strong>
    </div>
</div> -->

<?php


