<?php

/**
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
// No direct access
defined('_JEXEC') or die;

jimport('joomla.updater.update');

class SPStgSrvModelTransfer extends JModelLegacy {

    public $post;

    function getPost($data) {

        $result = 'success';

        $comm_id = $data['comm_id'];

        //get msg
        $source = new CYENDSource();
        $source_db = $source->source_db;
        $source_query = $source_db->getQuery(true);

        //$source_query->select('a.id, a.parent_id, a.stage_id, a.msg, a.status, a.updated');
        $source_query->select('a.msg');
        $source_query->from('#__spstgmng_comm as a');
        $source_query->where('a.id = ' . (int) $comm_id);
        $source_db->setQuery($source_query);
        if (!$source_db->query())
            return $source_db->getErrorMsg();
        $msg = $source_db->loadResult();
        if (is_null($msg))
            return JText::_('COM_SPSTGSRV_STATUS_FAIL');

        $this->post = json_decode($msg);

        if ($result) {
            return 'success';
        } else {
            return JText::_('COM_SPSTGSRV_STATUS_FAIL');
        }
    }

}
