/** * * @return unknown_type */ function getItems() { // Check the registry to see if our Tienda class has been overridden if (!class_exists('Tienda')) { JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php"); } // load the config class Tienda::load('Tienda', 'defines'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); // get the model $model = JModel::getInstance('Manufacturers', 'TiendaModel'); // TODO Make this depend on the current filter_category? // setting the model's state tells it what items to return $model->setState('filter_enabled', '1'); $model->setState('order', 'tbl.manufacturer_name'); // set the states based on the parameters // using the set filters, get a list $items = $model->getList(); if (!empty($items)) { foreach ($items as $item) { // this gives error $item->itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->manufacturer($item->manufacturer_id, false); if (empty($item->itemid)) { $item->itemid = $this->params->get('itemid'); } } } return $items; }
/** * downloads a file * * @return void */ function downloadFile() { $user = JFactory::getUser(); $productfile_id = intval(JRequest::getvar('id', '', 'request', 'int')); $product_id = intval(JRequest::getvar('product_id', '', 'request', 'int')); $link = 'index.php?option=com_tienda&view=products&task=edit&id=' . $product_id; Tienda::load('TiendaHelperBase', 'helpers._base'); $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper'); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables'); $productfile = JTable::getInstance('ProductFiles', 'TiendaTable'); $productfile->load($productfile_id); if (empty($productfile->productfile_id)) { $this->messagetype = 'notice'; $this->message = JText::_('COM_TIENDA_INVALID FILE'); $this->setRedirect($link, $this->message, $this->messagetype); return false; } // log and download Tienda::load('TiendaFile', 'library.file'); // geting the ProductDownloadId to updated for which productdownload_max is greater then 0 $productToDownload = $helper->getProductDownloadInfo($productfile->productfile_id, $user->id); if ($downloadFile = TiendaFile::download($productfile)) { $link = JRoute::_($link, false); $this->setRedirect($link); } }
/** * Override parent::_getData() * * @return unknown_type */ function _getData() { $app = JFactory::getApplication(); Tienda::load('TiendaQuery', 'library.query'); // just in case $db = JFactory::getDbo(); $state = $this->_getState(); $model = $this->_getModel(); // filter only complete orders ( 3 - Shipped, 5 - Complete, 17 - Payment Received ) $order_states = array('3', '5', '17'); $model->setState('filter_orderstates', $order_states); $model->setState('order', '`price_total`'); $model->setState('direction', 'DESC'); $query = $model->getQuery(true); $query->group('p.manufacturer_id'); $field[] = " SUM(tbl.orderitem_final_price) AS `price_total` "; $field[] = " SUM(tbl.orderitem_quantity) AS `count_items` "; $query->select($field); $model->setQuery($query); $list = $model->getList(); if (!count($list)) { return $list; } return $list; }
function fetchElement($name, $value, &$node, $control_name) { $output = '<span class="k2Note">' . JText::_('Click Apply to be able to create product attributes') . '</span>'; $id = JRequest::getInt('cid'); if ($id) { $K2Item = JTable::getInstance('K2Item', 'Table'); $K2Item->load($id); $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda'); $productID = $params->get('productID'); if ($productID) { Tienda::load('TiendaUrl', 'library.url'); Tienda::load("TiendaHelperProduct", 'helpers.product'); $attributes = TiendaHelperProduct::getAttributes($productID); $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributes&id=" . $productID . "&tmpl=component", JText::_('Set Attributes')) . '</div>'; $output .= '<div>'; foreach (@$attributes as $attribute) { $output .= ' <div> <span>' . $attribute->productattribute_name . '(' . $attribute->option_names_csv . ')</span> <div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributeoptions&id=" . $attribute->productattribute_id . "&tmpl=component", JText::_('Set Attribute Options')) . '</div> <div class="tiendaButton"><a href="' . "index.php?option=com_tienda&controller=productattributes&task=delete&cid[]=" . $attribute->productattribute_id . "&return=" . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div> </div>'; } $output .= '</div>'; } } return $output; }
/** * Method to calculate statistics about manufacturers in an order * * @param $items Array of order items * * @return Array with list of manufacturers and their stats */ function calculateStatsOrder($items) { $db = JFactory::getDbo(); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); Tienda::load('TiendaQuery', 'library.query'); $q = new TiendaQuery(); $q->select('manufacturer_id'); $q->from('`#__tienda_products`'); $result = array(); foreach ($items as $item) { $q->where('product_id = ' . (int) $item->product_id); $db->setQuery($q); $res = $db->loadObject(); if ($res == null) { $man_id = 0; } else { $man_id = $res->manufacturer_id; } if (!isset($result[$man_id])) { $model = JModel::getInstance('Manufacturers', 'TiendaModel'); $model->setId($man_id); if (!($man_item = $model->getItem())) { $man_item = new stdClass(); } $result[$man_id] = $man_item; $result[$man_id]->subtotal = 0; $result[$man_id]->total_tax = 0; } $result[$man_id]->subtotal += $item->orderitem_final_price; $result[$man_id]->total_tax += $item->orderitem_tax; } return $result; }
/** * Method to process the export * @return */ function processExport() { $export = new JObject(); if (empty($this->_model)) { $this->_errors = JText::_('COM_TIENDA_PLEASE_SET_A_MODEL_IN_THE_PLUGIN_METHOD_PROCESSEXPORT'); return $this; } $classname = 'TiendaGenericExporterModel' . $this->_model; if (version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.6+ code here Tienda::load($classname, 'genericexporter.genericexporter.models.' . $this->_model, array('site' => 'site', 'type' => 'plugins', 'ext' => 'tienda')); } else { // Joomla! 1.5 code here Tienda::load($classname, 'genericexporter.models.' . $this->_model, array('site' => 'site', 'type' => 'plugins', 'ext' => 'tienda')); } $class = new $classname(); $items = $class->loadDataList(); $this->_modelone = $class->getSingleName(); if (empty($items)) { $this->_errors = JText::_('COM_TIENDA_NO_DATA_FOUND'); return $this; } //convert items to array upto child nodes //$items = $this->objectToArray( $items ); $f_name = $this->_model . '_' . time() . '.xml'; $this->_link = 'tmp/' . $f_name; $this->_name = $f_name; if (!($res = $this->fromXMLToFile('tmp/' . $f_name, $items))) { $this->_errors = JText::_('COM_TIENDA_ERROR_SAVING_FILE'); } return $this; }
function export() { Tienda::load('TiendaCSV', 'library.csv'); $request = JRequest::get('request'); //// load the plugins JPluginHelper::importPlugin('tienda'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $params = json_decode(base64_decode($request['exportParams'])); $model = JModel::getInstance($params->view, 'TiendaModel'); $list = $model->getList(); $arr = array(); $header = array(); // header -> it'll be filled out when $fill_header = true; // we need to fill header for ($i = 0, $c = count($list); $i < $c; $i++) { if ($fill_header) { $list_vars = get_object_vars($list[$i]); foreach ($list_vars as $key => $value) { if ($fill_header) { $header[] = $key; } } $fill_header = false; // header is filled } $arr[] = $this->objectToString($list[$i], true); } $f_name = 'tmp/' . $params->view . '_' . time() . '.csv'; $res = TiendaCSV::FromArrayToFile($f_name, $arr, $header); $this->render_page($f_name, $params->view); }
function setRates() { Tienda::load('TiendaGrid', 'library.grid'); Tienda::load('TiendaSelect', 'library.select'); $this->includeCustomModel('ShippingRatesWeightbased'); $sid = JRequest::getVar('sid'); $this->includeCustomTables(); $row = JTable::getInstance('ShippingMethodsWeightbased', 'TiendaTable'); $row->load($sid); $model = JModel::getInstance('ShippingRatesWeightbased', 'TiendaModel'); $model->setState('filter_shippingmethod', $sid); $app = JFactory::getApplication(); $ns = $this->getNamespace(); $state = array(); $state['limit'] = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $state['limitstart'] = $app->getUserStateFromRequest($ns . 'limitstart', 'limitstart', 0, 'int'); foreach (@$state as $key => $value) { $model->setState($key, $value); } $items = $model->getList(); //form $form = array(); $form['action'] = $this->baseLink(); // view $view = $this->getView('shipping_weightbased', 'html'); $view->hidemenu = true; $view->hidestats = true; $view->setModel($model, true); $view->assign('row', $row); $view->assign('items', $items); $view->assign('form2', $form); $view->assign('baseLink', $this->baseLink()); $view->setLayout('setrates'); $view->display(); }
function fetchElement($name, $value, &$node, $control_name) { $output = ' <input type="text" class="text_area" value="" id="pluginstiendaproductPrice" name="plugins[tiendaproductPrice]"> <span class="k2Note">' . JText::_('Set Normal Price Now Special Prices Later') . '</span> '; $id = JRequest::getInt('cid'); if ($id) { $K2Item = JTable::getInstance('K2Item', 'Table'); $K2Item->load($id); $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda'); $productID = $params->get('productID'); if ($productID) { Tienda::load('TiendaUrl', 'library.url'); Tienda::load("TiendaHelperProduct", 'helpers.product'); $prices = TiendaHelperProduct::getPrices($productID); if (count($prices)) { $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setprices&id=" . $productID . "&tmpl=component", JText::_('COM_TIENDA_SET_PRICES')) . '</div>'; $output .= '<div>'; foreach (@$prices as $price) { $output .= ' <div> <span>' . TiendaHelperBase::currency($price->product_price) . '</span> <div class="tiendaButton"><a href="' . $price->link_remove . '&return=' . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div> </div>'; } $output .= '</div>'; } } } return $output; }
/** * * @return unknown_type */ function getItems() { // Check the registry to see if our Tienda class has been overridden if (!class_exists('Tienda')) { JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php"); } // load the config class Tienda::load('Tienda', 'defines'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); // get the model Tienda::load('TiendaModelCategories', 'models.categories'); $model = new TiendaModelCategories(array()); // $model = JModel::getInstance( 'Categories', 'TiendaModel' ); doesnt work sometimes without no apparent reason // TODO Make this depend on the current filter_category? // setting the model's state tells it what items to return $model->setState('filter_enabled', '1'); $model->setState('order', 'tbl.lft'); // set the states based on the parameters // using the set filters, get a list $items = $model->getList(); if (!empty($items)) { foreach ($items as $item) { Tienda::load('TiendaHelperRoute', 'helpers.route'); $item->itemid = TiendaHelperRoute::category($item->category_id, true); if (empty($item->itemid)) { $item->itemid = $this->params->get('itemid'); } } } return $items; }
/** * Checks row for data integrity. * Assumes working dates have been converted to local time for display, * so will always convert working dates to GMT * * @return unknown_type */ function check() { if (empty($this->product_id)) { $this->setError(JText::_('COM_TIENDA_PRODUCT_ASSOCIATION_REQUIRED')); return false; } $offset = JFactory::getConfig()->getValue('config.offset'); if (isset($this->publishing_date)) { $this->publishing_date = date('Y-m-d H:i:s', strtotime(TiendaHelperBase::getOffsetDate($this->publishing_date, -$offset))); } $nullDate = $this->_db->getNullDate(); Tienda::load('TiendaHelperBase', 'helpers._base'); if (empty($this->created_date) || $this->created_date == $nullDate) { $date = JFactory::getDate(); $this->created_date = $date->toMysql(); } $date = JFactory::getDate(); $this->modified_date = $date->toMysql(); $act = strtotime(Date('Y-m-d', strtotime($this->publishing_date))); $db = $this->_db; if (empty($this->product_issue_id)) { $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($next === null) { return true; } $next = strtotime($next); if ($act <= $next) { $this->setError(JText::_('COM_TIENDA_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } else { $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_issue_id`=' . $this->product_issue_id; $db->setQuery($q); $original = $db->loadResult(); if ($act == strtotime(Date('Y-m-d', strtotime($original)))) { return true; } $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` < \'' . $original . '\' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $prev = $db->loadResult(); $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` > \'' . $original . '\' ORDER BY `publishing_date` ASC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($prev === null) { $prev = 0; } else { $prev = strtotime($prev); } if ($next) { $next = strtotime($next); } if ($prev >= $act || $next && $next <= $act) { $this->setError(JText::_('COM_TIENDA_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } return true; }
function __construct($config = array()) { parent::__construct($config); $this->defines = Tienda::getInstance(); Tienda::load("TiendaHelperRoute", 'helpers.route'); $this->router = new TiendaHelperRoute(); $this->user = JFactory::getUser(); }
/** * Include a particular Tienda Model * @param $name the name of the mode (ex: products) */ protected function includeTiendaModel($name) { if (strtolower($name) != 'base') { Tienda::load('TiendaModel' . ucfirst(strtolower($name)), 'models.' . strtolower($name)); } else { Tienda::load('TiendaModelBase', 'models._base'); } }
function __construct($config = array()) { parent::__construct($config); if (empty($this->helpers)) { $this->helpers = array(); } Tienda::load("TiendaHelperProduct", 'helpers.product'); $this->helpers['product'] = new TiendaHelperProduct(); }
/** * Method to get content article data for the frontpage * * @since 1.5 */ function getList() { $where = array(); $mainframe = JFactory::getApplication(); if (!empty($this->_list)) { return $this->_list; } // Initialize variables $db = $this->getDBO(); $filter = null; // Get some variables from the request // $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); // $redirect = $sectionid; // $option = JRequest::getCmd( 'option' ); $filter_order = $mainframe->getUserStateFromRequest('userelement.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest('userelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest('userelement.limitstart', 'limitstart', 0, 'int'); $search = $mainframe->getUserStateFromRequest('userelement.search', 'search', '', 'string'); $search = JString::strtolower($search); if (!$filter_order) { $filter_order = 'tbl.product_id'; } $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; $all = 1; // Keyword filter if ($search) { $where[] = 'LOWER( tbl.product_id ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); $where[] = 'LOWER( tbl.product_name ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); } // Build the where clause of the query $where = count($where) ? ' WHERE ' . implode(' OR ', $where) : ''; // Get the total number of records $query = 'SELECT COUNT(tbl.product_id)' . ' FROM #__tienda_products AS tbl' . $where; $db->setQuery($query); $total = $db->loadResult(); // Create the pagination object jimport('joomla.html.pagination'); $this->_page = new JPagination($total, $limitstart, $limit); // Get the products $query = 'SELECT tbl.*, pp.* ' . ' FROM #__tienda_products AS tbl' . ' LEFT JOIN #__tienda_productprices pp ON pp.product_id = tbl.product_id ' . $where . $order; $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); $this->_list = $db->loadObjectList(); //currency formatting Tienda::load('TiendaHelperBase', 'helpers._base'); foreach ($this->_list as $item) { $item->product_price = TiendaHelperBase::currency($item->product_price); } // If there is a db query error, throw a HTTP 500 and exit if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); return false; } return $this->_list; }
/** * * @return void **/ function _default($tpl = null) { Tienda::load('TiendaSelect', 'library.select'); Tienda::load('TiendaGrid', 'library.grid'); Tienda::load('TiendaTools', 'library.tools'); // check config $row = Tienda::getInstance(); $this->assign('row', $row); // add toolbar buttons JToolBarHelper::apply('save'); JToolBarHelper::cancel('close', 'COM_TIENDA_CLOSE'); // plugins $filtered = array(); $items = TiendaTools::getPlugins(); for ($i = 0; $i < count($items); $i++) { $item =& $items[$i]; // Check if they have an event if ($hasEvent = TiendaTools::hasEvent($item, 'onListConfigTienda')) { // add item to filtered array $filtered[] = $item; } } $items = $filtered; $this->assign('items_sliders', $items); // Add pane jimport('joomla.html.pane'); $sliders = JPane::getInstance('sliders'); $this->assign('sliders', $sliders); // form $validate = JUtility::getToken(); $form = array(); $view = strtolower(JRequest::getVar('view')); $form['action'] = "index.php?option=com_tienda&controller={$view}&view={$view}"; $form['validate'] = "<input type='hidden' name='{$validate}' value='1' />"; $this->assign('form', $form); // set the required image // TODO Fix this to use defines $required = new stdClass(); $required->text = JText::_('COM_TIENDA_REQUIRED'); $required->image = "<img src='" . JURI::root() . "/media/com_tienda/images/required_16.png' alt='{$required->text}'>"; $this->assign('required', $required); // Elements $elementArticleModel = JModel::getInstance('ElementArticle', 'TiendaModel'); $this->assign('elementArticleModel', $elementArticleModel); // terms $elementArticle_terms = $elementArticleModel->fetchElement('article_terms', @$row->get('article_terms')); $resetArticle_terms = $elementArticleModel->clearElement('article_terms', '0'); $this->assign('elementArticle_terms', $elementArticle_terms); $this->assign('resetArticle_terms', $resetArticle_terms); // shipping $elementArticle_shipping = $elementArticleModel->fetchElement('article_shipping', @$row->get('article_shipping')); $resetArticle_shipping = $elementArticleModel->clearElement('article_shipping', '0'); $this->assign('elementArticle_shipping', $elementArticle_shipping); $this->assign('resetArticle_shipping', $resetArticle_shipping); }
/** * Tienda User store user method * * Method is called after user data is stored in the database * The sort order of this plugin must be set to be after the User - Tienda plugin, because * that creates an entry in userinfo, and we can't act without that. * * @param array holds the new user data * @param boolean true if a new user is stored * @param boolean true if user was succesfully stored in the database * @param string message */ function onAfterStoreUser($user, $isnew, $success, $msg) { $create_address = $this->params->get('create_address', 0); if ($isnew) { // load the config class Tienda::load('Tienda', 'defines'); $notify = $this->params->get('notify_person', 1); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); Tienda::load('TiendaHelperSubscription', 'helpers.subscription'); $component = JRequest::getCmd('option'); $tokens = explode(' ', $user['name']); $last_name = $first_name = ''; if (count($tokens) > 1) { $last_name = $tokens[count($tokens) - 1]; $first_name = str_replace($last_name, '', $user['name']); } else { $last_name = $user['name']; } //save the subscription number $tblUser = JTable::getInstance('UserInfo', 'TiendaTable'); $tblUser->load(array('user_id' => $user['id'])); $tblUser->user_id = $user['id']; $tblUser->sub_number = TiendaHelperSubscription::getNextSubNum(); // one-page checkout + other registrations that are not done via tienda -> we need to add data manually if ($component != 'com_tienda' || $component == 'com_tienda' && Tienda::getInstance()->get('one_page_checkout', 0)) { $tblUser->last_name = $last_name; $tblUser->first_name = $first_name; $tblUser->email = $user['email']; } if (!$tblUser->save()) { $this->sendNotification(JText::_('Error during saving subscription number'), $user['id']); JError::raiseError(500, JText::_('Error during saving subscription number')); return; } // we want to create a default address and are not registering via tienda // (tienda takes care about it automatically) if ($create_address && $component != 'com_tienda') { $tblAddress = JTable::getInstance('Addresses', 'TiendaTable'); $tblAddress->user_id = $user['id']; $tblAddress->addresstype_id = 1; $tblAddress->address_name = $this->params->get('address_title', JText::_('Main Address Default')); $tblAddress->country_id = $this->params->get('default_country', 0); $tblAddress->zone_id = $this->params->get('default_zone', 0); $tblAddress->is_default_billing = 1; $tblAddress->is_default_shipping = 1; $tblAddress->last_name = $last_name; $tblAddress->first_name = $first_name; if (!$tblAddress->store()) { $this->sendNotification(JText::_('Error during creating an empty address'), $user['id']); JError::raiseError(500, JText::_('Error during creating an empty address')); return; } } } }
/** * constructor */ function __construct() { if (empty(JFactory::getUser()->id)) { $url = JRoute::_("index.php?option=com_tienda&view=productdownloads"); Tienda::load("TiendaHelperUser", 'helpers.user'); $redirect = JRoute::_(TiendaHelperUser::getUserLoginUrl($url), false); JFactory::getApplication()->redirect($redirect); return; } parent::__construct(); $this->set('suffix', 'productdownloads'); }
public static function getAddresses() { Tienda::load('TiendaHelperUser', 'helpers.user'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); JModel::addIncludePath(JPATH_SITE . '/components/com_tienda/models'); // get the user's addresses using the address model $model = JModel::getInstance('Addresses', 'TiendaModel'); $model->setState('filter_userid', JRequest::getVar('id', 0, 'request', 'int')); $model->setState('filter_deleted', 0); $userAddresses = $model->getList(); return $userAddresses; }
/** * Displays the submit bug form */ function submitBug() { JRequest::setVar('tienda_display_submenu', 1); Tienda::load('TiendaViewBase', 'views._base'); $view = new TiendaViewBase(); $view->displayTitle(JText::_('COM_TIENDA_SUBMIT_BUG')); unset($view); ob_start(); include dirname(__FILE__) . '/bug_report/tmpl/submitbug.php'; $text = ob_get_contents(); ob_end_clean(); return $text; }
/** * * @param unknown_type $updateNulls * @return unknown_type */ function store($updateNulls = false) { if ($return = parent::store($updateNulls)) { if ($this->notify_customer == '1') { Tienda::load("TiendaHelperBase", 'helpers._base'); $helper = TiendaHelperBase::getInstance('Email'); $model = Tienda::getClass("TiendaModelSubscriptions", "models.subscriptions"); $model->setId($this->subscription_id); $subscription = $model->getItem(); $helper->sendEmailNotices($subscription, 'subscription'); } } return $return; }
/** * Sets the modules params as a property of the object * @param unknown_type $params * @return unknown_type */ function __construct($params) { $this->params = $params; if (!class_exists('Tienda')) { JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php"); } // load the config class Tienda::load('Tienda', 'defines'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $this->defines = Tienda::getInstance(); Tienda::load("TiendaHelperRoute", 'helpers.route'); $this->router = new TiendaHelperRoute(); $this->user = JFactory::getUser(); }
/** * * @return unknown_type */ function onAfterInitialise() { $success = null; if (!$this->isInstalled()) { return $success; } if (!$this->canRun()) { return $success; } Tienda::load('TiendaHelperSubscription', 'helpers.subscription'); $helper = new TiendaHelperSubscription(); $helper->checkExpired(); $helper->checkExpiring(); return $success; }
/** * * @param unknown_type $updateNulls * @return unknown_type */ function store($updateNulls = false) { if ($return = parent::store($updateNulls)) { if ($this->notify_customer == '1') { Tienda::load("TiendaHelperBase", 'helpers._base'); $helper = TiendaHelperBase::getInstance('Email'); $model = Tienda::getClass("TiendaModelOrders", "models.orders"); $model->setId($this->order_id); // this isn't necessary because you specify the requested PK id as a getItem() argument $order = $model->getItem($this->order_id, true); $helper->sendEmailNotices($order, 'order'); } } return $return; }
function save($src = '', $orderingFilter = '', $ignore = '') { $prev = clone $this; if (!empty($this->id)) { $prev->load($this->id); } if ($save = parent::save($src, $orderingFilter, $ignore)) { if ($prev->subscription_enabled && empty($this->subscription_enabled)) { // if it was previously enabled and now is disabled Tienda::load('TiendaHelperJuga', 'helpers.juga'); $helper = new TiendaHelperJuga(); $helper->doExpiredSubscription($this); } } return $save; }
/** * Expected to be called from ajax */ public function getProductAttributeOptions() { $attribute_id = JRequest::getInt('attribute_id', 0); $name = JRequest::getVar('select_name', 'parent'); $id = JRequest::getVar('select_id', '0'); $response = array(); $response['msg'] = ''; $response['error'] = ''; if ($attribute_id) { Tienda::load('TiendaSelect', 'library.select'); $response['msg'] = TiendaSelect::productattributeoptions($attribute_id, 0, $name . "[" . $id . "]"); } else { $response['msg'] = '<input type="hidden" name="' . $name . "[" . $id . "]" . '" />'; } echo json_encode($response); }
function fetchElement($name, $value, &$node, $control_name) { $mainframe = JFactory::getApplication(); Tienda::load('TiendaSelect', 'library.select'); $id = JRequest::getInt('cid'); if ($id) { $K2Item = JTable::getInstance('K2Item', 'Table'); $K2Item->load($id); $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda'); $id = $params->get('productID'); $db = JFactory::getDBO(); $query = "SELECT manufacturer_id FROM #__tienda_products WHERE product_id=" . (int) $id; $db->setQuery($query); $manufacturer = $db->loadResult(); } return TiendaSelect::manufacturer(@$manufacturer, 'plugins[tiendaproductManufacturer]', '', 'pluginstiendaproductManufacturer', false, true); }
function _isInstalled() { $success = false; jimport('joomla.filesystem.file'); if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_tienda/defines.php')) { $success = true; if (!class_exists('Tienda')) { JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php"); } Tienda::load('TiendaHelperBase', 'helpers._base'); Tienda::load('TiendaHelperProduct', 'helpers.product'); Tienda::load('TiendaModelProducts', 'models.products'); Tienda::load('TiendaSelect', 'library.select'); Tienda::load('TiendaUrl', 'library.url'); } return $success; }
/** * Method to process the export * @return */ function processExport() { $export = new JObject(); if (empty($this->_model)) { $this->_errors = JText::_('COM_TIENDA_PLEASE_SET_A_MODEL_IN_THE_PLUGIN_METHOD_PROCESSEXPORT'); return $this; } $arr = array(); $header = array(); $fill_header = true; $classname = 'TiendaGenericExporterModel' . $this->_model; if (version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.6+ code here Tienda::load($classname, 'genericexporter.genericexporter.models.' . $this->_model, array('site' => 'site', 'type' => 'plugins', 'ext' => 'tienda')); } else { // Joomla! 1.5 code here Tienda::load($classname, 'genericexporter.models.' . $this->_model, array('site' => 'site', 'type' => 'plugins', 'ext' => 'tienda')); } $class = new $classname(); $list = $class->loadDataList(); if (empty($list)) { $this->_errors = JText::_('COM_TIENDA_NO_DATA_FOUND'); return $this; } for ($i = 0, $c = count($list); $i < $c; $i++) { if ($fill_header) { $list_vars = get_object_vars($list[$i]); foreach ($list_vars as $key => $value) { if ($fill_header) { $header[] = $key; } } $fill_header = false; // header is filled } $arr[] = $this->objectToString($list[$i], true); } $f_name = $this->_model . '_' . time() . '.csv'; $this->_link = 'tmp/' . $f_name; $this->_name = $f_name; if (!($res = TiendaCSV::FromArrayToFile('tmp' . DS . $f_name, $arr, $header))) { $this->_errors = JText::_('COM_TIENDA_UNABLE_TO_WRITE_FILE'); } return $this; }
/** * Checks the entry to maintain DB integrity * @return unknown_type */ function check() { $config = Tienda::getInstance(); if (!$this->addresstype_id) { $this->addresstype_id = '1'; } $address_type = $this->addresstype_id; if (empty($this->user_id)) { $this->user_id = JFactory::getUser()->id; if (empty($this->user_id)) { $this->setError(JText::_('COM_TIENDA_USER_REQUIRED')); } } Tienda::load('TiendaHelperAddresses', 'helpers.addresses'); $elements = TiendaHelperAddresses::getAddressElementsData($address_type); if (empty($this->address_name)) { $this->address_name = $this->address_1; } if (empty($this->address_name) && $elements['address_name'][1]) { $this->setError(JText::_("COM_TIENDA_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type)); } $address_checks = array(array('first_name', 'name', "COM_TIENDA_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_TIENDA_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_TIENDA_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_TIENDA_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_TIENDA_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_TIENDA_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_TIENDA_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_TIENDA_CITY_REQUIRED"), array('postal_code', 'zip', "COM_TIENDA_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_TIENDA_PHONE_REQUIRED")); for ($i = 0, $c = count($address_checks); $i < $c; $i++) { $current = $address_checks[$i]; if (empty($this->{$current}[0]) && $elements[$current[1]][1]) { $this->setError(JText::_($current[2])); } } if (empty($this->country_id)) { if ($elements['country'][1]) { $this->setError(JText::_('COM_TIENDA_COUNTRY_REQUIRED')); } else { $this->country_id = 9999; } } $countryA = explode(',', trim($config->get('ignored_countries', '83,188,190'))); if (empty($this->zone_id) && !in_array($this->country_id, $countryA)) { if ($elements['zone'][1]) { $this->setError(JText::_('COM_TIENDA_ZONE_REQUIRED')); } else { $this->zone_id = 9999; } } return parent::check(); }