/** * @author Max Milbers */ function determineStoreOwner() { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $tsmart_user_id = tsmartModelVendor::getUserIdByVendorId(1); if (isset($tsmart_user_id) && $tsmart_user_id > 0) { $this->_user = JFactory::getUser($tsmart_user_id); } else { $this->_user = JFactory::getUser(); } return $this->_user->id; }
/** * Sets the internal user id with given vendor Id * * @author Max Milbers * @param int $vendorId */ function getVendor($vendorId = 1, $return = TRUE) { $vendorModel = tmsModel::getModel('vendor'); $userId = tsmartModelVendor::getUserIdByVendorId($vendorId); if ($userId) { $this->setUserId($userId); if ($return) { return $this->getUser(); } } else { return false; } }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $currentUser = JFactory::getUser(); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); $task = vRequest::getCmd('task', 'edit'); if ($task == 'editshop') { $isSuperOrVendor = vmAccess::isSuperVendor(); if (empty($isSuperOrVendor)) { JFactory::getApplication()->redirect('index.php?option=com_tsmart', tsmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } else { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $userId = tsmartModelVendor::getUserIdByVendorId($isSuperOrVendor); } $this->SetViewTitle('STORE'); } else { if ($task == 'add') { $userId = 0; } else { $userId = vRequest::getVar('tsmart_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', tsmText::_('com_tsmart_NEW_VENDOR'), 'shop_mart'); } $vendorid = $userDetails->tsmart_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_tsmart_YES', 'com_tsmart_NO'); $this->lists['sendEmail'] = JHtml::_('select.booleanlist', 'sendEmail', 'class="inputbox"', $userDetails->JUser->get('sendEmail'), 'com_tsmart_YES', 'com_tsmart_NO'); $this->lists['params'] = $userDetails->JUser->getParameters(true); // Shopper info $this->lists['shoppergroups'] = ShopFunctions::renderShopperGroupList($userDetails->shopper_groups, true, 'tsmart_shoppergroup_id'); $this->lists['vendors'] = ''; if ($this->showVendors()) { $this->lists['vendors'] = ShopFunctions::renderVendorList($userDetails->tsmart_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; } $tsmart_userinfo_id_BT = $model->getBTuserinfo_id($userId); $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'BT', $tsmart_userinfo_id_BT, false); $userFieldsBT = $userFieldsArray[$tsmart_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', $tsmart_userinfo_id_BT); $addrtype = vRequest::getCmd('addrtype'); $tsmart_userinfo_id = 0; if ($layoutName == 'edit_shipto' or $task == 'addST' or $addrtype == 'ST') { $tsmart_userinfo_id = vRequest::getString('tsmart_userinfo_id', '0', ''); $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'ST', $tsmart_userinfo_id, false); if ($new) { $tsmart_userinfo_id = 0; } else { } $userFieldsST = $userFieldsArray[$tsmart_userinfo_id]; $this->assignRef('shipToFields', $userFieldsST); vmdebug('hm ST $tsmart_userinfo_id', $tsmart_userinfo_id); } $this->assignRef('shipToId', $tsmart_userinfo_id); $this->assignRef('new', $new); if (!$_new) { // Check for existing orders for this user $orders = tmsModel::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 = tmsModel::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->tsmart_vendor_id); $vendorM->addImages($userDetails->vendor); $this->assignRef('vendor', $userDetails->vendor); $currencyModel = tmsModel::getModel('currency'); $_currencies = $currencyModel->getCurrencies(); $this->assignRef('currencies', $_currencies); $configModel = tmsModel::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_tsmart_USER_ISVENDOR'); JToolBarHelper::custom('toggle.user_is_vendor.0', 'unpublish', '', 'com_tsmart_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 = tmsModel::getModel('shopperGroup'); $this->defaultShopperGroup = $shoppergroupmodel->getDefault(0)->shopper_group_name; } if (!empty($this->orderlist)) { tsmConfig::loadJLang('com_tsmart_orders', TRUE); } parent::display($tpl); }
public function getVendorAddressFields($vendorId = 0) { if ($vendorId != 0) { $this->_id = (int) $vendorId; } if (!$this->_vendorFields) { $userId = tsmartModelVendor::getUserIdByVendorId($this->_id); $userModel = tmsModel::getModel('user'); $tsmart_userinfo_id = $userModel->getBTuserinfo_id($userId); // this is needed to set the correct user id for the vendor when the user is logged $userModel->getVendor($this->_id, FALSE); $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $tsmart_userinfo_id, FALSE, TRUE); $this->_vendorFields = $vendorFieldsArray[$tsmart_userinfo_id]; } return $this->_vendorFields; }