/**
  * Approve Pending Replies
  *
  * @param Array $ids
  * @return bool|string
  */
 public static function approvePendingReplies($ids)
 {
     global $db;
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $ids = $db->escapeInput($ids);
     //Getting Topics for confirmation
     $query = "SELECT r.topicID, r.replyID, t.categoryID, r.creatorID, r.createdDate, t.creatorID AS topicCreatorID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='pending' AND r.replyID IN (" . implode(', ', $ids) . ")";
     $rows = $db->getResultsArray($query);
     if (!$rows) {
         return MSG_INVALID_REQUEST;
     }
     $forumNotification = new BuckysForumNotification();
     foreach ($rows as $row) {
         //Update Topic Status
         $db->updateFromArray(TABLE_FORUM_REPLIES, array('status' => 'publish', 'createdDate' => date('Y-m-d H:i:s')), array('replyID' => $row['replyID']));
         //Update Category Table
         $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies`=`replies` + 1, lastTopicID='" . $row['topicID'] . "' WHERE categoryID=" . $row['categoryID']);
         $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies`=`replies` + 1 WHERE topicID=" . $row['topicID']);
         $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET lastReplyID=" . $row['replyID'] . ", lastReplyDate='" . date('Y-m-d H:i:s') . "', lastReplierID=" . $row['creatorID'] . " WHERE topicID=" . $row['topicID'] . " AND lastReplyID < " . $row['replyID']);
         //Increase user posts count
         $db->query("UPDATE " . TABLE_USERS . " SET `posts_count`=`posts_count` + 1 WHERE userID=" . $row['creatorID']);
         //Add Notifications
         $forumNotification->addNotificationsForPendingPost($row['creatorID'], $row['topicID'], $row['replyID']);
         $forumNotification->addNotificationsForReplies($row['creatorID'], $row['topicID'], $row['replyID']);
         if ($row['topicCreatorID'] != $row['creatorID']) {
             $forumNotification->addNotificationsForTopic($row['topicCreatorID'], $row['topicID'], $row['replyID']);
         }
         //Update User Stats
         BuckysUser::updateStats($row['topicCreatorID'], 'replies', 1);
     }
     return true;
 }
 /**
  * Approve Pending Topics
  *
  * @param mixed $ids
  * @return bool|string
  */
 public static function approvePendingTopics($ids)
 {
     global $db;
     if (!is_array($ids)) {
         $ids = [$ids];
     }
     $ids = $db->escapeInput($ids);
     //Getting Topics for confirmation
     $query = "SELECT topicID, categoryID, creatorID FROM " . TABLE_FORUM_TOPICS . " WHERE STATUS='pending' AND topicID IN (" . implode(', ', $ids) . ")";
     $rows = $db->getResultsArray($query);
     if (!$rows) {
         return MSG_INVALID_REQUEST;
     }
     $forumNotification = new BuckysForumNotification();
     foreach ($rows as $row) {
         //Update Topic Status
         $db->updateFromArray(TABLE_FORUM_TOPICS, ['status' => 'publish', 'createdDate' => date('Y-m-d H:i:s')], ['topicID' => $row['topicID']]);
         //Update Category Table
         $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `topics`=`topics` + 1 WHERE categoryID=" . $row['categoryID']);
         $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `lastTopicID`=" . $row['topicID'] . " WHERE categoryID=" . $row['categoryID'] . " AND lastTopicID < " . $row['topicID']);
         //Increase user posts count
         $db->query("UPDATE " . TABLE_USERS . " SET `posts_count`=`posts_count` + 1 WHERE userID=" . $row['creatorID']);
         $forumNotification->addNotificationsForPendingPost($row['creatorID'], $row['topicID']);
     }
     return true;
 }