Exemple #1
0
	public function loadUsers() {

        $app	= JFactory::getApplication();
        $cfg = BidsHelperTools::getConfig();
        $jconfig = &JFactory::getConfig();

        if ( $cfg->bid_opt_nr_items_per_page > 0 )
        	$list_limit = $cfg->bid_opt_nr_items_per_page;
        else
			$list_limit = $jconfig->getValue('config.list_limit');

        // Get the pagination request variables
        $this->setState('limit', $app->getUserStateFromRequest('com_bids.limit','limit', $list_limit, 'int'));
        $this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));
        // In case limit has been changed, adjust limitstart accordingly
        $this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) :0));

        $this->setState('filter_order_Dir', $app->getUserStateFromRequest('com_bids.filter_order_Dir', 'filter_order_Dir', "ASC"));
        $this->setState('filter_order', $app->getUserStateFromRequest('com_bids.filter_order','filter_order', "start_date"));

		$query = $this->buildQuery();
		$list = $this->_getList((string) $query, $this->getState('limitstart'), $this->getState('limit'));

		$this->users = $list;
	}
Exemple #2
0
 function __construct($config = array())
 {
     parent::__construct($config);
     $cfg = BidsHelperTools::getConfig();
     $this->assignRef('cfg', $cfg);
     JHTML::stylesheet('com_bids.css', JURI::root() . 'administrator/components/com_bids/css/');
 }
Exemple #3
0
 function display()
 {
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $cfg = BidsHelperTools::getConfig();
     $where = array();
     $context = 'com_bids.bidsadminview.users';
     $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', '', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     $search = $app->getUserStateFromRequest($context . 'search', 'search', '', 'string');
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0, 'int');
     // In case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     if (!$filter_order) {
         $filter_order = 'u.name';
     }
     $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . '';
     if ($search) {
         $where[] = " username LIKE '%" . $db->getEscaped($search) . "%' ";
     }
     // Build the where clause of the content record query
     $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
     // Get the total number of records
     $query = "SELECT COUNT(*) " . "FROM #__users" . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     // Create the pagination object
     jimport('joomla.html.pagination');
     $page = new JPagination($total, $limitstart, $limit);
     $profileObject = BidsHelperTools::getUserProfileObject();
     $profileTable = $profileObject->getIntegrationTable();
     $profileKey = $profileObject->getIntegrationKey();
     $profileFields = array('verified', 'powerseller');
     if ($cfg->bid_opt_enable_acl) {
         $profileFields = array_merge($profileFields, array('isBidder', 'isSeller'));
     }
     $sqlFields = array();
     foreach ($profileFields as $pf) {
         $field = $profileObject->getFilterField($pf);
         if ($field) {
             $sqlFields[] = 'p.' . $field . ' AS ' . $pf;
         }
     }
     // Get the users
     $query = "SELECT\r\n                    u.id as userid1, u.username as username,u.name as name, u.email AS email,\r\n                    p.id as profid, " . (count($sqlFields) ? implode(',', $sqlFields) . ',' : '') . "\r\n    \t\t\t    COUNT(DISTINCT a.id) AS nr_auctions,\r\n\r\n    \t\t\t    COUNT(DISTINCT btbl.id) as nr_closed_bids,\r\n\r\n    \t\t\t    COUNT(DISTINCT IF(a.close_offer,a.id,NULL)) AS nr_closed_offers,\r\n    \t\t\t    GROUP_CONCAT(DISTINCT IF(a.close_offer,a.id,NULL)) AS closed_offers,\r\n\r\n    \t\t\t    COUNT(DISTINCT IF(a.close_offer,NULL,a.id)) AS nr_open_offers,\r\n    \t\t\t    GROUP_CONCAT(DISTINCT IF(a.close_offer,NULL,a.id)) AS open_offers,\r\n\r\n    \t\t\t    COUNT(DISTINCT IF(a.featured='none',NULL,a.id)) AS nr_featured_offers,\r\n    \t\t\t    GROUP_CONCAT(DISTINCT IF(a.featured='none',NULL,a.id)) AS featured_offers,\r\n\r\n    \t\t\t    AVG(urate.rating) AS rating_user,\r\n    \t\t\t    u.block\r\n                FROM #__users AS u\r\n                LEFT JOIN " . $profileTable . " AS p ON u.id=p." . $profileKey . "\r\n                LEFT JOIN #__bid_auctions AS a ON u.id=a.userid\r\n                LEFT JOIN #__bid_rate AS urate ON u.id=urate.user_rated_id\r\n                LEFT JOIN #__bids AS btbl ON u.id=btbl.userid AND btbl.accept=1 " . $where . " GROUP BY u.id " . $order;
     $db->setQuery($query, $page->limitstart, $page->limit);
     $rows = $db->loadObjectList();
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $lists['search'] = $search;
     JHTML::_('behavior.tooltip');
     $this->assignRef('lists', $lists);
     $this->assignRef('page', $page);
     $this->assignRef('rows', $rows);
     parent::display();
 }
Exemple #4
0
    function __construct() {

        $this->_my = JFactory::getUser();

        $cfg = BidsHelperTools::getConfig();

        if ($cfg->bid_opt_allow_guest_messaging) {
            array_push($this->anonTasks, "savemessage");
        }
    }
 static function fbLikeButton($user)
 {
     $cfg = BidsHelperTools::getConfig();
     if (!$cfg->bid_opt_fblikebutton) {
         return;
     }
     $iframeURL = 'https://www.facebook.com/plugins/like.php?href=' . urlencode(self::userProfileURL($user));
     $iframeAttribs = 'scrolling="no" frameborder="0" class="bidsFbLikeButton"';
     return JHTML::iframe($iframeURL, APP_EXTENSION . '_fbLikeButton_' . $user->userid, $iframeAttribs);
 }
 static function calendar($isodate, $name)
 {
     $cfg = BidsHelperTools::getConfig();
     $result = JHTML::_('calendar', $isodate, $name, $name, BidsHelperDateTime::dateFormatConversion($cfg->date_format));
     if ($isodate) {
         //ISODATES and JHtml::_('calendar') doesn't take kindly all formats
         $result = str_replace(' value="' . htmlspecialchars($isodate, ENT_COMPAT, 'UTF-8') . '"', ' value="' . htmlspecialchars(JHtml::date($isodate, $cfg->date_format, false), ENT_COMPAT, 'UTF-8') . '"', $result);
     }
     return $result;
 }
Exemple #7
0
    static function getUTCDate($d,$h,$m,$s) {

        $jconfig = JFactory::getConfig();
        $cfg = BidsHelperTools::getConfig();

        $error_msg = array();

        $date = BidsHelperTools::auctionDatetoIso($d);

        if(!$date) {
            return false;
        }

        $hour = $minutes = '00';
        if ($cfg->bid_opt_enable_hour) {
            $hour = $h ? $h : '00';
            $minutes = $m ? $m : '00';
            if ($hour > 24 || $minutes > 60) {
                return false;
            }
        }

        $DateTime = JFactory::getDate($date . ' ' . $hour . ':' . $minutes . ':00', $jconfig->getValue('config.offset'));
        if (!$DateTime) {
            return false;
        }

        $date = BidsHelperTools::auctionDatetoIso($d);

        if ($cfg->bid_opt_enable_hour) {
            $hour = intval($h);
            if($hour<0 || $hour>59) {
                $hour = 0;
            }
            if( 1==strlen($hour) ) {
                $hour = '0'.$hour;
            }
            $minutes = intval($m);
            if($minutes<0 || $minutes>59) {
                $minutes = 0;
            }
            if( 1==strlen($minutes) ) {
                $minutes = '0'.$minutes;
            }
        } else {
            $hour = $minutes = '00';
        }

        $DateTime = JFactory::getDate($date . ' ' . $hour . ':' . $minutes . ':00', $jconfig->getValue('config.offset'));

        return ($DateTime->toUnix() < time() ) ? JFactory::getDate()->toMySQL() : $DateTime->toMySQL();
    }
 function selectCategory($selected = null)
 {
     $cfg = BidsHelperTools::getConfig();
     $cat = JModel::getInstance('bidscategory', 'bidsModel');
     $cat->loadCategoryTree();
     $treeCat = $cat->get('categories');
     $spacer = '&nbsp;&nbsp;&nbsp;';
     $opts = array();
     $opts[] = JHTML::_('select.option', 0, JText::_('COM_BIDS_ALL_CATEGORIES'));
     foreach ($treeCat as $c) {
         $text = '&nbsp;' . str_repeat($spacer, $c->depth) . $c->title . PHP_EOL;
         $opts[] = JHTML::_('select.option', $c->id, $text, 'value', 'text', $cfg->bid_opt_leaf_posting_only && $c->nrSubcategories);
     }
     return JHTML::_('select.genericlist', $opts, 'cat', '', 'value', 'text', $selected);
 }
    function setPagination() {

        jimport('joomla.html.pagination');
        $app = JFactory::getApplication();
        $jconfig = &JFactory::getConfig();

        $cfg = BidsHelperTools::getConfig();

        $limit = $cfg->bid_opt_nr_items_per_page>0 ? $cfg->bid_opt_nr_items_per_page : $jconfig->getValue('config.list_limit');
        $this->setState('limit', $app->getUserStateFromRequest($this->context.'limit','limit',$limit));
        $this->setState('limitstart', JRequest::getVar('limitstart', 0, 'default', 'int'));
        // In case limit has been changed, adjust limitstart accordingly
        //$this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0));

        $this->pagination = new JPagination( $this->countTotal(), $this->getState('limitstart'), $this->getState('limit'));
    }
