コード例 #1
0
ファイル: view.html.php プロジェクト: naka211/studiekorrektur
 function display($tpl = null)
 {
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $this->vendorId = VmConfig::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);
         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);
 }
コード例 #2
0
ファイル: mini.php プロジェクト: aldegtyarev/stelsvelo
 public static function isSuperVendor()
 {
     if (JVM_VERSION <= 2) {
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         if (Permissions::getInstance()->check("admin,storeadmin")) {
             return true;
         }
     } else {
         $text = '';
         $user = JFactory::getUser();
         if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or VmConfig::isSuperVendor()) {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: naka211/studiekorrektur
 /**
  * Collect all data to show on the template
  *
  * @author RolandD, Max Milbers
  */
 function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     $this->assignRef('show_prices', $show_prices);
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $task = vRequest::getCmd('task');
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     // Load the product
     //$product = $this->get('product');	//Why it is sensefull to use this construction? Imho it makes it just harder
     $product_model = VmModel::getModel('product');
     $this->assignRef('product_model', $product_model);
     $virtuemart_product_idArray = vRequest::getInt('virtuemart_product_id', 0);
     if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
         $virtuemart_product_id = (int) $virtuemart_product_idArray[0];
     } else {
         $virtuemart_product_id = (int) $virtuemart_product_idArray;
     }
     $quantityArray = vRequest::getInt('quantity', array());
     //is sanitized then
     $quantity = 1;
     if (!empty($quantityArray[0])) {
         $quantity = $quantityArray[0];
     }
     $ratingModel = VmModel::getModel('ratings');
     $product_model->withRating = $this->showRating = $ratingModel->showRating($virtuemart_product_id);
     $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
     $customfieldsModel = VmModel::getModel('Customfields');
     if ($product->customfields) {
         if (!class_exists('vmCustomPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
         }
         $customfieldsModel->displayProductCustomfieldFE($product, $product->customfields);
     }
     if (empty($product->slug)) {
         //Todo this should be redesigned to fit better for SEO
         $mainframe->enqueueMessage(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));
         $categoryLink = '';
         if (!$last_category_id) {
             $last_category_id = vRequest::getInt('virtuemart_category_id', false);
         }
         if ($last_category_id) {
             $categoryLink = '&virtuemart_category_id=' . $last_category_id;
         }
         if (VmConfig::get('handle_404', 1)) {
             $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
         } else {
             JError::raise(E_ERROR, '404', 'Not found');
         }
         return;
     }
     $isCustomVariant = false;
     if (!empty($product->customfields)) {
         foreach ($product->customfields as $k => $custom) {
             if ($custom->field_type == 'C' and $custom->virtuemart_product_id != $virtuemart_product_id) {
                 $isCustomVariant = $custom;
             }
             if (!empty($custom->layout_pos)) {
                 $product->customfieldsSorted[$custom->layout_pos][] = $custom;
                 unset($product->customfields[$k]);
             }
         }
         $product->customfieldsSorted['normal'] = $product->customfields;
         unset($product->customfields);
     }
     $product->event = new stdClass();
     $product->event->afterDisplayTitle = '';
     $product->event->beforeDisplayContent = '';
     $product->event->afterDisplayContent = '';
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc');
     }
     $product_model->addImages($product);
     if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
         $min_order_level = $product->min_order_level;
     } else {
         $min_order_level = 1;
     }
     $this->assignRef('min_order_level', $min_order_level);
     if (isset($product->step_order_level) && (int) $product->step_order_level > 0) {
         $step_order_level = $product->step_order_level;
     } else {
         $step_order_level = 1;
     }
     $this->assignRef('step_order_level', $step_order_level);
     // Load the neighbours
     if (VmConfig::get('product_navigation', 1)) {
         $product->neighbours = $product_model->getNeighborProducts($product);
     }
     $this->assignRef('product', $product);
     if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
         $manModel = VmModel::getModel('manufacturer');
         $mans = array();
         // Gebe die Hersteller aus
         foreach ($this->product->virtuemart_manufacturer_id as $manufacturer_id) {
             $mans[] = $manModel->getManufacturer($manufacturer_id);
         }
         $this->product->manufacturers = $mans;
     }
     // Load the category
     $category_model = VmModel::getModel('category');
     shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id);
     if ($category_model) {
         $category = $category_model->getCategory($product->virtuemart_category_id);
         $category_model->addImages($category, 1);
         $this->assignRef('category', $category);
         //Seems we dont need this anylonger, destroyed the breadcrumb
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 if (is_object($c) and isset($c->category_name)) {
                     $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
                 } else {
                     vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c);
                 }
             }
         }
         $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id);
         $category_model->addImages($category->children, 1);
     }
     $pathway->addItem(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)));
     if (!empty($tpl)) {
         $format = $tpl;
     } else {
         $format = vRequest::getCmd('format', 'html');
     }
     if ($format == 'html') {
         // remove joomla canonical before adding it
         foreach ($document->_links as $k => $array) {
             if ($array['relation'] == 'canonical') {
                 unset($document->_links[$k]);
                 break;
             }
         }
         // Set Canonic link
         if ($isCustomVariant !== false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)) {
             $parent = $product_model->getProduct($product->product_parent_id);
             $document->addHeadLink($parent->canonical, 'canonical', 'rel', '');
         } else {
             $document->addHeadLink($product->canonical, 'canonical', 'rel', '');
         }
     } else {
         if ($format == 'pdf') {
             defined('K_PATH_IMAGES') or define('K_PATH_IMAGES', VMPATH_ROOT);
         }
     }
     // Set the titles
     // $document->setTitle should be after the additem pathway
     if ($product->customtitle) {
         $document->setTitle(strip_tags(html_entity_decode($product->customtitle, ENT_QUOTES)));
     } else {
         $document->setTitle(strip_tags(html_entity_decode(($category->category_name ? $category->category_name . ' : ' : '') . $product->product_name, ENT_QUOTES)));
     }
     $this->allowReview = $ratingModel->allowReview($product->virtuemart_product_id);
     $this->showReview = $ratingModel->showReview($product->virtuemart_product_id);
     if ($this->showReview) {
         $this->review = $ratingModel->getReviewByProduct($product->virtuemart_product_id);
         $this->rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id);
     }
     if ($this->showRating) {
         $this->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
     }
     $this->allowRating = $ratingModel->allowRating($product->virtuemart_product_id);
     $superVendor = VmConfig::isSuperVendor();
     if ($superVendor == 1 or $superVendor == $product->virtuemart_vendor_id or $superVendor) {
         $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id;
         $this->edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false);
     } else {
         $this->edit_link = "";
     }
     // Load the user details
     $this->user = JFactory::getUser();
     // More reviews link
     $uri = JURI::getInstance();
     $uri->setVar('showall', 1);
     $uristring = vmURI::getCleanUrl();
     $this->assignRef('more_reviews', $uristring);
     if ($product->metadesc) {
         $document->setDescription(strip_tags(html_entity_decode($product->metadesc, ENT_QUOTES)));
     } else {
         $document->setDescription(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)) . " " . $category->category_name . " " . strip_tags(html_entity_decode($product->product_s_desc, ENT_QUOTES)));
     }
     if ($product->metakey) {
         $document->setMetaData('keywords', $product->metakey);
     }
     if ($product->metarobot) {
         $document->setMetaData('robots', $product->metarobot);
     }
     if ($mainframe->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $product->product_name);
         //Maybe better product_name
     }
     if ($mainframe->getCfg('MetaAuthor') == '1') {
         $document->setMetaData('author', $product->metaauthor);
     }
     $user = JFactory::getUser();
     $showBasePrice = ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or VmConfig::isSuperVendor());
     $this->assignRef('showBasePrice', $showBasePrice);
     $productDisplayShipments = array();
     $productDisplayPayments = array();
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmpayment');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments));
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments));
     $this->assignRef('productDisplayPayments', $productDisplayPayments);
     $this->assignRef('productDisplayShipments', $productDisplayShipments);
     if (empty($category->category_template)) {
         $category->category_template = VmConfig::get('categorytemplate');
     }
     shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout);
     shopFunctionsF::addProductToRecent($virtuemart_product_id);
     $currency = CurrencyDisplay::getInstance();
     $this->assignRef('currency', $currency);
     if (vRequest::getCmd('layout', 'default') == 'notify') {
         $this->setLayout('notify');
     }
     //Added by Seyi Awofadeju to catch notify layout
     VmConfig::loadJLang('com_virtuemart');
     vmJsApi::chosenDropDowns();
     //This must be loaded after the customfields are rendered (they may need to overwrite the handlers)
     vmJsApi::jDynUpdate();
     vmJsApi::addJScript('updDynamicListeners', "\njQuery(document).ready(function() { // GALT: Start listening for dynamic content update.\n\t// If template is aware of dynamic update and provided a variable let's\n\t// set-up the event listeners.\n\tif (Virtuemart.container)\n\t\tVirtuemart.updateDynamicUpdateListeners();\n\n}); ");
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
         }
         vmJsApi::jPrice();
     }
     parent::display($tpl);
 }
コード例 #4
0
ファイル: user.php プロジェクト: brenot/forumdesenvolvimento
    /**
     * Retrieve a list of users from the database.
     *
     * @author Max Milbers
     * @return object List of user objects
     */
    function getUserList()
    {
        //$select = ' * ';
        //$joinedTables = ' FROM #__users AS ju LEFT JOIN #__virtuemart_vmusers AS vmu ON ju.id = vmu.virtuemart_user_id';
        $search = vRequest::getString('search', false);
        $tableToUse = vRequest::getString('searchTable', 'juser');
        $where = array();
        if ($search) {
            $where = ' WHERE ';
            $db = JFactory::getDbo();
            $searchArray = array('ju.name', 'username', 'email', 'shopper_group_name');
            // removed ,'usertype' should be handled by extra dropdown
            if ($tableToUse != 'juser') {
                if (!class_exists('TableUserinfos')) {
                    require VMPATH_ADMIN . DS . 'tables' . DS . 'userinfos.php';
                }
                $userfieldTable = new TableUserinfos($db);
                $userfieldFields = get_object_vars($userfieldTable);
                $userFieldSearchArray = array('company', 'first_name', 'last_name');
                //We must validate if the userfields actually exists, they could be removed
                $userFieldsValid = array();
                foreach ($userFieldSearchArray as $ufield) {
                    if (array_key_exists($ufield, $userfieldFields)) {
                        $userFieldsValid[] = $ufield;
                    }
                }
                $searchArray = array_merge($userFieldsValid, $searchArray);
            }
            $search = str_replace(' ', '%', $db->escape($search, true));
            foreach ($searchArray as $field) {
                $whereOr[] = ' ' . $field . ' LIKE "%' . $search . '%" ';
            }
            //$where = substr($where,0,-3);
        }
        $select = ' ju.id AS id
			, ju.name AS name
			, ju.username AS username
			, ju.email AS email
			, IFNULL(vmu.user_is_vendor,"0") AS is_vendor
			, IFNULL(sg.shopper_group_name, "") AS shopper_group_name ';
        if ($search) {
            if ($tableToUse != 'juser') {
                $select .= ' , ui.name as uiname ';
            }
            foreach ($searchArray as $ufield) {
                $select .= ' , ' . $ufield;
            }
        }
        $joinedTables = ' FROM #__users AS ju
			LEFT JOIN #__virtuemart_vmusers AS vmu ON ju.id = vmu.virtuemart_user_id
			LEFT JOIN #__virtuemart_vmuser_shoppergroups AS vx ON ju.id = vx.virtuemart_user_id
			LEFT JOIN #__virtuemart_shoppergroups AS sg ON vx.virtuemart_shoppergroup_id = sg.virtuemart_shoppergroup_id ';
        if ($search and $tableToUse != 'juser') {
            $joinedTables .= ' LEFT JOIN #__virtuemart_userinfos AS ui ON ui.virtuemart_user_id = vmu.virtuemart_user_id';
        }
        $whereAnd = array();
        if (VmConfig::get('multixcart', 0) == 'byvendor') {
            $superVendor = VmConfig::isSuperVendor();
            if ($superVendor > 1) {
                $joinedTables .= ' LEFT JOIN #__virtuemart_vendor_users AS vu ON ju.id = vmu.virtuemart_user_id';
                $whereAnd[] = ' vu.virtuemart_vendor_id = ' . $superVendor . ' ';
            }
        }
        $where = '';
        $whereStr = ' WHERE ';
        if (!empty($whereOr)) {
            $where = $whereStr . implode(' OR ', $whereOr);
            $whereStr = 'AND';
        }
        if (!empty($whereAnd)) {
            $where .= $whereStr . ' (' . implode(' OR ', $whereAnd) . ')';
        }
        return $this->_data = $this->exeSortSearchListQuery(0, $select, $joinedTables, $where, ' GROUP BY ju.id', $this->_getOrdering());
    }
