当前位置: 首页>>代码示例>>PHP>>正文


PHP BuckysUser::updateStats方法代码示例

本文整理汇总了PHP中BuckysUser::updateStats方法的典型用法代码示例。如果您正苦于以下问题:PHP BuckysUser::updateStats方法的具体用法?PHP BuckysUser::updateStats怎么用?PHP BuckysUser::updateStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BuckysUser的用法示例。


在下文中一共展示了BuckysUser::updateStats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteReply

 /**
  * Delete Reply
  *
  * @param Int $replyID
  * @return bool
  */
 public static function deleteReply($replyID)
 {
     global $db;
     $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_REPLIES . " WHERE replyID=%d", $replyID);
     $reply = $db->getRow($query);
     if ($reply) {
         if ($reply['status'] == 'publish') {
             //Getting Topic
             $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=%d", $reply['topicID']);
             $topic = $db->getRow($query);
             //Update Replies Count For Topic
             $query = "UPDATE " . TABLE_FORUM_TOPICS . " SET `replies`=`replies` - 1 WHERE topicID=" . $reply['topicID'];
             $db->query($query);
             //Update Replies Count For Category
             $query = "UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies`=`replies` - 1 WHERE categoryID=" . $topic['categoryID'];
             $db->query($query);
             $db->query("UPDATE " . TABLE_USERS . " SET `posts_count`=`posts_count` - 1 WHERE userID=" . $reply['creatorID']);
             $db->query("UPDATE " . TABLE_USERS . " SET `posts_rating`=`posts_rating`" . ($reply['votes'] > 0 ? '-' : '+') . abs($reply['votes']) . " WHERE userID=" . $reply['creatorID']);
             //Update Stats
             BuckysUser::updateStats($topic['creatorID'], 'replies', -1);
             BuckysUser::updateStats($reply['creatorID'], 'voteUps', -1 * $reply['votes']);
         }
         //Remove Reply Votes
         $query = "DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID=" . $reply['replyID'];
         $db->query($query);
         //Delete Frome Reports Table
         $query = "DELETE FROM " . TABLE_REPORTS . " WHERE objectType='reply' AND objectID=" . $reply['replyID'];
         $db->query($query);
         //Remove Reply
         $query = "DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE replyID=" . $reply['replyID'];
         $db->query($query);
         BuckysForumTopic::updateTopicLastReplyID($reply['topicID']);
         BuckysForumCategory::updateCategoryLastTopicID($topic['categoryID']);
         return true;
     }
     return false;
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:43,代码来源:class.BuckysForumReply.php

