Index: branches/5.0.x/in-commerce/units/shipping/shipping_tag_processor.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin() || in_array( $original_shipping[$package_id]['ShippingId'], $shipping_type_keys ) ) ) + ( $this->Application->isAdminUser || in_array( $original_shipping[$package_id]['ShippingId'], $shipping_type_keys ) ) ) { $original_shipping = $original_shipping[$package_id]; $key = $original_shipping['ShippingId']; - $shipping_types[$key]['TotalCost'] = $this->Application->IsAdmin() ? $original_shipping['TotalCost'] : $shipping_types[$key]['TotalCost']; - $shipping_types[$key]['ShippingName'] = $this->Application->IsAdmin() ? 'Original: '.$original_shipping['ShippingName'] : $shipping_types[$key]['ShippingName']; + $shipping_types[$key]['TotalCost'] = $this->Application->isAdminUser ? $original_shipping['TotalCost'] : $shipping_types[$key]['TotalCost']; + $shipping_types[$key]['ShippingName'] = $this->Application->isAdminUser ? 'Original: '.$original_shipping['ShippingName'] : $shipping_types[$key]['ShippingName']; $shipping_types[$key]['ShippingId'] = $key; $selected_id = $key; } $last_shippings[$package_id] = $shipping_types; - if( $this->Application->IsAdmin() && $key) + if( $this->Application->isAdminUser && $key) { $orig_name = ltrim($last_shippings[$package_id][$key]['ShippingName'], 'Original: '); $last_shippings[$package_id][$key]['ShippingName'] = $orig_name; Index: branches/5.0.x/in-commerce/units/orders/orders_item.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/orders/orders_item.php (.../orders_item.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/orders/orders_item.php (.../orders_item.php) (revision 12722) @@ -1,6 +1,6 @@ Application->ConfigValue('Comm_MaskProcessedCreditCards')) { $mask_found = strpos($value, str_repeat('X', 4)) !== false; - if ($this->Application->IsAdmin() && $mask_found) { + if ($this->Application->isAdminUser && $mask_found) { // masked card numbers always appear valid in admin return true; } @@ -420,24 +420,24 @@ $formatter = getArrayValue($params, 'formatter'); if( ($formatter != 'kCCDateFormatter') || !$this->requireCreditCard() ) return true; - if( !$this->Application->IsAdmin() ) - { + if(!$this->Application->isAdminUser) { // validate expiration date only for front - if( preg_match('/([\d]{2})\/([\d]{2})/', $this->GetDBField($field), $rets) ) - { + if (preg_match('/([\d]{2})\/([\d]{2})/', $this->GetDBField($field), $rets)) { $month = $rets[1]; $year = $rets[2]; $now_date = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y') ); $day_count = adodb_date('t', adodb_mktime(0, 0, 0, $month, 1, $year) ); $cc_date = adodb_mktime(23, 59, 59, $month, $day_count, $year); - if($cc_date < $now_date) - { + + if ($cc_date < $now_date) { $error_field = isset($params['error_field']) ? $params['error_field'] : $field; $this->FieldErrors[$error_field]['pseudo'] = 'credit_card_expired'; + return false; } } } + return true; } Index: branches/5.0.x/in-commerce/units/products/products_item.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/products/products_item.php (.../products_item.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/products/products_item.php (.../products_item.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $user_id = $this->Application->RecallVar('user_id'); $primary_group = $user_id != -2 ? $this->Conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PrimaryGroup = 1 AND PortalUserId = '.$user_id) : false; + if ($primary_group) { $sql = 'SELECT Price, Cost FROM '.TABLE_PREFIX.'ProductsPricing WHERE (ProductId = '.$this->GetID().') AND (GroupId = '.$primary_group.') ORDER BY MinQty'; $a_values = $this->Conn->GetRow($sql); + if ($a_values !== false) { return $a_values; } } } + $pr_table = $this->Application->getUnitOption('pr', 'TableName'); + if ($this->mode == 't') { $pr_table = $this->Application->GetTempName($pr_table, 'prefix:'.$this->Prefix); } $sql = 'SELECT Price, Cost FROM '.$pr_table.' WHERE ('.$this->IDField.' = '.$this->GetID().') AND (IsPrimary = 1)'; + return $this->Conn->GetRow($sql); } Index: branches/5.0.x/in-commerce/units/pricing/pricing_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/pricing/pricing_event_handler.php (.../pricing_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/pricing/pricing_event_handler.php (.../pricing_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ getObject(); - if (!$this->Application->IsAdmin()){ - $user_groups = $this->Application->RecallVar('UserGroups'); + if ($this->Application->isAdminUser) { + return ; + } - $pricing_method = $this->Application->ConfigValue('Comm_PriceBracketCalculation'); - if ($pricing_method == 1){ - $primary_group = $this->Conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId='.$this->Application->GetVar('u_id').' AND PrimaryGroup=1'); - $pricing_group = $primary_group; - if ($pricing_group) { - $pricing_for_group_exists = $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'ProductsPricing WHERE ProductId='.$this->Application->GetVar('p_id').' AND GroupId='.$primary_group.' AND Price IS NOT NULL'); - } - if ($pricing_group && $pricing_for_group_exists > 0){ - $pricing_group = $primary_group; - } - else { - $pricing_group = $this->Application->ConfigValue('User_LoggedInGroup'); - } + $user_groups = $this->Application->RecallVar('UserGroups'); - + $pricing_method = $this->Application->ConfigValue('Comm_PriceBracketCalculation'); + if ($pricing_method == 1) { + $primary_group = $this->Conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId='.$this->Application->GetVar('u_id').' AND PrimaryGroup=1'); + $pricing_group = $primary_group; + if ($pricing_group) { + $pricing_for_group_exists = $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'ProductsPricing WHERE ProductId='.$this->Application->GetVar('p_id').' AND GroupId='.$primary_group.' AND Price IS NOT NULL'); } + if ($pricing_group && $pricing_for_group_exists > 0) { + $pricing_group = $primary_group; + } else { - //$cheapest_group = $this->Conn->GetOne('SELECT GroupId FROM '.$object->TableName.' WHERE ProductId='.$this->Application->GetVar('p_id').' AND Price IS NOT NULL AND GroupId IN ('.$user_groups.') AND MinQty = 1 GROUP BY GroupId ORDER BY Price ASC'); - $effective_brackets = $this->Conn->Query('SELECT PriceId, Price, GroupId FROM '.$object->TableName.' - WHERE ProductId='.$this->Application->GetVar('p_id').' AND Price IS NOT NULL AND GroupId IN ('.$user_groups.') ORDER BY GroupId ASC, MinQty ASC', 'PriceId'); - $group_prices = array(); - $min_price = -1; - $cheapest_group = 0; + $pricing_group = $this->Application->ConfigValue('User_LoggedInGroup'); + } - foreach ($effective_brackets as $bracket) { - if (!isset($group_prices[$bracket['GroupId']])) { - $group_prices[$bracket['GroupId']] = $bracket['Price']; - if ($bracket['Price'] < $min_price || $min_price == -1) { - $min_price = $bracket['Price']; - $cheapest_group = $bracket['GroupId']; - } + + } + else { + //$cheapest_group = $this->Conn->GetOne('SELECT GroupId FROM '.$object->TableName.' WHERE ProductId='.$this->Application->GetVar('p_id').' AND Price IS NOT NULL AND GroupId IN ('.$user_groups.') AND MinQty = 1 GROUP BY GroupId ORDER BY Price ASC'); + $effective_brackets = $this->Conn->Query('SELECT PriceId, Price, GroupId FROM '.$object->TableName.' + WHERE ProductId='.$this->Application->GetVar('p_id').' AND Price IS NOT NULL AND GroupId IN ('.$user_groups.') ORDER BY GroupId ASC, MinQty ASC', 'PriceId'); + $group_prices = array(); + $min_price = -1; + $cheapest_group = 0; + + foreach ($effective_brackets as $bracket) { + if (!isset($group_prices[$bracket['GroupId']])) { + $group_prices[$bracket['GroupId']] = $bracket['Price']; + if ($bracket['Price'] < $min_price || $min_price == -1) { + $min_price = $bracket['Price']; + $cheapest_group = $bracket['GroupId']; } } + } - if (!$cheapest_group) $cheapest_group = $this->Application->ConfigValue('User_LoggedInGroup'); - - $pricing_group = $cheapest_group; + if (!$cheapest_group) { + $cheapest_group = $this->Application->ConfigValue('User_LoggedInGroup'); } - $object->addFilter('price_user_group', $object->TableName.'.GroupId='.$pricing_group); + $pricing_group = $cheapest_group; } + + $object->addFilter('price_user_group', $object->TableName.'.GroupId='.$pricing_group); } } \ No newline at end of file Index: branches/5.0.x/in-commerce/units/orders/orders_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { if ($event->Name == 'OnCreate') { // user can't initiate custom order creation directly return false; @@ -160,7 +160,9 @@ */ function OnSelectAddress(&$event) { - if ($this->Application->IsAdmin()) return true; + if ($this->Application->isAdminUser) { + return ; + } $object =& $event->getObject(); @@ -397,8 +399,7 @@ $this->SplitOrder($event, $order); } - if( !$this->Application->IsAdmin() ) - { + if (!$this->Application->isAdminUser) { // for tracking code $this->Application->StoreVar('last_order_amount', $order->GetDBField('TotalAmount')); $this->Application->StoreVar('last_order_number', $order->GetDBField('OrderNumber')); @@ -603,7 +604,7 @@ parent::OnUpdate($event); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return true; } else { @@ -784,15 +785,15 @@ $event->setEventParam('ItemData', serialize($item_data)); // 1 for PacakgeNum when in admin - temporary solution to overcome splitting into separate sub-orders // of orders with items added through admin when approving them - $this->AddItemToOrder($event, $item_id, $qty, $this->Application->IsAdmin() ? 1 : null); + $this->AddItemToOrder($event, $item_id, $qty, $this->Application->isAdminUser ? 1 : null); } if ($event->status == erSUCCESS && !$event->redirect) { $event->redirect_params['pass'] = 'm'; $event->redirect_params['pass_category'] = 0; //otherwise mod-rewrite shop-cart URL will include category $event->redirect = true; } else { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { $event->redirect_params['opener'] = 'u'; } } @@ -878,7 +879,7 @@ if ($result) { $event->status = erSUCCESS; - $event->redirect = $this->Application->IsAdmin() ? true : $this->Application->GetVar('shop_cart_template'); + $event->redirect = $this->Application->isAdminUser ? true : $this->Application->GetVar('shop_cart_template'); } else { $event->status = erFAIL; @@ -918,7 +919,7 @@ $ord_item->SetDBField('OptionsSalt', $this->OptionsSalt($options)); $ord_item->Update(); $event->CallSubEvent('OnRecalculateItems'); - if ($event->status == erSUCCESS && $this->Application->IsAdmin()) { + if ($event->status == erSUCCESS && $this->Application->isAdminUser) { $event->redirect_params['opener'] = 'u'; } } @@ -1049,7 +1050,8 @@ { $event->setEventParam('raise_warnings', 0); $passed = parent::getPassedID($event); - if ( $this->Application->IsAdmin() ) { + + if ($this->Application->isAdminUser) { // work as usual in admin return $passed; } @@ -1215,14 +1217,14 @@ $check_cc = $this->Application->GetVar('check_credit_card'); $ord_event = $this->Application->GetVar($event->getPrefixSpecial().'_event'); - if (($ord_event !== 'OnProceedToPreview') && !$this->Application->IsAdmin()) { + if (($ord_event !== 'OnProceedToPreview') && !$this->Application->isAdmin) { // don't check credit card when going from "billing info" to "order preview" step $check_cc = 0; } if ($check_cc && ($field_values['PaymentType'] == $order->GetDBField('PaymentType'))) { // cc check required AND payment type was not changed during SUBMIT - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { $req_fields = array('PaymentCardType', 'PaymentAccount', 'PaymentNameOnCard', 'PaymentCCExpDate'); } else { @@ -1242,7 +1244,10 @@ */ function CheckUser(&$event) { - if ( $this->Application->IsAdmin() ) return; + if ($this->Application->isAdminUser) { + return; + } + $order =& $event->GetObject(); $ses_user = $this->Application->RecallVar('user_id'); @@ -2084,18 +2089,18 @@ function CheckQuantites(&$event) { if ($this->OnRecalculateItems($event)) { // if something has changed in the order - if ( $this->Application->IsAdmin() ) - { + if ($this->Application->isAdminUser) { if ($this->UseTempTables($event)) { $event->redirect = 'in-commerce/orders/orders_edit_items'; } } - else - { + else { $event->redirect = $this->Application->GetVar('viewcart_template'); } + return false; } + return true; } @@ -2635,7 +2640,7 @@ $order =& $this->Application->recallObject('ord'); /* @var $order kDBItem */ - if (!$order->isLoaded() && !$this->Application->IsAdmin()) { + if (!$order->isLoaded() && !$this->Application->isAdmin) { // no order was created before -> create one now if ($this->_createNewCart($event)) { $this->LoadItem($event); @@ -2753,7 +2758,7 @@ } $this->Application->HandleEvent($ord_event, 'ord:OnRecalculateItems'); - /*if ($ord_event->getEventParam('RecalculateChangedCart') && !$this->Application->IsAdmin() ) { + /*if ($ord_event->getEventParam('RecalculateChangedCart') && !$this->Application->isAdmin) { $event->SetRedirectParam('checkout_error', $ord_event->redirect_params['checkout_error']); }*/ } @@ -3814,7 +3819,7 @@ $fields['Number']['format'] = str_replace('%06d', '%0'.$order_number.'d', $fields['Number']['format']); $fields['SubNumber']['format'] = str_replace('%03d', '%0'.$order_sub_number.'d', $fields['SubNumber']['format']); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $user_groups = explode(',', $this->Application->RecallVar('UserGroups')); $default_group = $this->Application->ConfigValue('User_LoggedInGroup'); if (!in_array($default_group, $user_groups)){ @@ -3915,7 +3920,7 @@ */ function checkItemStatus(&$event) { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return true; } @@ -3985,7 +3990,7 @@ $UserName = explode(" ", $object->GetDBField('ShippingTo')); $item_table = TABLE_PREFIX.'OrderItems'; - if ( $this->Application->IsAdmin() ) { + if ($this->Application->isAdminUser) { // this strange contraption actually uses temp table from object (when in temp mode) $order_table = $object->TableName; $item_table = str_replace('Orders', 'OrderItems', $order_table); Index: branches/5.0.x/in-commerce/units/affiliates/affiliates_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return true; } Index: branches/5.0.x/in-commerce/units/currencies/currencies_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/currencies/currencies_event_handler.php (.../currencies_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ addFilter('status_filter', '%1$s.Status = 1'); } - if ( !$this->Application->IsAdmin() ) { + if (!$this->Application->isAdminUser) { $object->addFilter('status_filter', $object->TableName.'.Status = 1'); } } Index: branches/5.0.x/in-commerce/units/products/products_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/products/products_event_handler.php (.../products_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/products/products_event_handler.php (.../products_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ addFilter('not_virtual', '%1$s.Virtual = 0'); - if ( !$this->Application->IsAdmin() ) { + if (!$this->Application->isAdminUser) { $object->addFilter('expire_filter', '%1$s.Expire IS NULL OR %1$s.Expire > UNIX_TIMESTAMP()'); } @@ -1226,9 +1226,10 @@ return $passed; } - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // we may get product id out of OrderItem, if it exists $ord_item =& $this->Application->recallObject('orditems', null, Array ('raise_warnings' => 0)); + if ($ord_item->GetDBField('ProductId')) { $passed = $ord_item->GetDBField('ProductId'); } Index: branches/5.0.x/in-commerce/units/gateways/gw_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/gateways/gw_event_handler.php (.../gw_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/gateways/gw_event_handler.php (.../gw_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) return ; - $fh=opendir(GW_CLASS_PATH); + if (!$this->Application->isAdminUser) { + return ; + } + + $fh = opendir(GW_CLASS_PATH); + while( $entry=readdir($fh) ) { if ( !is_file(GW_CLASS_PATH.'/'.$entry) ) continue; Index: branches/5.0.x/in-commerce/units/gateways/gw_classes/authorizenet.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/gateways/gw_classes/authorizenet.php (.../authorizenet.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/gateways/gw_classes/authorizenet.php (.../authorizenet.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin())) return false; + if( ($item_data['PortalUserId'] != $gw_responce['customer_id']) && ($gw_repsponce['customer_id'] != -2 && !$this->Application->isAdmin)) return false; if( ( strtolower($gw_responce['transaction_type']) == 'auth_only') ) { Index: branches/5.0.x/in-commerce/units/shipping_quote_engines/custom_shipping_quote_engine.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/shipping_quote_engines/custom_shipping_quote_engine.php (.../custom_shipping_quote_engine.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/shipping_quote_engines/custom_shipping_quote_engine.php (.../custom_shipping_quote_engine.php) (revision 12722) @@ -1,6 +1,6 @@ QueryShippingCost($params['dest_country'], $params['dest_state'], $params['dest_postal'], $default_pack['weight'], $params['items'], $params['amount'], $params['shipping_type'], $params['promo_params']); $shipping_types = $db->Query($query, 'ShippingId'); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $user_groups = explode(',', $this->Application->RecallVar('UserGroups')); $filteres_shipping_types = array(); foreach ($shipping_types as $key=>$shipping_type) { Index: branches/5.0.x/in-commerce/units/manufacturers/manufacturers_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) { - return true; + if ($this->Application->isAdminUser) { + return ; } $category_id = $this->Application->GetVar('m_cat_id'); Index: branches/5.0.x/in-commerce/units/addresses/addresses_event_handler.php =================================================================== diff -u -r12674 -r12722 --- branches/5.0.x/in-commerce/units/addresses/addresses_event_handler.php (.../addresses_event_handler.php) (revision 12674) +++ branches/5.0.x/in-commerce/units/addresses/addresses_event_handler.php (.../addresses_event_handler.php) (revision 12722) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return ; } @@ -128,7 +128,7 @@ */ function setNextTemplate(&$event) { - if($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return ; } @@ -268,7 +268,7 @@ */ function checkItemStatus(&$event) { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { return true; }