<?php

/**
 * @package		SP Transfer
 * @subpackage	Components
 * @copyright	SP CYEND - All rights reserved.
 * @author		SP CYEND
 * @link		http://www.cyend.com
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

include_once JPATH_COMPONENT . '/models/com.php';

class SPTransferModelCom_Newsfeeds extends SPTransferModelCom
{

    public function categories($ids = null)    {
        $this->destination_table = $this->factory->getTable('Category', 'JTable');        
        $this->task->state = 2; //state for success
        
        parent::categories($ids);
    }
    public function newsfeeds($ids = null)    {
        JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_newsfeeds'.DS.'tables');
        $this->destination_table = $this->factory->getTable('Newsfeed', 'NewsfeedsTable');
        $this->task->query = 'SELECT * 
            FROM #__' . $this->task->name . '
            WHERE ' . $this->id . ' > 0';
        
        $this->items($ids);   
    }
    public function categories_fix($ids = null)    {       
        $this->destination_table = $this->factory->getTable('Category', 'JTable');        
        $this->task->state = 4; //state for success
        
        parent::categories_fix($ids);
    }
    public function newsfeeds_fix($ids = null)    {
        JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_newsfeeds'.DS.'tables');
        $this->destination_table = $this->factory->getTable('Newsfeed', 'NewsfeedsTable');
        $this->task->query = 'SELECT * 
            FROM #__' . $this->task->name . '
            WHERE catid > 0';
        
        $this->items_fix($ids);
    }
}
