static function letterFilter($filter_cat) { $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $filter_letter = JRequest::getString('filter_letter', 'all'); $letters_filter = "<div id='box_letters_filter'>"; foreach ($letters as $letter) { $active = strtolower($filter_letter) == strtolower($letter) ? 'active' : ''; $letters_filter .= "<a href='" . BidsHelperRoute::getCategoryRoute($filter_cat, 'listcats', null, true, $letter) . "' class='" . $active . "'>" . $letter . "</a>"; } // List all categories $letters_filter .= "<a href='" . BidsHelperRoute::getCategoryRoute($filter_cat, 'listcats', null, true, 'all') . "'>" . JText::_('COM_BIDS_CATEGORIES_LETTER_FILTER_ALL') . "</a>"; $letters_filter .= "</div>"; return $letters_filter; }
static function prepareCategoryTree(&$categories,$task='categories') { uasort($categories,array('self','levelSort')); foreach($categories as $k=>$cat) { $cat->link = BidsHelperRoute::getCategoryRoute($cat->id,$task); $cat->view = BidsHelperRoute::getAuctionListRoute(array('cat'=>$cat->id)); if (isset($cat->watchListed_flag)) { $cat->link_watchlist = $cat->watchListed_flag ? BidsHelperRoute::getDelToCatWatchlist($cat->id) : BidsHelperRoute::getAddToCatWatchlist($cat->id); } if(isset($categories[$cat->parent_id]) ) { $categories[$cat->parent_id]->subcategories[] = $cat; unset($categories[$k]); } } }
function getDisplayTab($tab, $user, $ui) { $my = JFactory::getUser(); $database = &JFactory::getDBO(); if ($my->id != $user->user_id || !$my->id) { return; } $componentPath = JPATH_SITE . DS . 'components' . DS . 'com_bids'; require_once($componentPath.DS.'options.php'); $cfg = new BidConfig(); require_once($componentPath . DS . 'helpers' . DS . 'tools.php'); require_once($componentPath . DS . 'thefactory' . DS . 'front.userprofile.php'); require_once($componentPath . DS . 'helpers' . DS . 'profile.php'); JModel::addIncludePath($componentPath . DS . 'models'); $bidsUserModel = JModel::getInstance('user','bidsModel'); $bidsUserModel->loadUser($my->id); $bidsProfile = $bidsUserModel->get('profile'); $balance = $bidsUserModel->getBalance(); //here begins output $html = '<div> <table width="100%"> <tr> <td colspan="4">'; if($cfg->bid_opt_enable_acl) { $sellerImg = JURI::root() . 'components/com_bids/images/f_can_sell'.( !empty($bidsProfile->isSeller) ? '1':'2').'.gif'; $html .= '<div style="width:120px;float:left;">'. JHTML::image($sellerImg,'','style="margin-right:50px;" border="0"'). '</div>'; $bidderImg = JURI::root() . 'components/com_bids/images/f_can_buy'.( !empty($bidsProfile->isBidder) ? '1':'2').'.gif'; $html .= '<div style="width:120px;float:left;">'. JHTML::image($bidderImg,'','style="margin-right:60px;" border="0"'). '</div>'; } elseif(!empty($bidsProfile->powerseller)) { $sellerImg = JURI::root() . 'components/com_bids/images/f_can_sell'.( !empty($bidsProfile->isSeller) ? '1':'2').'.gif'; $html .= '<div style="width:120px;float:left;">'. JHTML::image($sellerImg,'','style="margin-right:50px;" border="0"'). '</div>'; } $verifiedImg = JURI::root() . 'components/com_bids/images/verified_'.( !empty($bidsProfile->verified) ? '1':'0').'.gif'; $html .= '<div style="width:120px;float:left;">'. JHTML::image($verifiedImg,'','style="margin-right:50px;" border="0"'). '</div> </td> </tr> <tr> <td colspan="4">'; if($cfg->bid_opt_enable_acl) { if (!empty($bidsProfile->isSeller)){ $html .= "<div style='width:120px;float:left;'>" . Jtext::_('COM_BIDS_acl_group_seller') . ":" . ($bidsProfile->powerseller ? JText::_('Powerseller') : JText::_('Seller')) . "</div>"; } else { $html .= "<div style='width:120px;float:left;'>" . Jtext::_('COM_BIDS_acl_group_seller') . ":" . ($bidsProfile->isSeller ? Jtext::_('COM_BIDS_YES') : Jtext::_('COM_BIDS_no') ) . "</div>"; } $html .= "<div style='width:120px;float:left;'>" . Jtext::_('COM_BIDS_acl_group_bidder') . ":" . ($bidsProfile->isBidder ? Jtext::_('COM_BIDS_YES') : Jtext::_('COM_BIDS_no') ) . "</div>"; } elseif(!empty($bidsProfile->powerseller)) { $html .= "<div style='width:120px;float:left;'>" . Jtext::_('COM_BIDS_acl_group_seller') . ":" . ($bidsProfile->powerseller ? JText::_('Powerseller') : JText::_('Seller')) . "</div>"; } $html .= "<div style='width:120px;float:left;'>" . Jtext::_('COM_BIDS_user_verified') . ":" . ( (isset($bidsProfile->verified) && $bidsProfile->verified) ? Jtext::_('COM_BIDS_YES') : Jtext::_('COM_BIDS_no') ) . "</div>". '</td> </tr> <tr> <td colspan="4">'; $tasklist = array( 'newauction' => 'f_newauction.png', 'myauctions' => 'f_myauctions.png ', 'mybids' => 'f_mybids.png', 'mywonbids' => 'f_mywonbids.png', 'mywatchlist' => 'f_mywatchlist.png', 'listcats' => 'f_listcats.png', 'listauctions' => 'f_listauctions.png', 'search' => 'f_search.png' ); $keys = array_keys($tasklist); $html .= '<table width="100%"> <tr>'; for ($i = 0; $i < count($keys) / 2; $i++) { $f_task = JRoute::_("index.php?option=com_bids&task=" . $keys[$i]); $html .= "<td width='100'><a href='$f_task'><img src='" . JURI::root() . "components/com_bids/images/menu/" . $tasklist[$keys[$i]] . "' border=0></a></td>"; } $html .= '</tr> <tr>'; for ($i = count($keys) / 2; $i < count($keys); $i++) { $f_task = JRoute::_("index.php?option=com_bids&task=" . $keys[$i]); $html .= "<td width='100'><a href='$f_task'><img src='" . JURI::root() . "components/com_bids/images/menu/" . $tasklist[$keys[$i]] . "' border=0></a></td>"; } $html .= '</tr> </table> </td> </tr>'; $html .= '<tr> <td> <div class="auction_credits">'. JText::_('COM_BIDS_YOUR_CURRENT_BALANCE_IS').' '. $balance->balance.' '.$balance->currency. '</div> <div> <a href="'.BidsHelperRoute::getAddFundsRoute().'">'. JText::_('COM_BIDS_ADD_FUNDS_TO_YOUR_BALANCE'). '</a> </div> <div> <a href="'.BidsHelperRoute::getPaymentsHistoryRoute().'">'. JText::_('COM_BIDS_SEE_MY_PAYMENTS_HISTORY'). '</a> </div> </td> </tr>'; $html .= '</table> </div>'; return $html; }
function onBeforeExecuteTask(&$stopexecution) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $task = JRequest::getCmd('task', 'listauctions'); if ($task == 'paycomission') { $stopexecution = true; //task is fully processed here $app = JFactory::getApplication(); $user = JFactory::getUser(); $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $balance = $modelbalance->getUserBalance(); if ($balance->balance >= 0) { JError::raiseNotice(501, JText::_("COM_BIDS_YOU_HAVE_A_POSITIVE_BALANCE")); $app->redirect(BidsHelperRoute::getAddFundsRoute()); return; } $model = self::getModel(); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitemFromBalance($balance); $order = $modelorder->createNewOrder($item, $item->price, $item->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); return; } }
function bidsParseRoute($segments) { $vars = array(); switch($segments[0]){ case 'viewbids': $vars['task'] = 'viewbids'; $v=explode('/',$segments[1]); $vars['id']=$v[0]; break; case 'search': $vars['task'] = 'search'; break; case 'tags': $vars['task'] = 'tags'; $vars['tagid'] = $segments[1].':'.$segments[2]; break; case 'listauctions': $vars['task'] = 'listauctions'; $categories = $segments; unset($categories[0]); if( isset($segments[1]) && $segments[1]=="user" ) { $vars['users']=$segments[2]; } else { $vars['cat']=end($categories); } break; case 'userdetails': $vars['task']='userdetails'; $userId = isset($segments[1]) ? $segments[1] : 0; if($userId) { $vars['id']=$userId; } break; case 'listcats': case 'tree': $vars['task'] = $segments[0]; if(count($segments)>1) { $vars['cat'] = intval(end($segments)); } break; default: $vars['task'] = $segments[0]; break; } $needles = array(); if(!empty($vars['task'])) { $needles["task"]=$vars['task']; if($router_itemID = BidsHelperRoute::getMenuItemId($needles)){ $vars["Itemid"] = $router_itemID; } } return $vars; }
function onAfterExecuteTask($controller) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $session = JFactory::getSession(); $orderid = $session->get('checkout-order', 0, self::getContext()); $session->set('checkout-order', null, self::getContext()); $session->clear('checkout-order', self::getContext()); if ($orderid) { $controller->setRedirect(BidsHelperRoute::getCheckoutRoute($orderid, false)); } }
function onBeforeExecuteTask(&$stopexecution) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $task = JRequest::getCmd('task', 'listauctions'); if ($task == 'setfeatured') { $id = JRequest::getInt("id"); $auction = JTable::getInstance('auction'); $app = JFactory::getApplication(); if (!$auction->load($id)) { JError::raiseWarning(550, JText::_("COM_BIDS_ERROR_LOADING_AUCTION_ID") . $id); $app->redirect(BidsHelperRoute::getAuctionDetailRoute($auction)); return; } if (!$auction->isMyAuction()) { JError::raiseWarning(501, JText::_("COM_BIDS_THIS_AUCTION_DOES_NOT_BELONG_TO_YOU")); $app->redirect(BidsHelperRoute::getAuctionDetailRoute($auction)); return; } $model = self::getModel(); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $price = $model->getItemPrice(); $balance = $modelbalance->getUserBalance(); $item = $model->getOderitem($auction); if (BidsHelperPrices::comparePrices($price, array("price" => $balance->balance, "currency" => $balance->currency)) > 0) { $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); return; } //get funds from account, create confirmed order $balance_minus = BidsHelperPrices::convertCurrency($price->price, $price->currency, $balance->currency); $modelbalance->decreaseBalance($balance_minus); $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'C'); $auction->featured = 'featured'; $auction->store(); $app->redirect(BidsHelperRoute::getAuctionDetailRoute($auction)); return; } }
private function generateOrder($bid, $catid, $needsPositiveBalance) { $app = JFactory::getApplication(); $model = self::getModel(); $price = $model->getItemPrice($catid); if (!floatval($price->price)) { return; } // Free publishing $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $balance = $modelbalance->getUserBalance($bid->userid); if ($needsPositiveBalance) { if (BidsHelperPrices::comparePrices($price, array("price" => $balance->balance, "currency" => $balance->currency)) > 0) { $app->enqueueMessage(JText::_('COM_BIDS_NOT_ENOUGH_FUNDS_TO_BID'), 'notice'); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitem($bid); $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); } } //get funds from account, create confirmed order $balance_minus = BidsHelperPrices::convertCurrency($price->price, $price->currency, $balance->currency); $modelbalance->decreaseBalance($balance_minus, $bid->userid); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitem($bid); $modelorder->createNewOrder($item, $price->price, $price->currency, $bid->userid, 'C'); }
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']) . '" /> <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); }
function onBeforeExecuteTask(&$stopexecution) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $task = JRequest::getCmd('task', 'listauctions'); if ($task == 'buy_contact') { $user = JFactory::getUser(); $app = JFactory::getApplication(); $id = JRequest::getInt("id"); $model = self::getModel(); if ($user->id == $id && $model->checkContact($id)) { JError::raiseWarning(501, JText::_("COM_BIDS_CONTACT_IS_ALREADY_PURCHASED")); $app->redirect(BidsHelperRoute::getUserdetailsRoute($id, false)); return; } $modelorder = JTheFactoryPricingHelper::getModel('orders'); $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $price = $model->getItemPrice(); $balance = $modelbalance->getUserBalance(); $item = $model->getOderitem($id); if (BidsHelperPrices::comparePrices($price, array("price" => $balance->balance, "currency" => $balance->currency)) > 0) { $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); return; } //get funds from account, create confirmed order $balance_minus = BidsHelperPrices::convertCurrency($price->price, $price->currency, $balance->currency); $modelbalance->decreaseBalance($balance_minus); $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'C'); $model->addContact($id, $order->userid); $app->redirect(BidsHelperRoute::getUserdetailsRoute($id)); return; } }
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; } }