function remove($ids) { if (!vmAccess::manager('paymentsetting')) { vmWarn('Insufficient permissions to remove paymentsetting'); return false; } return parent::remove($ids); }
function store(&$data) { if (!vmAccess::manager('manufacturercategories')) { vmWarn('Insufficient permissions to store manufacturer category'); return false; } return parent::store($data); }
function remove($ids) { if (!vmAccess::manager('general')) { vmWarn('Insufficient permissions to remove general'); return false; } return parent::remove($ids); }
/** * Call at begin of every task to check if the permission is high enough. * Atm the standard is at least vm admin * @author Max Milbers */ private function checkPermissionForTools() { vRequest::vmCheckToken(); //Hardcore Block, we may do that better later $user = JFactory::getUser(); if (!vmAccess::manager('core')) { $msg = 'Forget IT'; $this->setRedirect('index.php?option=com_virtuemart', $msg); } return true; }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { if ($data === 0) { $data = vRequest::getRequest(); } if (vmAccess::manager('raw')) { $data['product_desc'] = vRequest::get('product_desc', ''); $data['product_s_desc'] = vRequest::get('product_s_desc', ''); $data['customtitle'] = vRequest::get('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::get('field'); } if (isset($data['childs'])) { foreach ($data['childs'] as $k => $v) { if ($n = vRequest::get('product_name', false, FILTER_UNSAFE_RAW, FILTER_FLAG_NO_ENCODE, $data['childs'][$k])) { $data['childs'][$k]['product_name'] = $n; } } } } else { if (vmAccess::manager('html')) { $data['product_desc'] = vRequest::getHtml('product_desc', ''); $data['product_s_desc'] = vRequest::getHtml('product_s_desc', ''); $data['customtitle'] = vRequest::getHtml('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::getHtml('field'); } } else { $data['product_desc'] = vRequest::getString('product_desc', ''); $data['product_s_desc'] = vRequest::getString('product_s_desc', ''); $data['customtitle'] = vRequest::getString('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::getString('field'); } } //Why we have this? $multix = Vmconfig::get('multix', 'none'); if ($multix != 'none') { //in fact this shoudl be used, when the mode is administrated and the system is so that //every product must be approved by an admin. unset($data['published']); //unset($data['childs']); } } parent::save($data); }
function synchronizeMedia() { if (vmAccess::manager('media')) { $configPaths = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($configPaths as $path) { $this->renameFileExtension(VMPATH_ROOT . DS . VmConfig::get($path)); } if (!class_exists('Migrator')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'migrator.php'; } $migrator = new Migrator(); $result = $migrator->portMedia(); $this->setRedirect($this->redirectPath, $result); } else { $msg = 'Forget IT'; $this->setRedirect('index.php?option=com_virtuemart', $msg); } }
function save($data = 0) { $data = vRequest::getPost(); if (vmAccess::manager('raw')) { $data['payment_name'] = vRequest::get('payment_name', ''); $data['payment_desc'] = vRequest::get('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::get('params', ''); } } else { $data['payment_name'] = vRequest::getHtml('payment_name', ''); $data['payment_desc'] = vRequest::getHtml('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } } parent::save($data); }
function save($data = 0) { if ($data === 0) { $data = vRequest::getPost(); } if (vmAccess::manager('raw')) { $data['description'] = vRequest::get('description', ''); if (isset($data['params'])) { $data['params'] = vRequest::get('params', ''); } } else { $data['description'] = vRequest::getHtml('description', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } } $data['name'] = vRequest::getCmd('name'); // onSaveCustom plugin; parent::save($data); }
/** * Select the products to list on the product list page * @author Max Milbers */ public function getInventory() { if (!vmAccess::manager('inventory')) { vmWarn('Insufficient permissions to remove shipmentmethod'); return false; } $select = ' `#__tsmart_products`.`tsmart_product_id`, `#__tsmart_products`.`product_parent_id`, `product_name`, `product_sku`, `product_in_stock`, `product_weight`, `published`, `product_price`'; $joinedTables = 'FROM `#__tsmart_products` LEFT JOIN `#__tsmart_product_prices` ON `#__tsmart_products`.`tsmart_product_id` = `#__tsmart_product_prices`.`tsmart_product_id` LEFT JOIN `#__tsmart_shoppergroups` ON `#__tsmart_product_prices`.`tsmart_shoppergroup_id` = `#__tsmart_shoppergroups`.`tsmart_shoppergroup_id`'; return $this->_data = $this->exeSortSearchListQuery(0, $select, $joinedTables, $this->getInventoryFilter(), '', $this->_getOrdering()); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { if ($data === 0) { $data = vRequest::getRequest(); } if (vmAccess::manager('raw')) { $data['product_desc'] = vRequest::get('product_desc', ''); $data['product_s_desc'] = vRequest::get('product_s_desc', ''); $data['customtitle'] = vRequest::get('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::get('field'); } if (isset($data['childs'])) { foreach ($data['childs'] as $k => $v) { if ($n = vRequest::get('product_name', false, FILTER_UNSAFE_RAW, FILTER_FLAG_NO_ENCODE, $data['childs'][$k])) { $data['childs'][$k]['product_name'] = $n; } } } } else { if (vmAccess::manager('html')) { $data['product_desc'] = vRequest::getHtml('product_desc', ''); $data['product_s_desc'] = vRequest::getHtml('product_s_desc', ''); $data['customtitle'] = vRequest::getHtml('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::getHtml('field'); } } else { $data['product_desc'] = vRequest::getString('product_desc', ''); $data['product_s_desc'] = vRequest::getString('product_s_desc', ''); $data['customtitle'] = vRequest::getString('customtitle', ''); if (isset($data['field'])) { $data['field'] = vRequest::getString('field'); } } } parent::save($data); }
/** * Method to render the plugin datas * this is an entry point to plugin to easy renders json or html * * * @access public */ function Plugin() { if (!vmAccess::manager()) { return false; } $type = vRequest::getCmd('type', 'vmcustom'); $typeWhiteList = array('vmshopper', 'vmcustom', 'vmcalculation', 'vmpayment', 'vmshipment', 'vmuserfield'); if (!in_array($type, $typeWhiteList)) { return false; } $name = vRequest::getString('name', ''); JPluginHelper::importPlugin($type, $name); $dispatcher = JDispatcher::getInstance(); // if you want only one render simple in the plugin use jExit(); // or $render is an array of code to echo as html or json Object! $render = null; $dispatcher->trigger('plgVmOnSelfCallBE', array($type, $name, &$render)); if ($render) { // Get the document object. $document = JFactory::getDocument(); if (vRequest::getCmd('cache', 'no')) { JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate'); JResponse::setHeader('Expires', 'Mon, 6 Jul 2000 10:00:00 GMT'); } $format = vRequest::getCmd('format', 'json'); if ($format == 'json') { $document->setMimeEncoding('application/json'); // Change the suggested filename. JResponse::setHeader('Content-Disposition', 'attachment;filename="' . $type . '".json"'); echo vmJsApi::safe_json_encode($render); } else { echo $render; } } return true; }
function display($tpl = null) { if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $this->vendorId = vmAccess::isSuperVendor(); // TODO add icon for media view $this->SetViewTitle(); $model = VmModel::getModel('media'); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->media = $model->getFile(); $this->addStandardEditViewCommands(); } else { $virtuemart_product_id = vRequest::getInt('virtuemart_product_id'); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $cat_id = vRequest::getInt('virtuemart_category_id', 0); $super = vmAccess::isSuperVendor(); if ($super == 1) { JToolBarHelper::custom('synchronizeMedia', 'new', 'new', vmText::_('COM_VIRTUEMART_TOOLS_SYNC_MEDIA_FILES'), false); } $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model, null, null, 'searchMedia'); $options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_TYPES'), 'product' => vmText::_('COM_VIRTUEMART_PRODUCT'), 'category' => vmText::_('COM_VIRTUEMART_CATEGORY'), 'manufacturer' => vmText::_('COM_VIRTUEMART_MANUFACTURER'), 'vendor' => vmText::_('COM_VIRTUEMART_VENDOR')); $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options, 1, '', 'onchange="this.form.submit();"'); $options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_ROLES'), 'file_is_displayable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DISPLAYABLE'), 'file_is_downloadable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DOWNLOADABLE'), 'file_is_forSale' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_SET_FORSALE')); $this->lists['search_role'] = VmHTML::selectList('search_role', vRequest::getVar('search_role'), $options, 1, '', 'onchange="this.form.submit();"'); $this->files = $model->getFiles(false, false, $virtuemart_product_id, $cat_id); $this->pagination = $model->getPagination(); } parent::display($tpl); }
/** * This displays a media handler. It displays the full and the thumb (icon) of the media. * It also gives a possibility to upload/change/thumbnail media * * @param string $imageArgs html atttributes, Just for displaying the fullsized image */ public function displayFileHandler() { VmConfig::loadJLang('com_virtuemart_media'); $this->addHiddenByType(); $html = '<fieldset class="checkboxes">'; $html .= '<legend>' . vmText::_('COM_VIRTUEMART_IMAGE_INFORMATION') . '</legend>'; $html .= '<div class="vm__img_autocrop">'; $imageArgs = array('id' => 'vm_display_image'); $html .= $this->displayMediaFull($imageArgs, false, '', false) . '</div>'; //This makes problems, when there is already a form, and there would be form in a form. breaks js in some browsers // $html .= '<form name="adminForm" id="adminForm" method="post" enctype="multipart/form-data">'; $html .= ' <table class="adminform"> '; if ($this->published || $this->virtuemart_media_id === 0) { $checked = 1; } else { $checked = 0; } $html .= '<tr>'; // The following was removed bacause the check box (publish/unpublish) was not functioning... // $this->media_published = $this->published; $html .= '<td class="labelcell" style="width:20em"> <label for="published">' . vmText::_('COM_VIRTUEMART_FILES_FORM_FILE_PUBLISHED') . '</label> </td> <td>'; if (!class_exists('VmHtml')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $html .= VmHtml::checkbox('media[media_published]', $checked, 1, 0, 'class="inputbox"', 'media[media_published]'); //<input type="checkbox" class="inputbox" id="media_published'.$identify.'" name="media_published'.$identify.'" '.$checked.' size="16" value="1" /> $html .= '</td>'; $imgWidth = VmConfig::get('img_width', ''); if (!empty($imgWidth)) { $imgWidth = 'width:' . VmConfig::get('img_width', 90) . 'px;'; } else { $imgWidth = 'max-width:200px;width:auto;'; } $imgHeight = VmConfig::get('img_height', ''); if (!empty($imgHeight)) { $imgHeight = 'height:' . VmConfig::get('img_height', 90) . 'px;'; } else { $imgHeight = ''; } $html .= '<td rowspan = "8" min-width = "' . (VmConfig::get('img_width', 90) + 10) . 'px" overflow="hidden">'; $thumbArgs = array('class' => 'vm_thumb_image', 'style' => 'overflow: auto;' . $imgWidth . $imgHeight); $html .= $this->displayMediaThumb($thumbArgs); //JHTML::image($this->file_url_thumb, 'thumbnail', 'id="vm_thumb_image" style="overflow: auto; float: right;"'); // $html .= $this->displayMediaThumb('',false,'id="vm_thumb_image" style="overflow: auto; float: right;"'); $html .= '</td>'; $html .= '</tr>'; if (vmAccess::manager('media')) { $readonly = 'readonly'; } else { $readonly = ''; } $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_TITLE', 'file_title'); $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_DESCRIPTION', 'file_description'); $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_META', 'file_meta'); $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_CLASS', 'file_class'); $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_URL', 'file_url', $readonly); //remove the file_url_thumb in case it is standard if (!empty($this->file_url_thumb) and is_a($this, 'VmImage')) { $file_url_thumb = $this->createThumbFileUrl(); //vmdebug('my displayFileHandler ',$this,$file_url_thumb); if ($this->file_url_thumb == $file_url_thumb) { $this->file_url_thumb = vmText::sprintf('COM_VIRTUEMART_DEFAULT_URL', $file_url_thumb); } } $html .= $this->displayRow('COM_VIRTUEMART_FILES_FORM_FILE_URL_THUMB', 'file_url_thumb', $readonly); $this->addMediaAttributesByType(); $html .= '<tr> <td class="labelcell">' . vmText::_('COM_VIRTUEMART_FILES_FORM_ROLE') . '</td> <td><fieldset class="checkboxes">' . JHtml::_('select.radiolist', $this->getOptions($this->_mRoles), 'media[media_roles]', '', 'value', 'text', $this->media_role) . '</fieldset></td></tr>'; // $html .= '<tr><td class="labelcell">'.VmHTML::checkbox('file_is_forSale', $this->file_is_forSale); // $html .= VmHTML::checkbox('file_is_downloadable', $this->file_is_downloadable); if (!empty($this->file_type)) { $html .= '<tr> <td class="labelcell">' . vmText::_('COM_VIRTUEMART_FILES_FORM_LOCATION') . '</td> <td><fieldset class="checkboxes">' . vmText::_('COM_VIRTUEMART_FORM_MEDIA_SET_' . strtoupper($this->file_type)) . '</fieldset></td></tr>'; } else { $mediaattribtemp = $this->media_attributes; if (empty($this->media_attributes)) { $mediaattribtemp = 'product'; } $html .= '<tr> <td class="labelcell">' . vmText::_('COM_VIRTUEMART_FILES_FORM_LOCATION') . '</td> <td><fieldset class="checkboxes">' . JHtml::_('select.radiolist', $this->getOptions($this->_mLocation), 'media[media_attributes]', '', 'value', 'text', $mediaattribtemp) . '</fieldset></td></tr>'; } // select language for image $active_languages = VmConfig::get('active_languages'); if (count($active_languages) > 1) { $selectedImageLangue = explode(",", $this->file_lang); $configM = VmModel::getModel('config'); $languages = $configM->getActiveLanguages($selectedImageLangue, 'media[active_languages][]'); $html .= '<tr> <td class="labelcell"><span class="hasTip" title="' . vmText::_('COM_VIRTUEMART_FILES_FORM_LANGUAGE_TIP') . '">' . vmText::_('COM_VIRTUEMART_FILES_FORM_LANGUAGE') . '</span></td> <td><fieldset class="inputbox">' . $languages . '</fieldset></td> </tr>'; } if (VmConfig::get('multix', 'none') != 'none') { if (empty($this->virtuemart_vendor_id)) { $vendorId = vmAccess::isSuperVendor(); } else { $vendorId = $this->virtuemart_vendor_id; } if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } $vendorList = ShopFunctions::renderVendorList($vendorId, 'media[virtuemart_vendor_id]'); $html .= VmHTML::row('raw', 'COM_VIRTUEMART_VENDOR', $vendorList); } $html .= '</table>'; $html .= '<br /></fieldset>'; $this->addMediaActionByType(); $html .= '<fieldset class="checkboxes">'; $html .= '<legend>' . vmText::_('COM_VIRTUEMART_FILE_UPLOAD') . '</legend>'; $html .= vmText::_('COM_VIRTUEMART_IMAGE_ACTION') . JHtml::_('select.radiolist', $this->getOptions($this->_actions), 'media[media_action]', '', 'value', 'text', 0) . '<br /><br style="clear:both" />'; $html .= vmText::_('COM_VIRTUEMART_FILE_UPLOAD') . ' <input type="file" name="upload" id="upload" size="50" class="inputbox" /><br />'; $html .= '<br />' . $this->displaySupportedImageTypes(); $html .= '<br /></fieldset>'; $html .= $this->displayFoldersWriteAble(); $html .= $this->displayHidden(); // $html .= '</form>'; return $html; }
public function getSwitchUserList($superVendor = null, $adminID = false) { if (!isset($superVendor)) { $superVendor = vmAccess::isSuperVendor(); } $result = false; if ($superVendor) { $db = JFactory::getDbo(); $search = vRequest::getUword('usersearch', ''); if (!empty($search)) { $search = ' WHERE (`name` LIKE "%' . $search . '%" OR `username` LIKE "%' . $search . '%" OR `customer_number` LIKE "%' . $search . '%")'; } else { if ($superVendor != 1) { $search = ' WHERE vu.tsmart_vendor_id = ' . $superVendor . ' '; } } $q = 'SELECT ju.`id`,`name`,`username` FROM `#__users` as ju'; if ($superVendor != 1 or !empty($search)) { $q .= ' LEFT JOIN #__tsmart_vmusers AS vmu ON vmu.tsmart_user_id = ju.id'; if ($superVendor != 1) { $q .= ' LEFT JOIN #__tsmart_vendor_users AS vu ON vu.tsmart_user_id = ju.id'; $search .= ' AND ( vmu.user_is_vendor = 0 OR (vmu.tsmart_vendor_id) IS NULL)'; } } $current = JFactory::getUser(); $hiddenUserID = $adminID ? $adminID : $current->id; if (!empty($search)) { $search .= ' AND ju.id!= "' . $hiddenUserID . '" '; } else { $q .= ' WHERE ju.id!= "' . $hiddenUserID . '" '; } $q .= $search . ' ORDER BY `name` LIMIT 0,10000'; $db->setQuery($q); $result = $db->loadObjectList(); if ($result) { foreach ($result as $k => $user) { $result[$k]->displayedName = $user->name . ' ( ' . $user->username . ' )'; } } else { $result = array(); } if ($adminID) { $user = JFactory::getUser($adminID); if ($current->id != $user->id) { $toAdd = new stdClass(); $toAdd->id = $user->id; $toAdd->name = $user->name; $toAdd->username = $user->username; $toAdd->displayedName = tsmText::sprintf('com_tsmart_RETURN_TO', $user->name, $user->username); array_unshift($result, $toAdd); } } $toAdd = new stdClass(); $toAdd->id = 0; $toAdd->name = ''; $toAdd->username = ''; $toAdd->displayedName = '-' . tsmText::_('com_tsmart_REGISTER') . '-'; array_unshift($result, $toAdd); } return $result; }
/** * Todo, works only for small stores, we need a new solution there with a bit filtering * For example by time, if already shopper, and a simple search * @return object list of users */ function getUserList() { $result = false; if ($this->allowChangeShopper) { $this->adminID = vmAccess::getBgManagerId(); $superVendor = vmAccess::isSuperVendor($this->adminID); if ($superVendor) { $uModel = VmModel::getModel('user'); $result = $uModel->getSwitchUserList($superVendor, $this->adminID); } } if (!$result) { $this->allowChangeShopper = false; } return $result; }
function display($tpl = null) { // Get the task $task = vRequest::getCmd('task', $this->getLayout()); $this->assignRef('task', $task); // Load helpers if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } $model = tmsModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': //this was in the controller for the edit tasks, we need this for the access by FE //$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl'); tsmConfig::loadJLang('com_tsmart_orders', TRUE); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); $model_country = tmsModel::getModel('country'); $this->countries = $model_country->getItemList(); $tsmart_product_id = vRequest::getInt('tsmart_product_id'); if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) { $tsmart_product_id = (int) $tsmart_product_id[0]; } else { $tsmart_product_id = (int) $tsmart_product_id; } $product = $model->getItem($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id); //$user = JFactory::getUser(); $superVendor = vmAccess::isSuperVendor(); if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) { vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id); JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error'); } if (!empty($product->product_parent_id)) { $product_parent = $model->getProductSingle($product->product_parent_id, false); } require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $this->tour_service_class = tsmserviceclass::get_list_tour_service_class(); $customfields = tmsModel::getModel('Customfields'); $product->allIds[] = $product->tsmart_product_id; if (!empty($product->product_parent_id)) { $product->allIds[] = $product->product_parent_id; } $product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds); // Get the category tree if (isset($product->categories)) { $this->category_tree = ShopFunctions::categoryListTree($product->categories); } else { $this->category_tree = ShopFunctions::categoryListTree(); } //Fallback for categories inherited by parent to correctly calculate the prices if (empty($product->categories) and !empty($product_parent->categories)) { $product->categories = $product_parent->categories; } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (!isset($product->shoppergroups)) { $product->shoppergroups = 0; } $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); // Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } //Do we need the children? If there is a C customfield, we dont want them $isCustomVariant = false; foreach ($product->customfields as $custom) { if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) { $isCustomVariant = true; break; } } if (!class_exists('tsmartModelConfig')) { require VMPATH_ADMIN . '/models/config.php'; } $productLayouts = tsmartModelConfig::getLayoutList('productdetails'); $this->productLayouts = $productLayouts; // Load Images $model->addImages($product); if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } $vmtemplate = VmTemplate::loadVmTemplateStyle(); $this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate); // Load the vendors $vendor_model = tmsModel::getModel('vendor'); $lists['vendors'] = ''; if ($this->showVendors()) { $lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id); } // Load the currencies $currency_model = tmsModel::getModel('currency'); $vendor_model->setId(vmAccess::isSuperVendor()); $this->vendor = $vendor_model->getVendor(); $currency = $currency_model->getItemList(); $this->vendor_currency_symb = $currency->currency_symbol; $lists['manufacturers'] = shopFunctions::renderManufacturerList($product->tsmart_manufacturer_id, true); if (!empty($product->product_weight_uom)) { $product_weight_uom = $product->product_weight_uom; } else { if (!empty($product_parent)) { $product_weight_uom = $product_parent->product_weight_uom; } else { $product_weight_uom = tsmConfig::get('weight_unit_default'); } } if (!empty($product->product_lwh_uom)) { $product_lwh_uom = $product->product_lwh_uom; } else { if (!empty($product_parent)) { $product_lwh_uom = $product_parent->product_lwh_uom; } else { $product_lwh_uom = tsmConfig::get('lwh_unit_default'); } } if (!empty($product->product_unit)) { $product_unit = $product->product_unit; } else { if (!empty($product_parent)) { $product_unit = $product_parent->product_unit; } else { $product_unit = tsmConfig::get('product_unit_default', 'KG'); } } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = tmsModel::getModel('waitinglist'); /* Load waiting list */ if ($product->tsmart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->tsmart_product_id); $this->assignRef('waitinglist', $waitinglist); } $orderstatusModel = tmsModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE); // Add the tsmart_shoppergroup_ids $cid = JFactory::getUser()->id; $this->activeShoppergroups = shopfunctions::renderGuiList($cid, 'shoppergroups', 'shopper_group_name', 'category', 'vmuser_shoppergroups', 'tsmart_user_id'); if (!empty($this->activeShoppergroups)) { $shoppergroupModel = tmsModel::getModel('shoppergroup'); $this->activeShoppergroups = tsmText::_($shoppergroupModel->getDefault(0)->shopper_group_name); } // Load protocustom lists $customModel = tmsModel::getModel('custom'); $this->fieldTypes = tsmartModelCustom::getCustomTypes(); $customsList = $customModel->getCustomsList(); $attribs = 'style= "width: 300px;"'; $customlist = JHtml::_('select.genericlist', $customsList, 'customlist', $attribs, 'value', 'text', null, false, true); $this->assignRef('customsList', $customlist); if ($product->product_parent_id > 0) { // Set up labels $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = tsmText::_('com_tsmart_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = tsmText::_('com_tsmart_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } //get countries require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $countries = tsmcountries::get_countries(); $this->assignRef('countries', $countries); //end get countries //get cities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmcities.php'; $cities = tsmcities::get_cities(); $this->assignRef('cities', $cities); //end get cities //get tour style require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourstyle.php'; $list_tour_style = tsmtourstyle::get_list_tour_style(); $this->assignRef('list_tour_style', $list_tour_style); //end get toursyle //get tour section require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtoursection.php'; $list_tour_section = tsmtoursection::get_list_tour_section(); $this->assignRef('list_tour_section', $list_tour_section); //end get toursyle //get tour physicalgrade require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmphysicalgrade.php'; $list_physical_grade = vmphysicalgrade::get_physical_grade(); $this->assignRef('list_physical_grade', $list_physical_grade); //end get physicalgrade //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourtype.php'; $list_tour_type = tsmtourtype::get_list_tour_type(); $this->assignRef('list_tour_type', $list_tour_type); //end get tour_type //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $list_tour_service_class = tsmserviceclass::get_list_tour_service_class(); $product->list_tour_service_class_id = tsmserviceclass::get_list_service_class_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_tour_service_class', $list_tour_service_class); //end get tour_type //get activities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmactivities.php'; $product->list_activity_id = tsmactivities::get_list_activity_id_by_tour_id($product->tsmart_product_id); $activities = tsmactivities::get_activities(); $this->assignRef('activities', $activities); //end get activities //get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $list_group_size = tsmGroupSize::get_list_group_size(); $product->list_group_size_id = tsmGroupSize::get_list_group_size_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_group_size', $list_group_size); //end get list group size //get list country require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $product->list_tsmart_country_id = tsmcountries::get_list_tsmart_country_id_by_tour_id($product->tsmart_product_id); //end get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $this->list_price_type = vmprice::get_list_price_type(); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php'; $this->list_tour_method = vmproduct::get_list_tour_method(); $this->assignRef('product', $product); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } //if (!empty($product->canonCatLink)) $canonLink = '&tsmart_category_id=' . $product->canonCatLink; else $canonLink = ''; if (!empty($product->tsmart_product_id)) { if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag()); $canonLink = ''; if ($product->canonCatId) { $canonLink = '&tsmart_category_id=' . $product->canonCatId; } $text = '<a href="' . juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE_TO_PRODUCT', juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID); } } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); $this->addStandardEditViewCommandsNoValidate($product->tsmart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); $showVendors = $this->showVendors(); $this->assignRef('showVendors', $showVendors); $keyWord = ''; $catmodel = tmsModel::getModel('category'); $this->assignRef('catmodel', $catmodel); $this->addStandardDefaultViewCommandsNoValidate(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $session = JFactory::getSession(); $reset = $session->get('reset_pag', false, 'vm'); $limit = ''; if ($reset) { $limit = 0; $session->set('reset_pag', false, 'vm'); } $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search'], $limit); $catpagination = $catmodel->getPagination(); $this->assignRef('catpagination', $catpagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_CAT_EXE'), false); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $sgrpmodel = tmsModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->assignRef('shoppergroups', $shoppergroups); $sgrppagination = $sgrpmodel->getPagination(); $this->assignRef('sgrppagination', $sgrppagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_SGRPS_EXE'), false); break; default: if ($product_parent_id = vRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProductSingle($product_parent_id, false); if ($product_parent) { $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHtml::_('link', JRoute::_('index.php?view=product&task=edit&tsmart_product_id=' . $product_parent->tsmart_product_id . '&option=com_tsmart'), $product_parent->product_name, array('title' => tsmText::_('com_tsmart_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = tsmText::_('com_tsmart_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT_CHILDREN_LIST'; $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found'; } } else { $title = 'PRODUCT'; $msg = ""; } $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on'); if ($cI = vRequest::getInt('tsmart_category_id', false)) { $app = JFactory::getApplication(); //$old_state = $app->getUserState('tsmart_category_id'); $old_state = $app->getUserState('tsmart_category_id'); if (empty($old_state) or $old_state != $cI) { vRequest::setVar('com_tsmart.product.filter_order', 'pc.ordering'); $model->filter_order = 'pc.ordering'; $old_state = $app->setUserState('tsmart_category_id', $cI); } } //Get the list of products $productlist = $model->getItemList(); //The pagination must now always set AFTER the model load the listing $this->pagination = $model->getPagination(); //Get the category tree $categoryId = $model->tsmart_category_id; //OSP switched to filter in model, was vRequest::getInt('tsmart_category_id'); $category_tree = ShopFunctions::categoryListTree(array($categoryId)); $this->assignRef('category_tree', $category_tree); //load service class //Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $vendor_model = tmsModel::getModel('vendor'); $productreviews = tmsModel::getModel('ratings'); $this->mfTable = $model->getTable('manufacturers'); $this->catTable = $model->getTable('categories'); $this->lists['vendors'] = ''; if ($this->showVendors()) { $this->lists['vendors'] = Shopfunctions::renderVendorList(vmAccess::getVendorId()); } foreach ($productlist as $tsmart_product_id => $product) { $product->mediaitems = count($product->tsmart_media_id); $product->reviews = $productreviews->countReviewsForProduct($product->tsmart_product_id); $vendor_model->setId($product->tsmart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->tsmart_vendor_id); if (!empty($product->allPrices[$product->selectedPrice]['product_price']) && !empty($product->allPrices[$product->selectedPrice]['product_currency'])) { $product->product_price_display = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['product_price'], (int) $product->allPrices[$product->selectedPrice]['product_currency'], 1, true); } else { if (!empty($product->allPrices) and count($product->allPrices) > 1) { $product->product_price_display = tsmText::_('com_tsmart_MULTIPLE_PRICES'); } else { $product->product_price_display = tsmText::_('com_tsmart_NO_PRICE_SET'); } } // Write the first 5 categories in the list $product->categoriesList = ''; if (!empty($product->categories[0])) { $product->categoriesList = shopfunctions::renderGuiList($product->categories, 'categories', 'category_name', 'category'); } // Write the first 5 manufacturers in the list $product->manuList = ''; if (!empty($product->tsmart_manufacturer_id[0])) { $product->manuList = shopfunctions::renderGuiList($product->tsmart_manufacturer_id, 'manufacturers', 'mf_name', 'manufacturer'); } } $mf_model = tmsModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown(); $this->assignRef('manufacturers', $manufacturers); /* add Search filter in lists*/ /* Search type */ $options = array('' => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'), 'parent' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options); /* Search order */ $options = array('bf' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'), $options); // Toolbar /*if (vmAccess::manager('product.edit')) { JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_CAT'), true); JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_SGRPS'), true); } if (vmAccess::manager('product.create')) { JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('com_tsmart_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('com_tsmart_PRODUCT_CLONE'), true); }*/ // JToolBarHelper::custom('addrating', 'default', '', vmText::_('com_tsmart_ADD_RATING'), true); $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart')); JToolBarHelper::divider(); if (vmAccess::manager($view . '.edit.state')) { JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); } if (vmAccess::manager($view . '.delete')) { JToolBarHelper::spacer('10'); JToolBarHelper::deleteList(); } $this->assignRef('productlist', $productlist); $this->assignRef('tsmart_category_id', $categoryId); $this->assignRef('model', $model); break; } parent::display($tpl); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } // set search and keyword if ($keyword = vRequest::getString('keyword', false)) { //uword('keyword', false, ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } //$search = vRequest::uword('keyword', null); $this->searchcustom = ''; $this->searchCustomValues = ''; //if (!empty($keyword)) { $this->getSearchCustom(); $search = $keyword; /*} else { $keyword =''; $search = NULL; }*/ $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1); if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) { $virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id']; vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id); } $this->categoryId = vRequest::getInt('virtuemart_category_id', -1); if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) { $this->categoryId = $menu->query['virtuemart_category_id']; vRequest::setVar('virtuemart_category_id', $this->categoryId); } else { if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) { $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId(); } } $this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id); if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) { $this->categoryId = 0; $catType = 'manufacturer'; $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType); } $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); if ($this->categoryId === -1) { $this->categoryId = 0; } $vendorId = 1; $category = $categoryModel->getCategory($this->categoryId); if (!isset($menu->query['showproducts'])) { $menu->query['showproducts'] = 1; } $this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']); if (!empty($category)) { $vendorId = $category->virtuemart_vendor_id; if ($this->showproducts) { //if(empty($category->category_layout) or $category->category_layout != 'categories') { // Load the products in the given category $ids = $productModel->sortSearchListQuery(TRUE, $this->categoryId); $this->perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->vmPagination = $productModel->getPagination($this->perRow); $ratingModel = VmModel::getModel('ratings'); $this->showRating = $ratingModel->showRating(); $productModel->withRating = $this->showRating; $this->orderByList = $productModel->getOrderByList($this->categoryId); $this->products = $productModel->getProducts($ids); //$products = $productModel->getProductsInCategory($this->categoryId); $imgAmount = VmConfig::get('prodimg_browse', 1); $productModel->addImages($this->products, $imgAmount); if ($this->products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); $display_stock = VmConfig::get('display_stock', 1); $showCustoms = VmConfig::get('show_pcustoms', 1); if ($display_stock or $showCustoms) { if (!$showCustoms) { foreach ($this->products as $i => $productItem) { $productItem->stock = $productModel->getStockIndicator($productItem); } } else { shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel); } } // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); } // Add feed links if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } $user = JFactory::getUser(); $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); } //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId); } } //Fallback $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $this->categoryId == $last_category_id) { $last_category_id = vRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $this->categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } shopFunctionsF::setLastVisitedCategoryId($this->categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $catImgAmount = VmConfig::get('catimg_browse', 1); $categoryModel->addImages($category, $catImgAmount); if (!isset($menu->query['showcategory'])) { $menu->query['showcategory'] = 1; } $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']); //$this->showcategory = vRequest::getInt('showcategory',true); if ($this->showcategory) { //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){ $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir); $categoryModel->addImages($category->children, $catImgAmount); } else { $category->children = false; } if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description'); } $metadesc = ''; $metakey = ''; $metarobot = ''; if (isset($menu->params)) { $metadesc = $menu->params->get('menu-meta_description'); $metakey = $menu->params->get('menu-meta_keywords'); $metarobot = $menu->params->get('robots'); } if ($category->metadesc) { $metadesc = $category->metadesc; } if ($category->metakey) { $metakey = $category->metakey; } if ($category->metarobot) { $metarobot = $category->metarobot; } $document->setDescription($metadesc); $document->setMetaData('keywords', $metakey); $document->setMetaData('robots', $metarobot); if ($app->getCfg('MetaAuthor') == '1' and !empty($category->metaauthor)) { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } if (!empty($menu->query['categorylayout'])) { //if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$this->categoryId){ $category->category_layout = $menu->query['categorylayout']; } $productsLayout = VmConfig::get('productsublayout', 'products'); if (empty($productsLayout)) { $productsLayout = 'products'; } $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout']; shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } $title = vmText::_($title); if (vRequest::getInt('error')) { $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . strip_tags(htmlspecialchars_decode($keyword)) . ')'; } if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0])) { $title .= ' ' . $this->products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0]) and isset($category->category_name)) { $category->category_name = $this->products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } parent::display($tpl); }
: <input type="text" name="filter_ratings" value="<?php echo vRequest::getVar('filter_ratings', ''); ?> " /> <button class="btn btn-small" onclick="this.form.submit();"><?php echo vmText::_('COM_VIRTUEMART_GO'); ?> </button> <button class="btn btn-small" onclick="document.adminForm.filter_ratings.value='';"><?php echo vmText::_('COM_VIRTUEMART_RESET'); ?> </button> <?php if (VmConfig::get('multix', 'none') != 'none') { echo Shopfunctions::renderVendorList(vmAccess::getVendorId()); } ?> </td> </tr> </table> </div> <div id="resultscounter" ><?php echo $this->pagination->getResultsCounter(); ?> </div> </div> <div style="text-align: left;"> <table class="adminlist table table-striped" cellspacing="0" cellpadding="0"> <thead>
function getPermOrderStatus() { if (vmAccess::manager('orders.status')) { return true; } else { return false; } }
public function display($tpl = null) { $vendorId = vRequest::getInt('vendorid', 1); $vendorModel = VmModel::getModel('vendor'); $vendorIdUser = vmAccess::isSuperVendor(); $vendorModel->setId($vendorId); $this->vendor = $vendorModel->getVendor(); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_store_desc'); shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_terms_of_service'); } $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $document = JFactory::getDocument(); if (!VmConfig::get('shop_is_offline', 0)) { if (ShopFunctionsF::isFEmanager('product.edit')) { $add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1'; $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false); } else { $add_product_link = ""; } $this->assignRef('add_product_link', $add_product_link); $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $ratingModel = VmModel::getModel('ratings'); $productModel->withRating = $this->showRating = $ratingModel->showRating(); $this->products = array(); $categoryId = vRequest::getInt('catid', 0); $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId); $categoryModel->addImages($categoryChildren, 1); $this->assignRef('categories', $categoryChildren); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } $this->currency = CurrencyDisplay::getInstance(); $products_per_row = VmConfig::get('homepage_products_per_row', 3); $featured_products_rows = VmConfig::get('featured_products_rows', 1); $featured_products_count = $products_per_row * $featured_products_rows; if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) { $this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count); $productModel->addImages($this->products['featured'], 1); } $latest_products_rows = VmConfig::get('latest_products_rows'); $latest_products_count = $products_per_row * $latest_products_rows; if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) { $this->products['latest'] = $productModel->getProductListing('latest', $latest_products_count); $productModel->addImages($this->products['latest'], 1); } $topTen_products_rows = VmConfig::get('topTen_products_rows'); $topTen_products_count = $products_per_row * $topTen_products_rows; if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) { $this->products['topten'] = $productModel->getProductListing('topten', $topTen_products_count); $productModel->addImages($this->products['topten'], 1); } $recent_products_rows = VmConfig::get('recent_products_rows'); $recent_products_count = $products_per_row * $recent_products_rows; if (!empty($recent_products_count) and VmConfig::get('show_recent', 1)) { $recent_products = $productModel->getProductListing('recent'); if (!empty($recent_products)) { $this->products['recent'] = $productModel->getProductListing('recent', $recent_products_count); $productModel->addImages($this->products['recent'], 1); } } if ($this->products) { $display_stock = VmConfig::get('display_stock', 1); $showCustoms = VmConfig::get('show_pcustoms', 1); if ($display_stock or $showCustoms) { if (!$showCustoms) { foreach ($this->products as $pType => $productSeries) { foreach ($productSeries as $i => $productItem) { $this->products[$pType][$i]->stock = $productModel->getStockIndicator($productItem); } } } else { if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } foreach ($this->products as $pType => $productSeries) { shopFunctionsF::sortLoadProductCustomsStockInd($this->products[$pType], $productModel); } } } } $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); $layout = VmConfig::get('vmlayout', 'default'); $this->setLayout($layout); $productsLayout = VmConfig::get('productsublayout', 'products'); if (empty($productsLayout)) { $productsLayout = 'products'; } $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout']; // Add feed links if ($this->products && (VmConfig::get('feed_featured_published', 0) == 1 or VmConfig::get('feed_topten_published', 0) == 1 or VmConfig::get('feed_latest_published', 0) == 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } vmJsApi::jPrice(); } else { $this->setLayout('off_line'); } $error = vRequest::getInt('error', 0); //Todo this may not work everytime as expected, because the error must be set in the redirect links. if (!empty($error)) { $document->setTitle(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND') . vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name)); } else { if (empty($this->vendor->customtitle)) { if ($menu) { $menuTitle = $menu->params->get('page_title'); if (empty($menuTitle)) { $menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name); } $document->setTitle($menuTitle); } else { $title = vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name); $document->setTitle($title); } } else { $document->setTitle($this->vendor->customtitle); } if (!empty($this->vendor->metadesc)) { $document->setMetaData('description', $this->vendor->metadesc); } if (!empty($this->vendor->metakey)) { $document->setMetaData('keywords', $this->vendor->metakey); } if (!empty($this->vendor->metarobot)) { $document->setMetaData('robots', $this->vendor->metarobot); } if (!empty($this->vendor->metaauthor)) { $document->setMetaData('author', $this->vendor->metaauthor); } } if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } vmTemplate::setTemplate(); parent::display($tpl); }
function remove($ids) { if (!vmAccess::manager('country')) { vmWarn('Insufficient permissions to remove state'); return false; } return parent::remove($ids); }
function remove($ids) { if (!vmAccess::manager('shipmentmethod.delete')) { vmWarn('Insufficient permissions to remove shipmentmethod'); return false; } return parent::remove($ids); }
/** * Handles the upload process of a media, sets the mime_type, when success * * @author Max Milbers * @param string $urlfolder relative url of the folder where to store the media * @return name of the uploaded file */ static function uploadFile($urlfolder, &$obj, $overwrite = false) { if (empty($urlfolder) or strlen($urlfolder) < 2) { vmError('Not able to upload file, give path/url empty/too short ' . $urlfolder . ' please correct path in your tsmart config'); return false; } if (!class_exists('JFile')) { require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php'; } $media = vRequest::getFiles('upload'); if (empty($media) or !isset($media['error'])) { vmError('Recieved no data for upload', 'Recieved no data for upload'); vmdebug('no data in uploadFile ', $_FILES); return false; } $app = JFactory::getApplication(); switch ($media['error']) { case 0: $path_folder = str_replace('/', DS, $urlfolder); //Sadly it does not work to upload unicode files, // the � for example is stored on windows as ä, this seems to be a php issue (maybe a config setting) /* $dotPos = strrpos($media['name'],'.'); $safeMediaName = vmFile::makeSafe( $media['name'] ); if($dotPos!==FALSE){ $mediaPure = substr($media['name'],0,$dotPos); $mediaExtension = strtolower(substr($media['name'],$dotPos)); } */ $safeMediaName = vmFile::makeSafe($media['name']); $media['name'] = $safeMediaName; $mediaPure = JFile::stripExt($media['name']); $mediaExtension = strtolower(JFile::getExt($media['name'])); if (empty($mediaExtension)) { vmError('Invalid media; no extension ' . $media['name']); return false; } if (!$overwrite) { $i = 0; while (file_exists(VMPATH_ROOT . DS . $path_folder . $mediaPure . '.' . $mediaExtension) and $i < 20) { $mediaPure = $mediaPure . rand(1, 9); $i++; } } $media['name'] = $obj->file_name = $mediaPure . '.' . $mediaExtension; $type = exif_imagetype($media['tmp_name']); if ($type) { vmdebug('Recognised image'); if (!self::checkMediaType($type, $mediaExtension)) { vmError('Invalid media, image type does not fit to extension ' . $media['name']); return false; } } else { if (!vmAccess::manager('media.potdang')) { $m2ext = self::getMime2ExtArray(); $realMime = self::getMimeType($media['tmp_name']); vmdebug('Uploading file $realMime', $realMime, $m2ext); if (isset($m2ext[$realMime])) { //if($rExt = array_search($realMime,$m2ext)!==false){ $rExt = $m2ext[$realMime]; $hless = self::getSafeExt2MimeArray(); vmdebug('Recognised nonimage, not safe ext', $rExt, $hless); //$rExt = $hless[$realMime]; if (!isset($hless[$rExt])) { vmError('Invalid media type, you are not allowed to upload this file, file type does not fit to mime ' . $media['name']); return false; } else { vmdebug('Uploading file ', $hless[$rExt]); } } else { return false; } } } if ($obj->file_is_forSale == 0) { JFile::upload($media['tmp_name'], VMPATH_ROOT . DS . $path_folder . $media['name']); } else { JFile::upload($media['tmp_name'], $path_folder . $media['name']); } $obj->file_mimetype = $media['type']; $obj->media_published = 1; $app->enqueueMessage(tsmText::sprintf('com_tsmart_FILE_UPLOAD_OK', VMPATH_ROOT . DS . $path_folder . $media['name'])); return $media['name']; case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini $app->enqueueMessage(tsmText::sprintf('com_tsmart_PRODUCT_FILES_ERR_UPLOAD_MAX_FILESIZE', $media['name'], $media['tmp_name']), 'warning'); break; case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $app->enqueueMessage(tsmText::sprintf('com_tsmart_PRODUCT_FILES_ERR_MAX_FILE_SIZE', $media['name'], $media['tmp_name']), 'warning'); break; case 3: //uploaded file was only partially uploaded $app->enqueueMessage(tsmText::sprintf('com_tsmart_PRODUCT_FILES_ERR_PARTIALLY', $media['name'], $media['tmp_name']), 'warning'); break; case 4: //no file was uploaded //$vmLogger->warning( "You have not selected a file/image for upload." ); break; default: //a default error, just in case! :) //$vmLogger->warning( "There was a problem with your upload." ); break; } return false; }
public static function categoryListTree($selectedCategories = array(), $cid = 0, $level = 0, $disabledFields = array()) { $hash = crc32(implode('.', $selectedCategories) . ':' . $cid . ':' . $level . implode('.', $disabledFields)); if (empty(self::$categoryTree[$hash])) { $cache = JFactory::getCache('com_virtuemart_cats'); $cache->setCaching(1); $app = JFactory::getApplication(); $vendorId = vmAccess::isSuperVendor(); self::$categoryTree[$hash] = $cache->call(array('ShopFunctions', 'categoryListTreeLoop'), $selectedCategories, $cid, $level, $disabledFields, $app->isSite(), $vendorId, VmConfig::$vmlang); } return self::$categoryTree[$hash]; }
function display($tpl = null) { //Load helpers if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } $orderStatusModel = tmsModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(true); $this->SetViewTitle('ORDER'); $orderModel = tmsModel::getModel(); $curTask = vRequest::getCmd('task'); if ($curTask == 'edit') { tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); tsmConfig::loadJLang('com_tsmart_orders', true); //For getOrderStatusName if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } // Load addl models $userFieldsModel = tmsModel::getModel('userfields'); // Get the data $tsmart_order_id = vRequest::getInt('tsmart_order_id'); $order = $orderModel->getOrder($tsmart_order_id); if (empty($order['details'])) { JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=orders', tsmText::_('com_tsmart_ORDER_NOTFOUND')); } $_orderID = $order['details']['BT']->tsmart_order_id; $orderbt = $order['details']['BT']; $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt; $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->tsmart_order_id); $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->tsmart_vendor_id); $this->assignRef('currency', $currency); $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'name', 'password', 'password2', 'agreed', 'address_type')); $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type')); $_userFields = array_merge($userFieldsCart, $_userFields); //Fallback for customer_note if (empty($orderbt->customer_note) and !empty($orderbt->oc_note)) { $orderbt->customer_note = $orderbt->oc_note; } $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_'); $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_'); // Create an array to allow orderlinestatuses to be translated // We'll probably want to put this somewhere in ShopFunctions... $_orderStatusList = array(); foreach ($orderStates as $orderState) { //$_orderStatusList[$orderState->tsmart_orderstate_id] = $orderState->order_status_name; //When I use update, I have to use this? $_orderStatusList[$orderState->order_status_code] = tsmText::_($orderState->order_status_name); } $_itemStatusUpdateFields = array(); $_itemAttributesUpdateFields = array(); foreach ($order['items'] as $_item) { $_itemStatusUpdateFields[$_item->tsmart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[" . $_item->tsmart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->tsmart_order_item_id, true); } if (!isset($_orderStatusList[$orderbt->order_status])) { if (empty($orderbt->order_status)) { $orderbt->order_status = 'unknown'; } $_orderStatusList[$orderbt->order_status] = tsmText::_('com_tsmart_UNKNOWN_ORDER_STATUS'); } $this->lists['search'] = ''; /* Assign the data */ $this->assignRef('orderdetails', $order); $this->assignRef('orderID', $_orderID); $this->assignRef('userfields', $userfields); $this->assignRef('shipmentfields', $shipmentfields); $this->assignRef('orderstatuslist', $_orderStatusList); $this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields); $this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields); $this->assignRef('orderbt', $orderbt); $this->assignRef('orderst', $orderst); $this->assignRef('tsmart_shipmentmethod_id', $orderbt->tsmart_shipmentmethod_id); /* Data for the Edit Status form popup */ $_currentOrderStat = $order['details']['BT']->order_status; // used to update all item status in one time $_orderStatusSelect = JHtml::_('select.genericlist', $orderStates, 'order_status', 'style="width:100px;"', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status', true); $this->assignRef('orderStatSelect', $_orderStatusSelect); $this->assignRef('currentOrderStat', $_currentOrderStat); /* Toolbar */ if (JVM_VERSION < 3) { $backward = "back"; $list = 'back'; } else { $backward = 'backward'; $list = 'list'; } JToolBarHelper::custom('prevItem', $backward, '', 'com_tsmart_ITEM_PREVIOUS', false); JToolBarHelper::custom('nextItem', 'forward', '', 'com_tsmart_ITEM_NEXT', false); JToolBarHelper::divider(); JToolBarHelper::custom('cancel', $list, '', 'com_tsmart_ORDER_LIST_LBL', false, false); } else { if ($curTask == 'editOrderItem') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $this->assignRef('orderstatuses', $orderStates); $model = tmsModel::getModel(); $orderId = vRequest::getString('orderId', ''); $orderLineItem = vRequest::getVar('orderLineId', ''); $this->assignRef('tsmart_order_id', $orderId); $this->assignRef('tsmart_order_item_id', $orderLineItem); $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem); $this->assignRef('orderitem', $orderItem); } else { $this->setLayout('orders'); $model = tmsModel::getModel(); $this->addStandardDefaultViewLists($model, 'created_on'); $orderStatusModel = tmsModel::getModel('orderstatus'); $orderstates = vRequest::getCmd('order_status_code', ''); $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" '); $orderslist = $model->getOrdersList(); $this->assignRef('orderstatuses', $orderStates); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } /* Apply currency This must be done per order since it's vendor specific */ $_currencies = array(); // Save the currency data during this loop for performance reasons if ($orderslist) { foreach ($orderslist as $tsmart_order_id => $order) { if (!empty($order->order_currency)) { $currency = $order->order_currency; } else { if ($order->tsmart_vendor_id) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $currObj = tsmartModelVendor::getVendorCurrency($order->tsmart_vendor_id); $currency = $currObj->tsmart_currency_id; } } //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code if (!array_key_exists('curr' . $currency, $_currencies)) { $_currencies['curr' . $currency] = CurrencyDisplay::getInstance($currency, $order->tsmart_vendor_id); } $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total); $order->invoiceNumber = $model->getInvoiceNumber($order->tsmart_order_id); } } //update order items button /*$q = 'SELECT * FROM #__tsmart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL '; $db = JFactory::getDBO(); $db->setQuery($q); //$res = $db->loadRow(); if(true) { JToolBarHelper::custom('updateCustomsOrderItems', 'new', 'new', vmText::_('com_tsmart_REPORT_UPDATEORDERITEMS'),false); vmError('com_tsmart_UPDATEORDERITEMS_WARN'); }*/ /* * UpdateStatus removed from the toolbar; don't understand how this was intented to work but * the order ID's aren't properly passed. Might be readded later; the controller needs to handle * the arguments. */ /* Toolbar */ //JToolBarHelper::customX( 'CreateOrderHead', 'new','new','New',false); JToolBarHelper::save('updatestatus', tsmText::_('com_tsmart_UPDATE_STATUS')); if (vmAccess::manager('orders.delete')) { JToolBarHelper::spacer('80'); JToolBarHelper::deleteList(); } /* Assign the data */ $this->assignRef('orderslist', $orderslist); $this->pagination = $model->getPagination(); } } if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } shopFunctions::checkSafePath(); parent::display($tpl); }
public static function getVendorId($task = 0, $uid = 0, $name = 'virtuemart_vendor_id') { if (self::$_site === null) { $app = JFactory::getApplication(); self::$_site = $app->isSite(); } if (self::$_site) { $feM = vRequest::getString('manage'); if (!$feM) { //normal shopper in FE and NOT in the FE managing mode vmdebug('getVendorId normal shopper'); return vRequest::getInt($name, false); } } if ($task === 0) { $task = 'managevendors'; } else { if (is_array($task)) { $task[] = 'managevendors'; } else { $task = array($task, 'managevendors'); } } if (self::manager($task, $uid)) { vmdebug('getVendorId manager'); return vRequest::getInt($name, self::isSuperVendor($uid)); } else { return self::isSuperVendor($uid); } }
/** * toggle (0/1) a field * or invert by $val for multi IDS; * @author Patrick Kohl * @param string $field the field to toggle * @param string $postName the name of id Post (Primary Key in table Class constructor) */ function toggle($field, $val = NULL, $cidname = 0, $tablename = 0, $view = false) { if ($view and !vmAccess::manager($view . '.edit.state')) { return false; } $ok = true; if (!in_array($field, $this->_togglesName)) { vmdebug('vmModel function toggle, field ' . $field . ' is not in white list'); return false; } if ($tablename === 0) { $tablename = $this->_maintablename; } if ($cidname === 0) { $cidname = $this->_cidName; } $table = $this->getTable($tablename); $ids = vRequest::getInt($cidname, vRequest::getInt('cid', array())); foreach ($ids as $id) { $table->load((int) $id); if (!$table->toggle($field, $val)) { vmError(get_class($this) . '::toggle ' . $id); $ok = false; } } return $ok; }
/** * Delete all categories selected * * @author jseros * @param array $cids categories to remove * @return boolean if the item remove was successful */ public function remove($cids) { vRequest::vmCheckToken(); if (!vmAccess::manager('category.delete')) { vmWarn('Insufficient permissions to delete category'); return false; } $table = $this->getTable('categories'); foreach ($cids as &$cid) { if (!$table->delete($cid)) { return false; } $db = JFactory::getDbo(); $q = 'SELECT `virtuemart_customfield_id` FROM `#__virtuemart_product_customfields` as pc '; $q .= 'LEFT JOIN `#__virtuemart_customs`as c using (`virtuemart_custom_id`) WHERE pc.`customfield_value` = "' . $cid . '" AND `field_type`= "Z"'; $db->setQuery($q); $list = $db->loadColumn(); if ($list) { $listInString = implode(',', $list); //Delete media xref $query = 'DELETE FROM `#__virtuemart_product_customfields` WHERE `virtuemart_customfield_id` IN (' . $listInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } } } $cidInString = implode(',', $cids); //Delete media xref $query = 'DELETE FROM `#__virtuemart_category_medias` WHERE `virtuemart_category_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //deleting product relations $query = 'DELETE FROM `#__virtuemart_product_categories` WHERE `virtuemart_category_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //deleting category relations $query = 'DELETE FROM `#__virtuemart_category_categories` WHERE `category_child_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //updating parent relations $query = 'UPDATE `#__virtuemart_category_categories` SET `category_parent_id` = 0 WHERE `category_parent_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } $cache = JFactory::getCache('com_virtuemart_cats', 'callback'); $cache->clean(); return true; }
public function manager($view = 0) { if (empty($view)) { $view = $this->_name; } return vmAccess::manager($view); }
/** * removes a product and related table entries * * @author Max Milberes */ public function remove($ids) { if (!vmAccess::manager('product.delete')) { vmWarn('Insufficient permissions to delete product'); return false; } $table = $this->getTable($this->_maintablename); $cats = $this->getTable('product_categories'); $customfields = $this->getTable('product_customfields'); $manufacturers = $this->getTable('product_manufacturers'); $medias = $this->getTable('product_medias'); $prices = $this->getTable('product_prices'); $shop = $this->getTable('product_shoppergroups'); $rating = $this->getTable('ratings'); $review = $this->getTable('rating_reviews'); $votes = $this->getTable('rating_votes'); $ok = TRUE; foreach ($ids as $id) { $childIds = $this->getProductChildIds($id); if (!empty($childIds)) { vmError(vmText::_('COM_VIRTUEMART_PRODUCT_CANT_DELETE_CHILD')); $ok = FALSE; continue; } if (!$table->delete($id)) { $ok = FALSE; } if (!$cats->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$customfields->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } $db = JFactory::getDbo(); $q = 'SELECT `virtuemart_customfield_id` FROM `#__virtuemart_product_customfields` as pc '; $q .= 'LEFT JOIN `#__virtuemart_customs`as c using (`virtuemart_custom_id`) WHERE pc.`customfield_value` = "' . $id . '" AND `field_type`= "R"'; $db->setQuery($q); $list = $db->loadColumn(); if ($list) { $listInString = implode(',', $list); //Delete media xref $query = 'DELETE FROM `#__virtuemart_product_customfields` WHERE `virtuemart_customfield_id` IN (' . $listInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getError()); } } if (!$manufacturers->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$medias->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$prices->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$shop->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$rating->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$review->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } if (!$votes->delete($id, 'virtuemart_product_id')) { $ok = FALSE; } // delete plugin on product delete // $ok must be set to false if an error occurs JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('plgVmOnDeleteProduct', array($id, &$ok)); } return $ok; }