Exemple #10
0
    function getUserProfile($userid=null) {

        parent::getUserProfile($userid);

        $cfg = BidsHelperTools::getConfig();

        //override main profile behavior with some component specific rules
        if(!$cfg->bid_opt_enable_acl) {
            $this->isSeller = 1-$this->guest;
            $this->isBidder = 1-$this->guest;
        } else {
            $u = JFactory::getUser($userid);

            $this->isBidder = count( array_intersect($u->groups,$cfg->bid_opt_bidder_groups) ) ? 1:0;
            $this->isSeller = count( array_intersect($u->groups,$cfg->bid_opt_seller_groups) ) ? 1:0;
        }
    }
Exemple #11
0
	static function &getGalleryPlugin()
    {
        static $gallery;
        if (isset($gallery)&&is_object($gallery))
            return $gallery;
            	   
        $cfg= BidsHelperTools::getConfig();
		$gallery_name = "gl_".$cfg->bid_opt_gallery;
		require_once(JPATH_COMPONENT_SITE.DS."gallery".DS."$gallery_name.php");
        
		$gallery = new $gallery_name( AUCTION_PICTURES,
            $cfg->bid_opt_medium_width,
            $cfg->bid_opt_medium_height,
            $cfg->bid_opt_thumb_width,
            $cfg->bid_opt_thumb_height
         );
		return $gallery;
	}
Exemple #12
0
    function display($tmpl) {

        $database = JFactory::getDBO();
        $my = JFactory::getUser();
        $cfg = BidsHelperTools::getConfig();

        $lists = array();

        $user = BidsHelperTools::getUserProfileObject($my->id);
        JFilterOutput::objectHTMLSafe( $user, ENT_QUOTES );

        $opts = array();
        $opts[] = JHTML::_('select.option', '', JText::_('COM_BIDS_CHOOSE_COUNTRY'));

        $database->setQuery("SELECT name AS value,name AS text FROM `#__bid_country` WHERE active=1 order by name");
        $opts = array_merge($opts, $database->loadObjectList());

        $lists["country"] = JHTML::_('select.genericlist', $opts, 'country', 'class="inputbox required"', 'value', 'text', $user->country);

        $lists['token'] = JHtml::_('form.token');

        $lists["validate_custom_fields"] = " new Array()";
        $lists["validate_custom_fields_count"] = "0";

        $fields = CustomFieldsFactory::getFieldsList("user_profile");
        $fields_html=JHtml::_('customfields.displayfieldshtml',$user,$fields);

        JHTML::_('behavior.formvalidation');
        JHTML::script(JURI::root().'components/com_bids/js/validator/validator.js');

        $formAction =
                ( !$my->id && 'component'==$cfg->bid_opt_registration_mode && 'component'==$cfg->bid_opt_profile_mode ) ?
                (JUri::root().'index.php?option=com_users&task=registration.register') :
                (JUri::root().'/index.php?option=com_bids&task=saveuserdetails') ;

        $this->assign("custom_fields_html", $fields_html );
        $this->assign("user", $user);
        $this->assign("formAction", $formAction);
        $this->assign("lists", $lists);

        parent::display($tmpl);
    }
Exemple #13
0
 function display($id)
 {
     $database = JFactory::getDBO();
     $my = JFactory::getUser();
     $modelAuction = $this->getModel('auction');
     $auction = $modelAuction->get('auction');
     $lists = array();
     $lang = JFactory::getLanguage();
     $lang->load('com_bids', JPATH_SITE);
     $bidCfg = BidsHelperTools::getConfig();
     $lists = array();
     $lists['title'] = JHTML::_('editauction.inputTitle', $auction, 1);
     $lists['cats'] = JHTML::_('editauction.selectCategory', $auction, 1);
     //$lists['cats']    = JHTML::_('factorycategory.select','cat','',$auction->cat,false,false,true);
     $lists['published'] = JHTML::_('editauction.selectPublished', $auction, 1);
     $lists['tags'] = JHTML::_('editauction.inputTags', $auction, 1);
     $lists['shortDescription'] = JHTML::_('editauction.inputShortDescription', $auction, 1);
     $lists['description'] = JHTML::_('editauction.inputDescription', $auction, 1);
     $lists['auctiontype'] = JHTML::_('editauction.selectAuctionType', $auction, 1);
     $lists['automatic'] = JHTML::_('editauction.inputAutomatic', $auction, 1);
     $lists['binType'] = JHTML::_('editauction.selectBINType', $auction, 1);
     $lists['binPrice'] = JHTML::_('editauction.inputBINPrice', $auction, 1);
     $lists['autoAcceptBIN'] = JHTML::_('editauction.selectAutoAcceptBIN', $auction, 1);
     $lists['quantity'] = JHTML::_('editauction.inputQuantity', $auction, 1);
     $lists['enableSuggestions'] = JHTML::_('editAuction.selectEnableSuggestions', $auction, 1);
     $lists['minNumberSuggestions'] = JHTML::_('editAuction.inputMinNumberSuggestions', $auction, 1);
     $lists['currency'] = JHTML::_('editauction.selectCurrency', $auction, 1);
     $lists['initialPrice'] = JHTML::_('editauction.inputInitialPrice', $auction, 1);
     $lists['showMaxPrice'] = JHTML::_('editauction.selectShowMaxPrice', $auction, 1);
     $lists['showNumberBids'] = JHTML::_('editauction.selectShowNumberBids', $auction, 1);
     $lists['reservePrice'] = JHTML::_('editauction.inputReservePrice', $auction, 1);
     $lists['showReservePrice'] = JHTML::_('editauction.selectShowReservePrice', $auction, 1);
     $lists['minIncrease'] = JHTML::_('editauction.inputMinIncrease', $auction, 1);
     $lists['shippingPrice'] = JHTML::_('editAuction.inputShipmentPrice', $auction, 1);
     $lists['uploadImages'] = JHTML::_('editauction.uploadImages', $auction, 1);
     $lists['paymentInfo'] = JHTML::_('editauction.textPaymentInfo', $auction, 1);
     $lists['shipmentInfo'] = JHTML::_('editauction.textShipmentInfo', $auction, 1);
     //$lists[''] = JHTML::_('editauction.',$auction);
     $lists['currentLocalTime_field'] = JHTML::_('editAuction.currentLocalTime', $auction);
     $lists['startDate_field'] = JHTML::_('editAuction.editStartDate', $auction, 1);
     $lists['endDate_field'] = JHTML::_('editAuction.editEndDate', $auction, 1);
     $lists['editFormTitle'] = JHTML::_('editAuction.formTitle', $auction);
     $auction->links = JHTML::_('auctiondetails.createLinks', $auction);
     $fields = CustomFieldsFactory::getFieldsList("auctions");
     $fields_html = JHtml::_('listauctions.displayfieldshtml', $auction, $fields);
     $custom_fields_with_cat = $modelAuction->getNrFieldsWithFilters();
     $this->assign("custom_fields", $fields);
     $this->assign("custom_fields_html", $fields_html);
     $this->assign("custom_fields_with_cat", $custom_fields_with_cat ? 1 : 0);
     $this->assign('lists', $lists);
     $this->assign('auction', $auction);
     $this->assign('bidCfg', $bidCfg);
     JHtml::_('behavior.framework');
     JHtml::_('behavior.tooltip');
     JHtml::_('behavior.calendar');
     JHTML::_('behavior.formvalidation');
     JHtml::script(JURI::root() . 'components/com_bids/js/auctions.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/date.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/multifile.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/auction_edit.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/jquery/jquery.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/jquery/jquery.noconflict.js');
     JHTML::script(JURI::root() . 'components/com_bids/js/jquery/clock/jquery.clock.js');
     JHtml::script(JURI::base() . 'index.php?option=com_bids&task=jsgen&view=editauction&format=raw');
     JHtml::stylesheet(JURI::root() . 'components/com_bids/templates/default/bid_template.css');
     $user = BidsHelperTools::getUserProfileObject($auction->userid);
     $auction->userdetails = $user;
     $query = "update #__bid_messages set wasread=1 where userid2='{$my->id}' and auction_id='{$id}'";
     $database->setQuery($query);
     $database->query();
     $query = "update #__bid_auctions set newmessages=0 where id='{$id}'";
     $database->setQuery($query);
     $database->query();
     $feat[] = JHTML::_('select.option', 'none', JText::_('COM_BIDS_NONE'));
     $feat[] = JHTML::_('select.option', 'featured', JText::_('COM_BIDS_PAYMENT_FEATURED'));
     $lists['featured'] = JHTML::_('select.genericlist', $feat, 'featured', 'class="inputbox" id="featured" style="width:120px;"', 'value', 'text', $auction->featured);
     $database = JFactory::getDBO();
     $my = JFactory::getUser();
     $database->setQuery("select max(bid_price) from #__bids where auction_id='{$auction->id}'");
     $auction->max_bid = $database->loadResult();
     $database->setQuery("select * from #__bid_pictures where auction_id='{$auction->id}'");
     $photos = $database->loadObjectList();
     $query = "select m.*,u1.username as fromuser, u2.username as touser  from #__bid_messages m\r\n                            left join #__users u1 on u1.id = m.userid1\r\n                            left join #__users u2 on u2.id = m.userid2\r\n                            where m.auction_id='{$auction->id}'\r\n\r\n            ";
     // and (m.userid1 = '$my->id' or m.userid2 = '$my->id') */
     $database->setQuery($query);
     $adminMessages = $database->loadObjectList();
     $query = "\r\n            SELECT a.*,b.username, bp.max_proxy_price\r\n            FROM `#__bids` AS a\r\n            LEFT JOIN `#__users` b\r\n                ON a.userid=b.id\r\n            LEFT JOIN `#__bid_proxy` AS bp\r\n                ON a.id_proxy=bp.id AND bp.active=1\r\n            WHERE a.auction_id=" . intval($auction->id);
     $database->setQuery($query);
     $bids = $database->loadObjectList();
     JHTML::_('behavior.modal');
     JHTML::_('behavior.tooltip');
     jimport('joomla.filesystem.file');
     $this->assignRef('lists', $lists);
     $this->assignRef('bids', $bids);
     $this->assignRef('adminMessages', $adminMessages);
     $this->assignRef('photos', $photos);
     $this->assignRef('user', $user);
     $this->assignRef('auction', $auction);
     parent::display();
 }
