Your IP : 216.73.216.251


Current Path : /home/digilove/public_html/components/com_marketplace/controllers/
Upload File :
Current File : /home/digilove/public_html/components/com_marketplace/controllers/follow.php

<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');
jimport('joomla.filesystem.file');
/**
 * MarketplaceControllerFollow class
 * 
 * @category Component
 * @package  Joomla
 * @author   WebKul software private limited <support@webkul.com>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link     Technical Support:  webkul.uvdesk.com
 */
class MarketplaceControllerFollow extends JControllerLegacy
{
    /**
     * Display function
     *
     * @param boolean $cachable  var
     * @param array   $urlparams var
     * 
     * @return void
     */
    function display($cachable = false, $urlparams = array())
    {
        parent::display();
    }
    /**
     * SearchFollower function
     *
     * @return void
     */
    function searchFollower()
    {
        $app = JFactory::getApplication();
        $_input = $app->input;

        $sel_id = $_input->getInt('seller', 0);
        $search=$_input->getString('srch', '');
        $start=$_input->getInt('start', 0);
        $limit=$_input->getInt('limit', 0);
        $model=$this->getModel('follow');
        $result=$model->getFollower($sel_id, $search, $start, $limit);
        if (empty($result)) {
            echo "<tr style='width:100%;padding-left:1%'><td style='pa".
            "dding-left:0px'  colspan='3'><div class='aler".
            "t alert-info'><strong>Info!</strong>".JText::_('NO_RECORD_FOUND').
            "</div></td></tr>";
            JFactory::getApplication()->close();
        }
        $pro='';
        $k=0;
        $i=0;
        $config=JFactory::getConfig();
        $offset=$config->get('offset');
        foreach ($result as $foll) {
            $jdate=JFactory::getDate($foll->date_follow, $offset);
            $foll->date_follow=$jdate->format('d-F-Y', true);
            $pro.='<tr class="rw_pg mprow row'.$k.'"><td data-title='.
            JText::_('FOLLOWER_EMAIL').'><p style="word-wrap:break-wo'.
            'rd;text-align:center">'.$foll->follower_email.'</p></td><t'.
            'd data-title='.JText::_('FOLLOWER_NAME').'><p style="word-w'.
            'rap:break-word;text-align:center">'.$foll->name.
            '</p></td><td data-title='.JText::_('FOLLOW_DATE').
            '><p style="word-wrap:break-word;text-align:center">'
            .$foll->date_follow.'</p></td></tr>';
            $i++; 
            $k = 1 - $k;
        }
        echo $pro;
        JFactory::getApplication()->close();
    }
    /**
     * Check Follower function
     *
     * @return void
     */
    function checkFollower()
    {
        $app = JFactory::getApplication();
        $_input = $app->input;
        $sel_id = $_input->getInt('seller', 0);
        $search=$_input->getInt('buyer_id', 0);
        $model=$this->getModel('follow');

        $search=JFactory::getUser($search)->email;
        $result=$model->checkFollower($sel_id, $search);
        
        if ($result==0) {
            $result=$model->follow($sel_id, $search);
            echo "1";
            JFactory::getApplication()->close();
        } else {
            $result=$model->unfollow($sel_id, $search);
            echo "0";
            JFactory::getApplication()->close();
        }
        
    }
}