예제 #1
0
            <center><div id='loadingImage'></div></center>
             <div id='preview'></div>
            <?php 
if ($posts) {
    foreach ($posts as $p) {
        ?>
                <?php 
        $userId = $p['user_id'];
        $user = UserProfile::model()->findByAttributes(array('user_id' => $userId));
        if (!empty($user->first_name)) {
            $userName = ucfirst($user->first_name) . ' ' . ucfirst($user->last_name);
        } else {
            $users = User::model()->findByPk($userId);
            $userName = $users['username'];
        }
        $postTag = PostTagging::model()->findAll('post_id=:postId', array(':postId' => $p['id']));
        if (!isset($p['page_id'])) {
            if (count($postTag) > 0) {
                foreach ($postTag as $pt) {
                    if ($pt->user_id == Yii::app()->user->userId) {
                        ?>
                        <table id ="row_<?php 
                        echo $pt->post_id;
                        ?>
" class="well-for-table"  style="margin-bottom:15px">
                    <tr>
                        <?php 
                        if (!empty($user->image)) {
                            ?>
                        <td><img height="50" width="50" src="<?php 
                            echo $this->geUserImage($user->user_id);
예제 #2
0
 public function actionViewProfile($userId)
 {
     $this->layout = "layout_profile";
     $user = UserProfile::model()->find('user_id=:userId', array(':userId' => $userId));
     $country = Country::model()->find('id=:cId', array(':cId' => $user->country_id));
     $gender = Gender::model()->find('id=:gId', array(':gId' => $user->gender));
     $userFriend = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => Yii::app()->user->userId, ':friendId' => $user->user_id, ':status' => 0));
     $userFriend2 = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => $user->user_id, ':friendId' => Yii::app()->user->userId, ':status' => 0));
     $isFriend = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => Yii::app()->user->userId, ':friendId' => $user->user_id, ':status' => 1));
     $isFriend2 = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => $user->user_id, ':friendId' => Yii::app()->user->userId, ':status' => 1));
     //$posts = Post::model()->findAll(array('select' => '*','condition' => 'user_id=:userId','params' => array(':userId' => $userId),'order'=>'date DESC'));
     //$posts = PostTagging::model()->with('post')->findAll(array('select' => '*','distinct'=>true,'condition' => 't.user_id=:userId OR t.sender_id=:userId','params' => array(':userId' => $userId),'order'=>'post.date DESC'));
     $posts = PostTagging::model()->findAllBySql("SELECT DISTINCT( post_id ) AS post_id FROM post_tagging,posts WHERE post_tagging.user_id={$userId} OR post_tagging.sender_id={$userId} ORDER By post_tagging.id DESC");
     if (!empty($posts)) {
         foreach ($posts as $p) {
             $post[] = Post::model()->find(array('select' => '*', 'condition' => 'id=:postId', 'params' => array(':postId' => $p->post_id), 'order' => 'date DESC'));
         }
     } else {
         $post = Null;
     }
     $CheckuserFriend = UserFriend::model()->find('(user_id=:userId AND friend_id=:friendId) OR (user_id=:friendId AND friend_id=:userId) AND status=1', array(':userId' => Yii::app()->user->userId, ':friendId' => $userId));
     $this->render('viewprofile', array('posts' => $post, 'model' => $user, 'country' => $country, 'gender' => $gender, 'userFriend' => $userFriend, 'userFriend2' => $userFriend2, 'isFriend' => $isFriend, 'isFriend2' => $isFriend2, 'checkFriend' => $CheckuserFriend));
 }