Exemple #14
0
    protected function checkTCAgreed() {

        $cfg = BidsHelperTools::getConfig();
        if ('component' != $cfg->bid_opt_profile_mode) {
            return true;
        }

        $my = JFactory::getUser();
        $db = JFactory::getDbo();
        $db->setQuery("SELECT agree_tc FROM #__bid_users WHERE userid=" . $my->id);

        return $db->loadResult();
    }
    function onBeforeExecuteTask(&$stopexecution)
    {
        $app = JFactory::getApplication();
        if ($app->isAdmin()) {
            return;
        }

        $task = strtolower(JRequest::getCmd('task','listauctions'));
        $controllerClass = JRequest::getWord('controller');
        $acl = BidsHelperTools::getBidsACL();
        $app = JFactory::getApplication();
        $cfg = BidsHelperTools::getConfig();
        $user = JFactory::getUser();
        if (strpos($task,'.')!==FALSE){
            $task=explode('.',$task);
            $controllerClass=$task[0];
            $task=$task[1];
        }
        if (in_array($task,$acl->anonTasks)) {
            return; //Anon Task ok
        }
        if (!$user->id){
            //By default tasks need to be done by logged users

            JError::raiseNotice("701",JText::_("COM_BIDS_YOU_NEED_TO_LOGIN_IN_ORDER_TO_ACCESS_THIS_SECTION"));
            $app->redirect(BidsHelperRoute::getAuctionListRoute(null,false));
            $stopexecution=true;
            return;
        }
        //Only Logged user from now on
        //var_dump($task);exit;
        //User must have his profile Filled for this task
        $userprofile = BidsHelperTools::getUserProfileObject();
        if (!$userprofile->checkProfile($user->id)) {
            //Profile is not filled! we must redirect
            if(!$r = BidsHelperTools::redirectToProfile()) {
                $r = BidsHelperRoute::getUserdetailsRoute();
            }
            $app->redirect($r, JText::_("COM_BIDS_ERR_MORE_USER_DETAILS") );
            $stopexecution=true;
            return;
        }


        if (!$cfg->bid_opt_enable_acl || !isset($acl->taskmapping[$task]))
            return; // no need to check other ACL Seller/Bidder taskmap

        if (!$userprofile)
            $userprofile = BidsHelperTools::getUserProfileObject();

        $userprofile->getUserProfile();

        //$cfg->bidder_groups
        //$cfg->seller_groups
        $user_groups=JAccess::getGroupsByUser($user->id);

        $isBidder=count(array_intersect($user_groups,$cfg->bid_opt_bidder_groups))>0;
        $isSeller=count(array_intersect($user_groups,$cfg->bid_opt_seller_groups))>0;

        if ($acl->taskmapping[$task]=='seller' && !$isSeller)
        {
            //Task allows only SELLERS
            JError::raiseNotice("701",JText::_("COM_BIDS_YOU_NEED_TO_BE_A_SELLER_IN_ORDER_TO_ACCESS_THIS_SECTION"));
            $app->redirect(BidsHelperRoute::getAuctionListRoute(null,false));
            $stopexecution=true;
            return;

        }

        if ($acl->taskmapping[$task]=='bidder' && !$isBidder)
        {
            //Task allows only SELLERS
            JError::raiseNotice("701",JText::_("COM_BIDS_YOU_NEED_TO_BE_A_BIDDER_IN_ORDER_TO_ACCESS_THIS_SECTION"));
            $app->redirect(BidsHelperRoute::getAuctionListRoute(null,false));
            $stopexecution=true;
            $app->close();
            return;

        }
    }
 static function uploadImages($auction)
 {
     $cfg = BidsHelperTools::getConfig();
     $document = JFactory::getDocument();
     $imageList = '';
     $images = $auction->get('images');
     foreach ($images as $img) {
         $imageList .= '<div>' . JHTML::image(AUCTION_PICTURES . 'resize_' . $img->picture, $img->picture, 'style="vertical-align:middle"') . '&nbsp;<input type="checkbox" name="delete_pictures[]" value="' . $img->id . '" id="bidsDelImg' . $img->id . '" />&nbsp;<label for="bidsDelImg' . $img->id . '" />' . JText::_('COM_BIDS_DELETE') . '</label>' . '</div><br />';
     }
     JHTML::script('Stickman.MultiUpload.js', 'components/' . APP_EXTENSION . '/js/');
     $dirImages = JUri::root() . 'components/com_bids/images/';
     $startScript = 'window.addEvent(\'domready\', function(){' . 'new MultiUpload( $( \'bidpicture\' ), ' . ($cfg->bid_opt_maxnr_images - $auction->get('imagecount')) . ', \'_{id}\', true, true, \'' . $dirImages . '\' );' . '});';
     $document->addScriptDeclaration($startScript);
     $class = 'inputbox ' . ($cfg->bid_opt_require_picture ? 'required' : '');
     $disabled = $auction->get('imagecount') >= $cfg->bid_opt_maxnr_images ? 'disabled="disabled"' : '';
     $inputUpload = JHTML::tooltip(JText::sprintf('COM_BIDS_UPLOAD_IMAGES_HELP', $cfg->bid_opt_max_picture_size)) . '&nbsp;' . '<input type="file" name="picture" id="bidpicture" ' . $class . ' ' . $disabled . ' />';
     $html = $imageList . $inputUpload;
     return $html;
 }
