function setFilters() { $app = JFactory::getApplication(); $reset = JRequest::getString('reset', ''); $this->setState('filters.reset',$reset); $this->resetFilters('reset'); foreach($this->knownFilters as $keyName=>$attribs) { $default = isset($attribs['default']) ? $attribs['default'] : null; $type = isset($attribs['type']) ? $attribs['type'] : 'none'; $value = $app->getUserStateFromRequest($this->context . '.filters.' . $keyName, $keyName, $default, $type ); if(!empty($value)) { $this->setState('filters.'.$keyName, $value ); } } $list_limit=BidsHelperTools::getItemsPerPage(); // Get the pagination request variables $this->setState('limit', $app->getUserStateFromRequest($this->context.'.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($this->context.'.filter_order_Dir', 'filter_order_Dir', "ASC")); $this->setState('filter_order', $app->getUserStateFromRequest($this->context.'.filter_order','filter_order', "start_date")); //this sets the model's filters according to custom fields $profile = BidsHelperTools::getUserProfileObject(); parent::setCustomFilters($profile); }
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(); }
function togglepowerseller() { $cid = JRequest::getVar("cid", array()); if (count($cid) < 1) { $this->setRedirect('index.php?option=com_bids&task=users', JText::_('COM_BIDS_SELECT_AN_USER')); } foreach ($cid as $id) { $profile = BidsHelperTools::getUserProfileObject($id); $profile->setFieldValue('powerseller', '1-#fieldName', $id); } $this->setRedirect('index.php?option=com_bids&task=users', JText::_('COM_BIDS_SUCCES')); }
function display() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $id = JRequest::getInt('id', 0, 'default', 'int'); if (!$id) { $cid = JRequest::getVar('cid', array()); $id = $cid[0]; } $profile = BidsHelperTools::getUserProfileObject($id); $lists = array(); $db->setQuery("SELECT\r\n rating,count(*) as nr,\r\n auction_id, a.title as auction,\r\n voter_id, u.username\r\n FROM #__bid_rate\r\n LEFT JOIN #__bid_auctions AS a on auction_id = a.id\r\n LEFT JOIN #__users AS u on voter_id = u.id\r\n WHERE user_rated_id=" . $db->quote($id) . "\r\n GROUP BY rating\r\n ORDER BY rating"); $lists['ratings'] = $db->loadObjectList(); $db->setQuery("SELECT\r\n m.id,\r\n auction_id, a.title as auction,\r\n u.id as from_id, u.username as fromuser,\r\n u2.id as to_id, u2.username as touser,\r\n m.modified,\r\n m.message,\r\n m.published\r\n\r\n FROM #__bid_messages as m\r\n LEFT JOIN #__bid_auctions AS a on m.auction_id = a.id\r\n LEFT JOIN #__users AS u on m.userid1 = u.id\r\n LEFT JOIN #__users AS u2 on m.userid2 = u2.id\r\n WHERE userid1=" . $db->quote($id) . " OR userid2 = " . $db->quote($id)); $lists['messages'] = $db->loadObjectList(); $query = "SELECT COUNT(*) AS nr_auctions,MAX(modified) AS last_auction_date FROM #__bid_auctions WHERE userid='{$id}'"; $db->setQuery($query); $res = $db->loadAssocList(); $lists['nr_auctions'] = $res[0]['nr_auctions']; $lists['last_auction_placed'] = $res[0]['last_auction_date']; $query = "select count(*) as nr_bids_won from #__bids where userid='{$id}' and accept=1 "; $db->setQuery($query); $res = $db->loadAssocList(); $lists['nr_won_bids'] = $res[0]['nr_bids_won']; $query = "select count(*) as nr_bids, max(modified) as last_date from #__bids where userid='{$id}' "; $db->setQuery($query); $res = $db->loadAssocList(); $lists['nr_bids'] = $res[0]['nr_bids']; $lists['last_bid_placed'] = $res[0]['last_date']; $query = "select c.*, a.title, a.BIN_price, cr.name as currency\r\n\t\tFROM #__bids as c\r\n\t\tLEFT join #__bid_auctions as a on c.auction_id = a.id\r\n\t\tLEFT join #__bid_currency as cr on a.currency = cr.id\r\n\t\tWHERE c.userid = '{$id}'"; $db->setQuery($query); $lists['bids'] = $db->loadObjectList(); $query = "SELECT * FROM #__bid_payment_balance WHERE userid=" . $db->quote($id); $db->setQuery($query); $r = $db->loadObject(); $lists['balance'] = new stdClass(); $lists['balance']->balance = isset($r->balance) ? $r->balance : 0; $lists['balance']->currency = isset($r->currency) ? $r->currency : ''; $u = JTable::getInstance('user'); $u->load($profile->id); jimport('joomla.html.pane'); $pane = JPane::getInstance('sliders', array('allowAllClose' => true)); JHTML::_('behavior.tooltip'); $this->assignRef('lists', $lists); $this->assignRef('pane', $pane); $this->assignRef('u', $u); $this->assignRef('user', $profile); parent::display(); }
function _selectProfileIntegrationFilter($filterName, $filterValue = null) { static $filters = array(); if (!isset($filters[$filterName])) { $db = JFactory::getDbo(); $profile = BidsHelperTools::getUserProfileObject(); $tableField = $profile->getFilterField($filterName); $tableName = $profile->getFilterTable($filterName); $query = 'SELECT DISTINCT `' . $tableField . '` AS value, `' . $tableField . '` AS text FROM `' . $tableName . '`' . 'WHERE `' . $tableField . '`<>\'\''; $db->setQuery($query); $rows = array(); $rows[] = JHTML::_('select.option', '', JText::_('COM_BIDS_ALL')); $rows = array_merge($rows, $db->loadObjectList()); $filters[$filterName] = JHTML::_('select.genericlist', $rows, 'user_profile%' . $tableField, 'class="inputbox"', 'value', 'text', $filterValue); } return $filters[$filterName]; }
function getItemPrice() { $userprofile = BidsHelperTools::getUserProfileObject(); $userprofile->getUserProfile(); $r = $this->loadPricingObject(); $params = new JParameter($r->params); if (isset($userprofile->powerseller) && $userprofile->powerseller) { $defaultprice = $params->get('price_powerseller', $r->price); } elseif (isset($userprofile->verified) && $userprofile->verified) { $defaultprice = $params->get('price_verified', $r->price); } else { $defaultprice = $r->price; } $res = new stdClass(); $res->price = $defaultprice; $res->currency = $r->currency; return $res; }
function __construct() { parent::__construct(); $this->register_function('print_price', array($this,'smarty_print_price')); $this->register_function('printdate',array($this,'smarty_printdate')); $this->register_function('set_css',array($this,'smarty_set_css')); $this->register_function('jroute',array($this,'smarty_jroute')); $cfg=BidsHelperTools::getConfig(); if($cfg->theme) { $this->template_dir = JPATH_COMPONENT_SITE . DS . 'templates' . DS . $cfg->theme . DS; } $this->assign_by_ref('bidCfg',$cfg); $this->assign('AUCTION_PICTURES',AUCTION_PICTURES); $this->assign('AUCTION_TYPES',array( 'AUCTION_TYPE_PUBLIC'=> AUCTION_TYPE_PUBLIC, 'AUCTION_TYPE_PRIVATE'=>AUCTION_TYPE_PRIVATE, 'AUCTION_TYPE_BIN_ONLY'=> AUCTION_TYPE_BIN_ONLY )); $this->assign('TEMPLATE_IMAGES',JURI::root().'components/'.APP_EXTENSION.'/templates/'.$cfg->theme.'/images/'); $this->assign('links',new BidsHelperRoute() ); $this->config_dir =JPATH_COMPONENT_SITE.DS.'templates'.DS.'configs'.DS; $userProfile = BidsHelperTools::getUserProfileObject(); $has_profile = $userProfile->checkProfile(); $this->assign('has_profile', $has_profile); $jdoc = JFactory::getDocument(); $this->assign('document_type', $jdoc->getType()); // from 1.7.0 $arr_dateformat = array( 'Y-m-d' => '%Y-%m-%d', 'Y-d-m' => '%Y-%d-%m', 'm/d/Y' => '%m/%d/%Y', 'd/m/Y' => '%d/%m/%Y', 'd.m.Y' => '%d.%m.%Y', 'D, F d Y' => '%Y-%m-%d'); $this->assign('opt_date_format', $arr_dateformat[$cfg->bid_opt_date_format]); }
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); }
function getItemPrice($category) { $userprofile = BidsHelperTools::getUserProfileObject(); $userprofile->getUserProfile(); $r = $this->loadPricingObject(); $params = new JParameter($r->params); if (isset($userprofile->powerseller) && $userprofile->powerseller) { $defaultprice = $params->get('price_powerseller', $r->price); } elseif (isset($userprofile->verified) && $userprofile->verified) { $defaultprice = $params->get('price_verified', $r->price); } else { $defaultprice = $r->price; } $db = $this->getDbo(); $db->setQuery("select price from `#__" . APP_PREFIX . "_pricing_categories` where `itemname`='" . $this->name . "' and category='{$category}'"); $price = $db->loadResult(); $res = new stdClass(); $res->price = $price === NULL ? $defaultprice : $price; $res->currency = $r->currency; return $res; }
function display($tmpl) { $model = $this->getModel('suggestions'); $userProfile = BidsHelperTools::getUserProfileObject(); $filter_bidtype = $model->getState('filters.filter_bidtype'); $lists['filter_bidtype'] = JHTML::_('listauctions.selectBidType', $filter_bidtype ); $sfilters['bid_type'] = $filter_bidtype; $gallery = BidsHelperGallery::getGalleryPlugin(); $suggestions = $model->get('suggestions'); $rownr = 0; foreach($suggestions as &$s) { $s->rownr = ++$rownr; $s->links = JHTML::_('auctiondetails.createLinks',$s); BidsHelperAuction::renderAuctionTiming($s); $s->countdownHtml = JHTML::_('auctiondetails.countdownHtml',$s); $gallery->clearImages(); $gallery->addImageList(explode(',', $s->pictures)); $s->thumbnail = $gallery->getThumbImage(); } JHTML::script(JURI::root().'components/com_bids/js/jquery/jquery.js'); JHTML::script(JURI::root().'components/com_bids/js/jquery/jquery.noconflict.js'); BidsHelperHtml::loadCountdownJS(); JHTML::script( JURI::root().'components/com_bids/js/startup.js' ); $this->assign('auction_rows', $suggestions); $this->assign('pagination', $model->get('pagination') ); $this->assign('lists', $lists); $this->assign('sfilters', $sfilters); $this->assign('userProfile',$userProfile); parent::display($tmpl); }
function display() { $model = $this->getModel('auctions'); $lists = array(); $lists['users'] = JHTML::_('searchform.selectUsers',$model->getState('filters.users') ); $lists['active_users'] = JHTML::_('searchform.selectActiveUsers', $model->getState('filters.username') ); $lists['cats'] = JHTML::_('searchform.selectCategory', $model->getState('filters.cat') ); $lists['tags'] = JHTML::_('searchform.inputTags', $model->getState('filters.tagnames') ); $lists['after_calendar'] = JHTML::calendar($model->getState('filters.afterd'),'afterd','afterd','%Y-%m-%d'); $lists['before_calendar'] = JHTML::calendar($model->getState('filters.befored'),'befored','befored','%Y-%m-%d'); $lists['startprice'] = JHTML::_('searchform.inputPrice', 'startprice', $model->getState('filters.startprice') ); $lists['endprice'] = JHTML::_('searchform.inputPrice', 'endprice', $model->getState('filters.endprice') ); $lists['currency'] = JHTML::_('searchform.selectCurrency', 'currency', $model->getState('filters.currency')); $lists['inputReset'] = JHTML::_('searchform.inputReset'); //filters for integration fields $profile = BidsHelperTools::getUserProfileObject(); $integrationArray = $profile->getIntegrationArray(); foreach($integrationArray as $alias=>$fieldName) { if(''!=$fieldName) { $lists[$alias] = JHTML::_('searchform._selectProfileIntegrationFilter', $fieldName, $model->getState('filters.user_profile%'.$fieldName) ); } } JHTML::_('behavior.calendar'); JHTML::script(JURI::root() . 'components/com_bids/js/auctions.js'); $fields = CustomFieldsFactory::getSearchableFieldsList('auctions'); $fields_html=JHtml::_('customfields.displaysearchhtml',$fields,'divs'); $this->assign('lists', $lists); $this->assign("custom_fields_html", $fields_html ); parent::display('t_search.tpl'); }
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 . ' ' . 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 htmlLabelFilters($filters) { $database = JFactory::getDBO(); $searchstrings = array(); if ($filters->get('keyword')) { $searchstrings[JText::_('COM_BIDS_FILTER_KEYWORD')] = $filters->get('keyword'); } if ($filters->get('userid')) { $u = JFactory::getUser($filters->get('userid')); if ($u && !$u->block) { $searchstrings[JText::_('COM_BIDS_FILTER_USERS')] = $u->username; } } if ($filters->get('users')) { $users = array_filter($filters->get('users')); foreach ($users as $k => $u) { $users[$k] = intval($u); if (!$users[$k]) { unset($users[$k]); } } if (count($users)) { $database->setQuery('SELECT username FROM #__users WHERE id IN (' . $database->escape(implode(',', $users)) . ')'); $usernames = $database->loadResultArray(); $searchstrings[JText::_('COM_BIDS_FILTER_USERS')] = implode(',', $usernames); } } $username = $filters->get('username'); if (!empty($username)) { $searchstrings[JText::_('COM_BIDS_FILTER_USERS')] = $username; } if ($filters->get('cat')) { $database->setQuery("SELECT title FROM #__categories WHERE id='" . $database->getEscaped($filters->get('cat')) . "'"); $catname = $database->loadResult(); $searchstrings[JText::_('COM_BIDS_FILTER_CATEGORY')] = $catname; } if ($filters->get('afterd')) { $searchstrings[JText::_('COM_BIDS_FILTER_START_DATE')] = $filters->get('afterd'); } if ($filters->get('befored')) { $searchstrings[JText::_('COM_BIDS_FILTER_END_DATE')] = $filters->get('befored'); } if ($filters->get('tagid')) { $database->setQuery('SELECT tagname FROM #__bid_tags WHERE id=' . $database->quote($filters->get('tagid'))); $searchstrings[JText::_('COM_BIDS_FILTER_TAGS')] = $database->loadResult(); } if ($filters->get('tagnames')) { $searchstrings[JText::_('COM_BIDS_FILTER_TAGS_LIKE')] = $filters->get('tagnames'); } if ($filters->get('auction_nr')) { $searchstrings[JText::_('COM_BIDS_FILTER_AUCTION_NUMBER')] = $filters->get('auction_nr'); } if ($filters->get('inarch')) { $searchstrings[JText::_('COM_BIDS_FILTER_ARCHIVE')] = $filters->get('inarch') == 1 ? JText::_('COM_BIDS_YES') : JText::_('COM_BIDS_NO'); } if ($filters->get('filter_rated')) { $searchstrings[JText::_('COM_BIDS_FILTER_RATED')] = JText::_('COM_BIDS_UNRATED'); } if ($filters->get('country')) { $searchstrings[JText::_('COM_BIDS_FILTER_COUNTRY')] = $filters->get('country'); } if ($filters->get('city')) { $searchstrings[JText::_('COM_BIDS_FILTER_CITY')] = $filters->get('city'); } if ($filters->get('area')) { $searchstrings[JText::_('COM_BIDS_FILTER_AREA')] = $filters->get('area'); } if ($filters->get('currency')) { if ($filters->get('startprice')) { $searchstrings[JText::_('COM_BIDS_PRICE_GT')] = $filters->get('startprice') . ' ' . $filters->get('currency'); } if ($filters->get('endprice')) { $searchstrings[JText::_('COM_BIDS_PRICE_LT')] = $filters->get('endprice') . ' ' . $filters->get('currency'); } } //integration filter labels $profile = BidsHelperTools::getUserProfileObject(); $integrationArray = $profile->getIntegrationArray(); foreach ($integrationArray as $alias => $fieldName) { if ($fieldName) { if ($fValue = $filters->get('user_profile%' . $fieldName)) { //$searchstrings[JText::_( strtoupper('COM_BIDS_'.$alias) )] = $fValue; } } } //custom fields filter labels $searchableFields = CustomFieldsFactory::getSearchableFieldsList(); foreach ($searchableFields as $field) { $requestKey = $field->page . '%' . $field->db_name; if ($filters->get($requestKey)) { $ftype = CustomFieldsFactory::getFieldType($field->ftype ? $field->ftype : 'inputbox'); $searchstrings[JText::_($field->name)] = $ftype->htmlSearchLabel($field, $filters->get($requestKey)); } } return $searchstrings; }
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; } }
private function buildQuery() { $user = JFactory::getUser(); $db = JFactory::getDBO(); $cfg = BidsHelperTools::getConfig(); $query = JTheFactoryDatabase::getQuery(); $query->from('#__bid_auctions','a'); //SELECTS $query->select('`a`.*'); $query->select('`a`.id AS auctionId'); //$query->select('`cat`.`id` as cati, `cat`.`catname`, `catsef`.`categories` as catslug'); $query->select('`cat`.`id` as cati, `cat`.`title` AS categoryname'); $query->select('`u`.`username`'); $query->select('GROUP_CONCAT(DISTINCT `t`.`id`) AS tagIds'); $query->select('GROUP_CONCAT(DISTINCT `t`.`tagname`) AS tagNames'); $query->select('GROUP_CONCAT(`pics`.`picture` ORDER BY `pics`.`ordering`) AS pictures'); $query->select('COUNT(DISTINCT bids.userid) AS nr_bidders'); $query->select( 'CASE a.auction_type WHEN '.AUCTION_TYPE_PUBLIC.' THEN MAX(bids.bid_price) WHEN '.AUCTION_TYPE_PRIVATE.' THEN a.initial_price WHEN '.AUCTION_TYPE_BIN_ONLY.' THEN a.bin_price END AS highest_bid' ); //NEXT ONE IS USED FOR PRICE RANGE SEARCHES $query->select( 'CASE a.auction_type WHEN ' . AUCTION_TYPE_PUBLIC . ' THEN IF(MAX(bids.bid_price)>0,MAX(bids.bid_price),a.initial_price) WHEN ' . AUCTION_TYPE_PRIVATE . ' THEN a.initial_price WHEN ' . AUCTION_TYPE_BIN_ONLY . ' THEN a.bin_price END AS current_price' ); $query->select('GROUP_CONCAT(IF(bids.userid='.$user->id.',bids.bid_price,NULL)) AS mybid'); $query->select('AVG(ru.rating) AS rating_overall'); $query->select('IF(ru.rate_type=\'auctioneer\',AVG(ru.rating),0) as rating_auctioneer'); $query->select('IF(ru.rate_type=\'bidder\',AVG(ru.rating),0) as rating_bidder'); if($cfg->bid_opt_quantity_enabled) { $query->select('bids.quantity AS nr_items'); } else { $query->select('1 AS nr_items'); } //JOINS $query->join('left','#__bids','bids','`bids`.`auction_id`=`a`.`id`'); $query->join('left','#__bid_rate','ru','ru.user_rated_id=`a`.`userid`'); $query->join('left','#__categories','cat','`a`.`cat`=`cat`.`id`'); $query->join('left','#__bid_tags','t','`a`.`id`=`t`.`auction_id`'); $query->join('left','#__bid_pictures','pics','`a`.`id`=`pics`.`auction_id`'); //WHERE conditions if ($user->id) { $query->select('IF ( `a`.`userid` = \'' . $user->id . '\', 1, 0 ) AS `isMyAuction`'); $query->select('IF ( `fav_table`.`id`>0, 1, 0 ) AS favorite'); } else { $query->select('0 AS `isMyAuction`'); $query->select('-1 AS `favorite`'); } if($this->getState('behavior')!='mywatchlist') { $query->join('left','#__bid_watchlist','fav_table','`fav_table`.`auction_id`=`a`.`id` AND `fav_table`.`userid`='.$user->id); } switch($this->getState('behavior')) { case 'myauctions': $query->where('`a`.`userid` = \'' . $user->id . '\''); switch ($this->getState('filters.filter_archive')) { case 'active': $query->where('`a`.`close_by_admin`=0'); $query->where('`a`.`close_offer`=0'); $query->where('`a`.`published`=1'); break; case 'unpublished': $query->where('`a`.`close_by_admin`=0'); $query->where('`a`.`close_offer`=0'); $query->where('`a`.`published`=0'); break; case 'archived': $query->where('`a`.`close_offer`=1'); break; case 'unsold': $query->where('`a`.`close_by_admin`=0'); $query->where('`a`.`close_offer`=1'); $query->where('`bids`.`accept`=0 OR `bids`.`accept` IS NULL'); break; case 'sold': $query->where('`a`.`close_by_admin`=0'); //auction_type=3 --> BIN Only with items sold $query->where('(`a`.`close_offer`=1 and `bids`.`accept`=1) OR (`a`.`auction_type`=3 and `a`.`quantity`<`a`.`nr_items`)'); break; case 'banned': $query->where('`a`.`close_by_admin`=1'); break; } $query->where(array('`cat`.`published`=1','`cat`.`published` IS NULL'),'OR'); if ($this->getState('filters.cat')) { if (!$cfg->bid_opt_inner_categories) { $query->where(" a.cat= '" . $db->escape($this->getState('filters.cat')) . "' "); } else { $catModel = BidsHelperTools::getCategoryModel(); $cTree = $catModel->getCategoryTree($this->getState('filters.cat'),false); $cat_ids = array(); if ($cTree) { foreach ($cTree as $cc) { if ($cc->id) $cat_ids[] = $cc->id; } } if (count($cat_ids)) { $cat_ids = implode(',', $cat_ids); } $query->where(' a.cat IN (' . $db->escape($cat_ids) . ') '); } } break; case 'mybids': //need a second join with table #__bids, for filtering purposes $query->join('left','#__bids','bids2','`bids2`.`auction_id`=`a`.`id`'); $query->where('`bids2`.`userid` = \'' . $user->id . '\''); //get my proxy $query->select('proxy.max_proxy_price AS my_proxy_bid'); $query->join('left','#__bid_proxy','proxy','`proxy`.`auction_id`=`a`.`id` AND `proxy`.`user_id`='.$user->id); $query->select('bids2.modified AS mybid_date'); switch ($this->getState('filters.filter_bidtype')) { default: case 0: $query->where('`a`.`close_offer`=0'); $query->where('`a`.`close_by_admin`=0'); break; case 1: $query->where('`a`.`close_by_admin`=0'); $query->where('`a`.`close_offer`=1'); break; } break; case 'mywonbids': $query->where('`bids`.`userid`='.intval($user->id)); $query->where('`bids`.`accept`=1'); break; case 'mywatchlist': $query->join('inner','#__bid_watchlist','fav_table','`fav_table`.`auction_id`=`a`.`id` AND `fav_table`.`userid`='.intval($user->id)); break; case 'listauctions': $query->where('`a`.`close_by_admin`=0'); switch ($this->getState('filters.filter_type')) { default: case 'all': //nothing break; case 'auctions_only': $query->where('a.BIN_price<=0'); break; case 'bin_only': $query->where('a.BIN_price>0'); break; } if (!$this->getState('filters.inarch')) { $query->where('`a`.`published`=1'); $query->where('a.close_offer=0'); } if ($this->getState('filters.keyword')) { $keyword = $db->escape($this->getState('filters.keyword')); $w = array(); $w[] = 'a.title LIKE \'%' . $keyword . '%\''; if ($this->getState('filters.indesc')) { $w[] = 'a.shortdescription LIKE \'%' . $keyword . '%\''; $w[] = 'a.description LIKE \'%' . $keyword . '%\''; } $query->where($w,'OR'); } if ($this->getState('filters.userid')) { $query->where(" a.userid = '" . $db->escape($this->getState('filters.userid')) . "' "); } $users = (array) $this->getState('filters.users'); $users = array_filter($users); foreach ($users as $k => $u) { $users[$k] = intval($u); if (!$users[$k]) { unset($users[$k]); } } if (count($users)) { $query->where(' a.userid IN (' . $db->escape(implode(',', $users)) . ') '); } $username = $this->getState('filters.username'); if( !empty($username) ) { $query->where(' u.username LIKE \'%' . $db->escape($username) . '%\' '); } if ( $this->getState('filters.tagnames') ) { $query->join('left','#__bid_tags','search_tagname2','`a`.`id`=`search_tagname2`.`auction_id`'); $query->where(' search_tagname2.tagname LIKE \'%' . $db->escape($this->getState('filters.keyword')) . '%\' '); } if ($this->getState('filters.tagid')) { $query->join('left','#__bid_tags','search_tagid','`a`.`id`=`search_tagid`.`auction_id`'); $query->join('left','#__bid_tags','search_tagname','`search_tagid`.`tagname`=`search_tagname`.`tagname`'); $query->where(" search_tagname.id='" . $db->escape($this->getState('filters.tagid')) . "'"); } if ($this->getState('filters.auction_nr')) { $query->where(" a.auction_nr ='" . $db->escape($this->getState('filters.auction_nr')) . "' "); } $query->where(array('`cat`.`published`=1','`cat`.`published` IS NULL'),'OR'); if ($this->getState('filters.cat')) { if (!$cfg->bid_opt_inner_categories) { $query->where(" a.cat= '" . $db->escape($this->getState('filters.cat')) . "' "); } else { $catModel = BidsHelperTools::getCategoryModel(); $cTree=$catModel->getCategoryTree($this->getState('filters.cat'),false); $cat_ids = array(); if ($cTree) { foreach ($cTree as $cc) { if ($cc->id) $cat_ids[] = $cc->id; } } if (count($cat_ids)) { $cat_ids = implode(',', $cat_ids); $query->where(' a.cat IN (' . $db->escape($cat_ids) . ') '); } } } if ($this->getState('filters.afterd')) { $query->where(' a.start_date>=\'' . $db->escape($this->getState('filters.afterd')) . '\''); } elseif(!$this->getState('filters.inarch')) { $query->where(' a.start_date<=UTC_TIMESTAMP()'); } if ($this->getState('filters.befored')) { $query->where('a.end_date<=\'' . $db->escape($this->getState('filters.befored')) . '\''); } elseif(!$this->getState('filters.inarch')) { $query->where(' a.end_date>=UTC_TIMESTAMP()'); } if($this->getState('filters.currency')) { $q = $db->getQuery(true); $q->select( '`name`,`convert`' ) ->from( '#__bid_currency' ) ; $db->setQuery($q); $currencies = $db->loadAssocList('name'); if(isset($currencies[$this->getState('filters.currency')])) { $query->select('curr.convert AS auctionCurrencyConversionRate'); $query->join('left','#__bid_currency','curr','a.currency=curr.name'); $this->_searchWithCurrency = true; $searchCurrencyConversionRate = $currencies[$this->getState('filters.currency')]['convert']; if ($this->getState('filters.startprice')) { $query->having( 'current_price>=('.$searchCurrencyConversionRate.'/COALESCE (auctionCurrencyConversionRate,1))*' . $db->escape($this->getState('filters.startprice')) . ' ' ); } if ($this->getState('filters.endprice')) { $query->having( 'current_price<=(' . $searchCurrencyConversionRate . '/COALESCE (auctionCurrencyConversionRate,1))*' . $db->escape($this->getState('filters.endprice')) . ' ' ); } } } if($user->id) { $query->select('1-MIN(msg.wasread) AS nrNewMessages'); $query->join('left','#__bid_messages','msg', 'a.id=msg.auction_id AND msg.userid2='.$user->id); } break; } // Featurings first if($this->getState('behavior')=='mywatchlist') { $query->order('`a`.`end_date` ASC'); } else { $query->order('`a`.`featured`=\'featured\' DESC'); $query->order('`a`.`featured`=\'none\' DESC'); } // Required ordering filter $filter_order = (string) $this->getState('filters.filter_order'); if ($filter_order) { $filter_order_Dir = $this->getState('filters.filter_order_Dir'); $query->order( $db->escape($this->order_fields[$filter_order] . ' ' . $filter_order_Dir ) ); } else { $query->order('`a`.`end_date` ASC'); } $query->group('`a`.`id`'); $profile = BidsHelperTools::getUserProfileObject(); $additionalFields = array('paypalemail'); //this binds to the query object everything that is related to custom fields parent::buildCustomQuery($query,$profile,'`a`.`userid`',$additionalFields); return $query; }
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); }
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(); }
function getUserCountries() { $db= $this->getDbo(); $query = JTheFactoryDatabase::getQuery(); $profile = BidsHelperTools::getUserProfileObject(); $field = $profile->getFilterField('country'); $table = $profile->getFilterTable('country'); $query->select("distinct `{$field}` country"); $query->from($table); $query->where("`{$field}`<>'' and `{$field}` is not null"); $db->setQuery((string)$query); return $db->loadObjectList(); }
function buildQuery() { $db = JFactory::getDbo(); $query = JTheFactoryDatabase::getQuery(); $query->select('`u`.*,`u`.`id` AS userid'); $query->select('null AS password'); $query->select('AVG(r.rating) AS rating_overall'); $query->select('COUNT(DISTINCT au.id) AS nr_auctions'); $query->select('COUNT(DISTINCT bi.id) AS nr_bids'); $query->from('#__users','u'); $query->join('left','#__bid_rate','r','`u`.`id`=`r`.`user_rated_id`'); $query->join('left','#__bid_auctions','au','`u`.`id`=`au`.`userid` and au.`published`=1'); $query->join('left','#__bids','bi','`u`.`id`=`bi`.`userid`'); $profile = BidsHelperTools::getUserProfileObject(); $this->buildCustomQuery($query,$profile); $queriedTables = $query->getQueriedTables(); //all the filters are profile related; in order to work, we have to append them to the query AFTER the join has been made with the profile tables, in parent::buildCustomQuery() $keyword = $this->getState('filters.keyword'); $name = $this->getState('filters.name'); $k = $keyword ? $keyword : ( $name ? $name : null ); if($k) { $s = array(); $table = $profile->getFilterTable('username'); $field = $profile->getFilterField('username'); $alias = array_search($table,$queriedTables); $s[] = ' (`'.$alias.'`.`'.$field.'` LIKE \'%'.$db->getEscaped($k).'%\') '; $table = $profile->getFilterTable('name'); $field = $profile->getFilterField('name'); if($table && $field) { $alias = array_search($table,$queriedTables); $s[] = ' (`'.$alias.'`.`'.$field.'` LIKE \'%'.$db->getEscaped($k).'%\') '; } $table = $profile->getFilterTable('surname'); $field = $profile->getFilterField('surname');; if($table && $field) { $alias = array_search($table,$queriedTables); $s[] = ' (`'.$alias.'`.`'.$field.'` LIKE \'%'.$db->getEscaped($k).'%\') '; } $query->where($s,'OR'); } switch ($this->getState('filters.search_type')){ case 1: $table = $profile->getFilterTable('isBidder'); $alias = array_search($table,$queriedTables); $query->where( ' (`'.$alias.'`.`name`=1 ' ); break; case 2: $table = $profile->getFilterTable('isSeller'); $alias = array_search($table,$queriedTables); $query->where( ' (`'.$alias.'`.`name`=1 ' ); break; } $filter_order = $this->getState('filters.filter_order'); if ($filter_order) { $filter_order_Dir = $this->getState('filters.filter_order_Dir'); $query->order( $db->getEscaped($filter_order . ' ' . $filter_order_Dir ) ); } $query->group('`u`.`id`'); return $query; }