コード例 #5
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * @author Max Milbers
  */
 function display($tpl = null)
 {
     $this->useSSL = VmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = vRequest::getCmd('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     $this->_model = VmModel::getModel('user');
     //$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     $virtuemart_user_id = vRequest::getInt('virtuemart_user_id', false);
     if ($virtuemart_user_id and is_array($virtuemart_user_id)) {
         $virtuemart_user_id = $virtuemart_user_id[0];
     }
     $this->_model->setId($virtuemart_user_id);
     $this->userDetails = $this->_model->getUser();
     $this->address_type = vRequest::getCmd('addrtype', 'BT');
     $new = false;
     if (vRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = vRequest::getString('virtuemart_userinfo_id', 0);
     }
     $userFields = null;
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $task = vRequest::getCmd('task', '');
     if (($this->cart->_fromCart or $this->cart->getInCheckOut()) && empty($virtuemart_userinfo_id)) {
         //New Address is filled here with the data of the cart (we are in the cart)
         $fieldtype = $this->address_type . 'address';
         $this->cart->prepareAddressFieldsInCart();
         $userFields = $this->cart->{$fieldtype};
     } else {
         if ($task == 'addST') {
             $this->address_type = 'ST';
         }
         if (!$new and empty($virtuemart_userinfo_id)) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $this->address_type, $virtuemart_userinfo_id, false);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             vmdebug('$userFields by getBTuserinfo_id', $userFields);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
     }
     $this->virtuemart_userinfo_id = $virtuemart_userinfo_id;
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = vmText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = vmText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         $this->shopper($userFields);
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $stTask = 'addST';
     if ($task == 'editaddresscart') {
         $stTask = 'editaddresscart';
     }
     $this->_lists['shipTo'] = ShopFunctionsF::generateStAddressList($this, $this->_model, $stTask);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = VmModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = vmText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = vmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if ($this->cart->_fromCart or $this->cart->getInCheckOut()) {
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(vmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = vmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if ($this->cart->_fromCart or $this->cart->getInCheckOut()) {
             if ($this->address_type == 'BT') {
                 $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($this->address_type == 'BT') {
                 $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = vmText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($this->address_type == 'BT') {
             $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = vmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     $this->add_product_link = "";
     $this->manage_link = "";
     if (VmConfig::isSuperVendor()) {
         $manage_link = JRoute::_('index.php?option=com_virtuemart&tmpl=component&manage=1');
         $this->manage_link = $this->linkIcon($manage_link, 'JACTION_MANAGE', 'new', false, false, true, true);
         $add_product_link = JRoute::_('index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0&manage=1');
         $this->add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
コード例 #6
0
 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 = VmConfig::isSuperVendor();
         self::$categoryTree[$hash] = $cache->call(array('ShopFunctions', 'categoryListTreeLoop'), $selectedCategories, $cid, $level, $disabledFields, $app->isSite(), $vendorId, VmConfig::$vmlang);
     }
     return self::$categoryTree[$hash];
 }
コード例 #7
0
ファイル: orders.php プロジェクト: kosmosby/medicine-prof
	/**
	 * Select the products to list on the product list page
	 * @param $uid integer Optional user ID to get the orders of a single user
	 * @param $_ignorePagination boolean If true, ignore the Joomla pagination (for embedded use, default false)
	 */
	public function getOrdersList($uid = 0, $noLimit = false)
	{
// 		vmdebug('getOrdersList');
		$this->_noLimit = $noLimit;
		$select = " o.*, CONCAT_WS(' ',u.first_name,u.middle_name,u.last_name) AS order_name "
		.',u.email as order_email,pm.payment_name AS payment_method ';
		$from = $this->getOrdersListQuery();

		$where = array();
		$user = JFactory::getUser();
		$virtuemart_vendor_id = vRequest::get('virtuemart_vendor_id',false);

		if($user->authorise('core.admin','com_virtuemart')){
			vmdebug('Vendor is core.admin and should see all');
			if($virtuemart_vendor_id){
				$where[]= ' o.virtuemart_vendor_id = "'.$virtuemart_vendor_id.'" ';
			}
			if(!empty($uid)){
				$where[]= ' u.virtuemart_user_id = ' . (int)$uid.' ';
			}
		}
		else if( $user->authorise('core.manage','com_virtuemart') or $user->authorise('vm.orders','com_virtuemart')){

			$virtuemart_vendor_id = VmConfig::isSuperVendor();
			vmdebug('Vendor is manager and should only see its own orders venodorId '.$virtuemart_vendor_id);
			if(!empty($virtuemart_vendor_id)){
				$where[]= ' (o.virtuemart_vendor_id = '.$virtuemart_vendor_id.' OR u.virtuemart_user_id = ' . (int)$uid.') ';
				$uid = 0;
			} else {
				//We map here as fallback to vendor 1.
				$where[]= ' u.virtuemart_user_id = ' . (int)$uid;

			}
		} else {
			//A normal user is only allowed to see its own orders, we map $uid to the user id
			$uid = (int)$user->id;
			$where = array();
		}
		if(!empty($uid)){
			$where[]= ' u.virtuemart_user_id = ' . (int)$uid.' ';
		}


		if ($search = vRequest::getString('search', false)){
			$db = JFactory::getDBO();
			$search = '"%' . $db->escape( $search, true ) . '%"' ;
			$search = str_replace(' ','%',$search);

			$searchFields = array();
			$searchFields[] = 'u.first_name';
			$searchFields[] = 'u.middle_name';
			$searchFields[] = 'u.last_name';
			$searchFields[] = 'o.order_number';
			$searchFields[] = 'u.company';
			$searchFields[] = 'u.email';
			$searchFields[] = 'u.phone_1';
			$searchFields[] = 'u.address_1';
			$searchFields[] = 'u.zip';
			$where[] = implode (' LIKE '.$search.' OR ', $searchFields) . ' LIKE '.$search.' ';
			//$where[] = ' ( u.first_name LIKE '.$search.' OR u.middle_name LIKE '.$search.' OR u.last_name LIKE '.$search.' OR `order_number` LIKE '.$search.')';
		}

		$order_status_code = vRequest::getString('order_status_code', false);
		if ($order_status_code and $order_status_code!=-1){
			$where[] = ' o.order_status = "'.$order_status_code.'" ';
		}

		if (count ($where) > 0) {
			$whereString = ' WHERE (' . implode (' AND ', $where) . ') ';
		}
		else {
			$whereString = '';
		}

		if ( vRequest::getCmd('view') == 'orders') {
			$ordering = $this->_getOrdering();
		} else {
			$ordering = ' order by o.modified_on DESC';
		}

		$this->_data = $this->exeSortSearchListQuery(0,$select,$from,$whereString,'',$ordering);


		return $this->_data ;
	}
コード例 #8
0
ファイル: media.php プロジェクト: cybershocik/Darek
    /**
     * Retrieve a list of files from the database. This is meant only for backend use
     *
     * @author Max Milbers
     * @param boolean $onlyPublished True to only retrieve the published files, false otherwise
     * @param boolean $noLimit True if no record count limit is used, false otherwise
     * @return object List of media objects
     */
    function getFiles($onlyPublished = false, $noLimit = false, $virtuemart_product_id = null, $cat_id = null, $where = array(), $nbr = false)
    {
        $this->_noLimit = $noLimit;
        if (empty($db)) {
            $db = JFactory::getDBO();
        }
        $query = '';
        $selectFields = array();
        $joinTables = array();
        $joinedTables = '';
        $whereItems = array();
        $groupBy = '';
        $orderByTable = '';
        if (!empty($virtuemart_product_id)) {
            $mainTable = '`#__virtuemart_product_medias`';
            $selectFields[] = ' `#__virtuemart_medias`.`virtuemart_media_id` as virtuemart_media_id ';
            $joinTables[] = ' LEFT JOIN `#__virtuemart_medias` ON `#__virtuemart_medias`.`virtuemart_media_id`=`#__virtuemart_product_medias`.`virtuemart_media_id` and `virtuemart_product_id` = "' . $virtuemart_product_id . '"';
            $whereItems[] = '`virtuemart_product_id` = "' . $virtuemart_product_id . '"';
            if ($this->_selectedOrdering == 'ordering') {
                $orderByTable = '`#__virtuemart_product_medias`.';
            } else {
                $orderByTable = '`#__virtuemart_medias`.';
            }
        } else {
            if (!empty($cat_id)) {
                $mainTable = '`#__virtuemart_category_medias`';
                $selectFields[] = ' `#__virtuemart_medias`.`virtuemart_media_id` as virtuemart_media_id';
                $joinTables[] = ' LEFT JOIN `#__virtuemart_medias` ON `#__virtuemart_medias`.`virtuemart_media_id`=`#__virtuemart_category_medias`.`virtuemart_media_id` and `virtuemart_category_id` = "' . $cat_id . '"';
                $whereItems[] = '`virtuemart_category_id` = "' . $cat_id . '"';
                if ($this->_selectedOrdering == 'ordering') {
                    $orderByTable = '`#__virtuemart_category_medias`.';
                } else {
                    $orderByTable = '`#__virtuemart_medias`.';
                }
            } else {
                $mainTable = '`#__virtuemart_medias`';
                $selectFields[] = ' `virtuemart_media_id` ';
                $user = JFactory::getUser();
                if (!$user->authorise('core.admin', 'com_virtuemart') and !$user->authorise('core.manager', 'com_virtuemart')) {
                    $vendorId = VmConfig::isSuperVendor();
                    $whereItems[] = '(`virtuemart_vendor_id` = "' . $vendorId . '" OR `shared`="1")';
                }
            }
        }
        if ($onlyPublished) {
            $whereItems[] = '`#__virtuemart_medias`.`published` = 1';
        }
        if ($search = vRequest::getString('searchMedia', false)) {
            $search = '"%' . $db->escape($search, true) . '%"';
            $where[] = ' (`file_title` LIKE ' . $search . '
								OR `file_description` LIKE ' . $search . '
								OR `file_meta` LIKE ' . $search . '
								OR `file_url` LIKE ' . $search . '
								OR `file_url_thumb` LIKE ' . $search . '
							) ';
        }
        if ($type = vRequest::getCmd('search_type')) {
            $where[] = 'file_type = "' . $type . '" ';
        }
        if ($role = vRequest::getCmd('search_role')) {
            if ($role == "file_is_downloadable") {
                $where[] = '`file_is_downloadable` = 1';
                $where[] = '`file_is_forSale` = 0';
            } elseif ($role == "file_is_forSale") {
                $where[] = '`file_is_downloadable` = 0';
                $where[] = '`file_is_forSale` = 1';
            } else {
                $where[] = '`file_is_downloadable` = 0';
                $where[] = '`file_is_forSale` = 0';
            }
        }
        if (!empty($where)) {
            $whereItems = array_merge($whereItems, $where);
        }
        if (count($whereItems) > 0) {
            $whereString = ' WHERE ' . implode(' AND ', $whereItems);
        } else {
            $whereString = ' ';
        }
        $orderBy = $this->_getOrdering($orderByTable);
        #
        if (count($selectFields) > 0) {
            $select = implode(', ', $selectFields) . ' FROM ' . $mainTable;
            //$selectFindRows = 'SELECT COUNT(*) FROM '.$mainTable;
            if (count($joinTables) > 0) {
                foreach ($joinTables as $table) {
                    $joinedTables .= $table;
                }
            }
        } else {
            vmError('No select fields given in getFiles', 'No select fields given');
            return false;
        }
        $this->_data = $this->exeSortSearchListQuery(2, $select, $joinedTables, $whereString, $groupBy, $orderBy, '', $nbr);
        if (empty($this->_data)) {
            return array();
        }
        if (!is_array($this->_data)) {
            $this->_data = explode(',', $this->_data);
        }
        $this->_data = $this->createMediaByIds($this->_data);
        return $this->_data;
    }
コード例 #9
0
ファイル: view.html.php プロジェクト: proyectoseb/Matrix
 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';
     }
     // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
     vmJsApi::jPrice();
     $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::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);
             $productModel->addImages($this->products, 1);
             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 {
                         $customfieldsModel = VmModel::getModel('Customfields');
                         if (!class_exists('vmCustomPlugin')) {
                             require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
                         }
                         foreach ($this->products as $i => $productItem) {
                             if (!empty($productItem->customfields)) {
                                 $product = clone $productItem;
                                 $customfields = array();
                                 foreach ($productItem->customfields as $cu) {
                                     $customfields[] = clone $cu;
                                 }
                                 $customfieldsSorted = array();
                                 $customfieldsModel->displayProductCustomfieldFE($product, $customfields);
                                 $product->stock = $productModel->getStockIndicator($product);
                                 foreach ($customfields as $k => $custom) {
                                     if (!empty($custom->layout_pos)) {
                                         $customfieldsSorted[$custom->layout_pos][] = $custom;
                                         unset($customfields[$k]);
                                     }
                                 }
                                 $customfieldsSorted['normal'] = $customfields;
                                 $product->customfieldsSorted = $customfieldsSorted;
                                 unset($product->customfields);
                                 $this->products[$i] = $product;
                             } else {
                                 $productItem->stock = $productModel->getStockIndicator($productItem);
                                 $this->products[$i] = $productItem;
                             }
                         }
                     }
                 }
             }
             // 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 = ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or VmConfig::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($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $categoryModel->addImages($category, 1);
         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, 1);
         } else {
             $category->children = false;
         }
         if (VmConfig::get('enable_content_plugin', 1)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         if ($category->metadesc) {
             $document->setDescription($category->metadesc);
         }
         if ($category->metakey) {
             $document->setMetaData('keywords', $category->metakey);
         }
         if ($category->metarobot) {
             $document->setMetaData('robots', $category->metarobot);
         }
         if ($app->getCfg('MetaAuthor') == '1') {
             $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);
     }
     if (vRequest::getInt('error')) {
         $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
     }
     if (!empty($keyword)) {
         $title .= ' (' . $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);
 }
