/** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'discussions.css', 'components/com_discussions/assets/'); require_once JPATH_COMPONENT . DS . 'classes/user.php'; require_once JPATH_COMPONENT . DS . 'classes/helper.php'; $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $app = JFactory::getApplication(); $CofiHelper = new CofiHelper(); // get parameters $params = JComponentHelper::getParams('com_discussions'); // website root directory $_root = JURI::root(); ?> <div class="codingfish"> <?php if ($this->params->def('show_page_title', 1)) { ?> <div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?> ">
require_once JPATH_COMPONENT . DS . 'classes/user.php'; require_once JPATH_COMPONENT . DS . 'classes/helper.php'; ?> <div class="codingfish"> <?php echo "<script type='text/javascript'>"; echo "function confirmdelete() { "; echo "return confirm('" . JText::_('COFI_CONFIRM_DELETE') . "');"; echo "}"; echo "</script>"; $app = JFactory::getApplication(); $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $CofiHelper = new CofiHelper(); // set page title and description $document =& JFactory::getDocument(); $title = $document->getTitle(); // $siteName = $mainframe->getCfg('sitename'); $title = $this->subject . " - " . $this->categoryName; //$title = $title . " | " . $siteName; $document->setTitle($title); //$document->setDescription( $this->subject . " " . $this->categoryName); $_metaDescription = trim(ereg_replace("\n", " ", $this->metaDescription)); $_metaDescription = ereg_replace("\r", " ", $_metaDescription); $_metaDescription = ereg_replace("\"", " ", $_metaDescription); $_metaDescription = ereg_replace("<", " ", $_metaDescription); $_metaDescription = ereg_replace(">", " ", $_metaDescription); $_metaDescription = ereg_replace("/", " ", $_metaDescription); $_metaDescription = ereg_replace(' +', ' ', $_metaDescription);
/** * Delete post / thread * * @return integer */ private function deletePost($post) { $app = JFactory::getApplication(); $CofiHelper = new CofiHelper(); $db =& $this->getDBO(); // 1. get thread id $_threadQuery = "SELECT thread FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post . "'"; $db->setQuery($_threadQuery); $_threadId = $db->loadResult(); // 2. get parent id $_parentQuery = "SELECT parent_id FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post . "'"; $db->setQuery($_parentQuery); $_parentId = $db->loadResult(); // 3. get category id $_categoryQuery = "SELECT cat_id FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post . "'"; $db->setQuery($_categoryQuery); $_categoryId = $db->loadResult(); // 4. get user id $_userQuery = "SELECT user_id FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post . "'"; $db->setQuery($_userQuery); $_userId = $db->loadResult(); // Check if thread id = post id, means this is the original post OP // if OP then delete all posts in this thread (delete thread) // if not OP then delete single post if ($_threadId == $post) { // get post ids in this thread $sql = "SELECT id FROM" . $db->nameQuote('#__discussions_messages') . " WHERE thread='" . $_threadId . "'"; $db->setQuery($sql); $_postList = $db->loadAssocList(); // remove images of these posts if (count($_postList)) { foreach ($_postList as $_post) { $p_id = $_post['id']; // remove images $CofiHelper->deleteImagesByPostId($p_id); } $rootDir = JPATH_ROOT; $threadfolder = $rootDir . "/images/discussions/posts/" . $_threadId; if (is_dir($threadfolder)) { rmdir($threadfolder); } } // get users who posted in this thread $sql = "SELECT DISTINCT user_id FROM" . $db->nameQuote('#__discussions_messages') . " WHERE thread='" . $_threadId . "'"; $db->setQuery($sql); $_userList = $db->loadAssocList(); // delete thread ( all posts in it) from db $sql = "DELETE FROM " . $db->nameQuote('#__discussions_messages') . " WHERE thread='" . $_threadId . "'"; $db->setQuery($sql); $db->query(); // now update user stats if (count($_userList)) { foreach ($_userList as $_user) { $u_id = $_user['user_id']; // update user stats $result = $CofiHelper->updateUserStats($u_id); } } } else { // not OP // remove images belonging to this post $CofiHelper->deleteImagesByPostId($post); // delete post from db $sql = "DELETE FROM " . $db->nameQuote('#__discussions_messages') . " WHERE id='" . $post . "'"; $db->setQuery($sql); $db->query(); // change parent id of possible replies to this post $sql = "UPDATE " . $db->nameQuote('#__discussions_messages') . " SET parent_id = '" . $_parentId . "'" . " WHERE parent_id = '" . $post . "'"; $db->setQuery($sql); $result = $db->query(); // update category stats $result = $CofiHelper->updateThreadStats($_threadId); // update user stats $result = $CofiHelper->updateUserStats($_userId); } // update category stats $result = $CofiHelper->updateCategoryStats($_categoryId); // redirect link $redirectLink = JRoute::_("index.php?option=com_discussions&view=index"); $app->redirect($redirectLink, JText::_('COFI_POST_DELETED'), "notice"); return 0; }
/** * Renders the view * */ function display() { //global $mainframe; $document =& JFactory::getDocument(); $app = JFactory::getApplication(); $pathway =& $app->getPathway(); $CofiHelper = new CofiHelper(); $postings =& $this->get('Postings'); $pagination =& $this->get('Pagination'); $categoryId =& $this->get('CategoryId'); $categorySlug =& $this->get('CategorySlug'); $categoryName =& $this->get('CategoryName'); $categoryDescription =& $this->get('CategoryDescription'); $categoryImage =& $this->get('CategoryImage'); $forumBannerTop =& $this->get('ForumBannerTop'); $forumBannerBottom =& $this->get('ForumBannerBottom'); $subject =& $this->get('Subject'); $thread =& $this->get('Thread'); $threadId =& $this->get('ThreadId'); $threadSlug =& $this->get('ThreadSlug'); $stickyStatus =& $this->get('StickyStatus'); $lockedStatus =& $this->get('LockedStatus'); $metaDescription =& $this->get('MetaDescription'); $metaKeywords =& $this->get('MetaKeywords'); // get parameters // $params = &$mainframe->getParams(); $params =& $app->getParams(); $menus =& JSite::getMenu(); $menu = $menus->getActive(); /* if (is_object( $menu )) { $menu_params = new JParameter( $menu->params ); if (!$menu_params->get( 'page_title')) { $params->set('page_title', JText::_( 'Forums' )); } } else { $params->set('page_title', JText::_( 'Forums' )); } $document->setTitle( $params->get( 'page_title' ) ); */ //set breadcrumbs if (is_object($menu) && $menu->query['view'] != 'thread') { $pathway->addItem($categoryName, 'index.php?option=com_discussions&view=category&catid=' . $this->escape($categorySlug)); $pathway->addItem($subject, ''); } $pzitemid = $CofiHelper->getItemidByComponentName("com_primezilla"); // calculate jump point to last entry $_threadListLength = $params->get('threadListLength', '20'); $_numberOfPosts = $CofiHelper->getNumberOfPostsByThreadId($threadId); $_lastPostId = $CofiHelper->getLastPostIdByThreadId($threadId); if ($_numberOfPosts % $_threadListLength == 0) { $_start = $_numberOfPosts / $_threadListLength - 1; } else { $_start = floor($_numberOfPosts / $_threadListLength); } $_start = $_start * $_threadListLength; if ($_start == 0) { // first page = no limitstart $lastEntryJumpPoint = "#p" . $_lastPostId; } else { $lastEntryJumpPoint = "&limitstart=" . $_start . "#p" . $_lastPostId; } $this->assignRef('postings', $postings); $this->assignRef('pagination', $pagination); $this->assignRef('categoryId', $categoryId); $this->assignRef('categorySlug', $categorySlug); $this->assignRef('categoryName', $categoryName); $this->assignRef('categoryDescription', $categoryDescription); $this->assignRef('categoryImage', $categoryImage); $this->assignRef('forumBannerTop', $forumBannerTop); $this->assignRef('forumBannerBottom', $forumBannerBottom); $this->assignRef('subject', $subject); $this->assignRef('thread', $thread); $this->assignRef('threadId', $threadId); $this->assignRef('threadSlug', $threadSlug); $this->assignRef('stickyStatus', $stickyStatus); $this->assignRef('lockedStatus', $lockedStatus); $this->assignRef('pzitemid', $pzitemid); $this->assignRef('lastEntryJumpPoint', $lastEntryJumpPoint); $this->assignRef('params', $params); $this->assignRef('metaDescription', $metaDescription); $this->assignRef('metaKeywords', $metaKeywords); // display the view parent::display(); }
/** * Method to calculate the link to the last post * * @access public * @return String */ function getLinkToLastPostByThreadId($thread) { $params = JComponentHelper::getParams('com_discussions'); $CofiHelper = new CofiHelper(); $_threadListLength = $params->get('threadListLength', '20'); $_numberOfPosts = $CofiHelper->getNumberOfPostsByThreadId($thread); $_lastPostId = $CofiHelper->getLastPostIdByThreadId($thread); if ($_numberOfPosts % $_threadListLength == 0) { $_start = $_numberOfPosts / $_threadListLength - 1; } else { $_start = floor($_numberOfPosts / $_threadListLength); } $_start = $_start * $_threadListLength; if ($_start == 0) { // first page = no limitstart $_lastEntryJumpPoint = "#p" . $_lastPostId; } else { $_lastEntryJumpPoint = "&limitstart=" . $_start . "#p" . $_lastPostId; } $lastTMP = "index.php?option=com_discussions&view=thread&catid=" . $this->getCategorySlug() . "&thread=" . $this->getThreadSlugByThreadId($thread); $lastTMP .= $_lastEntryJumpPoint; $last = JRoute::_($lastTMP); return $last; }
/** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'discussions.css', 'components/com_discussions/assets/'); require_once JPATH_COMPONENT . DS . 'classes/user.php'; require_once JPATH_COMPONENT . DS . 'classes/helper.php'; $app = JFactory::getApplication(); $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $CofiHelper = new CofiHelper(); // get parameters $params = JComponentHelper::getParams('com_discussions'); // website root directory $_root = JURI::root(); $document =& JFactory::getDocument(); // RSS feed stuff $useRssFeeds = $params->get('useRssFeeds', 1); if ($useRssFeeds == 1) { $_RssTitle = JText::_('COFI_RSS_NEW_THREADS'); $_RssTitleCategory = JText::_('COFI_RSS_NEW_THREADS_IN') . " " . $this->categoryName; $config =& JFactory::getConfig(); $_suffix = $config->getValue('config.sef_suffix'); if ($_suffix == 0) { // no .html suffix $link = JRoute::_('index.php?option=com_discussions&format=feed');
/** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'discussions.css', 'components/com_discussions/assets/'); require_once JPATH_COMPONENT . DS . 'classes/user.php'; require_once JPATH_COMPONENT . DS . 'classes/helper.php'; $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $CofiHelper = new CofiHelper(); $app = JFactory::getApplication(); // website root directory $_root = JURI::root(); ?> <div class="codingfish"> <!-- Codingfish Extension Icon --> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="noborder"> <tr> <td colspan="2" align="left" class="noborder"> <h1 class="componentheading"> <?php $app->getMenu()->getActive()->title;
} ?> <!-- HTML Box Top --> <?php include 'components/com_discussions/includes/topmenu.php'; ?> <!-- show moderator how many posts wait for approval --> <?php if ($logUser->isModerator() == 1) { if ($logUser->isApprovalNotification() == 1) { $countposts = CofiHelper::getPostsWFM(); if ($countposts > 0) { // here is something to do for the moderator ?> <center> <div class="cofiPostsWaitingForApproval"> <?php $approveLink = JRoute::_('index.php?option=com_discussions&view=moderation&task=approve'); echo "<a href='{$approveLink}' title='" . JText::_('COFI_APPROVE_NEW_POSTS') . "'>"; echo "<b>"; echo $countposts; echo "</b>"; if ($countposts == 1) { echo " " . JText::_('COFI_POST_IS_WAITING_FOR_APPROVAL'); } else {
<?php /** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ require_once JPATH_COMPONENT . DS . 'classes/helper.php'; $CofiHelper = new CofiHelper(); // get parameters //$params = &$mainframe->getParams(); $params =& JComponentHelper::getParams('com_discussions'); $_showFooter = $params->get('showFooter', '1'); ?> <div class="cofiFooter"> <?php if ($_showFooter == '1') { // display codingfish footer ?> Discussions v<?php echo $CofiHelper->getVersion(); ?> <br /> (c) 2010-2011 <a href="http://www.codingfish.com" target="_blank" title="Codingfish">Codingfish</a> <?php } else { ?>
/** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'discussions.css', 'components/com_discussions/assets/'); require_once JPATH_COMPONENT . DS . 'classes/user.php'; require_once JPATH_COMPONENT . DS . 'classes/helper.php'; $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $CofiHelper = new CofiHelper(); $app = JFactory::getApplication(); // get parameters $params = JComponentHelper::getParams('com_discussions'); $replyListLength = $params->get('replyListLength', '0'); $_useFlickr = $params->get('useFlickr', '0'); // 0 no, 1 yes $_useYouTube = $params->get('useYouTube', '0'); // 0 no, 1 yes // website root directory $_root = JURI::root(); ?> <div class="codingfish">