<?php

/**
 * @name          : Joomla Social Pinboard
 * @version	  : 1.5.0
 * @package       : apptha
 * @since         : Joomla 1.5
 * @author        : Apptha - http://www.apptha.com
 * @copyright     : Copyright (C) 2011 Powered by Apptha
 * @license       : http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 * @abstract      : Social Pinboard Module header
 * @Creation Date : August 2013
 * @Modified Date : August 2013
 * */

defined('_JEXEC') or die;

class ModRelatedArticlesHelper
{
	public static function GetRelatedArticles()
	{
            $db = JFactory::getDBO();
            $nullDate = $db->quote($db->getNullDate());
            $date = JFactory::getDate();
            $nowDate = $db->quote($date->toSql());
			$query = "SELECT #__content.created_by, #__users.name, #__content.introtext, #__content.id, #__content.title FROM #__content 
					  INNER JOIN #__users
					  ON #__users.id = #__content.created_by WHERE #__content.featured=1 
					  AND #__content.state=1 AND #__content.access=1 AND 
					  (#__content.publish_down>$nowDate OR #__content.publish_down=$nullDate) AND  
					  (#__content.publish_up<=$nowDate OR #__content.publish_up=$nullDate) ORDER BY #__content.id DESC LIMIT 3";
            $db->setQuery( $query );
            $rows = $db->loadObjectList();
            return $rows;
	}
}