本文整理汇总了PHP中vmAccess::isSuperVendor方法的典型用法代码示例。如果您正苦于以下问题:PHP vmAccess::isSuperVendor方法的具体用法?PHP vmAccess::isSuperVendor怎么用?PHP vmAccess::isSuperVendor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vmAccess
的用法示例。
在下文中一共展示了vmAccess::isSuperVendor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrenciesList
/**
* Retireve a list of currencies from the database.
* This function is used in the backend for the currency listing, therefore no asking if enabled or not
* @author Max Milbers
* @return object List of currency objects
*/
function getCurrenciesList($search, $vendorId = 1)
{
$where = array();
$user = JFactory::getUser();
$shared = '';
if (vmAccess::manager()) {
$shared = 'OR `shared`="1"';
}
$vendorId = vmAccess::isSuperVendor();
if ($vendorId) {
$where[] = '(`virtuemart_vendor_id` = "' . (int) $vendorId . '" ' . $shared . ')';
}
if (empty($search)) {
$search = vRequest::getString('search', false);
}
// add filters
if ($search) {
$db = JFactory::getDBO();
$search = '"%' . $db->escape($search, true) . '%"';
$where[] = '`currency_name` LIKE ' . $search . ' OR `currency_code_2` LIKE ' . $search . ' OR `currency_code_3` LIKE ' . $search;
}
$whereString = '';
if (count($where) > 0) {
$whereString = ' WHERE ' . implode(' AND ', $where);
}
$data = $this->exeSortSearchListQuery(0, '*', ' FROM `#__virtuemart_currencies`', $whereString, '', $this->_getOrdering());
return $data;
}
示例2: display
function display($tpl = null)
{
if (!class_exists('VmHTML')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
}
$this->vendorId = vmAccess::isSuperVendor();
// TODO add icon for media view
$this->SetViewTitle();
$model = VmModel::getModel('media');
$layoutName = vRequest::getCmd('layout', 'default');
if ($layoutName == 'edit') {
$this->media = $model->getFile();
$this->addStandardEditViewCommands();
} else {
$virtuemart_product_id = vRequest::getInt('virtuemart_product_id');
if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) {
$virtuemart_product_id = (int) $virtuemart_product_id[0];
} else {
$virtuemart_product_id = (int) $virtuemart_product_id;
}
$cat_id = vRequest::getInt('virtuemart_category_id', 0);
$super = vmAccess::isSuperVendor();
if ($super == 1) {
JToolBarHelper::custom('synchronizeMedia', 'new', 'new', vmText::_('COM_VIRTUEMART_TOOLS_SYNC_MEDIA_FILES'), false);
}
$this->addStandardDefaultViewCommands();
$this->addStandardDefaultViewLists($model, null, null, 'searchMedia');
$options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_TYPES'), 'product' => vmText::_('COM_VIRTUEMART_PRODUCT'), 'category' => vmText::_('COM_VIRTUEMART_CATEGORY'), 'manufacturer' => vmText::_('COM_VIRTUEMART_MANUFACTURER'), 'vendor' => vmText::_('COM_VIRTUEMART_VENDOR'));
$this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options, 1, '', 'onchange="this.form.submit();"');
$options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_ROLES'), 'file_is_displayable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DISPLAYABLE'), 'file_is_downloadable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DOWNLOADABLE'), 'file_is_forSale' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_SET_FORSALE'));
$this->lists['search_role'] = VmHTML::selectList('search_role', vRequest::getVar('search_role'), $options, 1, '', 'onchange="this.form.submit();"');
$this->files = $model->getFiles(false, false, $virtuemart_product_id, $cat_id);
$this->pagination = $model->getPagination();
}
parent::display($tpl);
}
示例3: isSuperVendor
public static function isSuperVendor($uid = 0)
{
return vmAccess::isSuperVendor($uid);
}
示例4: display
public function display($tpl = null)
{
$vendorId = vRequest::getInt('vendorid', 1);
$vendorModel = VmModel::getModel('vendor');
$vendorIdUser = vmAccess::isSuperVendor();
$vendorModel->setId($vendorId);
$this->vendor = $vendorModel->getVendor();
if (!class_exists('shopFunctionsF')) {
require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
if (VmConfig::get('enable_content_plugin', 0)) {
shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_store_desc');
shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_terms_of_service');
}
$app = JFactory::getApplication();
$menus = $app->getMenu();
$menu = $menus->getActive();
if (!empty($menu->id)) {
ShopFunctionsF::setLastVisitedItemId($menu->id);
} else {
if ($itemId = vRequest::getInt('Itemid', false)) {
ShopFunctionsF::setLastVisitedItemId($itemId);
}
}
$document = JFactory::getDocument();
if (!VmConfig::get('shop_is_offline', 0)) {
if (ShopFunctionsF::isFEmanager('product.edit')) {
$add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1';
$add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false);
} else {
$add_product_link = "";
}
$this->assignRef('add_product_link', $add_product_link);
$categoryModel = VmModel::getModel('category');
$productModel = VmModel::getModel('product');
$ratingModel = VmModel::getModel('ratings');
$productModel->withRating = $this->showRating = $ratingModel->showRating();
$this->products = array();
$categoryId = vRequest::getInt('catid', 0);
$categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);
$categoryModel->addImages($categoryChildren, 1);
$this->assignRef('categories', $categoryChildren);
if (!class_exists('CurrencyDisplay')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
}
$this->currency = CurrencyDisplay::getInstance();
$products_per_row = VmConfig::get('homepage_products_per_row', 3);
$featured_products_rows = VmConfig::get('featured_products_rows', 1);
$featured_products_count = $products_per_row * $featured_products_rows;
if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) {
$this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count);
$productModel->addImages($this->products['featured'], 1);
}
$latest_products_rows = VmConfig::get('latest_products_rows');
$latest_products_count = $products_per_row * $latest_products_rows;
if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) {
$this->products['latest'] = $productModel->getProductListing('latest', $latest_products_count);
$productModel->addImages($this->products['latest'], 1);
}
$topTen_products_rows = VmConfig::get('topTen_products_rows');
$topTen_products_count = $products_per_row * $topTen_products_rows;
if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) {
$this->products['topten'] = $productModel->getProductListing('topten', $topTen_products_count);
$productModel->addImages($this->products['topten'], 1);
}
$recent_products_rows = VmConfig::get('recent_products_rows');
$recent_products_count = $products_per_row * $recent_products_rows;
if (!empty($recent_products_count) and VmConfig::get('show_recent', 1)) {
$recent_products = $productModel->getProductListing('recent');
if (!empty($recent_products)) {
$this->products['recent'] = $productModel->getProductListing('recent', $recent_products_count);
$productModel->addImages($this->products['recent'], 1);
}
}
if ($this->products) {
$display_stock = VmConfig::get('display_stock', 1);
$showCustoms = VmConfig::get('show_pcustoms', 1);
if ($display_stock or $showCustoms) {
if (!$showCustoms) {
foreach ($this->products as $pType => $productSeries) {
foreach ($productSeries as $i => $productItem) {
$this->products[$pType][$i]->stock = $productModel->getStockIndicator($productItem);
}
}
} else {
if (!class_exists('vmCustomPlugin')) {
require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
}
foreach ($this->products as $pType => $productSeries) {
shopFunctionsF::sortLoadProductCustomsStockInd($this->products[$pType], $productModel);
}
}
}
}
$this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
$layout = VmConfig::get('vmlayout', 'default');
$this->setLayout($layout);
$productsLayout = VmConfig::get('productsublayout', 'products');
if (empty($productsLayout)) {
$productsLayout = 'products';
//.........这里部分代码省略.........
示例5: categoryListTree
public static function categoryListTree($selectedCategories = array(), $cid = 0, $level = 0, $disabledFields = array())
{
$hash = crc32(implode('.', $selectedCategories) . ':' . $cid . ':' . $level . implode('.', $disabledFields));
if (empty(self::$categoryTree[$hash])) {
$cache = JFactory::getCache('com_virtuemart_cats');
$cache->setCaching(1);
$app = JFactory::getApplication();
$vendorId = vmAccess::isSuperVendor();
self::$categoryTree[$hash] = $cache->call(array('ShopFunctions', 'categoryListTreeLoop'), $selectedCategories, $cid, $level, $disabledFields, $app->isSite(), $vendorId, VmConfig::$vmlang);
}
return self::$categoryTree[$hash];
}
示例6: display
function display($tpl = null)
{
// Get the task
$task = vRequest::getCmd('task', $this->getLayout());
$this->assignRef('task', $task);
// Load helpers
if (!class_exists('CurrencyDisplay')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
}
if (!class_exists('VmHTML')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
}
if (!class_exists('VmImage')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
}
$model = tmsModel::getModel();
// Handle any publish/unpublish
switch ($task) {
case 'add':
case 'edit':
//this was in the controller for the edit tasks, we need this for the access by FE
//$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl');
tsmConfig::loadJLang('com_tsmart_orders', TRUE);
tsmConfig::loadJLang('com_tsmart_shoppers', TRUE);
$model_country = tmsModel::getModel('country');
$this->countries = $model_country->getItemList();
$tsmart_product_id = vRequest::getInt('tsmart_product_id');
if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) {
$tsmart_product_id = (int) $tsmart_product_id[0];
} else {
$tsmart_product_id = (int) $tsmart_product_id;
}
$product = $model->getItem($tsmart_product_id);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
$product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id);
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
$product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id);
//$user = JFactory::getUser();
$superVendor = vmAccess::isSuperVendor();
if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) {
vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id);
JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error');
}
if (!empty($product->product_parent_id)) {
$product_parent = $model->getProductSingle($product->product_parent_id, false);
}
require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
$this->tour_service_class = tsmserviceclass::get_list_tour_service_class();
$customfields = tmsModel::getModel('Customfields');
$product->allIds[] = $product->tsmart_product_id;
if (!empty($product->product_parent_id)) {
$product->allIds[] = $product->product_parent_id;
}
$product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds);
// Get the category tree
if (isset($product->categories)) {
$this->category_tree = ShopFunctions::categoryListTree($product->categories);
} else {
$this->category_tree = ShopFunctions::categoryListTree();
}
//Fallback for categories inherited by parent to correctly calculate the prices
if (empty($product->categories) and !empty($product_parent->categories)) {
$product->categories = $product_parent->categories;
}
//Get the shoppergoup list - Cleanshooter Custom Shopper Visibility
if (!isset($product->shoppergroups)) {
$product->shoppergroups = 0;
}
$this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups);
// Load the product price
if (!class_exists('calculationHelper')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
}
//Do we need the children? If there is a C customfield, we dont want them
$isCustomVariant = false;
foreach ($product->customfields as $custom) {
if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) {
$isCustomVariant = true;
break;
}
}
if (!class_exists('tsmartModelConfig')) {
require VMPATH_ADMIN . '/models/config.php';
}
$productLayouts = tsmartModelConfig::getLayoutList('productdetails');
$this->productLayouts = $productLayouts;
// Load Images
$model->addImages($product);
if (!class_exists('VmTemplate')) {
require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
}
$vmtemplate = VmTemplate::loadVmTemplateStyle();
$this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate);
// Load the vendors
$vendor_model = tmsModel::getModel('vendor');
$lists['vendors'] = '';
if ($this->showVendors()) {
$lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id);
}
// Load the currencies
//.........这里部分代码省略.........
示例7: getSwitchUserList
public function getSwitchUserList($superVendor = null, $adminID = false)
{
if (!isset($superVendor)) {
$superVendor = vmAccess::isSuperVendor();
}
$result = false;
if ($superVendor) {
$db = JFactory::getDbo();
$search = vRequest::getUword('usersearch', '');
if (!empty($search)) {
$search = ' WHERE (`name` LIKE "%' . $search . '%" OR `username` LIKE "%' . $search . '%" OR `customer_number` LIKE "%' . $search . '%")';
} else {
if ($superVendor != 1) {
$search = ' WHERE vu.tsmart_vendor_id = ' . $superVendor . ' ';
}
}
$q = 'SELECT ju.`id`,`name`,`username` FROM `#__users` as ju';
if ($superVendor != 1 or !empty($search)) {
$q .= ' LEFT JOIN #__tsmart_vmusers AS vmu ON vmu.tsmart_user_id = ju.id';
if ($superVendor != 1) {
$q .= ' LEFT JOIN #__tsmart_vendor_users AS vu ON vu.tsmart_user_id = ju.id';
$search .= ' AND ( vmu.user_is_vendor = 0 OR (vmu.tsmart_vendor_id) IS NULL)';
}
}
$current = JFactory::getUser();
$hiddenUserID = $adminID ? $adminID : $current->id;
if (!empty($search)) {
$search .= ' AND ju.id!= "' . $hiddenUserID . '" ';
} else {
$q .= ' WHERE ju.id!= "' . $hiddenUserID . '" ';
}
$q .= $search . ' ORDER BY `name` LIMIT 0,10000';
$db->setQuery($q);
$result = $db->loadObjectList();
if ($result) {
foreach ($result as $k => $user) {
$result[$k]->displayedName = $user->name . ' ( ' . $user->username . ' )';
}
} else {
$result = array();
}
if ($adminID) {
$user = JFactory::getUser($adminID);
if ($current->id != $user->id) {
$toAdd = new stdClass();
$toAdd->id = $user->id;
$toAdd->name = $user->name;
$toAdd->username = $user->username;
$toAdd->displayedName = tsmText::sprintf('com_tsmart_RETURN_TO', $user->name, $user->username);
array_unshift($result, $toAdd);
}
}
$toAdd = new stdClass();
$toAdd->id = 0;
$toAdd->name = '';
$toAdd->username = '';
$toAdd->displayedName = '-' . tsmText::_('com_tsmart_REGISTER') . '-';
array_unshift($result, $toAdd);
}
return $result;
}
示例8: saveRating
/**
* 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');
$res = $votesTable->bindChecknStore($data, TRUE);
if (!$res) {
vmError(get_class($this) . '::Error store votes ');
}
}
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');
$res = $rating->bindChecknStore($data, TRUE);
if (!$res) {
vmError(get_class($this) . '::Error store rating ');
}
}
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 = vmAccess::isSuperVendor();
//.........这里部分代码省略.........
示例9: check
/**
* @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 = tsmConfig::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) . ' ' . tsmText::sprintf('com_tsmart_STRING_ERROR_OBLIGATORY_KEY', 'com_tsmart_' . 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 = tsmText::sprintf('com_tsmart_STRING_ERROR_NOT_UNIQUE_NAME', 'com_tsmart_' . 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, 'tsmart_vendor_id')) {
if (empty($this->tsmart_vendor_id) and $this->_pkey == 'tsmart_vendor_id') {
$this->tsmart_vendor_id = $this->_pvalue;
}
$multix = tsmConfig::get('multix', 'none');
//Lets check if the user is admin or the mainvendor
$tsmart_vendor_id = false;
//Todo removed Quickn Dirty, use check in derived class
if ($multix == 'none' and get_class($this) !== 'TableVmusers') {
$this->tsmart_vendor_id = 1;
return true;
} else {
$loggedVendorId = vmAccess::isSuperVendor();
$user = JFactory::getUser();
$tbl_key = $this->_tbl_key;
$className = get_class($this);
$admin = vmAccess::manager('managevendors');
//Todo removed Quickn Dirty, use check in derived class
if (strpos($this->_tbl, 'tsmart_vmusers') === FALSE) {
$q = 'SELECT `tsmart_vendor_id` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . '`="' . $this->{$tbl_key} . '" ';
//.........这里部分代码省略.........
示例10: getFiles
/**
* 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, $tsmart_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($tsmart_product_id)) {
$mainTable = '`#__tsmart_product_medias`';
$selectFields[] = ' `#__tsmart_medias`.`tsmart_media_id` as tsmart_media_id ';
$joinTables[] = ' LEFT JOIN `#__tsmart_medias` ON `#__tsmart_medias`.`tsmart_media_id`=`#__tsmart_product_medias`.`tsmart_media_id` and `tsmart_product_id` = "' . $tsmart_product_id . '"';
$whereItems[] = '`tsmart_product_id` = "' . $tsmart_product_id . '"';
if ($this->_selectedOrdering == 'ordering') {
$orderByTable = '`#__tsmart_product_medias`.';
} else {
$orderByTable = '`#__tsmart_medias`.';
}
} else {
if (!empty($cat_id)) {
$mainTable = '`#__tsmart_category_medias`';
$selectFields[] = ' `#__tsmart_medias`.`tsmart_media_id` as tsmart_media_id';
$joinTables[] = ' LEFT JOIN `#__tsmart_medias` ON `#__tsmart_medias`.`tsmart_media_id`=`#__tsmart_category_medias`.`tsmart_media_id` and `tsmart_category_id` = "' . $cat_id . '"';
$whereItems[] = '`tsmart_category_id` = "' . $cat_id . '"';
if ($this->_selectedOrdering == 'ordering') {
$orderByTable = '`#__tsmart_category_medias`.';
} else {
$orderByTable = '`#__tsmart_medias`.';
}
} else {
$mainTable = '`#__tsmart_medias`';
$selectFields[] = ' `tsmart_media_id` ';
if (!vmAccess::manager('managevendors')) {
$vendorId = vmAccess::isSuperVendor();
$whereItems[] = '(`tsmart_vendor_id` = "' . $vendorId . '" OR `shared`="1")';
}
}
}
if ($onlyPublished) {
$whereItems[] = '`#__tsmart_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;
}
//.........这里部分代码省略.........
示例11: getRevenue
/**
* 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)
{
if (!vmAccess::manager('report')) {
return false;
}
$vendorId = vmAccess::isSuperVendor();
if (vmAccess::manager('managevendors')) {
$vendorId = vRequest::getInt('virtuemart_vendor_id', $vendorId);
}
$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);
}
}
示例12: store
//.........这里部分代码省略.........
}
if ($isChild) {
$childPrices = $this->loadProductPrices($this->_id, array(0), false);
}
if ((isset($pricesToStore['product_price']) and $pricesToStore['product_price'] != '' and $pricesToStore['product_price'] !== '0') || (isset($childPrices) and count($childPrices) > 1)) {
if ($isChild) {
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']);
}
}
if ($pricesToStore) {
$toUnset = array();
if (!empty($old_price_ids) and count($old_price_ids)) {
foreach ($old_price_ids as $key => $oldprice) {
if ($pricesToStore['virtuemart_product_price_id'] == $oldprice['virtuemart_product_price_id']) {
$pricesToStore = array_merge($oldprice, $pricesToStore);
$toUnset[] = $key;
}
}
}
$this->updateXrefAndChildTables($pricesToStore, 'product_prices', $isChild);
foreach ($toUnset as $key) {
unset($old_price_ids[$key]);
}
}
}
}
}
if (!empty($old_price_ids) and 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 ($productId != $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'] = $this->_id;
$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) {
if (VmConfig::get('multix', 'none') != 'none' and !vmAccess::manager('managevendors')) {
$vendorId = vmAccess::isSuperVendor();
$vM = VmModel::getModel('vendor');
$ven = $vM->getVendor($vendorId);
if ($ven->max_cats_per_product >= 0) {
while ($ven->max_cats_per_product < count($data['categories'])) {
array_pop($data['categories']);
}
}
}
$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');
}
$cache = JFactory::getCache('com_virtuemart_cat_manus', 'callback');
$cache->clean();
return $product_data->virtuemart_product_id;
}
示例13: getCategories
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 = vmAccess::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];
}
示例14: getOrdersList
/**
* 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');
$tUserInfos = $this->getTable('userinfos');
$this->_noLimit = $noLimit;
$concat = array();
if (property_exists($tUserInfos, 'company')) {
$concat[] = 'u.company';
}
if (property_exists($tUserInfos, 'first_name')) {
$concat[] = 'u.first_name';
}
if (property_exists($tUserInfos, 'middle_name')) {
$concat[] = 'u.middle_name';
}
if (property_exists($tUserInfos, 'last_name')) {
$concat[] = 'u.last_name';
}
if (!empty($concat)) {
$concatStr = "CONCAT_WS(' '," . implode(',', $concat) . ")";
} else {
$concatStr = 'o.order_number';
}
// quorvia added phone, zip, city and shipping details and ST data
$select = " o.*, " . $concatStr . " AS order_name " . ',u.email as order_email,
pm.payment_name AS payment_method,
u.company AS company,
u.city AS city,
u.zip AS zip,
u.phone_1 AS phone,
st.address_type AS st_type,
st.company AS st_company,
st.city AS st_city,
st.zip AS st_zip,
u.customer_note AS customer_note';
$from = $this->getOrdersListQuery();
$where = array();
$virtuemart_vendor_id = vmAccess::isSuperVendor();
if (vmAccess::manager('managevendors')) {
vmdebug('Vendor is core.admin and should see all');
$virtuemart_vendor_id = vRequest::get('virtuemart_vendor_id', $virtuemart_vendor_id);
if ($virtuemart_vendor_id) {
$where[] = ' o.virtuemart_vendor_id = "' . $virtuemart_vendor_id . '" ';
}
if (!empty($uid)) {
$where[] = ' u.virtuemart_user_id = ' . (int) $uid . ' ';
}
} else {
if (vmAccess::manager('orders')) {
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
$user = JFactory::getUser();
$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';
//quorvia addedd ST data searches
$searchFields[] = 'st.company';
$searchFields[] = 'st.last_name';
$searchFields[] = 'st.city';
$searchFields[] = 'st.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) . ') ';
//.........这里部分代码省略.........
示例15: display
//.........这里部分代码省略.........
$this->showRating = $ratingModel->showRating();
$productModel->withRating = $this->showRating;
$this->orderByList = $productModel->getOrderByList($this->categoryId);
$this->products = $productModel->getProducts($ids);
//$products = $productModel->getProductsInCategory($this->categoryId);
$imgAmount = VmConfig::get('prodimg_browse', 1);
$productModel->addImages($this->products, $imgAmount);
if ($this->products) {
$currency = CurrencyDisplay::getInstance();
$this->assignRef('currency', $currency);
$display_stock = VmConfig::get('display_stock', 1);
$showCustoms = VmConfig::get('show_pcustoms', 1);
if ($display_stock or $showCustoms) {
if (!$showCustoms) {
foreach ($this->products as $i => $productItem) {
$productItem->stock = $productModel->getStockIndicator($productItem);
}
} else {
shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel);
}
}
// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
vmJsApi::jPrice();
}
// Add feed links
if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) {
$link = '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
}
$user = JFactory::getUser();
$this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
}
//No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) {
if (empty($category->slug)) {
vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
} else {
if ($category->virtuemart_id !== 0 and !$category->published) {
vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId);
}
}
//Fallback
$categoryLink = '';
if ($category->category_parent_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
} else {
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if (!$last_category_id or $this->categoryId == $last_category_id) {
$last_category_id = vRequest::getInt('virtuemart_category_id', false);
}
if ($last_category_id and $this->categoryId != $last_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
}
}
if (VmConfig::get('handle_404', 1)) {
$app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
} else {
JError::raise(E_ERROR, '404', 'Not found');
}
return;
}
shopFunctionsF::setLastVisitedCategoryId($this->categoryId);
shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);