public function sendVouchers($cids) { $app = JFactory::getApplication(); $config = JFactory::getConfig(); $params = J2Store::config(); $sitename = $config->get('sitename'); $emailHelper = J2Store::email(); $mailfrom = $config->get('mailfrom'); $fromname = $config->get('fromname'); $failed = 0; foreach ($cids as $cid) { $voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone(); $voucherTable->load($cid); $mailer = JFactory::getMailer(); $mailer->setSender(array($mailfrom, $fromname)); $mailer->isHtml(true); $mailer->addRecipient($voucherTable->email_to); $mailer->setSubject($voucherTable->subject); // parse inline images before setting the body $emailHelper->processInlineImages($voucherTable->email_body, $mailer); $mailer->setBody($voucherTable->email_body); //Allow plugins to modify J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer)); if ($mailer->Send() !== true) { $this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to)); $failed++; } J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer)); $mailer = null; } if ($failed > 0) { return false; } return true; }
public static function getAdavcedItems() { if (empty(self::$_items)) { $j2params = J2Store::config(); $order = F0FModel::getTmpInstance('Orders', 'J2StoreModel')->initOrder()->getOrder(); $module = JModuleHelper::getModule('mod_j2store_cart'); // Get params and output $params = new JRegistry($module->params); $items = $order->getItems(); self::$_items = $items; } return self::$_items; }
protected function onBeforeDelete($oid) { $status = true; // load cart items $query = $this->_db->getQuery(true); $query->select('*')->from('#__j2store_cartitems')->where('cart_id = ' . (int) $oid); $this->_db->setQuery($query); try { $items = $this->_db->loadObjectList(); // foreach orderitem foreach ($items as $item) { // remove from user's cart if (!F0FTable::getAnInstance('Cartitem', 'J2StoreTable')->delete($item->j2store_cartitem_id)) { //F0FTable::getAnInstance ( 'Cartitem', 'J2StoreTable' )->getError(); break; return false; } else { J2Store::plugin()->event('RemoveCartItem', array($item)); $status = true; } } } catch (Exception $e) { // do nothing } return $status; }
protected function onBeforeBrowse() { $db = JFactory::getDbo(); $config = J2Store::config(); $installation_complete = $config->get('installation_complete', 0); if (!$installation_complete) { //installation not completed JFactory::getApplication()->redirect('index.php?option=com_j2store&view=postconfig'); } //first check if the currency table has a default records at least. $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList(); if (count($rows) < 1) { //no records found. Dumb default data F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->create_currency_by_code('USD', 'USD'); } //update schema $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_j2store/sql/xml')); $dbInstaller->updateSchema(); //update cart table $cols = $db->getTableColumns('#__j2store_carts'); $cols_to_delete = array('product_id', 'vendor_id', 'variant_id', 'product_type', 'product_options', 'product_qty'); foreach ($cols_to_delete as $key) { if (array_key_exists($key, $cols)) { $db->setQuery('ALTER TABLE #__j2store_carts DROP COLUMN ' . $key); try { $db->execute(); } catch (Exception $e) { echo $e->getMessage(); } } } return parent::onBeforeBrowse(); }
/** * Method to return j2store cart html * @param object $item * @return string */ public function onDJCatalog2BeforeCart($itemObject, $params, $context) { if (!defined('F0F_INCLUDED')) { include_once JPATH_LIBRARIES . '/f0f/include.php'; } $app = JFactory::getApplication(); $option = $app->input->getString('option'); if ($app->isSite() && $option == 'com_djcatalog2') { $html = ''; $params = $this->params; $j2params = J2Store::config(); $cache = JFactory::getCache(); $cache->clean('com_j2store'); if (isset($itemObject->id) && !empty($itemObject->id)) { $product = F0FTable::getAnInstance('Product', 'J2StoreTable'); $product->reset(); if ($product->get_product_by_source('com_djcatalog2', $itemObject->id)) { $image_html = ''; if ($option == 'com_djcatalog2' && $context == 'items.items') { $mainimage_width = $this->params->get('list_image_thumbnail_width', 120); $additional_image_width = $this->params->get('list_product_additional_image_width', 80); if ($this->params->get('category_product_options', 1) == 1) { $html = $product->get_product_html(); } else { $html = $product->get_product_html('without_options'); } $show_image = $this->params->get('category_display_j2store_images', 1); $image_type = $this->params->get('category_image_type', 'thumbnail'); //to set enable zoom option in category view if ($this->params->get('category_enable_image_zoom', 1)) { $this->params->set('item_enable_image_zoom', 1); $images = $product->get_product_images_html($image_type, $this->params); } else { $this->params->set('item_enable_image_zoom', 0); $images = $product->get_product_images_html($image_type, $this->params); } } else { $html = $product->get_product_html(); //set the image width $mainimage_width = $this->params->get('item_product_main_image_width', 120); $additional_image_width = $this->params->get('item_product_additional_image_width', 100); $show_image = $this->params->get('item_display_j2store_images', 1); $image_type = $this->params->get('item_image_type', 'thumbnail'); $images = $product->get_product_images_html($image_type, $this->params); } //custom css to adjust the j2store product images width $content = ".j2store-product-images .j2store-mainimage img ,.j2store-product-images .j2store-thumbnail-image img ,.upsell-product-image img , .cross-sell-product-image img {width:{$mainimage_width}px} .j2store-img-responsive { width :{$additional_image_width}px;}"; JFactory::getDocument()->addStyleDeclaration($content); if ($show_image && $images !== false) { $image_html = $images; } if ($html === false) { $html = ''; } $html = $image_html . $html; } } } return $html; }
public function saveOne($metakey, $value) { $db = JFactory::getDbo(); $config = J2Store::config(); $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES '; jimport('joomla.filter.filterinput'); $filter = JFilterInput::getInstance(null, null, 1, 1); $conditions = array(); if (is_array($value)) { $value = implode(',', $value); } // now clean up the value if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') { $value = $app->input->get($metakey, '', 'raw'); $clean_value = $filter->clean($value, 'html'); } else { $clean_value = $filter->clean($value, 'string'); } $config->set($metakey, $clean_value); $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')'; $query .= implode(',', $conditions); try { $db->setQuery($query); $db->execute(); } catch (Exception $e) { return false; } return true; }
protected function onAdd($tpl = null) { $app = JFactory::getApplication(); JRequest::setVar('hidemainmenu', true); $model = $this->getModel(); $this->item = $model->runMyBehaviorFlag(true)->getItem(); $this->currency = J2Store::currency(); $this->form_prefix = $this->input->getString('form_prefix', ''); $this->product_source_view = $this->input->getString('product_source_view', 'article'); $this->product_types = JHtml::_('select.genericlist', $model->getProductTypes(), $this->form_prefix . '[product_type]', array(), 'value', 'text', $this->item->product_type); if ($this->item->j2store_product_id) { //manufacturers $this->manufacturers = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[manufacturer_id]')->value($this->item->manufacturer_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Manufacturers')->setRelations(array('fields' => array('key' => 'j2store_manufacturer_id', 'name' => array('company'))))->getHtml(); //vendor $this->vendors = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[vendor_id]')->value($this->item->vendor_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Vendors')->setRelations(array('fields' => array('key' => 'j2store_vendor_id', 'name' => array('first_name', 'last_name'))))->getHtml(); //tax profiles $this->taxprofiles = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[taxprofile_id]')->value($this->item->taxprofile_id)->setPlaceHolders(array('' => JText::_('J2STORE_NOT_TAXABLE')))->hasOne('Taxprofiles')->setRelations(array('fields' => array('key' => 'j2store_taxprofile_id', 'name' => 'taxprofile_name')))->getHtml(); } if ($this->item->j2store_product_id > 0) { $this->product_filters = F0FTable::getAnInstance('ProductFilter', 'J2StoreTable')->getFiltersByProduct($this->item->j2store_product_id); } else { $this->product_filters = array(); } return true; }
/** * Method to save data * (non-PHPdoc) * @see F0FController::save() */ public function save() { //security check JSession::checkToken() or die('Invalid Token'); $app = JFactory::getApplication(); $model = $this->getModel('configurations'); $data = $app->input->getArray($_POST); $task = $this->getTask(); $token = JSession::getFormToken(); unset($data['option']); unset($data['task']); unset($data['view']); unset($data[$token]); if ($task == 'populatedata') { $this->getPopulatedData($data); } $db = JFactory::getDbo(); $config = J2Store::config(); $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES '; jimport('joomla.filter.filterinput'); $filter = JFilterInput::getInstance(null, null, 1, 1); $conditions = array(); foreach ($data as $metakey => $value) { if (is_array($value)) { $value = implode(',', $value); } //now clean up the value if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') { $value = $app->input->get($metakey, '', 'raw'); $clean_value = $filter->clean($value, 'html'); } else { $clean_value = $filter->clean($value, 'string'); } $config->set($metakey, $clean_value); $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')'; } $query .= implode(',', $conditions); try { $db->setQuery($query); $db->execute(); //update currencies F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->updateCurrencies(false); $msg = JText::_('J2STORE_CHANGES_SAVED'); } catch (Exception $e) { $msg = $e->getMessage(); $msgType = 'Warning'; } switch ($task) { case 'apply': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'populatedata': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'save': $url = 'index.php?option=com_j2store&view=cpanels'; break; } $this->setRedirect($url, $msg, $msgType); }
/** * * @return unknown_type */ public function display($articleid) { $html = ''; if (empty($articleid)) { return; } //try loading language associations if (version_compare(JVERSION, '3.3', 'gt')) { $id = $this->getAssociatedArticle($articleid); if ($id && is_int($id)) { $articleid = $id; } } $item = $this->getArticle($articleid); $mainframe = JFactory::getApplication(); // Return html if the load fails if (!$item->id) { return $html; } $item->title = JFilterOutput::ampReplace($item->title); $item->text = ''; $item->text = $item->introtext . chr(13) . chr(13) . $item->fulltext; $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $params = $mainframe->getParams('com_content'); $prepare_content = J2Store::config()->get('prepare_content', 0); if ($prepare_content) { $html .= JHtml::_('content.prepare', $item->text); } else { $html .= $item->text; } return $html; }
public function getInfo() { $info = array(); $version = new JVersion(); $platform = new JPlatform(); $db = JFactory::getDbo(); if (isset($_SERVER['SERVER_SOFTWARE'])) { $sf = $_SERVER['SERVER_SOFTWARE']; } else { $sf = getenv('SERVER_SOFTWARE'); } $info['php'] = php_uname(); $info['dbversion'] = $db->getVersion(); $info['dbcollation'] = $db->getCollation(); $info['phpversion'] = phpversion(); $info['server'] = $sf; $info['sapi_name'] = php_sapi_name(); $info['version'] = $version->getLongVersion(); $info['platform'] = $platform->getLongVersion(); $info['useragent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; $info['j2store_version'] = $this->getJ2storeVerion(); $info['is_pro'] = J2Store::isPro(); $info['curl'] = $this->_isCurl(); $info['json'] = $this->_isJson(); $config = JFactory::getConfig(); $info['error_reporting'] = $config->get('error_reporting'); $caching = $config->get('caching'); $info['caching'] = $caching ? JText::_('J2STORE_ENABLED') : JText::_('J2STORE_DISABLED'); $cache_plugin = JPluginHelper::isEnabled('system', 'cache'); $info['plg_cache_enabled'] = $cache_plugin; $info['memory_limit'] = ini_get('memory_limit'); return $info; }
public function buildQuery($overrideLimits = false) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('#__j2store_product_prices.*')->from('#__j2store_product_prices'); $this->_buildQueryWhere($query); $this->_buildQueryOrder($query); J2Store::plugin()->event('ProductPricesAfterBuildQuery', array(&$query, &$this)); return $query; }
protected function onBeforeStore($updateNulls = false) { if (!isset($this->sku) || empty($this->sku)) { //sku is empty. Auto generate it based on product name $product_helper = J2Store::product(); $this->sku = $product_helper->generateSKU($this); } return parent::onBeforeStore($updateNulls); }
public static function addCSS() { $app = JFactory::getApplication(); $j2storeparams = J2Store::config(); $document = JFactory::getDocument(); if ($app->isAdmin()) { // always load namespaced bootstrap // $document->addStyleSheet(JURI::root(true).'/media/j2store/css/bootstrap.min.css'); } if (!version_compare(JVERSION, '3.0', 'ge')) { // for site side, check if the param is enabled. if ($app->isSite() && $j2storeparams->get('load_bootstrap', 1)) { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/bootstrap.min.css'); } } // jquery UI css $ui_location = $j2storeparams->get('load_jquery_ui', 3); switch ($ui_location) { case '0': // load nothing break; case '1': if ($app->isSite()) { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css'); } break; case '2': if ($app->isAdmin()) { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css'); } break; case '3': default: $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css'); break; } if ($app->isAdmin()) { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store_admin.css'); } else { $document->addStyleSheet(JUri::root() . 'media/j2store/css/font-awesome.min.css'); // Add related CSS to the <head> if ($document->getType() == 'html' && $j2storeparams->get('j2store_enable_css')) { $template = self::getDefaultTemplate(); jimport('joomla.filesystem.file'); // j2store.css if (JFile::exists(JPATH_SITE . '/templates/' . $template . '/css/j2store.css')) { $document->addStyleSheet(JURI::root(true) . '/templates/' . $template . '/css/j2store.css'); } else { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store.css'); } } else { $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store.css'); } } }
protected function onDisplay($tpl = null) { $app = JFactory::getApplication(); $session = JFactory::getSession(); $user = JFactory::getUser(); $view = $this->input->getCmd('view', 'checkout'); $this->params = J2Store::config(); $this->currency = J2Store::currency(); $this->storeProfile = J2Store::storeProfile(); $this->user = $user; return true; }
public function onBrowse($tpl = null) { $systemPlugin = JPluginHelper::isEnabled('system', 'j2store'); if (!$systemPlugin) { //System plugin disabled. Manually enable it J2Store::plugin()->enableJ2StorePlugin(); } $this->assign('systemPlugin', $systemPlugin); $this->assign('cachePlugin', JPluginHelper::isEnabled('system', 'cache')); $this->assign('params', J2Store::config()); return true; }
function read() { // Makes sure SiteGround's SuperCache doesn't cache the subscription page J2Store::utilities()->nocache(); $app = JFactory::getApplication(); $app->setHeader('X-Cache-Control', 'False', true); $method = $app->input->getCmd('method', 'none'); $model = $this->getModel('Callback'); $result = $model->runCallback($method); echo $result ? 'OK' : 'FAILED'; $app->close(); }
public function getStockProductListQuery($overrideLimits = false) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('#__j2store_productquantities.*')->from('#__j2store_productquantities'); $this->_buildQueryJoins($query); $this->_buildWhereQuery($query); $this->_buildQueryOrderBy($query); $query->group('#__j2store_products.j2store_product_id'); //$query->group('#__j2store_productquantities.variant_id'); J2Store::plugin()->event('AfterStockProductListQuery', array(&$query, &$this)); return $query; }
public function calculate() { $variant = $this->get('variant'); $quantity = $this->get('quantity'); $date = $this->get('date'); $group_id = $this->get('group_id'); $pricing = new JObject(); //set the base price $pricing->base_price = $variant->price; $pricing->price = $variant->price; $pricing->calculator = 'standard'; //see if we have advanced pricing for this product / variant $model = F0FModel::getTmpInstance('ProductPrices', 'J2StoreModel'); J2Store::plugin()->event('BeforeGetPrice', array(&$pricing, &$model)); $model->setState('variant_id', $variant->j2store_variant_id); //where quantity_from < $quantity $model->setState('filter_quantity', $quantity); $tz = JFactory::getConfig()->get('offset'); // does date even matter? $nullDate = JFactory::getDBO()->getNullDate(); if (empty($date) || $date == $nullDate) { $date = JFactory::getDate('now', $tz)->toSql(true); } //where date_from <= $date //where date_to >= $date OR date_to == nullDate $model->setState('filter_date', $date); // does group_id? $user = JFactory::getUser(); if (empty($group_id)) { $group_id = implode(',', JAccess::getGroupsByUser($user->id)); } //if(empty($group_id)) $group_id = implode(',', JAccess::getAuthorisedViewLevels($user->id)); $model->setState('group_id', $group_id); // set the ordering so the most discounted item is at the top of the list $model->setState('orderby', 'quantity_from'); $model->setState('direction', 'DESC'); try { $price = $model->getItem(); //var_dump($price); } catch (Exception $e) { $price = new stdClass(); } if (isset($price->price)) { $pricing->special_price = $price->price; //this is going to be the sale price $pricing->price = $price->price; $pricing->is_discount_pricing_available = $pricing->base_price > $pricing->price ? true : false; } return $pricing; }
public function updateCurrencies($force = false) { if (extension_loaded('curl')) { $data = array(); $db = JFactory::getDbo(); $store = J2Store::config(); //sanity check if ($store->get('config_currency_auto', 1) != 1) { return; } //update the default currency $query = $db->getQuery(true); $query->update('#__j2store_currencies')->set('currency_value =' . $db->q('1.00000'))->set('modified_on=' . $db->q(date('Y-m-d H:i:s')))->where('currency_code=' . $db->q($store->get('config_currency'))); $db->setQuery($query); try { $db->execute(); } catch (Exception $e) { $this->setError($e->getMessage()); } $query = $db->getQuery(true); $query->select('*')->from('#__j2store_currencies')->where('currency_code !=' . $db->q($store->get('config_currency'))); if ($force) { $nullDate = JFactory::getDbo()->getNullDate(); $query->where('(modified_on=' . $db->q(date('Y-m-d H:i:s', strtotime('-1 day'))) . ' OR modified_on=' . $db->q($nullDate) . ')'); } $db->setQuery($query); $rows = $db->loadAssocList(); foreach ($rows as $result) { $data[] = $store->get('config_currency') . $result['currency_code'] . '=X'; } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($curl); curl_close($curl); $lines = explode("\n", trim($content)); foreach ($lines as $line) { $currency = JString::substr($line, 4, 3); $value = JString::substr($line, 11, 6); if ((double) $value) { $query = $db->getQuery(true); $query->update('#__j2store_currencies')->set('currency_value =' . $db->q((double) $value))->set('modified_on=' . $db->q(date('Y-m-d H:i:s')))->where('currency_code=' . $db->q($currency)); $db->setQuery($query); $db->query(); } } } }
public function display($tpl = null) { $app = JFactory::getApplication(); $this->email = $app->input->getString('email_id'); $this->item = F0FModel::getTmpInstance('Customers', 'J2StoreModel')->getAddressesByemail($this->email); $task = $app->input->getString('task'); $this->currency = J2Store::currency(); if ($task == 'viewOrder' && $this->email) { $this->addresses = F0FModel::getTmpInstance('Addresses', 'J2StoreModel')->email($this->email)->getList(); $this->orders = F0FModel::getTmpInstance('Orders', 'J2StoreModel')->user_email($this->email)->getList(); } JToolbarHelper::title(JTEXT::_('J2STORE_CUSTOMER_VIEW')); JToolbarHelper::cancel(); return parent::display($tpl); //return true; }
public function checkAttachmentPathExists() { $error = false; JLoader::import('joomla.filesystem.folder'); JLoader::import('joomla.filesystem.file'); $params = J2Store::config(); $root = $params->get('attachmentfolderpath'); $folder = JPATH_ROOT . '/' . $root; if (empty($folder) || !JFolder::exists($folder)) { //in case, the attachment path is outside the root if (!JFolder::exists($root)) { $error = true; } } return $error; }
/** * Executes before rendering the page for the Add task. * * @param string $tpl Subtemplate to use * * @return boolean Return true to allow rendering of the page */ protected function onAdd($tpl = null) { $id = $this->input->getInt('id'); $this->order = F0FTable::getAnInstance('Order', 'J2StoreTable'); $this->order->load($id); $this->item = $this->order; $this->fieldClass = J2Store::getSelectableBase(); $this->params = J2Store::config(); $this->currency = J2Store::currency(); $this->taxes = $this->order->getOrderTaxrates(); $this->shipping = $this->order->getOrderShippingRate(); $this->coupons = $this->order->getOrderCoupons(); $this->vouchers = $this->order->getOrderVouchers(); $this->orderinfo = $this->order->getOrderInformation(); $this->orderhistory = $this->order->getOrderHistory(); parent::onAdd(); }
public function getShippingRates(&$order) { static $rates; if (empty($rates) || !is_array($rates)) { $rates = array(); } if (!empty($rates)) { return $rates; } $app = JFactory::getApplication(); JPluginHelper::importPlugin('j2store'); $plugins = $this->enabled(1)->getList(); $rates = array(); if ($plugins) { foreach ($plugins as $plugin) { $shippingOptions = $app->triggerEvent("onJ2StoreGetShippingOptions", array($plugin->element, $order)); if (in_array(true, $shippingOptions, true)) { $results = $app->triggerEvent("onJ2StoreGetShippingRates", array($plugin->element, $order)); foreach ($results as $result) { if (is_array($result)) { foreach ($result as $r) { $extra = 0; // here is where a global handling rate would be added // if ($global_handling = $this->defines->get( 'global_handling' )) // { // $extra = $global_handling; // } J2Store::plugin()->event('GetGlobalHandling', array($order, &$r, &$extra)); $r['extra'] += $extra; $r['total'] += $extra; $rates[] = $r; } } } } } } //order by the cheapest method if (function_exists('usort') && count($rates)) { usort($rates, function ($a, $b) { return $a['total'] - $b['total']; }); } return $rates; }
/** * Public constructor. Initialises the protected members as well. * * @param array $config */ public function __construct($config = array()) { parent::__construct($config); $isPro = defined('J2STORE_PRO') ? J2STORE_PRO : 0; JLoader::import('joomla.application.component.helper'); require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/j2store.php'; $params = J2Store::config(); $dlid = $params->get('downloadid', ''); $this->extraQuery = null; // If I have a valid Download ID I will need to use a non-blank extra_query in Joomla! 3.2+ if (preg_match('/^([0-9]{1,}:)?[0-9a-f]{32}$/i', $dlid)) { // Even if the user entered a Download ID in the Core version. Let's switch his update channel to Professional $isPro = true; $this->extraQuery = 'dlid=' . $dlid; } $this->updateSiteName = 'J2Store ' . ($isPro ? 'Professional' : 'Core'); $this->updateSite = 'http://cdn.j2store.org/j2store' . ($isPro ? '' : 'core') . '.xml'; }
public function alert($type, $title, $message) { $html = ''; //check if this alert to be shown. $params = J2Store::config(); if ($params->get($type, 0)) { return $html; } //message not hidden $url = JRoute::_('index.php?option=com_j2store&view=cpanels&task=notifications&message_type=' . $type . '&' . JSession::getFormToken() . '=1'); $html .= '<div class="user-notifications ' . $type . ' alert alert-block">'; $html .= '<h3>' . $title . '</h3>'; $html .= '<p>' . $message . '</p>'; $html .= '<br />'; $html .= '<a class="btn btn-danger" href="' . $url . '">' . JText::_('J2STORE_GOT_IT_AND_HIDE') . '</a>'; $html .= '</div>'; return $html; }
protected function onRead($tpl = null) { /* JRequest::setVar('hidemainmenu', true); $model = $this->getModel('Products'); $product_id = $this->input->getInt('id', 0); if(!$product_id) return false; $product = F0FTable::getAnInstance('Product', 'J2StoreTable')->get_product_by_id($product_id); if($product === false) return false; $model->getProduct($product); $this->product = $product; //process tax $this->taxModel = F0FModel::getTmpInstance('TaxProfiles', 'J2StoreModel'); $this->params = J2Store::config(); */ $this->params = J2Store::config(); return true; }
public function __construct($config = array()) { $this->session = JFactory::getSession(); $this->input = JFactory::getApplication()->input; if (count($this->currencies) < 1) { $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList(); foreach ($rows as $result) { $this->currencies[$result->currency_code] = (array) $result; } } $currency = $this->input->get('currency'); if (isset($currency) && array_key_exists($currency, $this->currencies)) { $this->set($currency); } elseif ($this->session->has('currency', 'j2store') && array_key_exists($this->session->get('currency', '', 'j2store'), $this->currencies)) { $this->set($this->session->get('currency', '', 'j2store')); } else { $this->set(J2Store::storeProfile()->get('config_currency')); } }
/** * Displays the view * * @param string $tpl The template to use * * @return boolean|null False if we can't render anything */ protected function onDisplay($tpl = null) { $view = $this->input->getCmd('view', 'cpanel'); if (in_array($view, array('cpanel', 'cpanels'))) { return; } // Load the model $model = $this->getModel(); $app = JFactory::getApplication(); $state = array(); $state['search'] = $app->input->getString('search', $model->getState('search', '')); $state['since'] = $app->input->get('since', $model->getState('since', '')); $state['until'] = $app->input->get('until', $model->getState('until', '')); $state['orderstate'] = $app->input->get('orderstate', $model->getState('orderstate', 0)); $state['user_id'] = $app->input->getInt('user_id', $model->getState('user_id', 0)); $state['coupon_code'] = $app->input->getString('coupon_code', $model->getState('coupon_code', '')); $state['moneysum'] = $app->input->getString('moneysum', ''); $state['frominvoice'] = $app->input->getString('frominvoice', $model->getState('frominvoice', '')); $state['toinvoice'] = $app->input->getString('toinvoice', $model->getState('toinvoice', '')); $state['paykey'] = $app->input->getString('paykey', ''); $state['filter_order'] = $app->input->getString('filter_order', 'order_id'); $state['filter_order_Dir'] = $app->input->getString('filter_order_Dir', 'DESC'); foreach ($state as $key => $value) { $model->setState($key, $value); } // ...ordering /* $this->lists->set('order', $model->getState('filter_order', 'id', 'cmd')); $this->lists->set('order_Dir', $model->getState('filter_order_Dir', 'DESC', 'cmd')); */ // Assign data to the view $this->items = $model->getOrderList(); $this->pagination = $model->getPagination(); // Pass page params on frontend only if (F0FPlatform::getInstance()->isFrontend()) { $params = JFactory::getApplication()->getParams(); $this->params = $params; } $state = $model->getState(); $this->state = $state; $this->currency = J2Store::currency(); return true; }
public function history() { $app = JFactory::getApplication(); $id = $app->input->getInt('id', 0); if ($id > 0) { $view = $this->getThisView(); if ($model = $this->getThisModel()) { // Push the model into the view (as default) $view->setModel($model, true); } $voucher = F0FTable::getAnInstance('Voucher', 'J2StoreTable'); $voucher->load($id); $view->assign('voucher', $voucher); $voucher_history = $model->getVoucherHistory(); $view->assign('vouchers', $voucher_history); $view->assign('params', J2Store::config()); } $view->setLayout('history'); $view->display(); }
public function history() { $app = JFactory::getApplication(); $coupon_id = $app->input->getInt('coupon_id'); $view = $this->getThisView(); if ($coupon_id > 0) { if ($model = $this->getThisModel()) { // Push the model into the view (as default) $view->setModel($model, true); } $coupon = F0FTable::getAnInstance('Coupon', 'J2StoreTable'); $coupon->load($coupon_id); $view->assign('coupon', $coupon); $coupon_history = $model->getCouponHistory(); $view->assign('coupon_history', $coupon_history); $view->assign('params', J2Store::config()); $view->assign('currency', J2Store::currency()); } $view->setLayout('history'); $view->display(); }