<?php if ($p->user_id == Yii::app()->user->userId) { ?> <span id="del_<?php echo $p->id; ?> "><i class="icon-eye-open"></i><a href="javascript:void(0)" onclick="deletePost(<?php echo $p->id; ?> )">DELETE</a></span></td> <?php } ?> </tr> <?php $comments = CommentBussinessPage::model()->findAll(array('select' => '*', 'condition' => "post_id = {$p->id}", 'order' => 'date DESC')); if ($comments) { foreach ($comments as $c) { ?> <?php $userId1 = $c->user_id; $user1 = UserProfile::model()->findByAttributes(array('user_id' => $userId1)); if (!empty($user1->first_name)) { $userName1 = ucfirst($user1->first_name) . ' ' . ucfirst($user1->last_name); } else { $user2 = User::model()->findByAttributes(array('id' => $userId1)); $userName1 = $user2['username']; } ?> <tr> <td> </td>
public function actioncommentdelete($commentId, $text) { if ($text == 'post') { $comment = CommentPost::model()->find('id=:id', array('id' => $commentId)); $comment->delete(); } elseif ($text == 'page') { $comment = CommentBussinessPage::model()->find('id=:id', array('id' => $commentId)); $comment->delete(); } }
if ($p['user_id'] == Yii::app()->user->userId) { ?> <span id="del_<?php echo $p['id']; ?> "><i class="icon-eye-open"></i><a href="javascript:void(0)" onclick="deletePost(<?php echo $p['id']; ?> )">DELETE</a></span></td> <?php } ?> </tr> <?php $comments1 = CommentBussinessPage::model()->findAll(array('select' => '*', 'condition' => "post_id = {$p['id']}", 'order' => 'id ASC')); if ($comments1) { foreach ($comments1 as $c) { ?> <?php $userId1 = $c->user_id; $user1 = UserProfile::model()->findByAttributes(array('user_id' => $userId1)); if (!empty($user1->first_name)) { $userName1 = ucfirst($user1->first_name) . ' ' . ucfirst($user1->last_name); } else { $user2 = User::model()->findByAttributes(array('id' => $userId1)); $userName1 = $user2['username']; } ?> <tr id="comment_<?php echo $c->id;
public function actioncommentdelete($commentId) { //echo $commentId; $comment = CommentBussinessPage::model()->find('id=:id', array('id' => $commentId)); $comment->delete(); }