static function registerEvents() { $db = JFactory::getDbo(); $db->setQuery("select * from `#__" . APP_PREFIX . "_pricing` where `enabled`=1"); $items = $db->loadObjectList(); foreach ($items as $item) { JTheFactoryEventsHelper::registerEvents(JPATH_ADMINISTRATOR . DS . 'components' . DS . APP_EXTENSION . DS . 'pricing' . DS . $item->itemname . DS . 'events'); } }
function SaveSettings() { JTheFactoryEventsHelper::triggerEvent('onBeforeSaveSettings'); $model = JModel::getInstance('Config', 'JTheFactoryModel', array('formxml' => $this->formxml)); $data = $model->getDataFromRequest(); if ($model->save($data)) { JError::raiseNotice(101, JText::_("FACTORY_SETTINGS_SAVED")); } JTheFactoryEventsHelper::triggerEvent('onAfterSaveSettings'); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=config.display"); }
static function registerModule($app = null) { if (!$app) { $app = JTheFactoryApplication::getInstance(); } if ($app->getIniValue('use_events')) { JLoader::register('JTheFactoryEvents', $app->app_path_admin . 'events/events.class.php'); JLoader::register('JTheFactoryEventsHelper', $app->app_path_admin . 'events/events.helper.php'); JLoader::register('JTheFactoryDispatcher', $app->app_path_admin . 'events/events.dispatcher.php'); if ($app->frontpage) { JTheFactoryEventsHelper::registerEvents(JPATH_SITE . DS . 'components' . DS . APP_EXTENSION . DS . 'events'); } else { JTheFactoryEventsHelper::registerEvents(JPATH_ADMINISTRATOR . DS . 'components' . DS . APP_EXTENSION . DS . 'events'); } } }
static function registerModule($app=null) { if (!$app) $app= JTheFactoryApplication::getInstance(); if ($app->getIniValue('use_payment_gateways')){ JLoader::register('JTheFactoryPricingHelper',$app->app_path_admin.'payments'.DS.'helper'.DS.'pricing.php'); JLoader::register('JTheFactoryBalanceController',$app->app_path_front.'payments'.DS.'controllers'.DS.'balance.php'); JLoader::register('JTheFactoryOrderProcessorController',$app->app_path_front.'payments'.DS.'controllers'.DS.'processor.php'); JLoader::register('JTheFactoryOrder',$app->app_path_admin.'payments'.DS.'classes'.DS.'orders.php'); if ($app->getIniValue('use_events')){ JTheFactoryPricingHelper::registerEvents(); JTheFactoryEventsHelper::registerEvents($app->app_path_admin.'payments'.DS.'events'); } $lang=JFactory::getLanguage(); $lang->load('thefactory.payments',JPATH_ADMINISTRATOR); } }
static function registerModule($app = null) { if (!$app) { $app = JTheFactoryApplication::getInstance(); } if ($app->getIniValue('use_payment_gateways')) { JLoader::register('JTheFactoryPricingHelper', $app->app_path_admin . 'payments' . DS . 'helper' . DS . 'pricing.php'); JLoader::register('JTheFactoryPaymentsHtmlHelper', $app->app_path_admin . 'payments' . DS . 'helper' . DS . 'paymentshtml.php'); JLoader::register('JTheFactoryBalancesController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'balances.php'); JLoader::register('JTheFactoryCurrenciesController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'currencies.php'); JLoader::register('JTheFactoryGatewaysController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'gateways.php'); JLoader::register('JTheFactoryOrdersController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'orders.php'); JLoader::register('JTheFactoryPricingController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'pricing.php'); if ($app->getIniValue('use_events')) { JTheFactoryPricingHelper::registerEvents(); JTheFactoryEventsHelper::registerEvents($app->app_path_admin . 'payments' . DS . 'events'); } } }
function Confirm() { $orderid = JRequest::getVar('id'); if (is_array($orderid)) { $orderid = $orderid[0]; } $order = JTable::getInstance('OrdersTable', 'JTheFactory'); $model = JModel::getInstance('Orders', 'JTheFactoryModel'); if (!$orderid || !$order->load($orderid)) { $this->setRedirect('index.php?option=' . APP_EXTENSION . '&task=orders.listing', JText::_("FACTORY_ORDER_DOES_NOT_EXIST")); return; } if ($order->status == 'C') { $this->setRedirect('index.php?option=' . APP_EXTENSION . '&task=orders.viewdetails&id=' . $orderid, JText::_("FACTORY_ORDER_IS_ALREADY_CONFIRMED")); return; } $paylog = $model->confirmOrder($order); JTheFactoryEventsHelper::triggerEvent('onPaymentForOrder', array($paylog, $order)); $this->setRedirect('index.php?option=' . APP_EXTENSION . '&task=orders.viewdetails&id=' . $orderid, JText::_("FACTORY_ORDER_WAS_CONFIRMED")); }
function display( $tpl_name, $cache_id = null, $compile_id = null){ $task = JRequest::getCmd('task'); JTheFactoryEventsHelper::triggerEvent('onBeforeDisplay',array($task,$this)); if(!file_exists($this->template_dir.$tpl_name)){ $tpl_name=JPATH_COMPONENT_SITE.DS.'templates'.DS.'default'.DS.$tpl_name; } if ($title=$this->get_template_vars('page_title')) { $doc = JFactory::getDocument(); $doc->setTitle($title); } if (!$this->get_template_vars('template_file')){ $template_file=$tpl_name; if (substr($template_file,0,2)=='t_') $template_file=substr($template_file,2); $template_file=preg_replace('#\.[^.]*$#', '', $template_file); self::assign('template_file',$template_file); } parent::display($tpl_name, $cache_id = null, $compile_id = null); JTheFactoryEventsHelper::triggerEvent('onAfterDisplay'); }
function RefreshConversions() { $model = JModel::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::_("FACTORY_ERROR_CONVERTING") . " {$currency->name} --> {$default_currency}"; continue; } $currtable->load($currency->id); $currtable->convert = $conversion; $currtable->store(); $results[] = $currency->name . " ---> " . $default_currency . " = {$conversion} see <a href='https://www.google.com/search?q=1+{$currency->name}+to+{$default_currency}' target='_blank'>in google</a>"; } JTheFactoryEventsHelper::triggerEvent('onConversionRateChange'); $view = $this->getView('currency', 'html'); $view->assignRef("default_currency", $default_currency); $view->assignRef("results", $results); $view->display("conversion"); }
function display($tmpl=null) { JHtml::_('behavior.mootools'); $jsRoot = JURI::root().'components/com_bids/js/jquery/'; JHTML::script($jsRoot.'jquery.js'); JHTML::script($jsRoot.'jquery.noconflict.js'); JHTML::script($jsRoot.'clock/jquery.clock.js'); $modelAuction = $this->getModel('auction'); $auction = $modelAuction->get('auction'); $auction->expired = false; $lists = array(); $lists['title'] = JHTML::_('editauction.inputTitle',$auction); $lists['cats'] = JHTML::_('editauction.selectCategory',$auction); //$lists['cats'] = JHTML::_('factorycategory.select','cat','',$auction->cat,false,false,true); $lists['published'] = JHTML::_('editauction.selectPublished',$auction); $lists['tags'] = JHTML::_('editauction.inputTags',$auction); $lists['shortDescription'] = JHTML::_('editauction.inputShortDescription',$auction); $lists['description'] = JHTML::_('editauction.inputDescription',$auction); $lists['auctiontype'] = JHTML::_('editauction.selectAuctionType',$auction); $lists['automatic'] = JHTML::_('editauction.inputAutomatic',$auction); $lists['binType'] = JHTML::_('editauction.selectBINType',$auction); $lists['binPrice'] = JHTML::_('editauction.inputBINPrice',$auction); $lists['autoAcceptBIN'] = JHTML::_('editauction.selectAutoAcceptBIN',$auction); $lists['quantity'] = JHTML::_('editauction.inputQuantity',$auction); $lists['enableSuggestions'] = JHTML::_('editAuction.selectEnableSuggestions',$auction); $lists['minNumberSuggestions'] = JHTML::_('editAuction.inputMinNumberSuggestions',$auction); $lists['currency'] = JHTML::_('editauction.selectCurrency',$auction); $lists['initialPrice'] = JHTML::_('editauction.inputInitialPrice',$auction); $lists['showMaxPrice'] = JHTML::_('editauction.selectShowMaxPrice',$auction); $lists['showNumberBids'] = JHTML::_('editauction.selectShowNumberBids',$auction); $lists['reservePrice'] = JHTML::_('editauction.inputReservePrice',$auction); $lists['showReservePrice'] = JHTML::_('editauction.selectShowReservePrice',$auction); $lists['minIncrease'] = JHTML::_('editauction.inputMinIncrease',$auction); $lists['shippingPrice'] = JHTML::_('editAuction.inputShipmentPrice',$auction); $lists['uploadImages'] = JHTML::_('editauction.uploadImages',$auction); $lists['paymentInfo'] = JHTML::_('editauction.textPaymentInfo',$auction); $lists['shipmentInfo'] = JHTML::_('editauction.textShipmentInfo',$auction); //$lists[''] = JHTML::_('editauction.',$auction); $lists['currentLocalTime_field'] = JHTML::_('editAuction.currentLocalTime',$auction); $lists['startDate_field'] = JHTML::_('editAuction.editStartDate',$auction); $lists['endDate_field'] = JHTML::_('editAuction.editEndDate',$auction); $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(); JTheFactoryEventsHelper::triggerEvent('onBeforeEditAuction',array($auction)); $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); parent::display($tmpl); }
function acceptSuggestion() { $my = JFactory::getUser(); $id = JRequest::getInt('id'); $auctionmodel = $this->getModel('auction'); $suggestion = JTable::getInstance('bidsuggestion'); if (!$suggestion->load($id)) { JError::raiseWarning(0, JText::_('COM_BIDS_DOES_NOT_EXIST')); return; } if ($suggestion->bid_price <= 0) { JError::raiseWarning(0, JText::_('COM_BIDS_DOES_NOT_EXIST')); return; } if (!$auctionmodel->load($suggestion->auction_id)) { JError::raiseWarning(0, JText::_('COM_BIDS_DOES_NOT_EXIST')); return; } $auction = $auctionmodel->get('auction'); if ($suggestion->parent_id > 0) { $suggestion_reply = JTable::getInstance('bidsuggestion'); if (!$suggestion_reply->load($suggestion->parent_id)) { JError::raiseWarning(0, JText::_('COM_BIDS_NOT_ALLOW_AUCTION')); return; } else { if ($suggestion_reply->userid != $my->id) { JError::raiseWarning(0, JText::_('COM_BIDS_NOT_ALLOW_AUCTION')); return; } } } else { if ($auction->userid != $my->id) { JError::raiseWarning(0, JText::_('COM_BIDS_NOT_ALLOW_AUCTION')); return; } } if(AUCTION_TYPE_BIN_ONLY!=$auction->auction_type) { JError::raiseWarning(0, JText::_('COM_BIDS_NOT_ALLOW_AUCTION')); return; } if ($auction->published != 1) { JError::raiseWarning(0, JText::_('COM_BIDS_DOES_NOT_EXIST')); return; } if ($auction->automatic == 1) { JError::raiseWarning(0, JText::_('COM_BIDS_ERR_IS_AUTOMATIC')); return; } if($auction->quantity < $suggestion->quantity) { JError::raiseWarning(0, JText::_('COM_BIDS_ERR_QUANTITY_LEFT')); return; } if($auction->accepted) { JError::raiseWarning(0, JText::_('COM_BIDS_ERR_NO_MORE_BIDS_TO_ACCEPT')); return; } $bid = $auctionmodel->bid($suggestion->userid,$suggestion->bid_price,0,$suggestion->quantity); //delete the suggestion (all its info has been saved in bid) $suggestion->delete(); JTheFactoryEventsHelper::triggerEvent('onBeforeAcceptSuggestion',array($auction,$bid)); $auctionmodel->close($bid); JTheFactoryEventsHelper::triggerEvent('onAfterAcceptSuggestion',array($auction,$bid)); $this->setRedirect( JHtml::_('auctiondetails.auctionDetailsURL', $auction, false) ); }
function sendNewMessage($message, $as_replyto = null, $force_recipientid = null) { $my = JFactory::getUser(); $m = JTable::getInstance('bidmessage'); //if $as_replyto is set then it is a reply from the auctioneer to the user asking something $m->auction_id = $this->id; $m->message = $message; $m->modified = gmdate('Y-m-d H:i:s'); $m->userid1 = $my->id; $m->wasread = 0; if (!$as_replyto) { //new Question from user $m->parent_message = 0; $m->userid2 = $force_recipientid ? $force_recipientid : $this->userid; } else { $parentmessage = JTable::getInstance('bidmessage'); $parentmessage->load($as_replyto); $parentmessage->wasread = 1; $parentmessage->store(); $m->parent_message = $as_replyto; $m->userid2 = $parentmessage->userid1; } JTheFactoryEventsHelper::triggerEvent('onBeforeSendMessage', array($this, $m)); if ($res = $m->store()) { JTheFactoryEventsHelper::triggerEvent('onAfterSendMessage', array($this, $m)); } }
function dispatch($task = null) { if ($this->_stopexecution) { return; } if (!$this->_controller) { return; } if (!$task) { $task = JRequest::getCmd('task'); } if (strpos($task, '.') !== FALSE) { $task = explode('.', $task); $task = $task[1]; } $this->_controller->execute($task); JTheFactoryEventsHelper::triggerEvent('onAfterExecuteTask', array($this->_controller)); $this->_controller->redirect(); }
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 } }
function ipn() { ob_clean(); $gateway_name=JRequest::getVar('gateway'); $orderid=JRequest::getVar('orderid'); $model= JModelLegacy::getInstance('Gateways','JTheFactoryModel'); $gw=$model->getGatewayObject($gateway_name); $order= JTable::getInstance('OrdersTable','JTheFactory'); if (!is_object($gw)){ //error exit; } $paylog=$gw->processIPN(); if(!$paylog->orderid) { $paylog->orderid=$orderid; $paylog->store(); } if (!$paylog->orderid){ //Still no order attached to this payment? $error=JText::_('FACTORY_PAYMENT_DID_NOT_MATCH_AN_ORDER'); JTheFactoryEventsHelper::triggerEvent('onPaymentIPNError',array($paylog,$error)); exit; } if (!$order->load($paylog->orderid)){ //Still no order attached to this payment? $error=JText::_('FACTORY_PAYMENT_DID_NOT_MATCH_AN_ORDER'); JTheFactoryEventsHelper::triggerEvent('onPaymentIPNError',array($paylog,$error)); exit; } if (floatval($order->order_total)<>floatval($paylog->amount)|| strtoupper($order->order_currency)<>strtoupper($paylog->currency)){ $paylog->status='error'; } $paylog->userid=$order->userid; $paylog->store(); $date=new JDate(); $order->modifydate=$date->toMySQL(); if ($paylog->status=='ok') $order->status='C'; $order->paylogid=$paylog->id; $order->store(); JTheFactoryEventsHelper::triggerEvent('onPaymentForOrder',array($paylog,$order)); exit; }
function opened() { $cid = JRequest::getVar('cid', array(), '', 'array'); if (empty($cid)) { $cid[] = JRequest::getInt('id'); } $auction = JTable::getInstance('auction'); foreach ($cid as $id) { $auction->load($id); $auction->close_by_admin = 0; $auction->closed_date = gmdate('Y-m-d H:i:s'); $auction->published = 1; $auction->store(); JTheFactoryEventsHelper::triggerEvent('onAfterSaveAuctionSuccess', array($auction)); } $this->setRedirect("index.php?option=com_bids&task=offers", count($cid) . JText::_("COM_BIDS_AUCTIONS_OPENED")); }
function Confirm() { $paylogid = JRequest::getInt('id'); $paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory'); if (!$paylogid || !$paylog->load($paylogid)) { $this->setRedirect('index.php?option=' . APP_EXTENSION . '&task=payments.listing', JText::_("FACTORY_PAYMENT_DOES_NOT_EXIST")); return; } if ($paylog->status == 'ok') { $this->setRedirect('index.php? option=' . APP_EXTENSION . '&task=payments.viewdetails&id=' . $paylogid, JText::_("FACTORY_PAYMENT_ALREADY_CONFIRMED")); return; } $paylog->status = 'ok'; $paylog->store(); $order = JTable::getInstance('OrdersTable', 'JTheFactory'); if (!$paylog->orderid) { //Still no order attached to this payment? $error = JText::_('FACTORY_PAYMENT_DID_NOT_MATCH_AN_ORDER'); JTheFactoryEventsHelper::triggerEvent('onPaymentIPNError', array($paylog, $error)); exit; } if (!$order->load($paylog->orderid)) { //Still no order attached to this payment? $error = JText::_('FACTORY_PAYMENT_DID_NOT_MATCH_AN_ORDER'); JTheFactoryEventsHelper::triggerEvent('onPaymentIPNError', array($paylog, $error)); exit; } $date = new JDate(); $order->modifydate = $date->toMySQL(); if ($paylog->status == 'ok') { $order->status = 'C'; } $order->paylogid = $paylog->id; $order->store(); JTheFactoryEventsHelper::triggerEvent('onPaymentForOrder', array($paylog, $order)); $this->setRedirect('index.php? option=' . APP_EXTENSION . '&task=payments.viewdetails&id=' . $paylogid, JText::_("FACTORY_PAYMENT_CONFIRMED")); }
function close(JTableBid $bid) { $cfg = BidsHelperTools::getConfig(); $a = $this->auction; JTheFactoryEventsHelper::triggerEvent('onBeforeAcceptBid',array($a,$bid)); $winner = JTable::getInstance('user'); if ( !$bid->userid || !$winner->load($bid->userid) || $winner->block) { JError::raiseWarning(0, JText::_('COM_BIDS_ERR_USER_DOES_NOT_EXIST')); return false; } $seller = JFactory::getUser($a->userid); @ignore_user_abort(true); //accept bid, close auction, send emails JTheFactoryEventsHelper::triggerEvent('onBeforeAcceptBid',array($a,$bid)); $bid->accept = 1; $bid->store(); //decrease auction's quantity $a->quantity -= $bid->quantity; $this->store(true); //possible scenarios for an auction that is about to close $closeAuction = (AUCTION_TYPE_BIN_ONLY!=$a->auction_type) //public or private || (AUCTION_TYPE_BIN_ONLY==$a->auction_type && $cfg->bid_opt_quantity_enabled && 0==$a->quantity) //bin only with quantity enabled || (AUCTION_TYPE_BIN_ONLY==$a->auction_type && !$cfg->bid_opt_quantity_enabled) //bin only with quantity disabled ; if( $closeAuction ) { $a->published = 1; $a->close_offer = 1; $a->closed_date = gmdate('Y-m-d H:i:s'); } $this->store(true); if($closeAuction) { JTheFactoryEventsHelper::triggerEvent('onAfterCloseAuction',array($a,$bid)); } JTheFactoryEventsHelper::triggerEvent('onAfterAcceptBid',array($a,$bid)); //delete followers $db = $this->getDBO(); $db->setQuery("DELETE FROM #__bid_watchlist WHERE auction_id=".$this->auction->id); $db->query(); }