*/ class MMModGuestbookSvc { /** * stores a entry, creates a new entry if id is null * @return MMModGuestbookEntry the stored entry */ public static function storeEntry(MMModGuestbookEntry $entry) { $db = \MCMS\System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $db->isTransactionSupported() and $db->commit(); } /** * fetches a board * @return MMModGuestbookEntry the board, or null if it dosent exist */ public static function getEntry($id) { $db = \MCMS\System::getInstance()->getDB(); $id = (int) $id; return $db->getObject("SELECT * FROM ".$db->escapeTableName('m_mcms.guestbook_entries')." WHERE id=".$id,'MMModGuestbookEntry'); } /** * @return array of MMModGuestbookEntry */ public static function getPageEntries($site, $instance, $page, $pagesize) { $db = \MCMS\System::getInstance()->getDB(); $start = $page*$pagesize; $sql = 'SELECT * FROM '.$db->escapeTableName('m_mcms.guestbook_entries'); $sql .= ' WHERE site_id='.$site.' AND instance='.$db->escapeValue($instance); $sql .= ' ORDER BY created_at DESC'; return $db->getObjectList($sql,'MMModGuestbookEntry',NULL,$pagesize,$start); } public static function getPageCount($site, $instance, $pagesize) { $db = \MCMS\System::getInstance()->getDB(); $where = 'WHERE site_id='.$site.' AND instance='.$db->escapeValue($instance); $count = $db->getObject("SELECT COUNT(id) AS c FROM ".$db->escapeTableName('m_mcms.guestbook_entries').' '.$where)->c; $pages = ceil($count/$pagesize); return $pages; } /** * removes a board and all its posts and topics * @return boolean true on success */ public static function deleteEntry(MMModGuestbookEntry $board) { $db = \MCMS\System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $db->isTransactionSupported() and $db->commit(); } /** * stores a board, creates a new entry if id is null * @return MMModBoardBoard the stored board */ public static function storeComment(MMModGuestbookComment $comment) { $db = \MCMS\System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $db->isTransactionSupported() and $db->commit(); } /** * fetches a board * @return MMModGuestbookComment the board, or null if it dosent exist */ public static function getComment($id) { $db = \MCMS\System::getInstance()->getDB(); $id = (int) $id; return $db->getObject("SELECT * FROM ".$db->escapeTableName('m_mcms.guestbook_comments')." WHERE id=".$id,'MMModGuestbookComment'); } /** * removes a board and all its posts and topics * @return boolean true on success */ public static function deleteComment(MMModGuestbookComment $comment) { $db = \MCMS\System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $db->isTransactionSupported() and $db->commit(); } } ?>