コード例 #10
0
ファイル: view.html.php プロジェクト: kosmosby/medicine-prof
	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 = VmModel::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');
				VmConfig::loadJLang('com_virtuemart_orders',TRUE);
				VmConfig::loadJLang('com_virtuemart_shoppers',TRUE);

				$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;
				}

				$product = $model->getProductSingle($virtuemart_product_id,false);
				//$user = JFactory::getUser();
				$superVendor =  VmConfig::isSuperVendor();
				if( $superVendor !=1 and $superVendor!=$product->virtuemart_vendor_id){
					JFactory::getApplication()->redirect( 'index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error');
				}
				if(!empty($product->product_parent_id)){
					$product_parent= $model->getProductSingle($product->product_parent_id,false);
				}


				$customfields = VmModel::getModel ('Customfields');

				$product->allIds[] = $product->virtuemart_product_id;
				if(!empty($product->product_parent_id)) $product->allIds[] = $product->product_parent_id;

				$product->customfields = $customfields->getCustomEmbeddedProductCustomFields ($product->allIds);
				//vmdebug('my customfields',$product->customfields);

				// 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);
				//$this->assignRef('shoppergroupList', $shoppergroupList);

				// Load the product price
				if(!class_exists('calculationHelper')) require(VMPATH_ADMIN.DS.'helpers'.DS.'calculationh.php');

				$product_childIds = $model->getProductChildIds($virtuemart_product_id);

				$product_childs = array();
				$childs = 0;
				$maxChilds = 50;
				foreach($product_childIds as $id){
					if($childs++>$maxChilds) break;
					$product_childs[] = $model->getProductSingle($id,false);
				}
				$this->product_childs = $product_childs;

				if(!class_exists('VirtueMartModelConfig')) require(VMPATH_ADMIN .'/models/config.php');
				$productLayouts = VirtueMartModelConfig::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 = VmModel::getModel('vendor');

				if(Vmconfig::get('multix','none')!=='none'){
					$lists['vendors'] = Shopfunctions::renderVendorList($product->virtuemart_vendor_id);
				}
				// Load the currencies
				$currency_model = VmModel::getModel('currency');

				$vendor_model->setId(VmConfig::isSuperVendor());
				$this->vendor = $vendor_model->getVendor();

				$currency = $currency_model->getCurrency($this->vendor->vendor_currency);
				$this->vendor_currency_symb = $currency->currency_symbol;


				$lists['manufacturers'] = shopFunctions::renderManufacturerList($product->virtuemart_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 = VmConfig::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 = VmConfig::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 = VmConfig::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 = VmModel::getModel('waitinglist');
				/* Load waiting list */
				if ($product->virtuemart_product_id) {
					//$waitinglist = $this->get('waitingusers', 'waitinglist');
					$waitinglist = $waitinglistmodel->getWaitingusers($product->virtuemart_product_id);
					$this->assignRef('waitinglist', $waitinglist);
				}
				$productShoppers = $model->getProductShoppersByStatus($product->virtuemart_product_id,array('S') );
				$this->assignRef('productShoppers', $productShoppers);
				$orderstatusModel = VmModel::getModel('orderstatus');
				$lists['OrderStatus'] = $orderstatusModel->renderOSList(array(),'order_status',TRUE);

				// Add the virtuemart_shoppergroup_ids
				$cid = JFactory::getUser()->id;

				$this->activeShoppergroups = shopfunctions::renderGuiList($cid,'shoppergroups','shopper_group_name','category','vmuser_shoppergroups','virtuemart_user_id');
				if(!empty($this->activeShoppergroups) ){
					//vmdebug('$this->activeShoppergroups',$this->activeShoppergroups);
					$shoppergroupModel = VmModel::getModel('shoppergroup');
					$this->activeShoppergroups = vmText::_($shoppergroupModel->getDefault(0)->shopper_group_name);
				}

				// Load protocustom lists
				$customModel = VmModel::getModel ('custom');

				$this->fieldTypes = VirtueMartModelCustom::getCustomTypes();

				$customsList = $customModel->getCustomsList ();
				$attribs='style= "width: 300px;"';
				$customlist = JHtml::_('select.genericlist', $customsList,'customlist', $attribs);

				$this->assignRef('customsList', $customlist);

				if ($product->product_parent_id > 0) {

					// Set up labels
					$info_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL');
					$status_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL');
					$dim_weight_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL');
					$images_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL');
					$delete_message = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG');
				}
				else {
					if ($task == 'add') $action = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL');
					else $action = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL');

					$info_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL');
					$status_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL');
					$dim_weight_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL');
					$images_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL');
					$delete_message = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_PRODUCT_MSG');
				}


				$this->assignRef('product', $product);
				/*$product_empty_price = array(
					'virtuemart_product_price_id' => 0
				, 'virtuemart_product_id'         => $virtuemart_product_id
				, 'virtuemart_shoppergroup_id'    => NULL
				, 'product_price'                 => NULL
				, 'override'                      => NULL
				, 'product_override_price'        => NULL
				, 'product_tax_id'                => NULL
				, 'product_discount_id'           => NULL
				, 'product_currency'              => $vendor->vendor_currency
				, 'product_price_publish_up'      => NULL
				, 'product_price_publish_down'    => NULL
				, 'price_quantity_start'          => NULL
				, 'price_quantity_end'            => NULL
				);
				$this->assignRef ('product_empty_price', $product_empty_price);*/

				$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 = '&virtuemart_category_id=' . $product->canonCatLink; else $canonLink = '';
				if(!empty($product->virtuemart_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 = '&virtuemart_category_id='.$product->canonCatId;

					$text = '<a href="'.juri::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_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_VIRTUEMART_LEAVE_TO_PRODUCT', juri::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.$canonLink.'&Itemid='. $menuItemID);
					}
				} else {
					$text = $product->product_name.$sku;
				}
				$this->SetViewTitle('PRODUCT',$text);

				$this->addStandardEditViewCommands ($product->virtuemart_product_id);

				break;

			case 'massxref_cats':
			case 'massxref_cats_exe':
				$this->SetViewTitle('PRODUCT_MASSXREF');

				$showVendors = $this->showVendors();
				$this->assignRef('showVendors',$showVendors);

				$keyWord ='';
				$catmodel = VmModel::getModel('category');
				$this->assignRef('catmodel',	$catmodel);
				//$this->addStandardDefaultViewCommands();
				$this->addStandardDefaultViewLists($catmodel,'category_name');

				$categories = $catmodel->getCategoryTree(0,0,false,$this->lists['search']);
				$this->assignRef('categories', $categories);

				$catpagination = $catmodel->getPagination();
				$this->assignRef('catpagination', $catpagination);

				//$this->addStandardDefaultViewCommands();
				$this->setLayout('massxref');

				JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT_EXE'), false);

				break;

			case 'massxref_sgrps':
			case 'massxref_sgrps_exe':
				$sgrpmodel = VmModel::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', vmText::_('COM_VIRTUEMART_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&virtuemart_product_id='.$product_parent->virtuemart_product_id.'&option=com_virtuemart'), $product_parent->product_name, array('title' => vmText::_('COM_VIRTUEMART_EDIT_PARENT').' '.$product_parent->product_name));
					$msg= vmText::_('COM_VIRTUEMART_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');

			/* Get the list of products */
			$productlist = $model->getProductListing(false,false,false,false,true);
			//vmdebug('my product listing',$productlist);
			//The pagination must now always set AFTER the model load the listing
			$pagination = $model->getPagination();
			$this->assignRef('pagination', $pagination);

			/* Get the category tree */
			$categoryId = $model->virtuemart_category_id; //OSP switched to filter in model, was vRequest::getInt('virtuemart_category_id');
			$category_tree = ShopFunctions::categoryListTree(array($categoryId));
			$this->assignRef('category_tree', $category_tree);

			/* Load the product price */
			if(!class_exists('calculationHelper')) require(VMPATH_ADMIN.DS.'helpers'.DS.'calculationh.php');

			$vendor_model = VmModel::getModel('vendor');
			$productreviews = VmModel::getModel('ratings');

			$loaded_virtuemart_manufacturer_id = array();
			$this->mfTable = $model->getTable ('manufacturers');

			$this->catTable = $model->getTable ('categories');

			foreach ($productlist as $virtuemart_product_id => $product) {
				$product->mediaitems = count($product->virtuemart_media_id);
				$product->reviews = $productreviews->countReviewsForProduct($product->virtuemart_product_id);

				$vendor_model->setId($product->virtuemart_vendor_id);
				$vendor = $vendor_model->getVendor();

				$currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency,$vendor->virtuemart_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 = vmText::_('COM_VIRTUEMART_MULTIPLE_PRICES');
				} else {
					$product->product_price_display = vmText::_('COM_VIRTUEMART_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->virtuemart_manufacturer_id[0])) {
					$product->manuList = shopfunctions::renderGuiList($product->virtuemart_manufacturer_id,'manufacturers','mf_name','manufacturer');
				}
			}

			$mf_model = VmModel::getModel('manufacturer');
			$manufacturers = $mf_model->getManufacturerDropdown();
			$this->assignRef('manufacturers',	$manufacturers);

			/* add Search filter in lists*/
			/* Search type */
			$options = array( '' => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'),
		    				'parent' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'),
							'product' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'),
							'price' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'),
							'withoutprice' => vmText::_('COM_VIRTUEMART_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' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'),
								  'af' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')
			);
			$this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'),$options);

			// Toolbar
			if ($this->canDo->get('core.admin') or $this->canDo->get('vm.product.edit')) {
				JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT'), true);
				JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS'), true);
			}
			if ($this->canDo->get('core.admin') || $this->canDo->get('vm.product.create')) {
				JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true);
				JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true);
			}
			JToolBarHelper::custom('addrating', 'default', '', vmText::_('COM_VIRTUEMART_ADD_RATING'), true);
			$this->addStandardDefaultViewCommands();


			$this->assignRef('productlist', $productlist);
			$this->assignRef('virtuemart_category_id', $categoryId);
			$this->assignRef('model', $model);

			break;
		}

		parent::display($tpl);
	}
コード例 #11
0
ファイル: view.html.php プロジェクト: spk063/vmonepage
 /**
  * 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()
 {
     $cart = $this->cart;
     $result = false;
     if ($this->allowChangeShopper) {
         $this->adminID = JFactory::getSession()->get('vmAdminID', false);
         if ($this->adminID) {
             if (!class_exists('vmCrypt')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
             }
             $this->adminID = vmCrypt::decrypt($this->adminID);
         }
         $superVendor = VmConfig::isSuperVendor($this->adminID);
         if ($superVendor) {
             $uModel = VmModel::getModel('user');
             $result = $uModel->getSwitchUserList($superVendor, $this->adminID);
         }
     }
     //vmdebug('my user list ',$result);
     if (!$result) {
         $this->allowChangeShopper = false;
     }
     return $result;
 }
コード例 #12
0
ファイル: product.php プロジェクト: lenard112/cms
 /**
  * Store a product
  *
  * @author Max Milbers
  * @param $product given as reference
  * @param bool $isChild Means not that the product is child or not. It means if the product should be threated as child
  * @return bool
  */
 public function store(&$product)
 {
     vRequest::vmCheckToken();
     if ($product) {
         $data = (array) $product;
     }
     $isChild = FALSE;
     if (!empty($data['isChild'])) {
         $isChild = $data['isChild'];
     }
     $superVendor = VmConfig::isSuperVendor();
     if (empty($superVendor)) {
         vmError('You are not a vendor or administrator, storing of product cancelled');
         return FALSE;
     }
     if (isset($data['intnotes'])) {
         $data['intnotes'] = trim($data['intnotes']);
     }
     // Setup some place holders
     $product_data = $this->getTable('products');
     if (!empty($data['virtuemart_product_id'])) {
         $product_data->load($data['virtuemart_product_id']);
     }
     //Set the decimals like product packaging
     //$decimals = array('product_length','product_width','product_height','product_weight','product_packaging');
     foreach ($this->decimals as $decimal) {
         if (array_key_exists($decimal, $data)) {
             if (!empty($data[$decimal])) {
                 $data[$decimal] = str_replace(',', '.', $data[$decimal]);
             } else {
                 $data[$decimal] = null;
                 $product_data->{$decimal} = null;
                 //vmdebug('Store product, set $decimal '.$decimal.' = null');
             }
         }
     }
     //with the true, we do preloading and preserve so old values note by Max Milbers
     //	$product_data->bindChecknStore ($data, $isChild);
     //We prevent with this line, that someone is storing a product as its own parent
     if (!empty($product_data->product_parent_id) and $product_data->product_parent_id == $data['virtuemart_product_id']) {
         $product_data->product_parent_id = 0;
     }
     $stored = $product_data->bindChecknStore($data, false);
     $errors = $product_data->getErrors();
     if (!$stored or count($errors) > 0) {
         foreach ($errors as $error) {
             vmError('Product store ' . $error);
         }
         if (!$stored) {
             vmError('You are not an administrator or the correct vendor, storing of product cancelled');
         }
         return FALSE;
     }
     $this->_id = $data['virtuemart_product_id'] = (int) $product_data->virtuemart_product_id;
     if (empty($this->_id)) {
         vmError('Product not stored, no id');
         return FALSE;
     }
     //We may need to change this, the reason it is not in the other list of commands for parents
     if (!$isChild) {
         $modelCustomfields = VmModel::getModel('Customfields');
         $modelCustomfields->storeProductCustomfields('product', $data, $product_data->virtuemart_product_id);
     }
     // Get old IDS
     $old_price_ids = $this->loadProductPrices($this->_id, 0, false);
     //vmdebug('$old_price_ids ',$old_price_ids);
     if (isset($data['mprices']['product_price']) and count($data['mprices']['product_price']) > 0) {
         foreach ($data['mprices']['product_price'] as $k => $product_price) {
             $pricesToStore = array();
             $pricesToStore['virtuemart_product_id'] = $this->_id;
             $pricesToStore['virtuemart_product_price_id'] = (int) $data['mprices']['virtuemart_product_price_id'][$k];
             if (!$isChild) {
                 //$pricesToStore['basePrice'] = $data['mprices']['basePrice'][$k];
                 $pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
                 $pricesToStore['override'] = (int) $data['mprices']['override'][$k];
                 $pricesToStore['virtuemart_shoppergroup_id'] = (int) $data['mprices']['virtuemart_shoppergroup_id'][$k];
                 $pricesToStore['product_tax_id'] = (int) $data['mprices']['product_tax_id'][$k];
                 $pricesToStore['product_discount_id'] = (int) $data['mprices']['product_discount_id'][$k];
                 $pricesToStore['product_currency'] = (int) $data['mprices']['product_currency'][$k];
                 $pricesToStore['product_price_publish_up'] = $data['mprices']['product_price_publish_up'][$k];
                 $pricesToStore['product_price_publish_down'] = $data['mprices']['product_price_publish_down'][$k];
                 $pricesToStore['price_quantity_start'] = (int) $data['mprices']['price_quantity_start'][$k];
                 $pricesToStore['price_quantity_end'] = (int) $data['mprices']['price_quantity_end'][$k];
             }
             if (!$isChild and isset($data['mprices']['use_desired_price'][$k]) and $data['mprices']['use_desired_price'][$k] == "1") {
                 if (!class_exists('calculationHelper')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
                 }
                 $calculator = calculationHelper::getInstance();
                 $pricesToStore['salesPrice'] = $data['mprices']['salesPrice'][$k];
                 $pricesToStore['product_price'] = $data['mprices']['product_price'][$k] = $calculator->calculateCostprice($this->_id, $pricesToStore);
                 unset($data['mprices']['use_desired_price'][$k]);
             } else {
                 if (isset($data['mprices']['product_price'][$k])) {
                     $pricesToStore['product_price'] = $data['mprices']['product_price'][$k];
                 }
             }
             if ($isChild) {
                 $childPrices = $this->loadProductPrices($this->_id, 0, false);
             }
             if ((isset($pricesToStore['product_price']) and $pricesToStore['product_price'] != '') || (isset($childPrices) and count($childPrices) > 1)) {
                 if ($isChild) {
                     //$childPrices = $this->loadProductPrices($pricesToStore['virtuemart_product_price_id'],0,0,false);
                     if (is_array($old_price_ids) and count($old_price_ids) > 1) {
                         //We do not touch multiple child prices. Because in the parent list, we see no price, the gui is
                         //missing to reflect the information properly.
                         $pricesToStore = false;
                         $old_price_ids = array();
                     } else {
                         unset($data['mprices']['product_override_price'][$k]);
                         unset($pricesToStore['product_override_price']);
                         unset($data['mprices']['override'][$k]);
                         unset($pricesToStore['override']);
                     }
                 }
                 //$data['mprices'][$k] = $data['virtuemart_product_id'];
                 if ($pricesToStore) {
                     $toUnset = array();
                     foreach ($old_price_ids as $key => $oldprice) {
                         if (array_search($pricesToStore['virtuemart_product_price_id'], $oldprice)) {
                             $pricesToStore = array_merge($oldprice, $pricesToStore);
                             $toUnset[] = $key;
                         }
                     }
                     $this->updateXrefAndChildTables($pricesToStore, 'product_prices', $isChild);
                     foreach ($toUnset as $key) {
                         unset($old_price_ids[$key]);
                     }
                 }
             }
         }
     }
     if (count($old_price_ids)) {
         $oldPriceIdsSql = array();
         foreach ($old_price_ids as $oldPride) {
             $oldPriceIdsSql[] = $oldPride['virtuemart_product_price_id'];
         }
         $db = JFactory::getDbo();
         // delete old unused Prices
         $db->setQuery('DELETE FROM `#__virtuemart_product_prices` WHERE `virtuemart_product_price_id` in ("' . implode('","', $oldPriceIdsSql) . '") ');
         $db->execute();
         $err = $db->getErrorMsg();
         if (!empty($err)) {
             vmWarn('In store prodcut, deleting old price error', $err);
         }
     }
     if (!empty($data['childs'])) {
         foreach ($data['childs'] as $productId => $child) {
             if ($child['virtuemart_product_id'] != $data['virtuemart_product_id']) {
                 if (empty($child['product_parent_id'])) {
                     $child['product_parent_id'] = $data['virtuemart_product_id'];
                 }
                 $child['virtuemart_product_id'] = $productId;
             }
             if (!empty($child['product_parent_id']) and $child['product_parent_id'] == $child['virtuemart_product_id']) {
                 $child['product_parent_id'] = 0;
             }
             $child['isChild'] = TRUE;
             $this->store($child);
         }
     }
     if (!$isChild) {
         $data = $this->updateXrefAndChildTables($data, 'product_shoppergroups');
         $data = $this->updateXrefAndChildTables($data, 'product_manufacturers');
         if (!empty($data['categories']) && count($data['categories']) > 0) {
             $data['virtuemart_category_id'] = $data['categories'];
         } else {
             $data['virtuemart_category_id'] = array();
         }
         $data = $this->updateXrefAndChildTables($data, 'product_categories');
         // Update waiting list
         //TODO what is this doing?
         if (!empty($data['notify_users'])) {
             if ($data['product_in_stock'] > 0 && $data['notify_users'] == '1') {
                 $waitinglist = VmModel::getModel('Waitinglist');
                 $waitinglist->notifyList($data['virtuemart_product_id']);
             }
         }
         // Process the images
         $mediaModel = VmModel::getModel('Media');
         $mediaModel->storeMedia($data, 'product');
         $errors = $mediaModel->getErrors();
         foreach ($errors as $error) {
             vmError($error);
         }
     }
     return $product_data->virtuemart_product_id;
 }
コード例 #13
0
ファイル: view.html.php プロジェクト: lenard112/cms
 private function checkShipmentMethodsConfigured()
 {
     //For the selection of the shipment method we need the total amount to pay.
     $shipmentModel = VmModel::getModel('Shipmentmethod');
     $shipments = $shipmentModel->getShipments();
     if (empty($shipments)) {
         $text = '';
         $user = JFactory::getUser();
         if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or VmConfig::isSuperVendor()) {
             $uri = JFactory::getURI();
             $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=shipmentmethod';
             $text = vmText::sprintf('COM_VIRTUEMART_NO_SHIPPING_METHODS_CONFIGURED_LINK', '<a href="' . $link . '" rel="nofollow">' . $link . '</a>');
         }
         vmInfo('COM_VIRTUEMART_NO_SHIPPING_METHODS_CONFIGURED', $text);
         $tmp = 0;
         $this->assignRef('found_shipment_method', $tmp);
         $this->cart->virtuemart_shipmentmethod_id = 0;
         return false;
     }
     return true;
 }
