Ejemplo n.º 1
0
    while ($ar_fields = $res->GetNext()) {
        $n++;
        // ай пока что через пень-колоду
    }
    global $CACHE_MANAGER;
    $CACHE_MANAGER->ClearByTag('iblock_id_9');
    // абы што
    CIBlockElement::SetPropertyValuesEx($itemID, false, array('COMMNETS_CNT' => $n));
}
CModule::IncludeModule('iblock');
$res = CIBlockElement::GetByID($id);
if ($comment = $res->GetNext()) {
    if ($comment['IBLOCK_ID'] != COption::GetOptionString('comments', 'iblock')) {
        die('err1');
    }
    if ($comment['CREATED_BY'] != $USER->GetID()) {
        die('err2');
    }
    $_REQUEST['text'] = trim($_REQUEST['text']);
    switch ($action) {
        case 'edit':
            $el = new CIBlockElement();
            $el->Update($id, array("PREVIEW_TEXT" => $_REQUEST['text']));
            break;
        case 'delete':
            CIBlockElement::Delete($id);
            $itemID = intval($_REQUEST['item']);
            reCalculateCommentsCnt($itemID);
            break;
    }
}
Ejemplo n.º 2
0
    if (!$arResult['ERROR']) { 
        CModule::IncludeModule('iblock');
        $el = new CIBlockElement; 
        $arLoadProductArray = Array(
            "MODIFIED_BY" => $USER->GetID(),
            "IBLOCK_SECTION_ID" => false,
            "IBLOCK_ID" => COMMENTS_IBLOCK_ID,
            "DATE_ACTIVE_FROM" => ConvertTimeStamp(false, 'FULL'),
            "PROPERTY_VALUES" => $PROP,
            "NAME" => TruncateText($_REQUEST['commment'], 255),
            "ACTIVE" => "Y",
            "PREVIEW_TEXT" => TruncateText($_REQUEST['commment'], 5000)
        ); 
        if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
            $arResult['OK'] = true;
            reCalculateCommentsCnt($arParams['ID']);
        } else {
            $arResult['ERROR'] = $el->LAST_ERROR;
        }
    }
}

$arResult['USER_ID'] = $USER->GetID();

$cache_id = serialize($arParams); 
$cache_dir = '/comments';
$obCache = new CPHPCache;
if ($obCache->InitCache($arParams['CACHE_TIME'], $cache_id, $cache_dir)) {
    
    $arResult = $obCache->GetVars();