コード例 #1
0
ファイル: discount.php プロジェクト: DarneoStudio/bitrix
 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;
 }
コード例 #2
0
ファイル: discount.php プロジェクト: rasuldev/torino
 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;
 }
コード例 #3
0
$tabControl->EndCustomField("LAST_DISCOUNT", '<input type="hidden" name="LAST_DISCOUNT" value="' . htmlspecialcharsbx($arDiscount['LAST_DISCOUNT']) . '">');
$tabControl->BeginNextFormTab();
$tabControl->AddSection("BT_SALE_DISCOUNT_SECT_APP", GetMessage("BT_SALE_DISCOUNT_SECTIONS_APP"));
$tabControl->BeginCustomField("ACTIONS", GetMessage('BT_SALE_DISCOUNT_EDIT_FIELDS_APP') . ":", false);
?>
<tr id="ACTIONS">
		<td valign="top" colspan="2"><div id="tree_actions" style="position: relative; z-index: 1;"></div><?php 
if (!is_array($arDiscount['APPICATIONS'])) {
    if (CheckSerializedData($arDiscount['APPICATIONS'])) {
        $arDiscount['APPICATIONS'] = unserialize($arDiscount['APPICATIONS']);
    } else {
        $arDiscount['APPICATIONS'] = '';
    }
}
$arCondParams = array('FORM_NAME' => 'sale_discount_form', 'CONT_ID' => 'tree_actions', 'JS_NAME' => 'JSSaleAct', 'PREFIX' => 'actrl', 'INIT_CONTROLS' => array('SITE_ID' => $arDiscount['LID'], 'CURRENCY' => CSaleLang::GetLangCurrency($arDiscount['LID'])), 'SYSTEM_MESSAGES' => array('SELECT_CONTROL' => GetMessage('BT_SALE_DISCOUNT_ACTIONS_SELECT_CONTROL'), 'ADD_CONTROL' => GetMessage('BT_SALE_DISCOUNT_ACTIONS_ADD_CONTROL'), 'DELETE_CONTROL' => GetMessage('BT_SALE_DISCOUNT_ACTIONS_DELETE_CONTROL')));
$obAct = new CSaleActionTree();
$boolAct = $obAct->Init(BT_COND_MODE_DEFAULT, BT_COND_BUILD_SALE_ACTIONS, $arCondParams);
if (!$boolAct) {
    if ($ex = $APPLICATION->GetException()) {
        echo $ex->GetString() . "<br>";
    }
} else {
    $obAct->Show($arDiscount['ACTIONS']);
}
?>
</td>
	</tr><?php 
$strHidden = '';
$strApp = base64_encode(serialize($arDiscount['ACTIONS']));
$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"));
コード例 #4
0
 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;
 }