コード例 #14
0
ファイル: view.html.php プロジェクト: kosmosby/medicine-prof
    /**
		 * Collect all data to show on the template
		 *
		 * @author RolandD, Max Milbers
		 */
		function display($tpl = null) {

			//TODO get plugins running
//		$dispatcher	= JDispatcher::getInstance();
//		$limitstart	= vRequest::getVar('limitstart', 0, '', 'int');

			$show_prices = VmConfig::get('show_prices', 1);
			if ($show_prices == '1') {
				if (!class_exists('calculationHelper'))
					require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php');
				vmJsApi::jPrice();
			}
			$this->assignRef('show_prices', $show_prices);

			$document = JFactory::getDocument();

			// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere


			$mainframe = JFactory::getApplication();
			$pathway = $mainframe->getPathway();
			$task = vRequest::getCmd('task');

			if (!class_exists('VmImage'))
				require(VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php');

			// Load the product
			//$product = $this->get('product');	//Why it is sensefull to use this construction? Imho it makes it just harder
			$product_model = VmModel::getModel('product');
			$this->assignRef('product_model', $product_model);
			$virtuemart_product_idArray = vRequest::getInt('virtuemart_product_id', 0);
			if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
				$virtuemart_product_id = (int)$virtuemart_product_idArray[0];
			} else {
				$virtuemart_product_id = (int)$virtuemart_product_idArray;
			}

			$quantityArray = vRequest::getInt ('quantity', array()); //is sanitized then

			$quantity = 1;
			if (!empty($quantityArray[0])) {
				$quantity = $quantityArray[0];
			}
			$ratingModel = VmModel::getModel('ratings');
			$product_model->withRating = $this->showRating = $ratingModel->showRating($virtuemart_product_id);
			$product = $product_model->getProduct($virtuemart_product_id,TRUE,TRUE,TRUE,$quantity);

			if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
			$last_category_id = shopFunctionsF::getLastVisitedCategoryId();

			$customfieldsModel = VmModel::getModel ('Customfields');

			//$product->customfields = $customfieldsModel->getCustomEmbeddedProductCustomFields ($product->allIds);
			if ($product->customfields){

				if (!class_exists ('vmCustomPlugin')) {
					require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
				}
				$customfieldsModel -> displayProductCustomfieldFE ($product, $product->customfields);
			}

			if (empty($product->slug)) {

				//Todo this should be redesigned to fit better for SEO
				$mainframe->enqueueMessage(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));

				$categoryLink = '';
				if (!$last_category_id) {
					$last_category_id = vRequest::getInt('virtuemart_category_id', false);
				}
				if ($last_category_id) {
					$categoryLink = '&virtuemart_category_id=' . $last_category_id;
				}

				if (VmConfig::get('handle_404',1)) {
					$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
				} else {
					JError::raise(E_ERROR,'404','Not found');
				}

				return;
			}

			if (!empty($product->customfields)) {
				foreach ($product->customfields as $k => $custom) {
					if (!empty($custom->layout_pos)) {
						$product->customfieldsSorted[$custom->layout_pos][] = $custom;
						unset($product->customfields[$k]);
					}
				}
				$product->customfieldsSorted['normal'] = $product->customfields;
				unset($product->customfields);
			}

			$product->event = new stdClass();
			$product->event->afterDisplayTitle = '';
			$product->event->beforeDisplayContent = '';
			$product->event->afterDisplayContent = '';
			if (VmConfig::get('enable_content_plugin', 0)) {
				shopFunctionsF::triggerContentPlugin($product, 'productdetails','product_desc');
			}

			$product_model->addImages($product);
			$this->assignRef('product', $product);

			if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
				$min_order_level = $product->min_order_level;
			} else {
				$min_order_level = 1;
			}
			$this->assignRef('min_order_level', $min_order_level);
			if (isset($product->step_order_level) && (int) $product->step_order_level > 0) {
				$step_order_level = $product->step_order_level;
			} else {
				$step_order_level = 1;
			}
			$this->assignRef('step_order_level', $step_order_level);

			// Load the neighbours
			if (VmConfig::get('product_navigation', 1)) {
				$product->neighbours = $product_model->getNeighborProducts($product);
			}

			// Load the category
			$category_model = VmModel::getModel('category');

			shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id);

			if ($category_model) {

				$category = $category_model->getCategory($product->virtuemart_category_id);

				$category_model->addImages($category, 1);
				$this->assignRef('category', $category);

				//Seems we dont need this anylonger, destroyed the breadcrumb
				if ($category->parents) {
					foreach ($category->parents as $c) {
						if(is_object($c) and isset($c->category_name)){
							$pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
						} else {
							vmdebug('Error, parent category has no name, breadcrumb maybe broken, category',$c);
						}
					}
				}

				$category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id);
				$category_model->addImages($category->children, 1);
			}

			if (!empty($tpl)) {
				$format = $tpl;
			} else {
				$format = vRequest::getCmd('format', 'html');
			}
			if ($format == 'html') {
				// Set Canonic link
				$document->addHeadLink($product->canonical, 'canonical', 'rel', '');
			} else if($format == 'pdf'){
				defined('K_PATH_IMAGES') or define ('K_PATH_IMAGES', VMPATH_ROOT);
			}

			$pathway->addItem(strip_tags($product->product_name));
			// Set the titles
			// $document->setTitle should be after the additem pathway
			if ($product->customtitle) {
				$document->setTitle(strip_tags($product->customtitle));
			} else {
				$document->setTitle(strip_tags(($category->category_name ? ($category->category_name . ' : ') : '') . $product->product_name));
			}

			$allowReview = $ratingModel->allowReview($product->virtuemart_product_id);
			$this->assignRef('allowReview', $allowReview);

			$showReview = $ratingModel->showReview($product->virtuemart_product_id);
			$this->assignRef('showReview', $showReview);

			if ($showReview) {

				$review = $ratingModel->getReviewByProduct($product->virtuemart_product_id);
				$this->assignRef('review', $review);

				$rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id);
				$this->assignRef('rating_reviews', $rating_reviews);
			}

			if ($this->showRating) {
				$vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
				$this->assignRef('vote', $vote);

				//$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
				//$this->assignRef('rating', $rating);
				//vmdebug('Should show rating vote and rating',$vote,$rating);
			}

			$allowRating = $ratingModel->allowRating($product->virtuemart_product_id);
			$this->assignRef('allowRating', $allowRating);

			// Check for editing access
			// @todo build edit page

			$user = JFactory::getUser();
			$superVendor = VmConfig::isSuperVendor();

			if($superVendor == 1 or $superVendor==$product->virtuemart_vendor_id or ($superVendor)){
				$edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id;
				$edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false);
			} else {
				$edit_link = "";
			}
			$this->assignRef('edit_link', $edit_link);


			// Load the user details
			$user = JFactory::getUser();
			$this->assignRef('user',$user);

			// More reviews link
			$uri = JURI::getInstance();
			$uri->setVar('showall', 1);
			$uristring = vmURI::getCleanUrl();
			$this->assignRef('more_reviews', $uristring);

			if ($product->metadesc) {
				$document->setDescription($product->metadesc);
			} else {
				$document->setDescription( $product->product_name . " " . $category->category_name . " " . $product->product_s_desc );
			}

			if ($product->metakey) {
				$document->setMetaData('keywords', $product->metakey);
			}

			if ($product->metarobot) {
				$document->setMetaData('robots', $product->metarobot);
			}

			if ($mainframe->getCfg('MetaTitle') == '1') {
				$document->setMetaData('title', $product->product_name);  //Maybe better product_name
			}
			if ($mainframe->getCfg('MetaAuthor') == '1') {
				$document->setMetaData('author', $product->metaauthor);
			}


			$user = JFactory::getUser();
			$showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::isSuperVendor());
			$this->assignRef('showBasePrice', $showBasePrice);

			$productDisplayShipments = array();
			$productDisplayPayments = array();

			if (!class_exists('vmPSPlugin'))
				require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
			JPluginHelper::importPlugin('vmshipment');
			JPluginHelper::importPlugin('vmpayment');
			$dispatcher = JDispatcher::getInstance();
			$returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments));
			$returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments));

			$this->assignRef('productDisplayPayments', $productDisplayPayments);
			$this->assignRef('productDisplayShipments', $productDisplayShipments);

			if (empty($category->category_template)) {
				$category->category_template = VmConfig::get('categorytemplate');
			}

			shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout);

			shopFunctionsF::addProductToRecent($virtuemart_product_id);

			$currency = CurrencyDisplay::getInstance();
			$this->assignRef('currency', $currency);

			if(vRequest::getCmd( 'layout', 'default' )=='notify') $this->setLayout('notify'); //Added by Seyi Awofadeju to catch notify layout
			VmConfig::loadJLang('com_virtuemart');

			vmJsApi::chosenDropDowns();

			parent::display($tpl);

    }
