public function read() { // Adding JavaScript file for Ajax Comment $this->design->addJs(PH7_LAYOUT . PH7_SYS . PH7_MOD . $this->registry->module . PH7_SH . PH7_TPL . PH7_TPL_MOD_NAME . PH7_SH . PH7_JS, 'comment.js'); $this->sTitle = t('Read Comment'); $this->view->page_title = $this->sTitle; $this->view->meta_description = $this->sTitle; $this->view->h1_title = $this->sTitle; $this->view->h4_title = CommentCore::count($this->iId, $this->sTable); $oPage = new Page(); $this->view->total_pages = $oPage->getTotalPages($this->oCommentModel->total($this->iId, $this->sTable), 15); $this->view->current_page = $oPage->getCurrentPage(); $oComment = $this->oCommentModel->read($this->iId, 1, $oPage->getFirstItem(), $oPage->getNbItemsByPage(), $this->sTable); unset($oPage); if (!empty($oComment)) { $this->view->avatarDesign = new AvatarDesignCore(); // Avatar Design Class $this->view->member_id = $this->session->get('member_id'); $this->view->csrf_token = (new Framework\Security\CSRF\Token())->generate('comment'); $this->view->comment = $oComment; } else { $this->_notFound(); } $this->output(); }
/** * Delete a comment. * * @param integer $iRecipientId The Comment Recipient ID. * @param string $sTable The Comment Table. * @return boolean Returns TRUE on success, FALSE on failure. */ public static function deleteRecipient($iRecipientId, $sTable) { $sTable = CommentCore::checkTable($sTable); $iRecipientId = (int) $iRecipientId; $rStmt = Db::getInstance()->prepare('DELETE FROM' . Db::prefix('Comments' . $sTable) . 'WHERE recipient = :recipient'); $rStmt->bindValue(':recipient', $iRecipientId, \PDO::PARAM_INT); return $rStmt->execute(); }
/** * To prevent spam! * * @param integer $iSenderId * @param integer $iWaitTime In minutes! * @param string $sCurrentTime In date format: 0000-00-00 00:00:00 * @param string $sTable * @return boolean Return TRUE if the weather was fine, otherwise FALSE */ public function checkWaitSend($iSenderId, $iWaitTime, $sCurrentTime, $sTable) { $sTable = CommentCore::checkTable($sTable); $rStmt = Db::getInstance()->prepare('SELECT commentId FROM' . Db::prefix('Comments' . $sTable) . 'WHERE sender = :sender AND DATE_ADD(createdDate, INTERVAL :waitTime MINUTE) > :currentTime LIMIT 1'); $rStmt->bindValue(':sender', $iSenderId, \PDO::PARAM_INT); $rStmt->bindValue(':waitTime', $iWaitTime, \PDO::PARAM_INT); $rStmt->bindValue(':currentTime', $sCurrentTime, \PDO::PARAM_STR); $rStmt->execute(); return $rStmt->rowCount() === 0; }
protected function totalComments($sTable, $iDay = 0) { CommentCore::checkTable($sTable); $iDay = (int) $iDay; $sSqlDay = $iDay > 0 ? ' WHERE (createdDate + INTERVAL ' . $iDay . ' DAY) > NOW()' : ''; $rStmt = Db::getInstance()->prepare('SELECT COUNT(commentId) AS totalComments FROM' . Db::prefix('Comments' . $sTable) . $sSqlDay); $rStmt->execute(); $oRow = $rStmt->fetch(\PDO::FETCH_OBJ); return (int) $oRow->totalComments; }