protected function __UpdateGroupsCache($intID, $arGroups = array())
 {
     global $DB;
     $intID = intval($intID);
     if (0 >= $intID) {
         return false;
     }
     if (!is_array($arGroups) || empty($arGroups)) {
         $rsDiscGroups = CCatalogDiscountSave::GetGroupByDiscount(array(), array('DISCOUNT_ID' => $intID), false, false, array('GROUP_ID'));
         while ($arDiscGroup = $rsDiscGroups->Fetch()) {
             $arGroups[] = $arDiscGroup['GROUP_ID'];
         }
     }
     if (empty($arGroups)) {
         return false;
     }
     $arDiscountSaveGroups = array();
     $strDataFileName = CATALOG_DISCOUNT_SAVE_FILE;
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $strDataFileName) && is_file($_SERVER["DOCUMENT_ROOT"] . $strDataFileName)) {
         include $_SERVER["DOCUMENT_ROOT"] . $strDataFileName;
     }
     if (!empty($arDiscountSaveGroups)) {
         foreach ($arDiscountSaveGroups as $intGroup => $arCurDisc) {
             $key = array_search($intID, $arCurDisc);
             if (false !== $key) {
                 unset($arDiscountSaveGroups[$intGroup][$key]);
                 if (empty($arDiscountSaveGroups[$intGroup])) {
                     unset($arDiscountSaveGroups[$intGroup]);
                 }
             }
         }
     }
     foreach ($arGroups as &$intGroup) {
         if (isset($arDiscountSaveGroups[$intGroup])) {
             if (!in_array($intID, $arDiscountSaveGroups[$intGroup])) {
                 $arDiscountSaveGroups[$intGroup][] = $intID;
             }
         } else {
             $arDiscountSaveGroups[$intGroup] = array();
             $arDiscountSaveGroups[$intGroup][] = $intID;
         }
     }
     if (isset($intGroup)) {
         unset($intGroup);
     }
     ignore_user_abort(true);
     if ($fp = @fopen($_SERVER["DOCUMENT_ROOT"] . $strDataFileName, "wb")) {
         if (flock($fp, LOCK_EX)) {
             fwrite($fp, "<" . "?\n");
             fwrite($fp, "\$arDiscountSaveGroups=unserialize('" . serialize($arDiscountSaveGroups) . "');");
             fwrite($fp, "if(!is_array(\$arDiscountSaveGroups))\$arDiscountSaveGroups=array();\n");
             fwrite($fp, "?" . ">");
             fflush($fp);
             flock($fp, LOCK_UN);
             fclose($fp);
         }
     }
     ignore_user_abort(false);
     return true;
 }
$str_COUNT_SIZE = 0;
$str_COUNT_TYPE = 'M';
$str_COUNT_FROM = '';
$str_COUNT_TO = '';
$str_ACTION_SIZE = 0;
$str_ACTION_TYPE = 'M';
$arRanges = array();
$arGroupList = array();
if ($ID > 0) {
    $rsDiscSaves = CCatalogDiscountSave::GetByID($ID);
    if (!$rsDiscSaves->ExtractFields("str_")) {
        $ID = 0;
    }
}
if ($ID > 0) {
    $rsDiscGroups = CCatalogDiscountSave::GetGroupByDiscount(array(), array('DISCOUNT_ID' => $ID));
    while ($arDiscGroup = $rsDiscGroups->Fetch()) {
        $arGroupList[] = $arDiscGroup['GROUP_ID'];
    }
    $rsDiscRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'ASC'), array('DISCOUNT_ID' => $ID));
    while ($arDiscRange = $rsDiscRanges->Fetch()) {
        $arRanges[] = $arDiscRange;
    }
}
if (!isset($COUNT_PERIOD)) {
    if ('' != $str_COUNT_FROM || '' != $str_COUNT_TO) {
        $str_COUNT_PERIOD = 'D';
    } elseif (0 < intval($str_COUNT_SIZE)) {
        $str_COUNT_PERIOD = 'P';
    } else {
        $str_COUNT_PERIOD = 'U';