public function addComment($blog_item_id, $content)
 {
     $user_id = session('user_id');
     $data['comment_user_id'] = $user_id;
     $data['blogitem_id'] = $blog_item_id;
     $data['content'] = $content;
     $this->model->add($data);
     $like_model = new LikeModel();
     $like_model->addComment($blog_item_id);
 }
Example #2
0
 public function DiscussionController_InsideCommentMeta_Handler($Sender)
 {
     $Session = Gdn::Session();
     $User = $Session->User;
     $UID = $User->UserID;
     $DiscussionModel = new DiscussionModel();
     $CommentModel = new CommentModel();
     $Discussion = $DiscussionModel->GetID($DiscussionID);
     if (!($Sender->EventArguments['Type'] == 'Discussion')) {
         $DiscussionID = $Sender->EventArguments['Object']->DiscussionID;
         $ID = $Sender->EventArguments['Object']->CommentID;
         $Model = new CommentModel();
         $Data = $Model->GetID($ID);
         $Likes = $this->LikeModel->GetCommentLikes($ID);
         $Url = $DiscussionID . '/comment/' . $ID;
     }
     $InsertID = $Data->InsertUserID;
     if ($InsertID == $UID) {
         $Self = TRUE;
     } else {
         $Self = FALSE;
     }
     // Check for permission.
     if (!Gdn::Session()->UserID) {
         $Self = TRUE;
     }
     if (!CheckPermission('Plugins.LikeThis.AllowedToLike')) {
         $Self = TRUE;
     }
     $LikeDisplay = $this->FormatLikes($Likes, $Url, $UID, $Self);
     echo '<span class="MItem Like">' . $LikeDisplay . '</span>';
 }
Example #3
0
 public function getLikesByUserId($userId)
 {
     $conditions = 'userId=:userId';
     $params = array(':userId' => $userId);
     $records = LikeRecord::model()->findAll($conditions, $params);
     return LikeModel::populateModels($records);
 }
Example #4
0
 public function checkUserLiked()
 {
     $user = Yii::app()->user;
     if (!$user->isGuest) {
         $model = LikeModel::model()->findByAttributes(array('user_id' => $user->id, 'model' => $this->getClassName(), 'object_id' => $this->getOwner()->primaryKey));
         if (!isset($model)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #5
0
 public function create($diary_id, $user_id)
 {
     if (empty(self::$conn)) {
         self::$conn = $this->connectPdo();
     }
     $sql = "INSERT INTO like_diary(diary_id,user_id)\r\n                VALUE(?,?)";
     $stmt = self::$conn->prepare($sql);
     $stmt->bindParam(1, $diary_id);
     $stmt->bindParam(2, $user_id);
     if ($stmt->execute()) {
         return true;
     } else {
         return false;
     }
 }
Example #6
0
<?php

// bai dang lay tu thong bao
session_start();
include '../model/diary_model.php';
include '../model/comment_model.php';
include '../model/notify_model.php';
include '../model/user_model.php';
include '../model/like_model.php';
include '../model/friend_model.php';
$f = new FriendModel();
$l = new LikeModel();
$t = new DIaryModel();
$c = new CommentModel();
$n = new NotifyModel();
$m = new NotifyModel();
$u = new userModel();
$diary_id = $_GET['diary_id'];
$diary = $t->getDiary($diary_id);
$id_notify = $_GET['id_nf'];
$m->notifyReed($id_notify);
include 'header.php';
$i = 0;
?>
  </div>
  </div>
    <div class="container">
  		<?php 
if ($diary == NULL) {
    echo '<div class="well">';
    echo 'bai dang khong hop le </div>';
 /**
  * 跳到repost页面
  * url定义为Home/repost/blog_id/xxxx
  * post: blog_item_id
  */
 public function repost()
 {
     if (!$this->hasLoginCheck()) {
         return;
     }
     $blog_id = $_POST['blog_item_id'];
     $likeItem = new LikeModel();
     $likeItem->addRepost($blog_id);
     echo json_encode(array('status' => 'true'));
 }
Example #8
0
 function actionLike()
 {
     $user_id = $_REQUEST['uid'];
     $style_id = $_REQUEST['sid'];
     //记录存储到like表
     $likeModel = new LikeModel();
     $ret = LikeModel::model()->find('user_id=:userid and style_id=:styleid', array(':userid' => $user_id, ':styleid' => $style_id));
     if (!isset($ret)) {
         $likeModel->user_id = $user_id;
         $likeModel->style_id = $style_id;
         $likeModel->like_time = time();
         if (!$likeModel->save()) {
             echo "like record saved fail!";
         }
     } else {
         echo json_encode(array('result' => 0, 'comment' => "you have liked it!"));
         return;
     }
     //修改style表,like_num 加1
     $styleModel = new StyleModel();
     $connection = Yii::app()->db;
     $sql = "select like_num from tbl_style where _id = :style_id";
     $command = $connection->createCommand($sql);
     $tmp = $command->query(array(':style_id' => $style_id))->readAll();
     $styleModel->updateByPk($style_id, array('like_num' => $tmp[0]["like_num"] + 1));
     echo json_encode(array('result' => 1, 'res' => array('style_id' => $likeModel->style_id, 'like_num' => $tmp[0]["like_num"] + 1)));
 }