Ejemplo n.º 1
0
    public static function the_dialogs()
    {
        $current_user_id = theme_cache::get_current_user_id();
        $pm_lists = self::get_lists($current_user_id);
        $history_users = theme_custom_pm::get_histories($current_user_id);
        $dialog_histories = [];
        if (empty($pm_lists)) {
            return false;
        }
        foreach ($pm_lists as $user_id) {
            if ($history_users && isset($history_users[$user_id])) {
                foreach ($history_users[$user_id] as $history) {
                    if ($history->pm_author == $user_id || $history->pm_receiver == $user_id) {
                        if (!isset($dialog_histories[$user_id])) {
                            $dialog_histories[$user_id] = [$history->pm_id => $history];
                        }
                        $dialog_histories[$user_id][$history->pm_id] = $history;
                    }
                }
            }
            /** sort */
            foreach ($pm_lists as $v) {
                if (isset($dialog_histories[$v])) {
                    ksort($dialog_histories[$v]);
                }
            }
        }
        foreach ($pm_lists as $user_id) {
            ?>
<form action="javascript:;" id="pm-dialog-<?php 
            echo self::get_niceid($user_id);
            ?>
" class="pm-dialog">
	<div class="form-group pm-dialog-list">
		<?php 
            if (isset($history_users[$user_id])) {
                foreach ($dialog_histories[$user_id] as $history) {
                    $name = $current_user_id == $history->pm_author ? ___('Me') : theme_cache::get_the_author_meta('display_name', $user_id);
                    ?>
				<section class="pm-dialog-<?php 
                    echo $current_user_id == $history->pm_author ? 'me' : 'sender';
                    ?>
">
					<div class="pm-dialog-bg">
						<h4>
							<span class="name"><a href="<?php 
                    echo theme_cache::get_author_posts_url($history->pm_author);
                    ?>
" target="_blank"><?php 
                    echo $name;
                    ?>
</a></span> 
							<span class="date"><?php 
                    echo date('Y/m/d H:i:s', strtotime($history->pm_date));
                    ?>
</span>
						</h4>
						<div class="media-content">
							<?php 
                    echo $history->pm_content;
                    ?>
						</div>
					</div>
				</section>
				<?php 
                }
                /** end dialog loop */
            }
            /** end if histories */
            ?>
	</div>
	<div class="form-group">
		<input type="text" id="pm-dialog-content-<?php 
            echo self::get_niceid($user_id);
            ?>
" name="content" class="pm-dialog-conteng form-control" placeholder="<?php 
            echo ___('Enter to send P.M.');
            ?>
" required title="<?php 
            echo ___('P.M. content');
            ?>
" autocomplete="off">
	</div>
	<div class="form-group">
		<button class="btn btn-success btn-block" type="submit"><i class="fa fa-check"></i>&nbsp;<?php 
            echo ___('Send P.M.');
            ?>
</button>
	</div>
</form>
		<?php 
        }
    }