示例#1
0
function EditOpinion($op_id, $message, $rating, $counter, $from = 'frl')
{
    @session_start();
    $objResponse = new xajaxResponse();
    $message = trim($message);
    if (!in_array($rating, array(-1, 0, 1))) {
        $objResponse->assign('rating_error', 'innerHTML', 'Вы не выбрали категорию отзыва');
    } elseif ($message == '') {
        $objResponse->script("opinionFormError('error_edit_msg_{$op_id}');");
    } elseif (strlen($message) > opinions::$opinion_max_length) {
        $objResponse->script("opinionMaxLengthError('edit_msg_{$op_id}', " . opinions::$opinion_max_length . ');');
    } else {
        $message = str_replace('&', '&', $message);
        $message = stripslashes($message);
        $message = change_q_x($message, FALSE, TRUE, '', false, false);
        $msg = opinions::GetMessageById($op_id);
        $old_rating = $msg['rating'];
        if (get_uid(0) == $msg['fromuser_id'] || hasPermissions('users')) {
            $error = opinions::Edit($msg['fromuser_id'], $op_id, $message, $rating, getRemoteIP(), hasPermissions('users'), get_uid(0));
        } else {
            $error = 'Ошибка';
        }
        if (!$error) {
            $msg = opinions::GetMessageById($op_id);
            if ($msg) {
                $user = new users();
                $user->GetUserByUID($_SESSION['page_user_id']);
                $objResponse->assign('opid_' . $op_id, 'innerHTML', opinions::printTheme($msg, $from, $counter, false));
                $ot = $old_rating == 1 ? 'plus' : ($old_rating == -1 ? 'minus' : 'neitral');
                $nt = $rating == 1 ? 'plus' : ($rating == -1 ? 'minus' : 'neitral');
                $objResponse->call('opinionChConuters', 'ops-' . $from . $ot, 'ops-' . $from . $nt);
                $block_class = 'ops-one-' . $nt;
                $objResponse->script("\$('opid_{$op_id}').removeClass('ops-one-plus').removeClass('ops-one-neitral').removeClass('ops-one-minus');");
                $objResponse->script("\$('opid_{$op_id}').addClass('{$block_class}')");
                $objResponse->script("opinionCheckMaxLengthStop('edit_msg_{$op_id}');");
            } else {
                $objResponse->script("alert('" . serialize($msg) . "')");
            }
        } else {
            $objResponse->script("alert('" . $error . "')");
        }
    }
    return $objResponse;
}
示例#2
0
            $error .= opinions::editCommentOpinion($theme, $uid, $id_edit);
            unset($theme);
            unset($action);
        }
        break;
    case "change":
        $theme = substr(change_q_x($_POST['msg'], false, false, 'br|b|i'), 0, 2000);
        $rating = intval($_POST['rating']);
        if ($rating !== -1 && $rating !== 0 && $rating !== 1) {
            header("Location: /404.php");
            exit;
        }
        $msgid = intval($_POST['msgid']);
        if ($_SESSION['uid'] && $msgid) {
            if ($theme || $attach['name']) {
                $error = opinions::Edit($_SESSION['uid'], $msgid, $theme, $rating, getRemoteIP(), hasPermissions('users'));
            } elseif (!$theme) {
                $error_flag = 1;
                $alert[2] = "Поле заполнено некорректно";
            }
            if ($error || $error_flag) {
                $action = "edit";
            } else {
                unset($msg_name);
                unset($theme);
                //header("Location: /blogs/viewgroup.php?gr=$gr&t=$t");
            }
        }
        break;
}
$ppage = trim($_GET['page']);