Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/includes/
Upload File :
Current File : /var/www/cesa.co.za/php/includes/cstUnreadMessages.php

<?php

include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/CCEMessages.php');

function cstUnreadMesssages_Row_Rendered($objThis)
{
    global $conni, $sqlf;

    static $objCceMessages = null;
    if ($objCceMessages === null) {
        $objCceMessages = new CCEMessages($sqlf);
    }

    if (isset($objThis->MessageText)) {
        $rawText = $objThis->MessageText->CurrentValue;
        if ($rawText === null || $rawText === '') {
            $rawText = $objThis->MessageText->ViewValue;
        }
        if ($rawText !== null && $rawText !== '') {
            $objThis->MessageText->ViewValue = $objCceMessages->formatForDisplay($rawText);
            $objThis->MessageText->CellAttrs['class'] = trim(
                (isset($objThis->MessageText->CellAttrs['class']) ? $objThis->MessageText->CellAttrs['class'] . ' ' : '')
                . 'cce-message-cell'
            );
        }
    }

    if (!isset($_SESSION['facilitator_user_id'])) {
        $_SESSION['facilitator_user_id'] = 0;
    }

    if ($_SESSION['facilitator_user_id'] <= 0) {
        $iUserID = 0;
        $sql = "SELECT FacilitatorID FROM CCEFacilitatorUsers WHERE Username='" . $_SESSION[EW_SESSION_USER_NAME] . "'";

        // echo $sql . '<br />';
        // exit;
        $rec = mysqli_query($conni, $sql);
        if ($row = mysqli_fetch_assoc($rec)) $iUserID = $row["FacilitatorID"];
        mysqli_free_result($rec);

        if ($iUserID > 0) {
            $_SESSION['facilitator_user_id'] = $iUserID;
        }
    }

    // var_dump($objThis->CCEMessageID);
    // exit;

    // ini_set('display_errors', 1);
    // error_reporting(E_ALL);

    if (!is_null($objThis->CCEMessageID->DbValue)) {
        $objCCEMessageLog = new CCEMessageLog($sqlf);
        $objCCEMessageLog->findByMessageUserId($objThis->CCEMessageID->DbValue, $_SESSION['facilitator_user_id']);

        if (is_array($objCCEMessageLog) && is_array($objCCEMessageLog) && $_SESSION['facilitator_user_id'] == $objCCEMessageLog['ReadById']) {
            $objThis->RowAttrs["class"] = "message-read";
        } else {
            $objThis->RowAttrs["class"] = "message-unread";
        }
    }
}