protected function prepareDiscountConditions(&$conditions, &$result, &$handlers, $type, $site) { global $APPLICATION; $obCond = null; $result = ''; $handlers = array(); $type = (int) $type; if ($type != self::PREPARE_CONDITIONS && $type != self::PREPARE_ACTIONS || empty($conditions)) { return false; } if (!is_array($conditions)) { if (!CheckSerializedData($conditions)) { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS"), "CONDITIONS"); } else { $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT"), "ACTIONS"); } return false; } $conditions = unserialize($conditions); if (!is_array($conditions) || empty($conditions)) { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS"), "CONDITIONS"); } else { $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT"), "ACTIONS"); } return false; } } if ($type == self::PREPARE_CONDITIONS) { $obCond = new CSaleCondTree(); $boolCond = $obCond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_SALE, array('INIT_CONTROLS' => array('SITE_ID' => $site, 'CURRENCY' => CSaleLang::GetLangCurrency($site)))); } else { $obCond = new CSaleActionTree(); $boolCond = $obCond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_SALE_ACTIONS, array()); } if (!$boolCond) { return false; } $result = $obCond->Generate($conditions, array('ORDER' => '$arOrder', 'ORDER_FIELDS' => '$arOrder', 'ORDER_PROPS' => '$arOrder[\'PROPS\']', 'ORDER_BASKET' => '$arOrder[\'BASKET_ITEMS\']', 'BASKET' => '$arBasket', 'BASKET_ROW' => '$row')); if ($result == '') { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS'), 'CONDITIONS'); } else { $APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT'), 'ACTIONS'); } return false; } else { $handlers['HANDLERS'] = $obCond->GetConditionHandlers(); $handlers['ENTITY'] = $obCond->GetUsedEntityList(); $handlers['EXECUTE_MODULE'] = $obCond->GetExecuteModule(); } $conditions = serialize($conditions); return true; }
protected function prepareDiscountConditions(&$conditions, &$result, &$handlers, $type) { global $APPLICATION; $obCond = null; $result = ''; $handlers = array(); $type = (int) $type; if ($type != self::PREPARE_CONDITIONS && $type != self::PREPARE_ACTIONS || empty($conditions)) { return false; } if (!is_array($conditions)) { if (!CheckSerializedData($conditions)) { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS"), "CONDITIONS"); } else { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT"), "ACTIONS"); } return false; } $conditions = unserialize($conditions); if (!is_array($conditions) || empty($conditions)) { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS"), "CONDITIONS"); } else { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT"), "ACTIONS"); } return false; } } if ($type == self::PREPARE_CONDITIONS) { $obCond = new CSaleCondTree(); $boolCond = $obCond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_SALE, array()); } else { $obCond = new CSaleActionTree(); $boolCond = $obCond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_SALE_ACTIONS, array()); } if (!$boolCond) { return false; } $result = $obCond->Generate($conditions, array('ORDER' => '$arOrder', 'ORDER_FIELDS' => '$arOrder', 'ORDER_PROPS' => '$arOrder[\'PROPS\']', 'ORDER_BASKET' => '$arOrder[\'BASKET_ITEMS\']', 'BASKET' => '$arBasket', 'BASKET_ROW' => '$row')); if ($result == '') { if ($type == self::PREPARE_CONDITIONS) { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_CONDITIONS"), "CONDITIONS"); } else { $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_BAD_ACTIONS_EXT"), "ACTIONS"); } return false; } else { $handlers = $obCond->GetConditionHandlers(); } $conditions = serialize($conditions); return true; }
$tabControl->EndCustomField('ACTIONS', '<input type="hidden" name="ACTIONS" value="' . htmlspecialcharsbx($strApp) . '">' . '<input type="hidden" name="ACTIONS_CHECK" value="' . htmlspecialcharsbx(md5($strApp)) . '">'); $tabControl->AddSection("BT_SALE_DISCOUNT_SECT_COND", GetMessage("BT_SALE_DISCOUNT_SECTIONS_COND_ADD")); $tabControl->BeginCustomField("CONDITIONS", GetMessage('BT_SALE_DISCOUNT_EDIT_FIELDS_COND_ADD') . ":", false); ?> <tr id="tr_CONDITIONS"> <td valign="top" colspan="2"><div id="tree" style="position: relative; z-index: 1;"></div><?php if (!is_array($arDiscount['CONDITIONS'])) { if (CheckSerializedData($arDiscount['CONDITIONS'])) { $arDiscount['CONDITIONS'] = unserialize($arDiscount['CONDITIONS']); } else { $arDiscount['CONDITIONS'] = ''; } } $arCondParams = array('FORM_NAME' => 'sale_discount_form', 'CONT_ID' => 'tree', 'JS_NAME' => 'JSSaleCond', 'INIT_CONTROLS' => array('SITE_ID' => $arDiscount['LID'], 'CURRENCY' => CSaleLang::GetLangCurrency($arDiscount['LID']))); $obCond = new CSaleCondTree(); $boolCond = $obCond->Init(BT_COND_MODE_DEFAULT, BT_COND_BUILD_SALE, $arCondParams); if (!$boolCond) { if ($ex = $APPLICATION->GetException()) { echo $ex->GetString() . "<br>"; } } else { $obCond->Show($arDiscount['CONDITIONS']); } ?> </td> </tr><?php $strHidden = ''; $strCond = base64_encode(serialize($arDiscount['CONDITIONS'])); $tabControl->EndCustomField('CONDITIONS', '<input type="hidden" name="CONDITIONS" value="' . htmlspecialcharsbx($strCond) . '">' . '<input type="hidden" name="CONDITIONS_CHECK" value="' . htmlspecialcharsbx(md5($strCond)) . '">'); $tabControl->BeginNextFormTab(); $tabControl->BeginCustomField('USER_GROUPS', GetMessage('BT_SALE_DISCOUNT_EDIT_FIELDS_GROUPS') . ':', true);
protected function __SetOldFields($strAction, &$arFields) { global $APPLICATION; $arMsg = array(); $boolResult = true; $strAction = ToUpper($strAction); if (array_key_exists('CONDITIONS', $arFields) && !empty($arFields['CONDITIONS'])) { $arConditions = false; if (!is_array($arFields['CONDITIONS'])) { if (CheckSerializedData($arFields['CONDITIONS'])) { $arConditions = unserialize($arFields['CONDITIONS']); } } else { $arConditions = $arFields['CONDITIONS']; } if (is_array($arConditions) && !empty($arConditions)) { $obCond = new CSaleCondTree(); $boolCond = $obCond->Init(BT_COND_MODE_SEARCH, BT_COND_BUILD_SALE, array()); if ($boolCond) { $arResult = $obCond->GetConditionValues($arConditions); } } } if (array_key_exists('ACTIONS', $arFields) && !empty($arFields['ACTIONS'])) { $arActions = false; if (!is_array($arFields['ACTIONS'])) { if (CheckSerializedData($arFields['ACTIONS'])) { $arActions = unserialize($arFields['ACTIONS']); } } else { $arActions = $arFields['ACTIONS']; } if (is_array($arActions) && !empty($arActions)) { $obAct = new CSaleActionTree(); $boolAct = $obAct->Init(BT_COND_MODE_SEARCH, BT_COND_BUILD_SALE_ACTIONS, array()); if ($boolAct) { $arResult = $obAct->GetConditionValues($arActions); } } } if (!$boolResult) { $obError = new CAdminException($arMsg); $APPLICATION->ThrowException($obError); } return $boolResult; }