Exemple #17
0
    function display($tpl=null) {

        $mainframe = JFactory::getApplication();
        $database = JFactory::getDBO();
        $my = JFactory::getUser();
        $cfg = BidsHelperTools::getConfig();

        $model = $this->getModel();
        $auction = $model->get('auction');

        $document = JFactory::getDocument();
        $document->setTitle($auction->title);
        $document->setMetaData('description', strip_tags($auction->shortdescription));
        $document->setMetaData('abstract', strip_tags($auction->description));
        foreach($auction->tagNames as $tag) {
            $document->setMetaData('keywords', $tag);
        }

        $jsQuantity = 'var has_quantity = ' . ( ($cfg->bid_opt_quantity_enabled && $auction->nr_items > 1) ?
                'true' : 'false' ) . ';';
        $document->addScriptDeclaration($jsQuantity);

        $links_path = JHtml::_('auctiondetails.auctionDetailsURL',$auction);

        $pathway = $mainframe->getPathway();
        $pathway->addItem($auction->title, $links_path);

        /* PLUGINS */
        $database->setQuery("select * from #__bid_pricing where enabled=1 order by ordering");
        $pp = $database->loadObjectList();
        $pricing_plugins = array();
        foreach ($pp as $p) {
            $pricing_plugins[$p->itemname] = $p;
        }
        $this->assign('pricing_plugins', $pricing_plugins);

        $auction->countdownHtml = JHTML::_('auctiondetails.countdownHtml',$auction);

        $auctioneer = JFactory::getUser($auction->userid);
        $profile = BidsHelperTools::getUserProfileObject($auctioneer->id);

        $this->assign('auctioneer', $auctioneer);
        $this->assign('auctioneer_details', $profile);

        $document = JFactory::getDocument();
        $js = 'var must_accept_term = '.((strip_tags($cfg->terms_and_conditions))?"true;":"false;");
        $this->assign('terms_and_conditions',(strip_tags($cfg->terms_and_conditions))?1:0);
        $document->addScriptDeclaration($js);
        $document->addScriptDeclaration('var auction_currency=\''.$auction->currency.'\';');

        /* PLUGINS */
        if ($cfg->bid_opt_enable_captcha) {
            $this->assign("cs", BidsHelperHtml::init_captcha());
        }

        $u = JTable::getInstance('biduser');
        $ratings = $u->getRatingsList($auctioneer->id);

        $list = array();

        $list['auctionWatchlist'] = JHTML::_('auctiondetails.follow',$auction);
        $list['auctionReport'] = JHTML::_('auctiondetails.report',$auction);
        $list['auctionChooseWinner'] = JHTML::_('auctiondetails.chooseWinner',$auction);
        $list['auctionRate'] = JHTML::_('auctiondetails.rate',$auction);
        $list['auctionFbLikeButton'] = JHTML::_('auctionDetails.fbLikeButton',$auction);
        $list['userRated'] = JHTML::_('auctionDetails.selectUserRated',$auction);
        $list['ratingsDetails'] = JHTML::_('auctionDetails.linkRatingsDetails',$auction,$ratings);

        $modelAuctions = JModelLegacy::getInstance('auctions','bidsModel');
        $otherAuctions = $modelAuctions->getOtherAuctionsList($auction->userid,$auction->id,4);

        $gallery = BidsHelperGallery::getGalleryPlugin();
        foreach($otherAuctions as &$oa) {
            BidsHelperAuction::renderAuctionTiming($oa);

            $gallery->clearImages();
            $gallery->addImageList($oa->imagelist);

            $oa->thumbnail = $oa->get('thumbnail');
            $oa->countdownHtml = JHTML::_('auctiondetails.countdownHtml',$oa);
        }
        $list['other_items'] = $otherAuctions;
        $list['tagLinks'] = JHtml::_('auctiondetails.taglinks',$auction);

        $list['ratings'] = BidsHelperHtml::getRatingsSelect();

        if(AUCTION_TYPE_BIN_ONLY==$auction->auction_type && $auction->quantity > 1) {

            $itemsPurchased = 0;

            foreach($auction->wonBids as $wb) {
                if($wb->userid==$my->id) {
                    $itemsPurchased += $wb->quantity;
                }
            }

            $list['myPurchasedItems'] = $itemsPurchased;
        }

        $userProfile = BidsHelperTools::getUserProfileObject();

	    $gallery->writeJS();

        $sellerProfile = BidsHelperTools::getUserProfileObject($auction->userid);

        $list['bidderPaypalButton'] = JHTML::_('auctiondetails.bidderPaypalButton',$auction);

        $auction->payment_name = $auction->payment_method;
        $auction->thumbnail = $auction->get('thumbnail');
        $auction->gallery = $auction->get('gallery');
        $auction->links = JHTML::_('auctiondetails.createLinks',$auction);
        $auction->username = $sellerProfile->username;
        $auction->paypalemail = isset($sellerProfile->paypalemail) ? $sellerProfile->paypalemail : null;
        $auction->start_date_text = JHTML::_('auctiondetails.startDateHtml', $auction);
        $auction->end_date_text = JHTML::_('auctiondetails.endDateHtml', $auction);

        $auction->minIncrement = $model->getMinIncrement();
        $auction->minAcceptedPrice = $model->getMinAcceptedPrice();
        $auction->isMyAuction = $model->ownsAuction($my->id);

        $mybids = $model->getUserBids($my->id);
        $auction->myBid = reset($mybids);

        $auction->my_proxy_bid = $auction->myBid ? $auction->myBid->max_proxy_price : 0;
        $auction->mybid = $auction->myBid ? $auction->myBid->bid_price : 0;

        $auction->winner_list = $auction->wonBids;
        $auction->winBid = 0;

        if($auction->highestBid && $auction->highestBid->accept) {
            $auction->winBid = $auction->highestBid->bid_price;
        }

        $auction->highestBidder = $auction->highestBid ? $auction->highestBid->username : '';
        $auction->highestBidderId = $auction->highestBid ? $auction->highestBid->userid : 0;

        if(!$auction->highestBid) {
            $auction->highestBid = new stdClass();
            $auction->highestBid->bid_price = 0;
        }
        $auction->highestBid->bid_price =
                (
                    $auction->isMyAuction ||
                    (!empty($auction->params['max_price']) && $auction->auction_type!=AUCTION_TYPE_PRIVATE)
                ) ?
                ($auction->highestBid ? $auction->highestBid->bid_price : 0) : 'private';


        $auction->iAmWinner = $model->isWinner($my->id);

        $suggestions = isset($auction->suggestions) ? $auction->suggestions : null;

        JHTML::script(JURI::root().'components/com_bids/js/jquery/jquery.js');
        JHTML::script(JURI::root().'components/com_bids/js/jquery/jquery.noconflict.js');
        JHTML::script(JURI::root().'components/com_bids/js/auctions.js');
        JHTML::script(JURI::root().'components/com_bids/js/startup.js');
        JHTML::_('behavior.modal');

        BidsHelperHtml::loadCountdownJS();

        $this->assign('auction', $auction);
        $this->assign('userProfile',$userProfile);
        $this->assign('message_list', $model->getAuctionMessages($auction->id));
        $this->assign('bid_list', $auction->bids );
        $this->assign('bid_history', $auction->bids_history );
        $this->assign('positions', array());
        $this->assign('suggestions', $suggestions);
        $this->assign('lists', $list);

        parent::display($tpl);
    }
Exemple #18
0
    static function formatDate($gmdate,$usehour=null) {

        $cfg = BidsHelperTools::getConfig();

        $dateFormat = $cfg->bid_opt_date_format;

        if(($usehour===null && $cfg->bid_opt_enable_hour)||($usehour)) {
            if ($cfg->bid_opt_date_time_format=='h:iA')
                $dateFormat .= ' I:i p';
            elseif ($cfg->bid_opt_date_time_format=='H:i')
                $dateFormat .= ' H:i';
            else
                $dateFormat .= ' H:i';
        }

        return JHTML::date( JFactory::getDate($gmdate)->toUnix() , $dateFormat );
    }