コード例 #15
0
ファイル: virtuemart.php プロジェクト: proyectoseb/Matrix
 }
 //dont remove that file it is actually in every view
 $_controller = vRequest::getCmd('view', vRequest::getCmd('controller', 'virtuemart'));
 $trigger = 'onVmSiteController';
 // 	$task = vRequest::getCmd('task',vRequest::getCmd('layout',$_controller) );		$this makes trouble!
 $task = vRequest::getCmd('task', '');
 $session = JFactory::getSession();
 $manage = vRequest::getCmd('manage', $session->get('manage', false, 'vm'));
 if (!$manage) {
     $session->set('manage', 0, 'vm');
 }
 $feViews = array('askquestion', 'cart', 'invoice', 'pdf', 'pluginresponse', 'productdetails', 'recommend', 'vendor');
 if ($manage and !in_array($_controller, $feViews)) {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $vendorIdUser = VmConfig::isSuperVendor();
     if ($vendorIdUser) {
         VmConfig::loadJLang('com_virtuemart');
         $jlang = JFactory::getLanguage();
         $tag = $jlang->getTag();
         $jlang->load('', JPATH_ADMINISTRATOR, $tag, true);
         VmConfig::loadJLang('com_virtuemart');
         $basePath = VMPATH_ADMIN;
         $trigger = 'onVmAdminController';
         vmdebug('$vendorIdUser use FE managing ' . $vendorIdUser);
         $session->set('manage', 1, 'vm');
         vRequest::setVar('manage', '1');
         vmJsApi::jQuery(false);
         vmJsApi::loadBECSS();
         $app = JFactory::getApplication();
         $router = $app->getRouter();
コード例 #16
0
ファイル: virtuemart.php プロジェクト: kosmosby/medicine-prof
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
VmConfig::loadConfig();

if (!class_exists( 'VmController' )) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php');
if (!class_exists( 'VmModel' )) require(VMPATH_ADMIN.DS.'helpers'.DS.'vmmodel.php');


vmRam('Start');
vmSetStartTime('Start');


$_controller = vRequest::getCmd('view', vRequest::getCmd('controller', 'virtuemart'));

// check for permission Only vendor and Admin can use VM BE
if($_controller!='updatesmigration' and !VmConfig::isSuperVendor()){
	$app = JFactory::getApplication();
	vmError( 'Access restricted to Vendor and Administrator only (you are admin and should not see this messsage?)','Access restricted to Vendors and Administrator only' );
	$app->redirect('index.php');
} else if($_controller=='updatesmigration'){
	$user = JFactory::getUser();
	if(!$user->authorise('core.admin', 'com_virtuemart')){
		$app = JFactory::getApplication();
		vmError( 'Access restricted to Administrators only (you are admin and should not see this messsage?)','Access restricted to Vendors and Administrator only' );
		$app->redirect('index.php');
	}
}

VmConfig::loadJLang('com_virtuemart');

vmJsApi::jQuery(0);
コード例 #17
0
ファイル: virtuemart.php プロジェクト: lenard112/cms
//$output = filter_var($testString,FILTER_SANITIZE_ENCODED,FILTER_FLAG_STRIP_LOW);
//vmdebug('Filter test FILTER_SANITIZE_ENCODED ',$output);

$output = filter_var($testString,FILTER_SANITIZE_STRING,FILTER_FLAG_STRIP_LOW );
vmdebug('Filter test FILTER_SANITIZE_STRING ',$output);

$output = filter_var($testString,FILTER_SANITIZE_SPECIAL_CHARS);
vmdebug('Filter test FILTER_SANITIZE_SPECIAL_CHARS ',$output);
*/
VmConfig::loadJLang('com_virtuemart');
vmJsApi::jQuery(0);
vmJsApi::jSite();
// check for permission Only vendor and Admin can use VM2 BE
// this makes trouble somehow, we need to check if the perm object works not too strict maybe
if (!VmConfig::isSuperVendor()) {
    $app = JFactory::getApplication();
    vmError('Access restricted to Vendor and Administrator only (you are admin and should not see this messsage?)', 'Access restricted to Vendors and Administrator only');
    $app->redirect('index.php');
}
// Require specific controller if requested
if ($_controller = vRequest::getCmd('view', vRequest::getCmd('controller', 'virtuemart'))) {
    if (file_exists(JPATH_VM_ADMINISTRATOR . DS . 'controllers' . DS . $_controller . '.php')) {
        // Only if the file exists, since it might be a Joomla view we're requesting...
        require JPATH_VM_ADMINISTRATOR . DS . 'controllers' . DS . $_controller . '.php';
    } else {
        // try plugins
        JPluginHelper::importPlugin('vmextended');
        $dispatcher = JDispatcher::getInstance();
        $results = $dispatcher->trigger('onVmAdminController', array($_controller));
        if (empty($results)) {
コード例 #18
0
ファイル: view.html.php プロジェクト: jamielaff/als_projects
 /**
  * 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()
 {
     $adminID = JFactory::getSession()->get('vmAdminID', false);
     $superVendor = VmConfig::isSuperVendor($adminID);
     $result = false;
     if ($this->allowChangeShopper and $superVendor) {
         //if(!$superVendor) $superVendor = 1;
         $db = JFactory::getDbo();
         $search = vRequest::getUword('usersearch', '');
         if (!empty($search)) {
             $search = 'WHERE (`name` LIKE %' . $search . '% OR `username` LIKE %' . $search . '%)';
         }
         $q = 'SELECT ju.`id`,`name`,`username` FROM `#__users` as ju';
         $q .= ' LEFT JOIN #__virtuemart_vmusers AS vmu ON vmu.virtuemart_user_id = ju.id';
         $q .= ' LEFT JOIN #__virtuemart_vendor_users AS vu ON vu.virtuemart_user_id = ju.id';
         if (!empty($search)) {
             $search .= ' AND (vu.virtuemart_vendor_id = ' . $superVendor . ' ';
         } else {
             $search = ' WHERE (vu.virtuemart_vendor_id = ' . $superVendor . ' ';
         }
         if ($superVendor == 1) {
             $search .= ' OR (vu.virtuemart_vendor_id) IS NULL)';
         } else {
             $search .= ' )';
         }
         $search .= ' AND ( vmu.user_is_vendor = 0 OR (vmu.virtuemart_vendor_id) IS NULL)';
         $q .= $search . ' ORDER BY `name` LIMIT 0,10000';
         $db->setQuery($q);
         $result = $db->loadObjectList();
         //vmdebug('user list',$q);
         foreach ($result as $k => $user) {
             $result[$k]->displayedName = $user->name . '&nbsp;&nbsp;( ' . $user->username . ' )';
         }
         if ($adminID) {
             $user = JFactory::getUser($adminID);
             $toAdd = new stdClass();
             $toAdd->id = $user->id;
             $toAdd->name = $user->name;
             $toAdd->username = $user->username;
             $toAdd->displayedName = $user->name . '&nbsp;&nbsp;( ' . $user->username . ' )';
             array_unshift($result, $toAdd);
         }
         $toAdd = new stdClass();
         $toAdd->id = 0;
         $toAdd->name = '';
         $toAdd->username = '';
         $toAdd->displayedName = '-' . vmText::_('COM_VIRTUEMART_REGISTER') . '-';
         array_unshift($result, $toAdd);
     }
     return $result;
 }
コード例 #19
0
ファイル: category.php プロジェクト: proyectoseb/Matrix
    public function getCategories($onlyPublished = true, $parentId = false, $childId = false, $keyword = "", $vendorId = false)
    {
        static $cats = array();
        $select = ' c.`virtuemart_category_id`, category_description, category_name, c.`ordering`, c.`published`, cx.`category_child_id`, cx.`category_parent_id`, c.`shared` ';
        $joinedTables = ' FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` l
				  JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`)
				  LEFT JOIN `#__virtuemart_category_categories` AS cx
				  ON l.`virtuemart_category_id` = cx.`category_child_id` ';
        $where = array();
        if ($onlyPublished) {
            $where[] = " c.`published` = 1 ";
        }
        if ($parentId !== false) {
            $where[] = ' cx.`category_parent_id` = ' . (int) $parentId;
        }
        if ($childId !== false) {
            $where[] = ' cx.`category_child_id` = ' . (int) $childId;
        }
        if ($vendorId === false) {
            $vendorId = VmConfig::isSuperVendor();
        }
        if ($vendorId != 1) {
            $where[] = ' (c.`virtuemart_vendor_id` = "' . (int) $vendorId . '" OR c.`shared` = "1") ';
        }
        if (!empty($keyword)) {
            $db = JFactory::getDBO();
            $keyword = '"%' . $db->escape($keyword, true) . '%"';
            //$keyword = $db->Quote($keyword, false);
            $where[] = ' ( category_name LIKE ' . $keyword . '
							   OR category_description LIKE ' . $keyword . ') ';
        }
        $whereString = '';
        if (count($where) > 0) {
            $whereString = ' WHERE ' . implode(' AND ', $where);
        } else {
            $whereString = 'WHERE 1 ';
        }
        if (trim($this->_selectedOrdering) == 'c.ordering') {
            $this->_selectedOrdering = 'c.ordering, category_name';
        }
        $ordering = $this->_getOrdering();
        $hash = md5($keyword . '.' . (int) $parentId . VmConfig::$vmlang . (int) $childId . $this->_selectedOrderingDir . (int) $vendorId . $this->_selectedOrdering);
        if (!isset($cats[$hash])) {
            $cats[$hash] = $this->_category_tree = $this->exeSortSearchListQuery(0, $select, $joinedTables, $whereString, 'GROUP BY virtuemart_category_id', $ordering);
        }
        return $cats[$hash];
    }
コード例 #20
0
ファイル: vmviewadmin.php プロジェクト: cybershocik/Darek
 public function manager($view = 0)
 {
     if (empty($view)) {
         $view = $this->_name;
     }
     if (!isset(self::$_manager[$view])) {
         if (JFactory::getApplication()->isSite()) {
             $adminId = JFactory::getSession()->get('vmAdminID', null);
             if ($adminId) {
                 if (!class_exists('vmCrypt')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
                 }
                 $adminId = vmCrypt::decrypt($adminId);
             }
             $user = JFactory::getUser($adminId);
             $vendorIdUser = VmConfig::isSuperVendor($user->id);
         } else {
             $user = JFactory::getUser();
         }
         if ($user->authorise('core.admin') or $user->authorise('core.admin', 'com_virtuemart') or ($user->authorise('core.manage', 'com_virtuemart') or $user->authorise('vm.manage', 'com_virtuemart')) and $user->authorise('vm.' . $view, 'com_virtuemart')) {
             self::$_manager[$view] = true;
         } else {
             self::$_manager[$view] = false;
         }
     }
     return self::$_manager[$view];
 }
コード例 #21
0
ファイル: helper.php プロジェクト: proyectoseb/Matrix
    /**
     * Override function getCategories in model Category
     */
    public static function getCategories($onlyPublished = true, $parentId = false, $childId = false, $keyword = "", $vendorId = false)
    {
        $categoryModel = VmModel::getModel('Category');
        $select = ' c.`virtuemart_category_id`, l.`category_description`, l.`category_name`, c.`ordering`, c.`published`, cx.`category_child_id`, cx.`category_parent_id`, c.`shared` ';
        $joinedTables = ' FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` l
				  JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`)
				  LEFT JOIN `#__virtuemart_category_categories` AS cx
				  ON l.`virtuemart_category_id` = cx.`category_child_id` ';
        $where = array();
        if ($onlyPublished) {
            $where[] = " c.`published` = 1 ";
        }
        if ($parentId !== false) {
            $where[] = ' cx.`category_parent_id` = ' . (int) $parentId;
        }
        if ($childId !== false) {
            $where[] = ' cx.`category_child_id` = ' . (int) $childId;
        }
        if ($vendorId === false) {
            $vendorId = VmConfig::isSuperVendor();
        }
        if ($vendorId == 1) {
            $where[] = ' (c.`virtuemart_vendor_id` = "' . (int) $vendorId . '" OR c.`shared` = "1") ';
        }
        if (!empty($keyword)) {
            $db = JFactory::getDBO();
            $keyword = '"%' . $db->escape($keyword, true) . '%"';
            //$keyword = $db->Quote($keyword, false);
            $where[] = ' ( l.`category_name` LIKE ' . $keyword . '
							   OR l.`category_description` LIKE ' . $keyword . ') ';
        }
        $whereString = '';
        if (count($where) > 0) {
            $whereString = ' WHERE ' . implode(' AND ', $where);
        } else {
            $whereString = 'WHERE 1 ';
        }
        $ordering = $categoryModel->_getOrdering();
        self::$_category_tree = $categoryModel->exeSortSearchListQuery(0, $select, $joinedTables, $whereString, 'GROUP BY virtuemart_category_id', $ordering);
        return self::$_category_tree;
    }
コード例 #22
0
ファイル: view.html.php プロジェクト: cybershocik/Darek
 function display($tpl = null)
 {
     // Load the helper(s)
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $currentUser = JFactory::getUser();
     VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
     $task = vRequest::getCmd('task', 'edit');
     if ($task == 'editshop') {
         $isSuperOrVendor = VmConfig::isSuperVendor();
         if (empty($isSuperOrVendor)) {
             JFactory::getApplication()->redirect('index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error');
         } else {
             if (!class_exists('VirtueMartModelVendor')) {
                 require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
             }
             $userId = VirtueMartModelVendor::getUserIdByVendorId($isSuperOrVendor);
         }
         $this->SetViewTitle('STORE');
     } else {
         if ($task == 'add') {
             $userId = 0;
         } else {
             $userId = vRequest::getVar('virtuemart_user_id', 0);
             if (is_array($userId)) {
                 $userId = $userId[0];
             }
             $this->SetViewTitle('USER');
         }
     }
     $userId = $model->setId($userId);
     //$layoutName = vRequest::getCmd('layout', 'default');
     $layoutName = $this->getLayout();
     if ($layoutName == 'edit' || $layoutName == 'edit_shipto') {
         $editor = JFactory::getEditor();
         if (!class_exists('VmImage')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
         }
         $userDetails = $model->getUser();
         if ($task == 'editshop' && $userDetails->user_is_vendor) {
             // 				$model->setCurrent();
             if (!empty($userDetails->vendor->vendor_store_name)) {
                 $this->SetViewTitle('STORE', $userDetails->vendor->vendor_store_name, 'shop_mart');
             } else {
                 $this->SetViewTitle('STORE', vmText::_('COM_VIRTUEMART_NEW_VENDOR'), 'shop_mart');
             }
             $vendorid = $userDetails->virtuemart_vendor_id;
             if ($vendorid == 1) {
                 $this->checkTCPDFinstalled();
             }
         } else {
             $vendorid = 0;
             $this->SetViewTitle('USER', $userDetails->JUser->get('name'));
         }
         $_new = $userDetails->JUser->get('id') < 1;
         $this->addStandardEditViewCommands($vendorid);
         // User details
         $_contactDetails = $model->getContactDetails();
         $this->lists['canBlock'] = $currentUser->authorise('com_users', 'block user') && $userDetails->JUser->get('id') != $currentUser->get('id');
         // Can't block myself
         $this->lists['canSetMailopt'] = $currentUser->authorise('workflow', 'email_events');
         $this->lists['block'] = JHtml::_('select.booleanlist', 'block', 'class="inputbox"', $userDetails->JUser->get('block'), 'COM_VIRTUEMART_YES', 'COM_VIRTUEMART_NO');
         $this->lists['sendEmail'] = JHtml::_('select.booleanlist', 'sendEmail', 'class="inputbox"', $userDetails->JUser->get('sendEmail'), 'COM_VIRTUEMART_YES', 'COM_VIRTUEMART_NO');
         $this->lists['params'] = $userDetails->JUser->getParameters(true);
         // Shopper info
         $this->lists['shoppergroups'] = ShopFunctions::renderShopperGroupList($userDetails->shopper_groups, true, 'virtuemart_shoppergroup_id');
         $this->lists['vendors'] = ShopFunctions::renderVendorList($userDetails->virtuemart_vendor_id);
         $model->setId($userDetails->JUser->get('id'));
         $this->lists['custnumber'] = $model->getCustomerNumberById();
         // Shipment address(es)
         $this->lists['shipTo'] = ShopFunctions::generateStAddressList($this, $model, 'addST');
         $new = false;
         if (vRequest::getInt('new', '0') === 1) {
             $new = true;
         }
         $virtuemart_userinfo_id_BT = $model->getBTuserinfo_id($userId);
         $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'BT', $virtuemart_userinfo_id_BT, false);
         $userFieldsBT = $userFieldsArray[$virtuemart_userinfo_id_BT];
         // Load the required scripts
         if (count($userFieldsBT['scripts']) > 0) {
             foreach ($userFieldsBT['scripts'] as $_script => $_path) {
                 JHtml::script($_script, $_path);
             }
         }
         // Load the required stylesheets
         if (count($userFieldsBT['links']) > 0) {
             foreach ($userFieldsBT['links'] as $_link => $_path) {
                 JHtml::stylesheet($_link, $_path);
             }
         }
         $this->assignRef('userFieldsBT', $userFieldsBT);
         $this->assignRef('userInfoID', $virtuemart_userinfo_id_BT);
         $addrtype = vRequest::getCmd('addrtype');
         $virtuemart_userinfo_id = 0;
         if ($layoutName == 'edit_shipto' or $task == 'addST' or $addrtype == 'ST') {
             $virtuemart_userinfo_id = vRequest::getString('virtuemart_userinfo_id', '0', '');
             $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'ST', $virtuemart_userinfo_id, false);
             if ($new) {
                 $virtuemart_userinfo_id = 0;
             } else {
             }
             $userFieldsST = $userFieldsArray[$virtuemart_userinfo_id];
             $this->assignRef('shipToFields', $userFieldsST);
             vmdebug('hm ST $virtuemart_userinfo_id', $virtuemart_userinfo_id);
         }
         $this->assignRef('shipToId', $virtuemart_userinfo_id);
         $this->assignRef('new', $new);
         if (!$_new) {
             // Check for existing orders for this user
             $orders = VmModel::getModel('orders');
             $orderList = $orders->getOrdersList($userDetails->JUser->get('id'), true);
         } else {
             $orderList = null;
         }
         if (count($orderList) > 0 || !empty($userDetails->user_is_vendor)) {
             if (!class_exists('CurrencyDisplay')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
             }
             $currency = CurrencyDisplay::getInstance();
             $this->assignRef('currency', $currency);
         }
         if (!empty($userDetails->user_is_vendor)) {
             $vendorM = VmModel::getModel('vendor');
             //if(empty($userDetails->vendor->vendor_currency)){
             $vendorCurrency = $vendorM->getVendorCurrency(1);
             if ($vendorCurrency) {
                 $userDetails->vendor->vendor_currency = $vendorCurrency->vendor_currency;
                 vmdebug('No vendor currency given, fallback to main vendor', $userDetails->vendor->vendor_currency);
             }
             //}
             $vendorM->setId($userDetails->virtuemart_vendor_id);
             $vendorM->addImages($userDetails->vendor);
             $this->assignRef('vendor', $userDetails->vendor);
             $currencyModel = VmModel::getModel('currency');
             $_currencies = $currencyModel->getCurrencies();
             $this->assignRef('currencies', $_currencies);
             $configModel = VmModel::getModel('config');
             $TCPDFFontsList = $configModel->getTCPDFFontsList();
             $this->assignRef('pdfFonts', $TCPDFFontsList);
         }
         $this->assignRef('userDetails', $userDetails);
         $this->assignRef('orderlist', $orderList);
         $this->assignRef('contactDetails', $_contactDetails);
         $this->assignRef('editor', $editor);
     } else {
         JToolBarHelper::divider();
         JToolBarHelper::custom('toggle.user_is_vendor.1', 'publish', '', 'COM_VIRTUEMART_USER_ISVENDOR');
         JToolBarHelper::custom('toggle.user_is_vendor.0', 'unpublish', '', 'COM_VIRTUEMART_USER_ISNOTVENDOR');
         JToolBarHelper::divider();
         JToolBarHelper::deleteList();
         JToolBarHelper::editList();
         self::showACLPref('user');
         //This is intentionally, creating new user via BE is buggy and can be done by joomla
         //JToolBarHelper::addNewX();
         $this->addStandardDefaultViewLists($model, 'ju.id');
         $userList = $model->getUserList();
         $this->assignRef('userList', $userList);
         $this->pagination = $model->getPagination();
         $shoppergroupmodel = VmModel::getModel('shopperGroup');
         $this->defaultShopperGroup = $shoppergroupmodel->getDefault(0)->shopper_group_name;
     }
     if (!empty($this->orderlist)) {
         VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     }
     parent::display($tpl);
 }
コード例 #23
0
ファイル: customfields.php プロジェクト: proyectoseb/Matrix
    /**
     * @author Max Milbers
     * @param $field
     * @param $product_id
     * @param $row
     */
    public function displayProductCustomfieldBE($field, $product, $row)
    {
        //This is a kind of fallback, setting default of custom if there is no value of the productcustom
        $field->customfield_value = empty($field->customfield_value) ? $field->custom_value : $field->customfield_value;
        $field->customfield_price = empty($field->customfield_price) ? 0 : $field->customfield_price;
        if (is_object($product)) {
            $product_id = $product->virtuemart_product_id;
            $virtuemart_vendor_id = $product->virtuemart_vendor_id;
        } else {
            $product_id = $product;
            $virtuemart_vendor_id = VmConfig::isSuperVendor();
            vmdebug('displayProductCustomfieldBE product was not object, use for productId ' . $product_id . ' and $virtuemart_vendor_id = ' . $virtuemart_vendor_id);
        }
        //vmdebug('displayProductCustomfieldBE',$product_id,$field,$virtuemart_vendor_id,$product);
        //the option "is_cart_attribute" gives the possibility to set a price, there is no sense to set a price,
        //if the custom is not stored in the order.
        if ($field->is_input) {
            if (!class_exists('VirtueMartModelVendor')) {
                require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
            }
            if (!class_exists('VirtueMartModelCurrency')) {
                require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
            }
            $vendor_model = VmModel::getModel('vendor');
            //$virtuemart_vendor_id = 1;
            $vendor = $vendor_model->getVendor($virtuemart_vendor_id);
            $currency_model = VmModel::getModel('currency');
            $vendor_currency = $currency_model->getCurrency($vendor->vendor_currency);
            $priceInput = '<span style="white-space: nowrap;"><input type="text" size="12" style="text-align:right;" value="' . $field->customfield_price . '" name="field[' . $row . '][customfield_price]" /> ' . $vendor_currency->currency_symbol . "</span>";
        } else {
            $priceInput = ' ';
        }
        switch ($field->field_type) {
            case 'C':
                //vmdebug('displayProductCustomfieldBE $field',$field);
                //if(!isset($field->withParent)) $field->withParent = 0;
                //if(!isset($field->parentOrderable)) $field->parentOrderable = 0;
                //vmdebug('displayProductCustomfieldBE',$field,$product);
                if (!empty($product->product_parent_id) and $product->product_parent_id == $field->virtuemart_product_id) {
                    return 'controlled by parent';
                }
                $html = '';
                if (!class_exists('VmHTML')) {
                    require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
                }
                //$html = vmText::_('COM_VIRTUEMART_CUSTOM_WP').VmHTML::checkbox('field[' . $row . '][withParent]',$field->withParent,1,0,'');
                //$html .= vmText::_('COM_VIRTUEMART_CUSTOM_PO').VmHTML::checkbox('field[' . $row . '][parentOrderable]',$field->parentOrderable,1,0,'').'<br />';
                if (empty($field->selectoptions) or count($field->selectoptions) == 0) {
                    $selectOption = new stdClass();
                    //The json conversts it anyway in an object, so suitable to use an object here
                    $selectOption->voption = 'product_name';
                    $selectOption->slabel = '';
                    $selectOption->clabel = '';
                    $selectOption->canonical = 0;
                    $selectOption->values = '';
                    $c = 0;
                    $field->selectoptions = new stdClass();
                    $field->selectoptions->{$c} = $selectOption;
                    $field->options = new stdClass();
                } else {
                    if (is_array($field->selectoptions)) {
                        $field->selectoptions = (object) $field->selectoptions;
                    }
                }
                $field->options = (object) $field->options;
                $optAttr = array();
                $optAttr[] = array('value' => '0', 'text' => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'));
                $optAttr[] = array('value' => 'product_name', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_FORM_NAME'));
                $optAttr[] = array('value' => 'product_sku', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_SKU'));
                $optAttr[] = array('value' => 'slug', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_ALIAS'));
                $optAttr[] = array('value' => 'product_length', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_LENGTH'));
                $optAttr[] = array('value' => 'product_width', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_WIDTH'));
                $optAttr[] = array('value' => 'product_height', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_HEIGHT'));
                $optAttr[] = array('value' => 'product_weight', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_WEIGHT'));
                $optAttr[] = array('value' => 'clabels', 'text' => vmText::_('COM_VIRTUEMART_CLABELS'));
                $productModel = VmModel::getModel('product');
                $childIds = array();
                $sorted = array();
                //vmSetStartTime();
                $productModel->getAllProductChildIds($product_id, $childIds);
                if (isset($childIds[$product_id])) {
                    $sorted = self::sortChildIds($product_id, $childIds[$product_id]);
                }
                array_unshift($sorted, array('parent_id' => $product_id, 'vm_product_id' => $product_id));
                $showSku = true;
                $k = 0;
                if (empty($field->selectoptions)) {
                    $field->selectoptions = array();
                }
                foreach ($field->selectoptions as $k => &$soption) {
                    $options = array();
                    $options[] = array('value' => '0', 'text' => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'));
                    $added = array();
                    if ($soption->voption != 'clabels') {
                        foreach ($sorted as $vmProductId) {
                            if (empty($vmProductId) or $vmProductId['vm_product_id'] == $product_id) {
                                continue;
                            }
                            $product = $productModel->getProductSingle($vmProductId['vm_product_id'], false);
                            $voption = trim($product->{$soption->voption});
                            if (!empty($voption)) {
                                $found = false;
                                //Guys, dont tell me about in_array or array_search, it does not work here
                                foreach ($added as $add) {
                                    if ($add == $voption) {
                                        $found = true;
                                    }
                                }
                                if (!$found) {
                                    $added[] = $voption;
                                }
                            }
                        }
                        if ($soption->voption == 'product_sku') {
                            $showSku = false;
                        }
                    }
                    if (!empty($soption->values)) {
                        $values = explode("\n", $soption->values);
                        foreach ($values as $value) {
                            $found = false;
                            $value = trim($value);
                            foreach ($added as $add) {
                                if ($add == $value) {
                                    $found = true;
                                    vmdebug('Found true due $soption->values');
                                }
                            }
                            if (!$found) {
                                $added[] = $value;
                            }
                        }
                    }
                    $soption->values = implode("\n", $added);
                    foreach ($added as &$value) {
                        $options[] = array('value' => $value, 'text' => $value);
                    }
                    $soption->comboptions = $options;
                    if (!isset($soption->clabel)) {
                        $soption->clabel = '';
                    }
                    $soption->slabel = empty($soption->clabel) ? vmText::_('COM_VIRTUEMART_' . strtoupper($soption->voption)) : vmText::_($soption->clabel);
                    if ($k == 0) {
                        $html .= '<div style="float:left">';
                    } else {
                        $html .= '<div class="removable">';
                    }
                    $idTag = 'selectoptions' . $k;
                    $html .= JHtml::_('select.genericlist', $optAttr, 'field[' . $row . '][selectoptions][' . $k . '][voption]', '', 'value', 'text', $soption->voption, $idTag);
                    $html .= '<input type="text" value="' . $soption->clabel . '" name="field[' . $row . '][selectoptions][' . $k . '][clabel]" style="line-height:2em;margin:5px 5px 0;" />';
                    $html .= '<textarea name="field[' . $row . '][selectoptions][' . $k . '][values]" rows="5" cols="35" style="float:none;margin:5px 5px 0;" >' . $soption->values . '</textarea>';
                    if ($k > 0) {
                        $html .= '<span class="vmicon vmicon-16-remove"></span>';
                    } else {
                    }
                    $html .= '</div>';
                    if ($k == 0) {
                        $html .= '<div style="float:right;max-width:60%;width:45%;min-width:30%" >' . vmText::_('COM_VIRTUEMART_CUSTOM_CV_DESC') . '</div>';
                        $html .= '<div class="clear"></div>';
                    }
                }
                $idTag = 'selectoptions' . ++$k;
                $html .= '<fieldset style="background-color:#F9F9F9;">
					<legend>' . vmText::_('COM_VIRTUEMART_CUSTOM_RAMB_NEW') . '</legend>
					<div id="new_ramification">';
                //$html .= JHtml::_ ('select.genericlist', $options, 'field[' . $row . '][selectoptions]['.$k.'][voption]', '', 'value', 'text', 'product_name',$idTag) ;
                //$html .= '<input type="text" value="" name="field[' . $row . '][selectoptions]['.$k.'][slabel]" />';
                $html .= JHtml::_('select.genericlist', $optAttr, 'voption', '', 'value', 'text', 'product_name', 'voption');
                $html .= '<input type="text" value="" id="vlabel" name="vlabel" />';
                $html .= '<span id="new_ramification_bt"><span class="icon-nofloat vmicon vmicon-16-new"></span>' . vmText::_('COM_VIRTUEMART_ADD') . '</span>
					</div>
				</fieldset>';
                vmJsApi::addJScript('new_ramification', "\n\tjQuery( function(\$) {\n\t\t\$('#new_ramification_bt').click(function() {\n\t\t\tvar Prod = \$('.new_ramification');//obsolete?\n\n\t\t\tvar voption = jQuery('#voption').val();\n\t\t\tvar label = jQuery('#vlabel').val();\n\t\t\t\t//console.log ('my label '+label);\n\t\t\tform = document.getElementById('adminForm');\n\t\t\tvar newdiv = document.createElement('div');\n\t\t\tnewdiv.innerHTML = '<input type=\"text\" value=\"'+voption+'\" name=\"field[" . $row . "][selectoptions][" . $k . "][voption]\" /><input type=\"text\" value=\"'+label+'\" name=\"field[" . $row . "][selectoptions][" . $k . "][clabel]\" />';\n\t\t\tform.appendChild(newdiv);\n\n\t\t\tform.task.value = 'apply';\n\t\t\tform.submit();\n\t\t\treturn false;\n\t\t});\n\t});\n\t");
                if ($product_id) {
                    $link = JRoute::_('index.php?option=com_virtuemart&view=product&task=createChild&virtuemart_product_id=' . $product_id . '&' . JSession::getFormToken() . '=1&target=parent');
                    $add_child_button = "";
                } else {
                    $link = "";
                    $add_child_button = " not-active";
                }
                $html .= '<div class="button2-left ' . $add_child_button . ' btn-wrapper">
						<div class="blank">';
                if ($link) {
                    $html .= '<a href="' . $link . '" class="btn btn-small">';
                } else {
                    $html .= '<span class="hasTip" title="' . vmText::_('COM_VIRTUEMART_PRODUCT_ADD_CHILD_TIP') . '">';
                }
                $html .= vmText::_('COM_VIRTUEMART_PRODUCT_ADD_CHILD');
                if ($link) {
                    $html .= '</a>';
                } else {
                    $html .= '</span>';
                }
                $html .= '</div>
					</div><div class="clear"></div>';
                //vmdebug('my $field->selectoptions',$field->selectoptions,$field->options);
                $html .= '<table id="syncro">';
                $html .= '<tr>
<th style="text-align: left !important;width:130px;">#</th>';
                if ($showSku) {
                    $html .= '<th style="text-align: left !important;width:90px;">' . vmText::_('COM_VIRTUEMART_PRODUCT_SKU') . '</th>';
                }
                $html .= '<th style="text-align: left !important;width:80px;">' . vmText::_('COM_VIRTUEMART_PRODUCT_GTIN') . '</th>
<th style="text-align: left !important;" width="5%">' . vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRICE_COST') . '</th>
<th style="text-align: left !important;width:30px;">' . vmText::_('COM_VIRTUEMART_PRODUCT_FORM_IN_STOCK') . '</th>
<th style="text-align: left !important;width:30px;">' . vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ORDERED_STOCK') . '</th>';
                foreach ($field->selectoptions as $k => $option) {
                    $html .= '<th>' . vmText::_('COM_VIRTUEMART_' . strtoupper($option->voption)) . '</th>';
                }
                $html .= '</tr>';
                if (isset($childIds[$product_id])) {
                    foreach ($sorted as $i => $line) {
                        $html .= self::renderProductChildLine($i, $line, $field, $productModel, $row, $showSku);
                    }
                }
                $html .= '</table>';
                return $html;
                // 					return 'Automatic Childvariant creation (later you can choose here attributes to show, now product name) </td><td>';
                break;
            case 'A':
                //vmdebug('displayProductCustomfieldBE $field',$field);
                if (!isset($field->withParent)) {
                    $field->withParent = 0;
                }
                if (!isset($field->parentOrderable)) {
                    $field->parentOrderable = 0;
                }
                //vmdebug('displayProductCustomfieldBE',$field);
                if (!class_exists('VmHTML')) {
                    require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
                }
                $html = '</td><td>' . vmText::_('COM_VIRTUEMART_CUSTOM_WP') . VmHTML::checkbox('field[' . $row . '][withParent]', $field->withParent, 1, 0, '') . '<br />';
                $html .= vmText::_('COM_VIRTUEMART_CUSTOM_PO') . VmHTML::checkbox('field[' . $row . '][parentOrderable]', $field->parentOrderable, 1, 0, '');
                $options = array();
                $options[] = array('value' => 'product_name', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_FORM_NAME'));
                $options[] = array('value' => 'product_sku', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_SKU'));
                $options[] = array('value' => 'slug', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_ALIAS'));
                $options[] = array('value' => 'product_length', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_LENGTH'));
                $options[] = array('value' => 'product_width', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_WIDTH'));
                $options[] = array('value' => 'product_height', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_HEIGHT'));
                $options[] = array('value' => 'product_weight', 'text' => vmText::_('COM_VIRTUEMART_PRODUCT_WEIGHT'));
                $html .= JHtml::_('select.genericlist', $options, 'field[' . $row . '][customfield_value]', '', 'value', 'text', $field->customfield_value);
                return $html;
                // 					return 'Automatic Childvariant creation (later you can choose here attributes to show, now product name) </td><td>';
                break;
                /* string or integer */
            /* string or integer */
            case 'B':
            case 'S':
                if ($field->is_list) {
                    $options = array();
                    $values = explode(';', $field->custom_value);
                    foreach ($values as $key => $val) {
                        $options[] = array('value' => $val, 'text' => $val);
                    }
                    $currentValue = $field->customfield_value;
                    return $priceInput . '</td><td>' . JHtml::_('select.genericlist', $options, 'field[' . $row . '][customfield_value]', NULL, 'value', 'text', $currentValue);
                } else {
                    return $priceInput . '</td><td><input type="text" value="' . $field->customfield_value . '" name="field[' . $row . '][customfield_value]" />';
                    break;
                }
                break;
                /* parent hint, this is a GROUP and should be G not P*/
            /* parent hint, this is a GROUP and should be G not P*/
            case 'G':
                return $field->customfield_value . '<input type="hidden" value="' . $field->customfield_value . '" name="field[' . $row . '][customfield_value]" /></td><td>';
                break;
                /* image */
            /* image */
            case 'M':
                if ($field->is_list and $field->is_input) {
                    $html = $priceInput . '</td><td>is list ';
                    $values = explode(';', $field->custom_value);
                    foreach ($values as $val) {
                        $html .= $this->displayCustomMedia($val, 'product');
                    }
                    return $html;
                } else {
                    if (empty($field->custom_value)) {
                        $q = 'SELECT `virtuemart_media_id` as value,`file_title` as text FROM `#__virtuemart_medias` WHERE `published`=1
					AND (`virtuemart_vendor_id`= "' . $virtuemart_vendor_id . '" OR `shared` = "1")';
                        $db = JFactory::getDBO();
                        $db->setQuery($q);
                        $options = $db->loadObjectList();
                    } else {
                        $values = explode(';', $field->custom_value);
                        $mM = VmModel::getModel('media');
                        foreach ($values as $key => $val) {
                            $mM->setId($val);
                            $file = $mM->getFile();
                            $tmp = array('value' => $val, 'text' => $file->file_name);
                            $options[] = (object) $tmp;
                        }
                    }
                    return $priceInput . '</td><td>' . JHtml::_('select.genericlist', $options, 'field[' . $row . '][customfield_value]', '', 'value', 'text', $field->customfield_value);
                }
                break;
            case 'D':
                return $priceInput . '</td><td>' . vmJsApi::jDate($field->customfield_value, 'field[' . $row . '][customfield_value]', 'field_' . $row . '_customvalue');
                break;
                //'X'=>'COM_VIRTUEMART_CUSTOM_EDITOR',
            //'X'=>'COM_VIRTUEMART_CUSTOM_EDITOR',
            case 'X':
                // Not sure why this block is needed to get it to work when editing the customfield (the subsequent block works fine when creating it, ie. in JS)
                $document = JFactory::getDocument();
                if (get_class($document) == 'JDocumentHTML') {
                    $editor = JFactory::getEditor();
                    return $editor->display('field[' . $row . '][customfield_value]', $field->customfield_value, '550', '400', '60', '20', false) . '</td><td>';
                }
                return $priceInput . '</td><td><textarea class="mceInsertContentNew" name="field[' . $row . '][customfield_value]" id="field-' . $row . '-customfield_value">' . $field->customfield_value . '</textarea>
						<script type="text/javascript">// Creates a new editor instance
							tinymce.execCommand("mceAddControl",true,"field-' . $row . '-customfield_value")
						</script>';
                //return '<input type="text" value="'.$field->customfield_value.'" name="field['.$row.'][customfield_value]" /></td><td>'.$priceInput;
                break;
                //'Y'=>'COM_VIRTUEMART_CUSTOM_TEXTAREA'
            //'Y'=>'COM_VIRTUEMART_CUSTOM_TEXTAREA'
            case 'Y':
                return $priceInput . '</td><td><textarea id="field[' . $row . '][customfield_value]" name="field[' . $row . '][customfield_value]" class="inputbox" cols=80 rows=6 >' . $field->customfield_value . '</textarea>';
                //return '<input type="text" value="'.$field->customfield_value.'" name="field['.$row.'][customfield_value]" /></td><td>'.$priceInput;
                break;
                /*Extended by plugin*/
            /*Extended by plugin*/
            case 'E':
                $html = '<input type="hidden" value="' . $field->customfield_value . '" name="field[' . $row . '][customfield_value]" />';
                if (!class_exists('vmCustomPlugin')) {
                    require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php';
                }
                //vmdebug('displayProductCustomfieldBE $field',$field);
                JPluginHelper::importPlugin('vmcustom', $field->custom_element);
                $dispatcher = JDispatcher::getInstance();
                $retValue = '';
                $dispatcher->trigger('plgVmOnProductEdit', array($field, $product_id, &$row, &$retValue));
                return $html . $priceInput . '</td><td>' . $retValue;
                break;
                /* related category*/
            /* related category*/
            case 'Z':
                if (!$product_id or empty($field->customfield_value)) {
                    return '';
                }
                // special case it's category ID !
                $q = 'SELECT * FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` INNER JOIN `#__virtuemart_categories` AS p using (`virtuemart_category_id`) WHERE `virtuemart_category_id`= "' . (int) $field->customfield_value . '" ';
                $db = JFactory::getDBO();
                $db->setQuery($q);
                //echo $db->_sql;
                if ($category = $db->loadObject()) {
                    $q = 'SELECT `virtuemart_media_id` FROM `#__virtuemart_category_medias` WHERE `virtuemart_category_id`= "' . (int) $field->customfield_value . '" ';
                    $db->setQuery($q);
                    $thumb = '';
                    if ($media_id = $db->loadResult()) {
                        $thumb = $this->displayCustomMedia($media_id, 'category');
                    }
                    $display = '<input type="hidden" value="' . $field->customfield_value . '" name="field[' . $row . '][customfield_value]" />';
                    $display .= '<span class="custom_related_image">' . $thumb . '</span><span class="custom_related_title">';
                    $display .= JHtml::link('index.php?option=com_virtuemart&view=category&task=edit&virtuemart_category_id=' . (int) $field->customfield_value, $category->category_name, array('title' => $category->category_name, 'target' => 'blank')) . '</span>';
                    return $display;
                } else {
                    return 'no result $product_id = ' . $product_id . ' and ' . $field->customfield_value;
                }
                /* related product*/
            /* related product*/
            case 'R':
                if (!$product_id) {
                    return '';
                }
                $pModel = VmModel::getModel('product');
                $related = $pModel->getProduct((int) $field->customfield_value, TRUE, FALSE, FALSE, 1);
                if (!empty($related->virtuemart_media_id[0])) {
                    $thumb = $this->displayCustomMedia($related->virtuemart_media_id[0]) . ' ';
                } else {
                    $thumb = $this->displayCustomMedia(0) . ' ';
                }
                $display = '<input type="hidden" value="' . $field->customfield_value . '" name="field[' . $row . '][customfield_value]" />';
                $display .= '<span class="custom_related_image">' . $thumb . '</span><span class="custom_related_title">';
                $display .= JHtml::link('index.php?option=com_virtuemart&view=product&task=edit&virtuemart_product_id=' . $related->virtuemart_product_id, $related->product_name, array('title' => $related->product_name, 'target' => 'blank')) . '</span>';
                return $display;
        }
    }
コード例 #24
0
 /**
  * Retrieve a list of report items from the database.
  *
  * @param string $noLimit True if no record count limit is used, false otherwise
  * @return object List of order objects
  */
 function getRevenue($cache = 0)
 {
     $user = JFactory::getUser();
     if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manager', 'com_virtuemart')) {
         $vendorId = vRequest::getInt('virtuemart_vendor_id');
     } else {
         $vendorId = VmConfig::isSuperVendor();
     }
     $orderstates = vRequest::getVar('order_status_code', array('C', 'S'));
     $intervals = vRequest::getCmd('intervals', 'day');
     $filterorders = vRequest::getvar('filter_order', 'intervals');
     $orderdir = vRequest::getCmd('filter_order_Dir', NULL) == 'desc' ? 'desc' : '';
     $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', FALSE);
     if ($cache) {
         $c = JFactory::getCache('com_virtuemart_revenue');
         $c->setCaching(1);
         $c->setLifeTime($cache);
         return $c->call(array('VirtuemartModelReport', 'getRevenueDiag'), $vendorId, $orderstates, $intervals, $filterorders, $orderdir, $virtuemart_product_id, $this->from_period, $this->until_period);
     } else {
         return $this->getRevenueSortListOrderQuery($vendorId, $orderstates, $intervals, $filterorders, $orderdir, $virtuemart_product_id);
     }
 }
コード例 #25
0
ファイル: ratings.php プロジェクト: lenard112/cms
 /**
  * Save a rating
  * @author  Max Milbers
  */
 public function saveRating($data = 0)
 {
     //Check user_rating
     $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);
     $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', 0);
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $user = JFactory::getUser();
         $userId = $user->id;
         $allowReview = $this->allowReview($virtuemart_product_id);
         $allowRating = $this->allowRating($virtuemart_product_id);
     } else {
         $userId = $data['created_by'];
         $allowReview = true;
         $allowRating = true;
     }
     if (!empty($virtuemart_product_id)) {
         //if ( !empty($data['virtuemart_product_id']) && !empty($userId)){
         if (empty($data)) {
             $data = vRequest::getPost();
         }
         if ($allowRating) {
             //normalize the rating
             if ($data['vote'] < 0) {
                 $data['vote'] = 0;
             }
             if ($data['vote'] > $maxrating + 1) {
                 $data['vote'] = $maxrating;
             }
             $data['lastip'] = $_SERVER['REMOTE_ADDR'];
             $data['vote'] = (int) $data['vote'];
             $rating = $this->getRatingByProduct($data['virtuemart_product_id']);
             vmdebug('$rating', $rating);
             $vote = $this->getVoteByProduct($data['virtuemart_product_id'], $userId);
             vmdebug('$vote', $vote);
             $data['virtuemart_rating_vote_id'] = empty($vote->virtuemart_rating_vote_id) ? 0 : $vote->virtuemart_rating_vote_id;
             if (isset($data['vote'])) {
                 $votesTable = $this->getTable('rating_votes');
                 $votesTable->bindChecknStore($data, TRUE);
                 $errors = $votesTable->getErrors();
                 foreach ($errors as $error) {
                     vmError(get_class($this) . '::Error store votes ' . $error);
                 }
             }
             if (!empty($rating->rates) && empty($vote)) {
                 $data['rates'] = $rating->rates + $data['vote'];
                 $data['ratingcount'] = $rating->ratingcount + 1;
             } else {
                 if (!empty($rating->rates) && !empty($vote->vote)) {
                     $data['rates'] = $rating->rates - $vote->vote + $data['vote'];
                     $data['ratingcount'] = $rating->ratingcount;
                 } else {
                     $data['rates'] = $data['vote'];
                     $data['ratingcount'] = 1;
                 }
             }
             if (empty($data['rates']) || empty($data['ratingcount'])) {
                 $data['rating'] = 0;
             } else {
                 $data['rating'] = $data['rates'] / $data['ratingcount'];
             }
             $data['virtuemart_rating_id'] = empty($rating->virtuemart_rating_id) ? 0 : $rating->virtuemart_rating_id;
             vmdebug('saveRating $data', $data);
             $rating = $this->getTable('ratings');
             $rating->bindChecknStore($data, TRUE);
             $errors = $rating->getErrors();
             foreach ($errors as $error) {
                 vmError(get_class($this) . '::Error store rating ' . $error);
             }
         }
         if ($allowReview and !empty($data['comment'])) {
             //if(!empty($data['comment'])){
             $data['comment'] = substr($data['comment'], 0, VmConfig::get('vm_reviews_maximum_comment_length', 2000));
             // no HTML TAGS but permit all alphabet
             $value = preg_replace('@<[\\/\\!]*?[^<>]*?>@si', '', $data['comment']);
             //remove all html tags
             $value = (string) preg_replace('#on[a-z](.+?)\\)#si', '', $value);
             //replace start of script onclick() onload()...
             $value = trim(str_replace('"', ' ', $value), "'");
             $data['comment'] = (string) preg_replace('#^\'#si', '', $value);
             //replace ' at start
             $data['comment'] = nl2br($data['comment']);
             // keep returns
             //set to defaut value not used (prevent hack)
             $data['review_ok'] = 0;
             $data['review_rating'] = 0;
             $data['review_editable'] = 0;
             // Check if ratings are auto-published (set to 0 prevent injected by user)
             //
             $app = JFactory::getApplication();
             if ($app->isSite()) {
                 if (VmConfig::get('reviews_autopublish', 1)) {
                     $data['published'] = 1;
                 } else {
                     $model = new VmModel();
                     $product = $model->getTable('products');
                     $product->load($data['virtuemart_product_id']);
                     $vendorId = VmConfig::isSuperVendor();
                     if (!$user->authorise('core.admin', 'com_virtuemart') and !$user->authorise('core.manage', 'com_virtuemart') or $vendorId != $product->virtuemart_vendor_id) {
                         $data['published'] = 0;
                     }
                 }
             }
             $review = $this->getReviewByProduct($data['virtuemart_product_id'], $userId);
             if (!empty($review->review_rates)) {
                 $data['review_rates'] = $review->review_rates + $data['vote'];
             } else {
                 $data['review_rates'] = $data['vote'];
             }
             if (!empty($review->review_ratingcount)) {
                 $data['review_ratingcount'] = $review->review_ratingcount + 1;
             } else {
                 $data['review_ratingcount'] = 1;
             }
             $data['review_rating'] = $data['review_rates'] / $data['review_ratingcount'];
             $data['virtuemart_rating_review_id'] = empty($review->virtuemart_rating_review_id) ? 0 : $review->virtuemart_rating_review_id;
             $reviewTable = $this->getTable('rating_reviews');
             $reviewTable->bindChecknStore($data, TRUE);
             $errors = $reviewTable->getErrors();
             foreach ($errors as $error) {
                 vmError(get_class($this) . '::Error store review ' . $error);
             }
         }
         return $data['virtuemart_rating_review_id'];
     } else {
         vmError('Cant save rating/review/vote without vote/product_id');
         return FALSE;
     }
 }
コード例 #26
0
 /**
  * @author Max Milbers
  * @param
  */
 function check()
 {
     if (!empty($this->_slugAutoName)) {
         $slugAutoName = $this->_slugAutoName;
         $slugName = $this->_slugName;
         if (in_array($slugAutoName, $this->_translatableFields)) {
             $checkTable = $this->_tbl_lang;
             vmTrace('Language table in normal check?');
         } else {
             $checkTable = $this->_tbl;
         }
         if (empty($this->{$slugName})) {
             // 				vmdebug('table check use _slugAutoName '.$slugAutoName.' '.$slugName);
             if (!empty($this->{$slugAutoName})) {
                 $this->{$slugName} = $this->{$slugAutoName};
             } else {
                 $pkey = $this->_pkey;
                 vmError('VmTable ' . $checkTable . ' Check not passed. Neither slug nor obligatory value at ' . $slugAutoName . ' for auto slug creation is given ' . $this->{$pkey});
                 return false;
             }
         }
         //if (JVM_VERSION === 1) $this->$slugName = JFilterOutput::stringURLSafe($this->$slugName);
         //else $this->$slugName = JApplication::stringURLSafe($this->$slugName);
         //pro+#'!"§$%&/()=?duct-w-| ||cu|st|omfield-|str<ing>
         //vmdebug('my slugName '.$slugName,$this->$slugName);
         $this->{$slugName} = str_replace('-', ' ', $this->{$slugName});
         $this->{$slugName} = html_entity_decode($this->{$slugName}, ENT_QUOTES);
         //$config =& JFactory::getConfig();
         //$transliterate = $config->get('unicodeslugs');
         $unicodeslugs = VmConfig::get('transliterateSlugs', false);
         if ($unicodeslugs) {
             $lang = JFactory::getLanguage();
             $this->{$slugName} = $lang->transliterate($this->{$slugName});
         }
         // Trim white spaces at beginning and end of alias and make lowercase
         $this->{$slugName} = trim(JString::strtolower($this->{$slugName}));
         $this->{$slugName} = str_replace(array('`', '´', "'"), '', $this->{$slugName});
         $this->{$slugName} = vRequest::filterUword($this->{$slugName}, '-,_,|', '-');
         while (strpos($this->{$slugName}, '--')) {
             $this->{$slugName} = str_replace('--', '-', $this->{$slugName});
         }
         // Trim dashes at beginning and end of alias
         $this->{$slugName} = trim($this->{$slugName}, '-');
         if ($unicodeslugs) {
             $this->{$slugName} = rawurlencode($this->{$slugName});
         }
         $valid = $this->checkCreateUnique($checkTable, $slugName);
         vmdebug('my Final slugName ' . $slugName, $this->{$slugName});
         if (!$valid) {
             return false;
         }
     }
     foreach ($this->_obkeys as $obkeys => $error) {
         if (empty($this->{$obkeys})) {
             $error = get_class($this) . ' ' . vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', 'COM_VIRTUEMART_' . strtoupper($obkeys));
             vmError($error);
             return false;
         }
     }
     if ($this->_unique) {
         if (empty($this->_db)) {
             $this->_db = JFactory::getDBO();
         }
         foreach ($this->_unique_name as $obkeys => $error) {
             if (empty($this->{$obkeys})) {
                 $error = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', 'COM_VIRTUEMART_' . strtoupper($obkeys));
                 vmError('Non unique ' . $this->_unique_name . ' ' . $error);
                 return false;
             } else {
                 $valid = $this->checkCreateUnique($this->_tbl, $obkeys);
                 if (!$valid) {
                     return false;
                 }
             }
         }
     }
     if (property_exists($this, 'virtuemart_vendor_id')) {
         if (empty($this->virtuemart_vendor_id) and $this->_pkey == 'virtuemart_vendor_id') {
             $this->virtuemart_vendor_id = $this->_pvalue;
         }
         $multix = Vmconfig::get('multix', 'none');
         //Lets check if the user is admin or the mainvendor
         $virtuemart_vendor_id = false;
         if ($multix == 'none' and get_class($this) !== 'TableVmusers') {
             $this->virtuemart_vendor_id = 1;
             return true;
         } else {
             $loggedVendorId = VmConfig::isSuperVendor();
             $user = JFactory::getUser();
             $admin = $user->authorise('core.admin', 'com_virtuemart') || $user->authorise('core.manage', 'com_virtuemart') || $user->authorise('vm.user.edit', 'com_virtuemart');
             $tbl_key = $this->_tbl_key;
             $className = get_class($this);
             if (strpos($this->_tbl, 'virtuemart_vmusers') === FALSE) {
                 $q = 'SELECT `virtuemart_vendor_id` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . '`="' . $this->{$tbl_key} . '" ';
                 if (!isset(self::$_cache[md5($q)])) {
                     $this->_db->setQuery($q);
                     self::$_cache[md5($q)] = $virtuemart_vendor_id = $this->_db->loadResult();
                 } else {
                     $virtuemart_vendor_id = self::$_cache[md5($q)];
                 }
             } else {
                 $q = 'SELECT `virtuemart_vendor_id`,`user_is_vendor` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . '`="' . $this->{$tbl_key} . '" ';
                 if (!isset(self::$_cache[md5($q)])) {
                     $this->_db->setQuery($q);
                     $vmuser = $this->_db->loadRow();
                     self::$_cache[md5($q)] = $vmuser;
                 } else {
                     $vmuser = self::$_cache[md5($q)];
                 }
                 if ($vmuser and count($vmuser) === 2) {
                     $virtuemart_vendor_id = $vmuser[0];
                     $user_is_vendor = $vmuser[1];
                     if ($multix == 'none') {
                         if (empty($user_is_vendor)) {
                             $this->virtuemart_vendor_id = 0;
                         } else {
                             $this->virtuemart_vendor_id = 1;
                         }
                         return true;
                     } else {
                         if (!$admin) {
                             $this->virtuemart_vendor_id = $loggedVendorId;
                             return true;
                         }
                     }
                 } else {
                     //New User
                     //vmInfo('We run in multivendor mode and you did not set any vendor for '.$className.' and '.$this->_tbl);//, Set to mainvendor '.$this->virtuemart_vendor_id
                 }
             }
             if (!$admin and !empty($virtuemart_vendor_id) and !empty($loggedVendorId) and $loggedVendorId != $virtuemart_vendor_id) {
                 //vmWarn('COM_VIRTUEMART_NOT_SAME_VENDOR',$loggedVendorId,$virtuemart_vendor_id
                 //vmWarn('Stop try to hack this store, you got logged');
                 vmdebug('Blocked storing, logged vendor ' . $loggedVendorId . ' but data belongs to ' . $virtuemart_vendor_id);
                 return false;
             } else {
                 if (!$admin) {
                     if ($virtuemart_vendor_id) {
                         $this->virtuemart_vendor_id = $virtuemart_vendor_id;
                         vmdebug('Non admin is storing using loaded vendor_id');
                     } else {
                         if (empty($this->virtuemart_vendor_id)) {
                             $this->virtuemart_vendor_id = $loggedVendorId;
                         }
                         //No id is stored, even users are allowed to use for the storage and vendorId, no change
                     }
                 } else {
                     //Admins are allowed to do anything. We just trhow some messages
                     if (!empty($virtuemart_vendor_id) and $loggedVendorId != $virtuemart_vendor_id) {
                         vmdebug('Admin with vendor id ' . $loggedVendorId . ' is using for storing vendor id ' . $this->virtuemart_vendor_id);
                     } else {
                         if (empty($virtuemart_vendor_id) and empty($this->virtuemart_vendor_id)) {
                             if (strpos($this->_tbl, 'virtuemart_vendors') === FALSE and strpos($this->_tbl, 'virtuemart_vmusers') === FALSE) {
                                 $this->virtuemart_vendor_id = $loggedVendorId;
                                 vmdebug('Fallback to ' . $this->virtuemart_vendor_id . ' for $loggedVendorId ' . $loggedVendorId . ': We run in multivendor mode and you did not set any vendor for ' . $className . ' and ' . $this->_tbl);
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #27
0
ファイル: view.html.php プロジェクト: kosmosby/medicine-prof
	public function display($tpl = null) {

		$vendorId = vRequest::getInt('vendorid', 1);

		$vendorModel = VmModel::getModel('vendor');

		$vendorIdUser = VmConfig::isSuperVendor();
		$vendorModel->setId($vendorId);
		$vendor = $vendorModel->getVendor();

		if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
		if (VmConfig::get ('enable_content_plugin', 0)) {
			shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_store_desc');
			shopFunctionsF::triggerContentPlugin($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);
		}

		$this->assignRef('vendor',$vendor);

		$document = JFactory::getDocument();

		if(!VmConfig::get('shop_is_offline',0)){

			vmJsApi::jPrice();
			//if($vendorIdUser){
				//$user = JFactory::getUser();
				if( $vendorIdUser ){
					$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');
			$currency = CurrencyDisplay::getInstance( );
			$this->assignRef('currency', $currency);
			
			$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;
			$recent_products = $productModel->getProductListing('recent');
			
			if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) {
				$this->products['recent']= $productModel->getProductListing('recent', $recent_products_count);
				$productModel->addImages($this->products['recent'],1);
			}

			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 $pType => $productSeries){
							foreach($productSeries as $i => $productItem){
								$productItem->stock = $productModel->getStockIndicator($productItem);
							}
						}
					} else {
						$customfieldsModel = VmModel::getModel ('Customfields');
						if (!class_exists ('vmCustomPlugin')) {
							require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
						}
						foreach($this->products as $pType => $productSeries){

							foreach($productSeries as $i => $productItem){

								if (!empty($productItem->customfields)) {

									$product = clone($productItem);
									$customfields = array();
									foreach($productItem->customfields as $cu){
										$customfields[] = clone ($cu);
									}

									$customfieldsSorted = array();
									$customfieldsModel -> displayProductCustomfieldFE ($product, $customfields);
									$product->stock = $productModel->getStockIndicator($product);
									foreach ($customfields as $k => $custom) {
										if (!empty($custom->layout_pos)  ) {
											$customfieldsSorted[$custom->layout_pos][] = $custom;
											unset($customfields[$k]);
										}
									}
									$customfieldsSorted['normal'] = $customfields;
									$product->customfieldsSorted = $customfieldsSorted;
									unset($product->customfields);
									$this->products[$pType][$i] = $product;
								} else {
									$productItem->stock = $productModel->getStockIndicator($productItem);
									$this->products[$pType][$i] = $productItem;
								}

							}
						}
					}
				}
			}

			$user = JFactory::getUser();
			$showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::isSuperVendor());
			$this->assignRef('showBasePrice', $showBasePrice);

			$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);
			}
		} 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',$vendor->vendor_store_name));
		} else {

			if(empty($vendor->customtitle)){

				if ($menu){
					$menuTitle = $menu->params->get('page_title');
					if(empty($menuTitle)) {
						$menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name);
					}
					$document->setTitle($menuTitle);
				} else {
					$title = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name);
					$document->setTitle($title);
				}
			} else {
				$document->setTitle($vendor->customtitle);
			}


			if(!empty($vendor->metadesc)) $document->setMetaData('description',$vendor->metadesc);
			if(!empty($vendor->metakey)) $document->setMetaData('keywords',$vendor->metakey);
			if(!empty($vendor->metarobot)) $document->setMetaData('robots',$vendor->metarobot);
			if(!empty($vendor->metaauthor)) $document->setMetaData('author',$vendor->metaauthor);

		}

		if(!class_exists('VmTemplate')) require(VMPATH_SITE.DS.'helpers'.DS.'vmtemplate.php');
		vmTemplate::setTemplate();

		parent::display($tpl);

	}
コード例 #28
0
ファイル: user.php プロジェクト: chaudhary4k4/modernstore
 /**
  * Save the user info. The saveData function don't use the userModel store function for anonymous shoppers, because it would register them.
  * We make this function private, so we can do the tests in the tasks.
  *
  * @author Max Milbers
  * @author Valérie Isaksen
  *
  * @param boolean Defaults to false, the param is for the userModel->store function, which needs it to determine how to handle the data.
  * @return String it gives back the messages.
  */
 private function saveData($cartObj)
 {
     $mainframe = JFactory::getApplication();
     $msg = '';
     $data = vRequest::getPost(FILTER_SANITIZE_STRING);
     $register = isset($_REQUEST['register']);
     $userModel = VmModel::getModel('user');
     $currentUser = JFactory::getUser();
     if (empty($data['address_type'])) {
         $data['address_type'] = vRequest::getCmd('addrtype', 'BT');
     }
     if ($cartObj) {
         if ($cartObj->_fromCart or $cartObj->getInCheckOut()) {
             if (!class_exists('VirtueMartCart')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
             }
             $cart = VirtueMartCart::getCart();
             $prefix = '';
             if ($data['address_type'] == 'STaddress' || $data['address_type'] == 'ST') {
                 $prefix = 'shipto_';
                 vmdebug('Storing user ST prefix ' . $prefix);
             }
             $cart->saveAddressInCart($data, $data['address_type'], true, $prefix);
         }
     }
     if (isset($data['vendor_accepted_currencies'])) {
         // Store multiple selectlist entries as a ; separated string
         if (array_key_exists('vendor_accepted_currencies', $data) && is_array($data['vendor_accepted_currencies'])) {
             $data['vendor_accepted_currencies'] = implode(',', $data['vendor_accepted_currencies']);
         }
         $data['vendor_store_name'] = vRequest::getHtml('vendor_store_name');
         $data['vendor_store_desc'] = vRequest::getHtml('vendor_store_desc');
         $data['vendor_terms_of_service'] = vRequest::getHtml('vendor_terms_of_service');
         $data['vendor_letter_css'] = vRequest::getHtml('vendor_letter_css');
         $data['vendor_letter_header_html'] = vRequest::getHtml('vendor_letter_header_html');
         $data['vendor_letter_footer_html'] = vRequest::getHtml('vendor_letter_footer_html');
     }
     if ($data['address_type'] == 'ST' and !$currentUser->guest) {
         $ret = $userModel->storeAddress($data);
         if ($cartObj and !empty($ret)) {
             $cartObj->selected_shipto = $ret;
             $cartObj->setCartIntoSession();
         }
     } else {
         if ($currentUser->guest == 1 and ($register or !$cartObj)) {
             if ($this->checkCaptcha('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT') == FALSE) {
                 $msg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL');
                 if ($cartObj and $cartObj->_fromCart) {
                     $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'), $msg);
                 } else {
                     if ($cartObj and $cartObj->getInCheckOut()) {
                         $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscheckout&addrtype=BT'), $msg);
                     } else {
                         $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=edit&addrtype=BT'), $msg);
                     }
                 }
                 return $msg;
             }
         }
         if ($currentUser->guest != 1 or !$cartObj or $currentUser->guest == 1 and $register) {
             $switch = false;
             if ($currentUser->guest == 1 and $register) {
                 $userModel->setId(0);
                 $adminID = JFactory::getSession()->get('vmAdminID', false);
                 if ($adminID) {
                     if (!class_exists('vmCrypt')) {
                         require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
                     }
                     $adminID = vmCrypt::decrypt($adminID);
                     $adminIdUser = JFactory::getUser($adminID);
                     if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                         $superUser = VmConfig::isSuperVendor($adminID);
                         if ($superUser > 1) {
                             $data['vendorId'] = $superUser;
                         }
                         $switch = true;
                     }
                 }
             }
             if (!class_exists('VirtueMartCart')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
             }
             $cart = VirtueMartCart::getCart();
             if (!empty($cart->vendorId) and $cart->vendorId != 1) {
                 $data['vendorId'] = $cart->vendorId;
             }
             $ret = $userModel->store($data);
             if ($switch) {
                 //and VmConfig::get ('oncheckout_change_shopper')){
                 //update session
                 $current = JFactory::getUser($ret['newId']);
                 $session = JFactory::getSession();
                 $session->set('user', $current);
             }
         }
         if ($currentUser->guest == 1 and ($register or !$cartObj)) {
             $msg = is_array($ret) ? $ret['message'] : $ret;
             $usersConfig = JComponentHelper::getParams('com_users');
             $useractivation = $usersConfig->get('useractivation');
             if (is_array($ret) and $ret['success'] and !$useractivation) {
                 // Username and password must be passed in an array
                 $credentials = array('username' => $ret['user']->username, 'password' => $ret['user']->password_clear);
                 $return = $mainframe->login($credentials);
             } else {
                 if (VmConfig::get('oncheckout_only_registered', 0)) {
                     $layout = vRequest::getCmd('layout', 'edit');
                     $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&layout=' . $layout, FALSE), $msg);
                 }
             }
         }
     }
     return $msg;
 }
コード例 #29
0
ファイル: view.html.php プロジェクト: proyectoseb/Matrix
 /**
  * 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()
 {
     $adminID = JFactory::getSession()->get('vmAdminID', false);
     $superVendor = VmConfig::isSuperVendor($adminID);
     if ($superVendor > 1) {
         $db = JFactory::getDbo();
         $search = vRequest::getUword('usersearch', '');
         if (!empty($search)) {
             $search = 'WHERE (`name` LIKE %' . $search . '% OR `username` LIKE %' . $search . '%)';
         }
         $q = 'SELECT ju.`id`,`name`,`username` FROM `#__users` as ju';
         $q .= ' LEFT JOIN #__virtuemart_vmusers AS vmu ON vmu.virtuemart_user_id = ju.id';
         $q .= ' LEFT JOIN #__virtuemart_vendor_users AS vu ON vu.virtuemart_user_id = ju.id';
         if (!empty($search)) {
             $search .= ' AND (vu.virtuemart_vendor_id = ' . $superVendor . ' ';
         } else {
             $search = ' WHERE (vu.virtuemart_vendor_id = ' . $superVendor . ' ';
         }
         $search .= ' OR ISNULL(vu.virtuemart_vendor_id))';
         $search .= ' AND ( vmu.user_is_vendor = 0 OR ISNULL(vmu.virtuemart_vendor_id))';
         $q .= $search . ' ORDER BY `name` LIMIT 0,10000';
         $db->setQuery($q);
         $result = $db->loadObjectList();
         if ($adminID) {
             $user = JFactory::getUser($adminID);
             $toAdd = new stdClass();
             $toAdd->id = $user->id;
             $toAdd->name = $user->name;
             $toAdd->username = $user->username;
             $toAdd->displayedName = $user->name . '&nbsp;&nbsp;( ' . $user->username . ' )';
             array_unshift($result, $toAdd);
         }
         foreach ($result as $k => $user) {
             $result[$k]->displayedName = $user->name . '&nbsp;&nbsp;( ' . $user->username . ' )';
         }
     }
     return $result;
 }
コード例 #30
0
ファイル: user.php プロジェクト: chaudhary4k4/modernstore
 public function getSwitchUserList($superVendor = null, $adminID = false)
 {
     if (!isset($superVendor)) {
         $superVendor = VmConfig::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.virtuemart_vendor_id = ' . $superVendor . ' ';
             }
         }
         $q = 'SELECT ju.`id`,`name`,`username` FROM `#__users` as ju';
         if ($superVendor != 1 or !empty($search)) {
             $q .= ' LEFT JOIN #__virtuemart_vmusers AS vmu ON vmu.virtuemart_user_id = ju.id';
             if ($superVendor != 1) {
                 $q .= ' LEFT JOIN #__virtuemart_vendor_users AS vu ON vu.virtuemart_user_id = ju.id';
                 $search .= ' AND ( vmu.user_is_vendor = 0 OR (vmu.virtuemart_vendor_id) IS NULL)';
             }
         }
         $current = JFactory::getUser();
         if (!empty($search)) {
             $search .= ' AND ju.id!= "' . $current->id . '" ';
         } else {
             $q .= ' WHERE ju.id!= "' . $current->id . '" ';
         }
         $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 . '&nbsp;&nbsp;( ' . $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 = vmText::sprintf('COM_VIRTUEMART_RETURN_TO', $user->name, $user->username);
                 array_unshift($result, $toAdd);
             }
         }
         $toAdd = new stdClass();
         $toAdd->id = 0;
         $toAdd->name = '';
         $toAdd->username = '';
         $toAdd->displayedName = '-' . vmText::_('COM_VIRTUEMART_REGISTER') . '-';
         array_unshift($result, $toAdd);
     }
     return $result;
 }