Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 11-23-2010 09:43:43

picstart
Member
From: United Kingdom
Registered: 07-11-2006
Posts: 428

code modifications help

have found the code below , which appears to select the user type can this be modified to show only wholesale products i.e. "L "  visibility if the wholesaler has logged in ?

can anyone tell me what each line does ?



Code:

// +--
// | Handle visibility.
// +--

$usergroup = $this->globals('core_user.usergroup');

if (empty($usergroup)) {

     if (!(empty($where))) {$where .= 'AND ';}     
     $where .= '(prodview=' . $this->CORE_DB->quote('A') . ') ';

} else {

     if (!(empty($where))) {$where .= 'AND ';}  
     $where .= '((prodview=' . $this->CORE_DB->quote('A') . ') OR ';
     $where .= '(prodview=' . $this->CORE_DB->quote('L') . ' AND ';
     $where .= '(prodviewg LIKE ' . $this->CORE_DB->quote_like($usergroup . ',', 'SUFFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg='       . $this->CORE_DB->quote($usergroup) . ')))';

} // End of if statement.

does this code test for the user group , or could an if statement be placed in this code to determine which usergroup logged in to display relavent product, also is it this peice of code which locks out non wholesale users from seeing wholesale products ?

also found this code in the same file which seems to also have something to do with it, could an elseif statement go in this part to elminate the all products "A" displaying if usr group is equal to "L"
e

Code:

// +--
// | Handle visibility.
// +--

$view_product = 1;

if ($product['prodview'] == 'N') {

     $view_product = 0;

} elseif (($product['prodview'] == 'L') && (!($this->globals('core_user.usergroup')))) {

     $view_product = 0;

} elseif ($product['prodview'] == 'L') {

     $group_found = 0;
     $group_list  = $this->make_list($product['prodviewg']);

     foreach ($group_list as $num => $group) {

          if ($group == $this->globals('core_user.usergroup')) {$group_found = 1;}

     } // End of foreach statement.

     if (empty($group_found)) {$view_product = 0;}

} // End of if statement.

"It may be my worst nightmare at present..... but soon it will be my dream"

Offline

 

#2 11-23-2010 10:32:08

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: code modifications help

Code:

// +--
// | Handle visibility.
// +--

$usergroup = $this->globals('core_user.usergroup');

if (empty($usergroup)) {

     if (!(empty($where))) {$where .= 'AND ';}     
     $where .= '(prodview=' . $this->CORE_DB->quote('A') . ') ';

} else if ($usergroup == 'wholesale') {

     if (!(empty($where))) {$where .= 'AND ';}  
     $where .= '(prodview=' . $this->CORE_DB->quote('L') . ' AND ';
     $where .= '(prodviewg LIKE ' . $this->CORE_DB->quote_like($usergroup . ',', 'SUFFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg='       . $this->CORE_DB->quote($usergroup) . '))';

} else {

     if (!(empty($where))) {$where .= 'AND ';}  
     $where .= '((prodview=' . $this->CORE_DB->quote('A') . ') OR ';
     $where .= '(prodview=' . $this->CORE_DB->quote('L') . ' AND ';
     $where .= '(prodviewg LIKE ' . $this->CORE_DB->quote_like($usergroup . ',', 'SUFFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(','  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg LIKE ' . $this->CORE_DB->quote_like(', '  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'prodviewg='       . $this->CORE_DB->quote($usergroup) . ')))';

} // End of if statement.

John

Offline

 

#3 11-23-2010 17:59:10

picstart
Member
From: United Kingdom
Registered: 07-11-2006
Posts: 428

Re: code modifications help

nice to know i had found the right areas to mod, i did try a couple of ideas that did'nt work ,

works a treat and so simple to an expert , easy to see why you are part of beta team

thanks John


"It may be my worst nightmare at present..... but soon it will be my dream"

Offline

 

Board footer