Exemple #19
0
 function RefreshCategory()
 {
     $cfg = BidsHelperTools::getConfig();
     $id = JRequest::getInt('id', 0);
     $oldid = JRequest::getInt('oldid', 0);
     $isRepost = $oldid && !$id;
     $auctionmodel = $this->getModel('auction');
     $auctionmodel->bind(JRequest::get('post', JREQUEST_ALLOWHTML), JRequest::get('files'), true);
     $auctionmodel->saveToSession();
     $auction = $auctionmodel->get('auction');
     $extra = '';
     if ($isRepost) {
         $redirectTask = 'republish';
     } elseif ($id) {
         $redirectTask = 'editoffer';
         $extra = '&id=' . $id;
     } else {
         $redirectTask = 'newauction';
         $extra = 'catpage' == $cfg->bid_opt_category_page ? '&category_selected=' . $auction->cat : '';
     }
     $redirectURL = JRoute::_('index.php?option=com_bids&task=' . $redirectTask . $extra, false);
     $this->setRedirect($redirectURL);
 }
 static function bidderPaypalButton($auction)
 {
     $my = JFactory::getUser();
     $cfg = BidsHelperTools::getConfig();
     $tfApp = JTheFactoryApplication::getInstance();
     //build paypal url based on the payment gateway settings
     JModel::addIncludePath($tfApp->app_path_admin . DS . 'payments' . DS . 'models');
     $model = JModel::getInstance('Gateways', 'JTheFactoryModel');
     $gateways = $model->getGatewayList(true);
     $pgw = null;
     foreach ($gateways as $gw) {
         if ('pay_paypal' == $gw->classname) {
             $pgw = $gw;
         }
     }
     $paypalURL = JDEBUG ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
     $sellerProfile = BidsHelperTools::getUserProfileObject($auction->userid);
     $totalPrice = 0;
     $totalItems = 0;
     $priceDetails = array();
     foreach ($auction->wonBids as $b) {
         if ($b->userid == $my->id) {
             $totalPrice += $cfg->bid_opt_quantity_enabled ? $b->bid_price * $b->quantity : $b->bid_price;
             $totalItems += $cfg->bid_opt_quantity_enabled ? $b->quantity : 1;
             $priceDetails[] = $b->quantity . ' x ' . BidsHelperAuction::formatPrice($b->bid_price) . ' ' . $auction->currency;
         }
     }
     $auction->shipmentPrices = isset($auction->shipmentPrices) ? (array) $auction->shipmentPrices : array();
     if ($cfg->bid_opt_multiple_shipping && count($auction->shipmentPrices) > 1) {
         //multiple shipment options
         $opts = array();
         $opts[] = JHTML::_('select.option', 0, JText::_('COM_BIDS_SELECT_SHIPMENT_ZONE'));
         foreach ($auction->shipmentPrices as $sp) {
             $opts[] = JHTML::_('select.option', number_format($sp->price, $cfg->bid_opt_number_decimals), $sp->name . ' (' . BidsHelperAuction::formatPrice($sp->price) . ' ' . $auction->currency . ')');
         }
         $shipmentPrice = '<input type="hidden" id="bidderTotalPrice' . $auction->id . '" value="' . number_format($totalPrice, $cfg->bid_opt_number_decimals) . '" />' . (count($opts) > 1 ? JText::_('COM_BIDS_SHIP_TO') . JHTML::_('select.genericlist', $opts, 'amount', 'onchange="refreshTotalPrice(' . $auction->id . ',this.value);"') : '');
     } elseif (count($auction->shipmentPrices) == 1) {
         //single shipment zone
         $totalPrice += $auction->shipmentPrices[0]->price;
         $shipmentPrice = JText::_('COM_BIDS_SHIPMENT') . ': ' . BidsHelperAuction::formatPrice($auction->shipmentPrices[0]->price) . ' ' . $auction->currency . ' ' . ($auction->shipment_info ? JHTML::tooltip($auction->shipment_info) : '');
     } else {
         $shipmentPrice = '';
     }
     $html = $shipmentPrice ? $shipmentPrice . '<br />' : "";
     $tooltip = ($totalItems > 1 ? $totalItems . ' ' . JText::_('COM_BIDS_PAYPAL_BUTTON_ITEMS') . '<br />' : '') . implode('<br />', $priceDetails);
     $html .= ' <span id="amount_total' . $auction->id . '" class="bids_price">' . BidsHelperAuction::formatPrice($totalPrice) . '</span> ' . $auction->currency . '&nbsp;' . JHTML::tooltip($tooltip);
     if (empty($sellerProfile->paypalemail)) {
         $html .= '';
     } else {
         $html .= '<form name="paypalForm' . $auction->id . '" action="' . $paypalURL . '" method="post">
                 <input type="hidden" name="cmd" value="_xclick" />
                 <input type="hidden" name="business" value="' . $sellerProfile->paypalemail . '" />
                 <input type="hidden" name="item_name" value="' . $auction->title . '" />
                 <input type="hidden" name="item_number" value="' . $auction->id . '" />
                 <input type="hidden" name="invoice" value="' . $auction->auction_nr . '" />
                 <input type="hidden" name="quantity" value="1" />
                 <input type="hidden" name="return" value="' . trim(JUri::root(), '/') . self::auctionDetailsURL($auction) . '" />
                 <input type="hidden" name="tax" value="0" />
                 <input type="hidden" name="rm" value="2" />
                 <input type="hidden" name="no_note" value="1" />
                 <input type="hidden" name="no_shipping" value="1" />
                 <input type="hidden" name="currency_code" value="' . $auction->currency . '" />
                 <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but06.gif" name="submit" alt="' . JText::_('COM_BIDS_PAYPAL_BUYNOW') . '" />
                 <input type="hidden" name="amount" value="' . $totalPrice . '" />
             </form><br />';
     }
     return $html;
 }
 function onPaymentForOrder($paylog, $order)
 {
     if (!$order->status == 'C') {
         return;
     }
     $modelorder = JTheFactoryPricingHelper::getModel('orders');
     $items = $modelorder->getOrderItems($order->id, self::getItemName());
     if (!is_array($items) || !count($items)) {
         return;
     }
     //no Listing items in order
     $cfg = BidsHelperTools::getConfig();
     $nowDate = new JDate();
     $auction = JTable::getInstance('auction');
     foreach ($items as $item) {
         if (!$item->iteminfo) {
             continue;
         }
         //AuctionID is stored in iteminfo
         if ($item->itemname != self::getItemName()) {
             continue;
         }
         if (!$auction->load($item->iteminfo)) {
             continue;
         }
         //auction no longer exists
         $auction->modified = $nowDate->toMySQL();
         $auction->published = 1;
         if (!$cfg->bid_opt_enable_date) {
             $startDate = new JDate($auction->start_date);
             $diff = $nowDate->toUnix() - $startDate->toUnix();
             if ($diff > 0) {
                 $auction->start_date = $nowDate->toMySQL();
                 $endDate = new JDate($auction->end_date);
                 $endDate->add(new DateInterval('PT' . $diff . 'S'));
                 $auction->end_date = $endDate->toMySQL();
             }
         }
         $auction->store();
         JTheFactoryEventsHelper::triggerEvent('onAfterSaveAuctionSuccess', array($auction));
         //for email notifications
     }
 }
Exemple #22
0
<?php

defined('_JEXEC') or die('Restrited access.');
$bidCfg = BidsHelperTools::getConfig();
$lang = JFactory::getLanguage();
$lang->load('com_bids', JPATH_SITE);
?>
function html_entity_decode(str)
{
    //jd-tech.net
    var tarea=document.createElement('textarea');
    tarea.innerHTML = str; return tarea.value;
    tarea.parentNode.removeChild(tarea);
}


function dateformat(php_format)
{
    d='y-mm-dd';
    if (php_format=='Y-m-d') d='y-mm-dd';
    if (php_format=='Y-d-m') d='y-dd-mm';
    if (php_format=='m/d/Y') d='mm/dd/y';
    if (php_format=='d/m/Y') d='dd/mm/y';
    if (php_format=='D, F d Y') d='y-mm-dd';

    return d;
}