示例2: deleteComment

 /**
  * @param $userID
  * @param $commentID
  * @return bool
  */
 public static function deleteComment($userID, $commentID)
 {
     global $db;
     $query = $db->prepare("SELECT c.commentID, c.postID FROM " . TABLE_COMMENTS . " AS c LEFT JOIN " . TABLE_POSTS . " AS p ON p.postID=c.postID WHERE c.commentID=%s AND (c.commenter=%s OR p.poster=%s)", $commentID, $userID, $userID);
     $row = $db->getRow($query);
     if (!$row) {
         return false;
     } else {
         $cID = $row['commentID'];
         $postID = $row['postID'];
         $db->query('DELETE FROM ' . TABLE_COMMENTS . " WHERE commentID=" . $cID);
         //Remove Activity
         $db->query('DELETE FROM ' . TABLE_MAIN_ACTIVITIES . " WHERE actionID=" . $cID);
         //Remove From Report
         $db->query('DELETE FROM ' . TABLE_REPORTS . " WHERE objectType='comment' AND objectID=" . $cID);
         //Update comments on the posts table
         $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `comments`=`comments` - 1 WHERE postID=%d', $postID);
         $db->query($query);
         $postData = BuckysPost::getPostById($postID);
         //Update User Stats
         BuckysUser::updateStats($postData['poster'], 'comments', -1);
         return true;
     }
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:29,代码来源:class.BuckysComment.php

示例3: likePost

 /**
  * Like Post
  *
  * @param int $userID
  * @param int $postID
  * @param $action
  * @param bool $checkToken
  * @return bool|int|null|string
  */
 public static function likePost($userID, $postID, $action, $checkToken = true)
 {
     global $db;
     $post = BuckysPost::getPostById($postID);
     if ($checkToken && !buckys_check_form_token('request')) {
         buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
         return false;
     }
     if (!$post || $post['poster'] == $userID) {
         buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
         return false;
     }
     if ($post['visibility'] == 0 && !BuckysFriend::isFriend($userID, $post['poster'])) {
         buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
         return false;
     }
     if (!BuckysUsersDailyActivity::checkUserDailyLimit($userID, 'likes')) {
         buckys_add_message(sprintf(MSG_DAILY_LIKES_LIMIT_EXCEED_ERROR, USER_DAILY_LIMIT_LIKES), MSG_TYPE_ERROR);
         return false;
     }
     //Check already like it or not
     $query = $db->prepare("SELECT likeID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID);
     $likeId = $db->getVar($query);
     if ($action == 'likePost') {
         if ($likeId) {
             buckys_add_message(MSG_ALREADY_LIKED_POST, MSG_TYPE_ERROR);
             return false;
         }
         BuckysUsersDailyActivity::addLikes($userID);
         //Like This post
         $rs = $db->insertFromArray(TABLE_POSTS_LIKES, ['userID' => $userID, 'postID' => $postID]);
         //Update likes on the posts table
         $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` + 1 WHERE postID=%d', $postID);
         $db->query($query);
         //Add Activity
         $activityId = BuckysActivity::addActivity($userID, $postID, 'post', 'like', $rs);
         //Add Notification
         BuckysActivity::addNotification($post['poster'], $activityId, BuckysActivity::NOTIFICATION_TYPE_LIKE_POST);
         //Increase Hits
         BuckysHit::addHit($postID, $userID);
         //Update User Stats
         BuckysUser::updateStats($post['poster'], 'likes', 1);
         return $rs;
     } else {
         if ($action == 'unlikePost') {
             if (!$likeId) {
                 buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
                 return false;
             }
             BuckysUsersDailyActivity::addLikes($userID);
             $query = $db->prepare("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID);
             $db->query($query);
             //Update likes on the posts table
             $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` - 1 WHERE postID=%d', $postID);
             $db->query($query);
             //Increase Hits
             BuckysHit::removeHit($postID, $userID);
             //Update User Stats
             BuckysUser::updateStats($post['poster'], 'likes', -1);
             return true;
         }
     }
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:72,代码来源:class.BuckysPost.php

示例4: removeAllFollowersByPageID

 /**
  * Remove page followers when removing page
  *
  * @param mixed $pageID
  */
 public function removeAllFollowersByPageID($pageID)
 {
     global $db;
     if (!is_numeric($pageID)) {
         return;
     }
     //Getting Followers
     $query = $db->prepare("SELECT userID FROM " . TABLE_PAGES . " WHERE pageID=%d", $pageID);
     $pageCreatorId = $db->getVar($query);
     //Getting Followers
     $query = $db->prepare("SELECT count(*) FROM " . TABLE_PAGE_FOLLOWERS . " WHERE pageID=%d", $pageID);
     $followers = $db->getVar($query);
     if ($followers > 0) {
         BuckysUser::updateStats($pageCreatorId, 'pageFollowers', -1 * $followers);
     }
     $query = sprintf("DELETE FROM %s WHERE pageID=%d", TABLE_PAGE_FOLLOWERS, $pageID);
     $db->query($query);
     return;
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:24,代码来源:class.BuckysPageFollower.php

示例5: voteTopic

 /**
  * Cast a vote on a topic
  *
  * @param Int $userID : voterID
  * @param $topicID
  * @param Int $voteType : 1: Thumb up, -1: Thumb Down
  * @return Int|null|string
  */
 public static function voteTopic($userID, $topicID, $voteType)
 {
     global $db, $TNB_GLOBALS;
     //Check Reply ID
     $query = $db->prepare("SELECT topicID, votes, creatorID FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=%d AND STATUS='publish'", $topicID);
     $topic = $db->getRow($query);
     if (!$topic) {
         return MSG_INVALID_REQUEST;
     }
     $topicID = $topic['topicID'];
     $votes = $topic['votes'];
     //Check the user already casted his vote or not
     $query = $db->prepare("SELECT voteID FROM " . TABLE_FORUM_VOTES . " WHERE objectID=%d AND voterID=%d AND objectType='topic'", $topicID, $userID);
     $voteID = $db->getVar($query);
     if ($voteID) {
         return MSG_ALREADY_CASTED_A_VOTE;
     }
     //Add Vote
     $voteID = $db->insertFromArray(TABLE_FORUM_VOTES, ['objectID' => $topicID, 'voterID' => $userID, 'objectType' => 'topic', 'voteStatus' => $voteType, 'voteDate' => date('Y-m-d H:i:s')]);
     if (!$voteID) {
         return $db->getLastError();
     }
     $votes += $voteType;
     $db->update('UPDATE ' . TABLE_FORUM_TOPICS . ' SET `votes` = ' . $votes . ' WHERE topicID=' . $topicID);
     //Update user ragings
     $db->query("UPDATE " . TABLE_USERS . " SET `posts_rating`=`posts_rating` " . ($voteType > 0 ? '+' : '-') . " 1 WHERE userID=" . $topic['creatorID']);
     if ($voteType > 0) {
         //Update User Stats
         BuckysUser::updateStats($topic['creatorID'], 'voteUps', 1);
     }
     return $votes;
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:40,代码来源:class.BuckysForumTopic.php


注:本文中的BuckysUser::updateStats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。