$id = intval($_POST['opid']);
     $theme = substr(change_q_x($_POST['comment'], false, false, 'br|b|i'), 0, 3000);
     if (!$uid) {
         $com_error_flag = 1;
     }
     if (!$theme) {
         $com_error_flag = 1;
         $com_alert[2] = "Поле заполнено некорректно";
     }
     if (strlen($_POST['comment']) > 3000) {
         $com_error_flag = 1;
         $com_alert[2] = "Слишком большой комментарий. Допускается не более 3000 знаков";
     }
     $com_msg = $theme;
     if (!$com_error_flag) {
         $error .= opinions::newCommentOpinion($theme, $uid, $id);
     }
     if (!$error && !$com_error_flag) {
         unset($theme);
         unset($action);
     }
     break;
 case "edit":
     $edit_tr = intval(trim($_GET['msg']));
     if ($edit_tr) {
         $edit_msg = opinions::GetMsgInfo($edit_tr, $error);
         if ($edit_msg['fromuser_id'] != $uid && !hasPermissions('users')) {
             unset($edit_msg);
             unset($action);
         }
     }
Beispiel #2
0
function EditOpinionComm($op_id, $comm_id, $text, $from = 'frl', $isFeedback = false)
{
    @session_start();
    $objResponse = new xajaxResponse();
    $text = trim($text);
    if ($text == '') {
        $objResponse->script("opinionCommentFormError('{$op_id}');");
    } elseif (strlen(stripslashes($text)) > opinions::$comment_max_length) {
        $objResponse->script("opinionMaxLengthError('edit_comm_{$op_id}', " . opinions::$comment_max_length . ');');
    } else {
        if ($isFeedback) {
            $msg = sbr_meta::getFeedback($op_id, true);
        } else {
            $msg = opinions::GetMessageById($op_id);
        }
        $text = str_replace('&', '&', $text);
        $text = stripslashes($text);
        $text = change_q_x($text, FALSE, TRUE, '', false, false);
        $prefix = $isFeedback ? 'feedback_' : '';
        if ((int) $comm_id > 0) {
            // Редактируем
            if ($isFeedback) {
                opinions::editCommentFeedback($text, get_uid(false), $comm_id, $msg['fromuser_id']);
            } else {
                opinions::editCommentOpinion($text, get_uid(false), $comm_id);
            }
            $objResponse->script("\$('" . $prefix . "comment_content_{$op_id}').setStyle('display', '');\n                                  \$('" . $prefix . "opinion_btn_edit_comment_{$op_id}').setProperty('disabled', '');\n                              \$('" . $prefix . "ed_comm_form_{$op_id}').dispose();");
            //$objResponse->assign($prefix . "comment_text_{$op_id}", "innerHTML", $text);
            $html = opinions::printCommentOpinions($op_id, $isFeedback);
            $objResponse->script("\$('" . $prefix . "comment_cont_{$op_id}').empty()");
            $objResponse->append($prefix . "comment_cont_{$op_id}", 'innerHTML', $html);
        } else {
            // Добавляем
            if ($isFeedback) {
                opinions::newCommentFeedback($text, get_uid(false), $op_id);
            } else {
                opinions::newCommentOpinion($text, get_uid(false), $op_id);
            }
            $html = opinions::printCommentOpinions($op_id, $isFeedback);
            $objResponse->script("\$('" . $prefix . "ed_comm_form_{$op_id}').dispose();");
            $objResponse->append($prefix . "comment_cont_{$op_id}", 'innerHTML', $html);
        }
        $objResponse->script("opinionCheckMaxLengthStop('" . $prefix . "edit_comm_{$op_id}');");
    }
    return $objResponse;
}