コード例 #1
0
 public static function getAuthenticatedUser()
 {
     return self::isAuthenticated() ? DataManager::getUserById($_SESSION['user']) : null;
 }
コード例 #2
0
ファイル: welcome.php プロジェクト: amigobv/chat
    DataManager::getChannelByName($_SESSION['channel']);
    ?>
">
                <div class = "panel-heading">
                    <h4 class="channelName"><?php 
    echo isset($_SESSION['channel']) && $_SESSION['channel'] ? $_SESSION['channel'] : "Default";
    ?>
</h4></div>
                <div class = "panel-body panel-height">
                    <ul class = "media-list messageContainer">
                        <?php 
    $channel = DataManager::getChannelByName($_SESSION['channel']);
    $messages = DataManager::getPostsByChannel($channel->getID());
    //Util::stable_uasort($messages, 'Util::MessageCmp');
    foreach ($messages as $message) {
        $author = DataManager::getUserById($message->getAuthor());
        $status = DataManager::getPostStatus($message->getId());
        if ($status != Status::PRIOR && $status != Status::DELETED) {
            Viewtility::viewMessage($message, $status);
        }
        /*
        if ($currUser) {
            if ($status == Status::UNREAD && $author->getUsername() != $currUser->getUsername()) {
                DataManager::changePostStatus($message->getID(), Status::READ);
                $message->setRead();
            }
        }
        */
    }
    ?>
コード例 #3
0
        ?>
                <div class="row">
                    <h4 class="page-header" style="margin: 10px 20px; padding-bottom: 0;">
                        <a href="?view=channel&id=<?php 
        echo $channel->getId();
        ?>
">
                            <?php 
        echo $channel->getName();
        ?>
                        </a>
                    </h4>

                    <?php 
        foreach ($posts as $post) {
            $user = DataManager::getUserById($post->getUserId());
            ?>
                        <div class='col-lg-8'>
                            <div class='panel panel-primary'>
                                <div class='panel-heading'>
                                    <h3 class='panel-title'>
                                        <?php 
            echo $post->getTitle();
            ?>
                                        <span class='align-right'>
                                        <?php 
            echo $user->getFirstName() . " " . $user->getLastName() . ", " . $post->getDatetime();
            ?>
                                    </span>
                                    </h3>
                                </div>
コード例 #4
0
ファイル: Post.php プロジェクト: TSchmiedlechner/SlackLight
 /**
  * Specify data which should be serialized to JSON
  * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
  * @return mixed data which can be serialized by <b>json_encode</b>,
  * which is a value of any type other than a resource.
  */
 function jsonSerialize()
 {
     $user = DataManager::getUserById($this->userId);
     return ['id' => $this->getId(), 'title' => $this->title, 'text' => $this->text, 'user' => $user, 'threadId' => $this->channelId, "datetime" => $this->datetime, 'isFavorite' => intval($this->favorite), 'isUnread' => intval($this->unread)];
 }
コード例 #5
0
ファイル: Viewtility.php プロジェクト: amigobv/chat
    public static function viewMessage($message, $status)
    {
        ?>
            <li class = 'media'>
                <div class = 'media-body <?php 
        echo $status == Status::UNREAD ? 'mark' : ' ';
        ?>
 '>
                    <p class='lead'><?php 
        echo $message->getTitle();
        ?>
<p>
                        <?php 
        echo $message->getContent();
        ?>
                        <br>
                    <div>
                        <small class = 'text-muted'>
                            <a class = 'pull-left' href = '#'>
                                            <span class = 'glyphicon glyphicon-user'>
                                                <?php 
        $author = DataManager::getUserById($message->getAuthor());
        echo $author->getUsername();
        ?>
                                            </span>
                            </a>

                            <?php 
        $id = $message->getID();
        switch ($status) {
            case Status::UNREAD:
                ?>
                                    <a href = '#' id = "<?php 
                echo $id;
                ?>
" class = 'glyphicon glyphicon-star-empty custom-star' onclick='setPrior(<?php 
                echo $id;
                ?>
)'></a>
                                    <a href = '#' id = "<?php 
                echo $id;
                ?>
" class = 'glyphicon glyphicon-remove customRemoveActive' onclick='removeMessage(<?php 
                echo $id;
                ?>
)'></a>
                                    <?php 
                break;
            case Status::READ:
                ?>
                                    <a href = '#' id = '<?php 
                echo $id;
                ?>
' class = 'glyphicon glyphicon-star-empty custom-star' onclick='setPrior(<?php 
                echo $id;
                ?>
)'></a>
                                    <a href = '#' id = "<?php 
                echo $id;
                ?>
" class = 'glyphicon glyphicon-remove customRemoveActive' onclick='removeMessage(<?php 
                echo $id;
                ?>
)'></a>
                                    <?php 
                break;
            case Status::ANSWERED:
                ?>
                                    <a href = '#' id = '<?php 
                echo $id;
                ?>
' class = 'glyphicon glyphicon-star-empty custom-star' onclick='setPrior(<?php 
                echo $id;
                ?>
)'></a>
                                    <?php 
                break;
            case Status::PRIOR:
                ?>
                                    <a href = '#' id = '<?php 
                echo $id;
                ?>
' class = 'glyphicon glyphicon-star custom-star' onclick='resetPrior(<?php 
                echo $id;
                ?>
)'></a>
                                    <?php 
                break;
            default:
            case Status::DELETED:
                break;
        }
        ?>
                        </small>
                    </div>
                </div>
                <hr>
            </li>
    <?php 
    }