function termsAlert(){
    var txt_info = language['bid_err_terms'];
    alert(txt_info);
Exemple #23
0
 function onAfterSendMessage($auction,$message)//
 {
     $cfg= BidsHelperTools::getConfig();
     $usr=JFactory::getUser($message->userid2);
     
     $app=JFactory::getApplication();
     
     if ($app->isAdmin()) {
         $auction->SendMails(array($usr), 'bid_admin_message');
     } else {
         $auction->SendMails(array($usr),"new_message");
     }
     if ($cfg->bid_opt_uddeim) {
         $comment = str_replace('<br>', "\n", $message->message);
         $comment = JText::sprintf('COM_BIDS_SUBJECT_FORMAT', $auction->title, $auction->auction_nr) . PHP_EOL . $comment;
         BidsHelperUdde::sendMessage($message->userid1, $message->userid2, $comment);
     }
         
 }
Exemple #24
0
    function cron()
    {
        /* cron script Pass and authentication*/
        $cfg=BidsHelperTools::getConfig();
        $config =JFactory::getConfig();
        $pass=JRequest::getVar('pass');
        $debug= JRequest::getVar('debug',0);

        $date=new JDate();
        $nowMysql=$date->toMySQL(false);

        $database = JFactory::getDbo();

        JTheFactoryHelper::modelIncludePath('payments');
        JTheFactoryHelper::tableIncludePath('payments');

        $log= JTable::getInstance('bidcronlog');
        $log->priority='log';
        $log->event='cron';
        $log->logtime=$nowMysql;
        $logtext="";

        if ($cfg->bid_opt_cron_password!==$pass) {
            //Bad Password, log and exit;
            $log->log=JText::_("COM_BIDS_BAD_PASSWORD_USED")." > $pass";
            $log->store();
            die(JText::_("COM_BIDS_ACCESS_DENIED"));
        }
    	@set_time_limit(0);
    	@ignore_user_abort(true);



        // reminder for due to expire suggestions
        $database->setQuery(" SELECT s.auction_id,a.userid
                                FROM #__bid_suggestions AS s
                                LEFT JOIN #__bid_auctions AS a
                                    ON s.auction_id = a.id
                                WHERE
                                    s.status=2
                                    AND UTC_TIMESTAMP() > DATE_ADD( s.modified, INTERVAL 24 HOUR)
                                    AND a.published=1
                                    AND a.close_offer=0
                                    AND a.close_by_admin=0
                                    AND UTC_TIMESTAMP() < a.end_date
                                GROUP BY s.auction_id");
        $curs = $database->loadObjectList();
        
        if(count($curs)>0) {
            $auction =  JTable::getInstance('auction');
            $userIds = array();
        
            foreach($curs as $k=>$val) {
                $userIds[] = $val->userid;
            }
            $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ( '.implode(',',$userIds).' )');
            $mails = $database->loadObjectList();
            $auction->SendMails($mails,'suggest_reminder'); //Notyfy Sellers abour pending suggestions
        }
        
        // reject expired suggestions
        $database->setQuery(" SELECT a.id AS suggestionId,a.auction_id,b.userid
                                FROM #__bid_suggestions AS a
                                LEFT JOIN #__bid_auctions AS b
                                    ON a.auction_id = b.id
        			WHERE
                                    UTC_TIMESTAMP() > DATE_ADD( a.modified, INTERVAL 48 HOUR)
                                    AND a.status=2");
        $curs = $database->loadObjectList();
        
        if(count($curs)>0) {
            $auction =  JTable::getInstance('auction');
            $userIds = array();
            $suggestionIds = array();
        
            foreach($curs as $k=>$val) {
                $suggestionIds[] = $val->suggestionId;
                $userIds[] = $val->userid;
            }
        
            $database->setQuery('UPDATE #__bid_suggestions SET status=0 WHERE id IN ('.implode(',',$suggestionIds).')');
            $database->query();// reject the suggestions
        
            $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ( '.implode(',',$userIds).' )');
            $mails = $database->loadObjectList();
            $auction->SendMails($mails,'suggest_rejected'); //Notyfy Bidders abour rejected suggestion
        }
        
        //CLOSE auctions
        $query = "SELECT
                        a.*,
                        a.id as auctionId,
                        GROUP_CONCAT(b.userid) AS bidderIds,
                        GROUP_CONCAT(w.userid) AS watcherIds
                    FROM #__bid_auctions AS a
                    LEFT JOIN #__bids AS b
                        ON a.id=b.auction_id
                    LEFT JOIN #__bid_watchlist AS w
                        ON a.id=w.auction_id
                    WHERE
                        UTC_TIMESTAMP() >= a.end_date
                        AND a.close_offer = 0
                        AND a.published = 1
                        AND a.close_by_admin=0
                    GROUP BY a.id";
        $database->setQuery($query);
        $rows = $database->loadObjectList('auctionId');


        $extendedAuctions = array();
        if($cfg->bid_opt_auto_extent && $cfg->bid_opt_auto_extent_nobids) {
            //these auctions have no bids and will be extended
            foreach($rows as $id=>$r) {
                if(!$r->bidderIds) {
                    $extendedAuctions[] = $id;
                }
            }
        }

        if(count($rows)>0) {
            $auction =  JTable::getInstance('auction');

            //exclude auctions that are going to be extended
            $closeAuctions = array_diff(array_keys($rows),$extendedAuctions);
            if(count($closeAuctions)) {
                $database->setQuery('UPDATE
                                        #__bid_auctions
                                     SET
                                        close_offer=1,
                                        closed_date=UTC_TIMESTAMP()
                                     WHERE
                                        id IN ('.implode(',',  $closeAuctions).')');
                $database->query();
            }
        
            foreach ($rows as $r) {
                //Notify bidders
                $auction->bind($r);
        
                //extend auctions with no bids
                if($cfg->bid_opt_auto_extent && $cfg->bid_opt_auto_extent_nobids>0 && !$r->bidderIds) {
                    $extendedPeriodSeconds = $cfg->bid_opt_auto_extent_nobids * BidsHelperDateTime::translateAutoextendPeriod($cfg->bid_opt_auto_extent_nobids_type);
                    $endTime = BidsHelperDateTime::getTimeStamp($auction->end_date);
                    $newEndTime = $endTime + $extendedPeriodSeconds;

                    $auction->end_date = gmdate('Y-m-d H:i:s',$newEndTime);
                    $auction->store();

                    continue;
                }
        
                jimport('joomla.application.component.model');
                JModelLegacy::addIncludePath(JPATH_COMPONENT_SITE.DS.'models');
                $auctionmodel = JModelLegacy::getInstance('auction','bidsModel');
                $auctionmodel->load($r->auctionId);
        
                $seller = JTable::getInstance('user');
                $seller->load($r->userid);
        
                if($r->automatic) {
        
                    $a = $auctionmodel->get('auction');
                    $highestBid = $a->highestBid;
        
                    $nrHighestBids = 1;
                    if( AUCTION_TYPE_PRIVATE == $a->auction_type ) {
                        if($highestBid) {
                            $query = 'SELECT COUNT(1) AS nrHighestBids
                                        FROM #__bids
                                        WHERE
                                            auction_id='.$r->auctionId.'
                                            AND bid_price='.$highestBid->bid_price;
                            $database->setQuery($query);
                            $nrHighestBids = $database->loadResult();
                        }
                        else {
                            $nrHighestBids = 0;
                        }
                    }
        
                    if($highestBid) {
                        if ($nrHighestBids>1) {
                            //mark auction as NOT automatic and alert owner that 2 or more bids are the same
                            $database->setQuery('UPDATE #__bid_auctions SET automatic=0 WHERE id='.$a->id);
                            $database->query();
        
                            $auctionmodel->SendMails(array($seller),'bid_choose_winner');
                        } else {
                            if ($cfg->bid_opt_global_enable_reserve_price && $a->reserve_price>0 && $a->reserve_price>=$highestBid->bid_price) {
                                //reserve price not met!
                                $auctionmodel->SendMails(array($seller),'bid_reserve_not_met');//reserve price not met
                            } else {
                                $bid = JTable::getInstance('bid');
                                $bid->bind($highestBid);
                                $auctionmodel->close($bid);
                            }
                        }
                    } else {
                        $auctionmodel->SendMails(array($seller),'bid_offer_no_winner_to_owner');
                    }
        
                } else {
                    // Notify owner to choose winner OR that his auction has no winner
                    $auctionmodel->SendMails(array($seller), $r->bidderIds ? 'bid_choose_winner' : 'bid_offer_no_winner_to_owner');
                }
        
                if($r->bidderIds) {
                    $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ('.$r->bidderIds.')');
                    $mails = $database->loadObjectList();
                    $auctionmodel->SendMails($mails,'bid_closed'); //Notyfy Bidders abour closed Auction
        
                    $database->setQuery('DELETE FROM #__bid_watchlist WHERE auction_id='.$r->id.' AND userid IN ('.$r->bidderIds.')');
                    $database->query();//delete bidders from watchlist, to avoid double notification
                }
                //Notify  Watchlist, Clean Watchlist
                if($r->watcherIds) {
                    $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ('.$r->watcherIds.')');
                    $mails = $database->loadObjectList();
                    $auctionmodel->SendMails($mails,'bid_watchlist_closed'); //Notify Watchlist
        
                    $database->setQuery('DELETE FROM #__bid_watchlist WHERE auction_id='.$r->id);
                    $database->query();
                }
            }
        }
        
        // END EXPIRED AUCTION
    
    
        //Daily Jobs (things that should run once a day )
        $daily= JRequest::getVar('daily','');
        if ($daily){
            //Notify upcoming expirations
        	$query = "SELECT a.* from #__bid_auctions AS a
        		 	  WHERE UTC_TIMESTAMP() >= DATE_ADD(end_date,INTERVAL -1 DAY) AND a.close_offer != 1 AND published = 1 AND a.close_by_admin!=1";
        	$database->setQuery($query);
        	$rows = $database->loadObjectList();
    
        	$auction =  JTable::getInstance('auction');
  	        
            $logtext.=sprintf("Soon to expire: %d auctions\r\n",count($rows));
    
            foreach ($rows as $row){
                    $auction->load($row->id);
                    $usr=JFactory::getUser($row->userid);
                    $auction->SendMails(array($usr),'bid_your_will_expire'); // Notify Owner that his auction will soon expire
    
                    $query = "SELECT u.* FROM #__users u
                            left join #__bid_watchlist w on u.id = w.userid
                            where w.auction_id = ".$row->id;
    
                    $database->setQuery($query);
                    $watchlist_mails = $database->loadObjectList();
                    $auction->SendMails($watchlist_mails,'bid_watchlist_will_expire'); //Notify Users in watchlist that an auction will expire
            }
    
        	//Close all auctions without a parent user (deleted users?)s
        	$query = "UPDATE
                        #__bid_auctions AS a
                        LEFT JOIN #__users AS b
                            ON a.userid=b.id
                        SET
                            close_by_admin=1,
                            closed_date=UTC_TIMESTAMP()
                        WHERE b.id IS NULL";
        	$database->setQuery($query);
        	$database->query();
            //delete Very old auctions (past Archived time)
        	$interval =  intval($bidCfg->bid_opt_archive);
            $d_opt = ( $bidCfg->bid_opt_archive_type!='') ? $bidCfg->bid_opt_archive_type : 'month';
            $d_opt_sql = strtoupper($d_opt);
        	if ($interval>0){
            	$query = "SELECT id
                                FROM #__bid_auctions
                                WHERE UTC_TIMESTAMP() > DATE_ADD( closed_date, INTERVAL $interval
                                {$d_opt_sql} )
                                AND (close_offer =1
                                or  close_by_admin=1)";
                $database->setQuery($query);
                $idx = $database->loadResultArray(); //select auctions that have to be purged
    
    
                $row =  JTable::getInstance('auction');
                if (count($idx)) {
                    foreach ($idx as $id){
                        $row->delete($id);
                    }
                }
        	}

            $model= JModelLegacy::getInstance('Currency','JTheFactoryModel');
            $currtable= JTable::getInstance('CurrencyTable','JTheFactory');
    
            $currencies=$model->getCurrencyList();
            $default_currency=$model->getDefault();
            $results=array();
            foreach($currencies as $currency){
                if ($currency->name==$default_currency){
                    $currtable->load($currency->id);
                    $currtable->convert=1;
                    $currtable->store();
                    $results[]=$currency->name." ---> ".$default_currency." = 1";
                    continue;
                }
                $conversion=$model->getGoogleCurrency($currency->name,$default_currency);
                if ($conversion===false){
                    $results[]=JText::_("COM_BIDS_ERROR_CONVERTING")." {$currency->name} --> $default_currency";
                    continue;
                }
                $currtable->load($currency->id);
                $currtable->convert=$conversion;
                $currtable->store();
                $results[]=$currency->name." ---> ".$default_currency." = $conversion ";
            }
            $logtext.=implode("\r\n",$results);
            $logtext.="\r\n";
            //some cleanup
        	
        }
        $log->log=$logtext;
        $log->store();
        if ($debug) return;
        ob_clean();
        exit();
        

    }
Exemple #25
0
    static function loadCountdownJS() {
        $cfg = BidsHelperTools::getConfig();

        if ( !$cfg->bid_opt_enable_countdown ) {
            return;
        }

        JHTML::script( JURI::root().'components/com_bids/js/countdown.js');

        $jdoc =  JFactory::getDocument();
        $js_declaration = "var days='" . JText::_("COM_BIDS_DAYS") . ",';	var expired='" . JText::_("COM_BIDS_EXPIRED") . "';";
        $jdoc->addScriptDeclaration($js_declaration);
    }
Exemple #26
0
    function display($tpl=null) {

        $database = JFactory::getDBO();
        $my = JFactory::getUser();
        $cfg = BidsHelperTools::getConfig();

        JHTML::_('behavior.modal');
        JHTML::_('behavior.tooltip');

        JHTML::script(JURI::root().'components/com_bids/js/ratings.js');
        JHTML::script( JURI::root().'components/com_bids/js/startup.js' );

        $model = $this->getModel();
        $profile = $model->get('profile');

        $lists['balance'] = $model->getBalance();

        $lists["ratings"] = $model->getRatings(10);
        $lists["messages"]["received"] = $model->getMessages();

        if ($cfg->bid_opt_allow_user_settings && $profile->isSeller) {

            $p = JTable::getInstance('bidusersettings');
            $p->load($my->id);
            $settings = $p->settings;

            $lists['user_settings'] = array();

            if($cfg->bid_opt_enable_hour) {
                //convert end time to GMT
                try {
                    $endTime = @$settings["end_hour"].':'.@$settings["end_minute"];
                    @list($settings["end_hour"],$settings["end_minute"]) = explode(':',JHTML::date($endTime,'H:i'));
                } catch(Exception $e) {
                    if(JDEBUG) {
                        //JError::raiseWarning(1,$e->getMessage());
                    }
                }
                //end time is GMT, convert it to locale

                $lists['user_settings']['end_hour'] = '<input type="text" name="end_hour" class="inputbox" value="'.@$settings['end_hour'].'" style="width:20px;" />';
                $lists['user_settings']['end_minute'] = '<input type="text" name="end_minute" class="inputbox" value="'.@$settings['end_minute'].'" style="width:20px;" />';
            }
            $lists['user_settings']['payment_info'] = '<input style="width: 300px;" type="text" name="payment_info"
            class="inputbox"
            value="'.@$settings['payment_info'].'" />';
            $lists['user_settings']['shipment_info'] = '<input style="width: 300px;" type="text" name="shipment_info" class="inputbox" value="'.@$settings['shipment_info'].'" />';
            $lists['user_settings']['show_reserve'] = JHTML::_('select.booleanlist','show_reserve',null,@$settings['show_reserve'],'COM_BIDS_SHOW','COM_BIDS_HIDE');
            $lists['user_settings']['auto_accept_bin'] = JHTML::_('select.booleanlist','auto_accept_bin',null,@$settings['auto_accept_bin']);
            $lists['user_settings']['bid_counts'] = JHTML::_('select.booleanlist','bid_counts',null,@$settings['bid_counts'],'COM_BIDS_SHOW','COM_BIDS_HIDE');
            $lists['user_settings']['max_price'] = JHTML::_('select.booleanlist','max_price',null,@$settings['max_price'],'COM_BIDS_SHOW','COM_BIDS_HIDE');

            $fi = isset($settings['auction_type']) ? $settings['auction_type'] : null;

            $opts = array();
            $opts[] = JHTML::_('select.option', '', JText::_('COM_BIDS_PICK_TYPE_OF_AUCTION'));
            $opts[] = JHTML::_('select.option', AUCTION_TYPE_PUBLIC, JText::_('COM_BIDS_PUBLIC_LABEL'));
            if ($cfg->bid_opt_global_enable_private)
                $opts[] = JHTML::_('select.option', AUCTION_TYPE_PRIVATE, JText::_('COM_BIDS_PRIVATE_LABEL'));
            if ($cfg->bid_opt_enable_bin_only)
                $opts[] = JHTML::_('select.option', AUCTION_TYPE_BIN_ONLY, JText::_('COM_BIDS_BIN_ONLY_LABEL'));

            $lists['user_settings']['auction_type'] = JHTML::_('select.genericlist', $opts, 'auction_type', 'class="inputbox" alt="auction_type"', 'value', 'text', $fi);

            $fi = isset($settings['currency']) ? $settings['currency'] : null;

            $query = "SELECT name AS value, name AS text FROM #__bid_currency ORDER BY id";
            $opts = null;
            $database->setQuery($query);
            $opts = $database->loadObjectList();
            $defaultOpt = JHtml::_('select.option','',JText::_('COM_BIDS_SELECT_CURRENCY'));
            array_unshift($opts,$defaultOpt);
            $lists["user_settings"]['currency'] = JHTML::_('select.genericlist', $opts, 'currency',
                'class="inputbox" onchange="bidsRefreshCurrency(this.value)"', 'value', 'text', $fi);

            $lists['user_settings']['shipment_price'] = '<input type="text" name="shipment_price" class="inputbox"
            style="text-align: right; width: 80px;" value="' . BidsHelperAuction::formatPrice
            (@$settings['shipment_price']) . '" />&nbsp;&nbsp;<span class="bidsRefreshCurrency">'.$fi.'</span>';
        }

        $lists["links"]=array(
          "upload_funds"=>BidsHelperRoute::getAddFundsRoute(),
          "payment_history"=>BidsHelperRoute::getPaymentsHistoryRoute()
        );

        $lists['fbLikeButton'] = JHTML::_('userProfile.fbLikeButton', $profile);
        $lists['linkEditProfile'] = JHTML::_('userprofile.linkEditProfile');
        $lists['linkUserRatings'] = JHTML::_('userprofile.linkUserRatings',$profile);

        $profile->paypalemail = BidsHelperTools::cloack_email($profile->paypalemail);

        $fields = CustomFieldsFactory::getFieldsList("user_profile");

        if($cfg->terms_and_conditions) {
            $lists['linktc'] = JRoute::_('index.php?option=com_bids&task=terms_and_conditions&tmpl=component');
        }


        $this->assign("user", $profile);
        $this->assign("lists", $lists);
        $this->assign("fields", $fields);
        $this->assign('return', JRequest::getCmd("return"));

        return parent::display($tpl);
    }
Exemple #27
0
    static function getItemsPerPage()
    {
        $jconfig = JFactory::getConfig();
        $cfg = BidsHelperTools::getConfig();

        return $cfg->bid_opt_nr_items_per_page>0 ? $cfg->bid_opt_nr_items_per_page : $jconfig->getValue('config.list_limit');         
    }
Exemple #28
0
    function display($tmpl) {

        jimport('joomla.html.parameter');

        $cfg = BidsHelperTools::getConfig();

        $model = $this->getModel('auctions');
        $items = $model->get('auctions');

        $lists=array();

		$gallery = BidsHelperGallery::getGalleryPlugin();

        $i=0;
        foreach($items as $k=>&$item) {

            $item->rownr = ++$i;
            $item->params = new JParameter($item->params);

            $gallery->clearImages();
            $gallery->addImageList(explode(',',$item->pictures));
            $item->thumbnail = $gallery->getThumbImage();

            $item->start_date_text = JHTML::_('auctiondetails.startDateHtml', $item);

            $item->description = JFilterOutput::cleanText($item->description);
            $item->shortdescription = JFilterOutput::cleanText($item->shortdescription);

            $item->tagIds = $item->tagIds ? explode(',', $item->tagIds) : array();
            $item->tagNames = $item->tagNames ? explode(',', $item->tagNames) : array();

            $item->links = JHTML::_('auctiondetails.createLinks',$item);
            if (!isset($item->favorite))
                $item->favorite = false;
            $item->del_from_watchlist = (bool) $item->favorite;
            $item->add_from_watchlist = !$item->del_from_watchlist;

            if ($cfg->bid_opt_multiple_shipping) {
                $p = JTable::getInstance('bidshipzone');
                $item->shipping_zones = $p->getPriceList($item->id);
            }

            BidsHelperAuction::renderAuctionTiming($item);
            $item->countdownHtml = JHTML::_('auctiondetails.countdownHtml',$item);

            if ( BidsHelperDateTime::getTimeStamp($item->end_date) <= time() ) {
                $item->expired = true;
            } else {
                $item->expired = false;
            }

            $item->start_date_text = JHTML::_('auctiondetails.startDateHtml', $item);
            $item->end_date_text = JHTML::_('auctiondetails.endDateHtml', $item);

            BidsHelperAuction::setAuctionStatus($item);

            if ($item->params->get('max_price', '1') == 0 || $item->auction_type == AUCTION_TYPE_PRIVATE) {
                $item->highest_bid = null;
            }

            $lists['bidderPaypalButton'][$item->id] = isset($item->wonBids) ? JHTML::_('auctiondetails.bidderPaypalButton',$item) : null;
        }

        $this->assign('positions', array());

        $filter_type = $model->getState('filters.filter_type');
        $filter_bidtype = $model->getState('filters.filter_bidtype');
        $filter_archive = $model->getState('filters.filter_archive');
        $filter_order = $model->getState('filters.filter_order');
        $filter_order_Dir = $model->getState('filters.filter_order_Dir');
        $pagination = $model->get('pagination');

        $lists['archive'] = JHTML::_('listauctions.selectMyFilter', $model->getState('filters.filter_archive'));
        $lists['filter_bidtype'] = JHTML::_('listauctions.selectBidType', $model->getState('filters.filter_bidtype') );
        $lists['orders'] = JHTML::_('listauctions.selectOrder',$filter_order);
        $lists['filter_order_asc'] = JHTML::_('listauctions.selectOrderDir', $filter_order_Dir);
        $lists['filter_cats'] = JHTML::_('listAuctions.selectCategory', $model->getState('filters.cat'));
        $lists['inputKeyword'] = JHTML::_('listAuctions.inputKeyword', $model->getState('filters.keyword'));
        $filters = $model->getFilters();
        $lists['inputsHiddenFilters'] = JHTML::_('listAuctions.inputsHiddenFilters', $filters );
        $lists['htmlLabelFilters'] = JHTML::_('listAuctions.htmlLabelFilters', $filters, false );
        $lists['resetFilters'] = JHTML::_('listAuctions.linkResetFilters', $model->getState('behavior'));

        $this->assign('lists', $lists);

        $uri = JFactory::getURI();
        $this->assign("action", JRoute::_(JFilterOutput::ampReplace($uri->toString())));
        $this->assign("auction_rows", $items);

        $this->assign("filter_type", $filter_type);
        $this->assign("filter_bidtype", $filter_bidtype);
        $this->assign("filter_order_Dir", $filter_order_Dir);
        $this->assign("reverseorder_Dir", $filter_order_Dir=='ASC' ? 'ASC' : 'DESC' );
        $this->assign("filter_order", $filter_order);
        $this->assign("filter_archive", $filter_archive);
        $this->assign("pagination", $pagination);

        JHTML::script( JURI::root().'components/com_bids/js/jquery/jquery.js' );
        JHTML::script( JURI::root().'components/com_bids/js/jquery/jquery.noconflict.js' );

        JHTML::script( JURI::root().'components/com_bids/js/ratings.js' );
        JHTML::script( JURI::root().'components/com_bids/js/startup.js' );

        JHTML::_('behavior.modal');
        JHTML::_('behavior.tooltip');

        BidsHelperHtml::loadCountdownJS();

        parent::display($tmpl);
    }
Exemple #29
0
    function saveUserDetails() {

        $cfg = BidsHelperTools::getConfig();


        $errors=$this->validateSaveUser('post');
        if (count($errors)) return $errors;

		$my = JFactory::getUser();
		$currentUser = $my->id ? $my->id : 0;
        if (!$currentUser) {
            return JText::_("COM_BIDS_USER_NOT_AVAILABLE");
        }

        $user = JTable::getInstance('biduser');
        if (!$user->load( $currentUser ) ) {
            $user->createRecord($currentUser);
        }

        $user->bind(JRequest::get('post'));

        $jform = JRequest::getVar('jform');
        $user->name = $jform['name'];

        $user->userid=$currentUser;

        $date = JFactory::getDate(time());
        $user->modified = $date->toSQL();

        if($user->store()){
            $act = JRequest::getCmd("act",null);
            if($act=="savesettings"){
                if ($cfg->bid_opt_allow_user_settings) {
                    $this->saveDefaultAuctionSettings(JRequest::get());
                }
            }

        }

        return true;
    }
Exemple #30
0
 function display($tpl = null)
 {
     $lang = JFactory::getLanguage();
     $lang->load('com_bids', JPATH_SITE);
     $model = $this->getModel('auction');
     $auction = $model->get('auction');
     $bidCfg = BidsHelperTools::getConfig();
     $lists = array();
     $lists['title'] = JHTML::_('editauction.inputTitle', $auction, 1);
     $lists['cats'] = JHTML::_('editauction.selectCategory', $auction, 1);
     //$lists['cats']    = JHTML::_('factorycategory.select','cat','',$auction->cat,false,false,true);
     $lists['published'] = JHTML::_('editauction.selectPublished', $auction, 1);
     $lists['tags'] = JHTML::_('editauction.inputTags', $auction, 1);
     $lists['shortDescription'] = JHTML::_('editauction.inputShortDescription', $auction, 1);
     $lists['description'] = JHTML::_('editauction.inputDescription', $auction, 1);
     $lists['auctiontype'] = JHTML::_('editauction.selectAuctionType', $auction, 1);
     $lists['automatic'] = JHTML::_('editauction.inputAutomatic', $auction, 1);
     $lists['binType'] = JHTML::_('editauction.selectBINType', $auction, 1);
     $lists['binPrice'] = JHTML::_('editauction.inputBINPrice', $auction, 1);
     $lists['autoAcceptBIN'] = JHTML::_('editauction.selectAutoAcceptBIN', $auction, 1);
     $lists['quantity'] = JHTML::_('editauction.inputQuantity', $auction, 1);
     $lists['enableSuggestions'] = JHTML::_('editAuction.selectEnableSuggestions', $auction, 1);
     $lists['minNumberSuggestions'] = JHTML::_('editAuction.inputMinNumberSuggestions', $auction, 1);
     $lists['currency'] = JHTML::_('editauction.selectCurrency', $auction, 1);
     $lists['initialPrice'] = JHTML::_('editauction.inputInitialPrice', $auction, 1);
     $lists['showMaxPrice'] = JHTML::_('editauction.selectShowMaxPrice', $auction, 1);
     $lists['showNumberBids'] = JHTML::_('editauction.selectShowNumberBids', $auction, 1);
     $lists['reservePrice'] = JHTML::_('editauction.inputReservePrice', $auction, 1);
     $lists['showReservePrice'] = JHTML::_('editauction.selectShowReservePrice', $auction, 1);
     $lists['minIncrease'] = JHTML::_('editauction.inputMinIncrease', $auction, 1);
     $lists['shippingPrice'] = JHTML::_('editAuction.inputShipmentPrice', $auction, 1);
     $lists['uploadImages'] = JHTML::_('editauction.uploadImages', $auction, 1);
     $lists['paymentInfo'] = JHTML::_('editauction.textPaymentInfo', $auction, 1);
     $lists['shipmentInfo'] = JHTML::_('editauction.textShipmentInfo', $auction, 1);
     //$lists[''] = JHTML::_('editauction.',$auction);
     $lists['currentLocalTime_field'] = JHTML::_('editAuction.currentLocalTime', $auction);
     $lists['startDate_field'] = JHTML::_('editAuction.editStartDate', $auction, 1);
     $lists['endDate_field'] = JHTML::_('editAuction.editEndDate', $auction, 1);
     $lists['editFormTitle'] = JHTML::_('editAuction.formTitle', $auction);
     $auction->links = JHTML::_('auctiondetails.createLinks', $auction);
     $fields = CustomFieldsFactory::getFieldsList("auctions");
     $fields_html = JHtml::_('listauctions.displayfieldshtml', $auction, $fields);
     $custom_fields_with_cat = $model->getNrFieldsWithFilters();
     $this->assign("custom_fields", $fields);
     $this->assign("custom_fields_html", $fields_html);
     $this->assign("custom_fields_with_cat", $custom_fields_with_cat ? 1 : 0);
     $this->assign('lists', $lists);
     $this->assign('auction', $auction);
     $this->assign('bidCfg', $bidCfg);
     JHtml::_('behavior.framework');
     JHtml::_('behavior.tooltip');
     JHtml::_('behavior.calendar');
     JHTML::_('behavior.formvalidation');
     JHtml::script(JURI::root() . 'components/com_bids/js/auctions.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/date.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/multifile.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/auction_edit.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/jquery/jquery.js');
     JHtml::script(JURI::root() . 'components/com_bids/js/jquery/jquery.noconflict.js');
     JHTML::script(JURI::root() . 'components/com_bids/js/jquery/clock/jquery.clock.js');
     JHtml::script(JURI::base() . 'index.php?option=com_bids&task=jsgen&view=editauction&format=raw');
     JHtml::stylesheet(JURI::root() . 'components/com_bids/templates/default/bid_template.css');
     parent::display($tpl);
 }