} $comment = new RMComment($id); if ($comment->isNew()) { redirect_header(XOOPS_URL, 1, __('Specified comment does not exist!', 'rmcommon')); die; } $status = $xoopsUser->isAdmin($comment->getVar('id_obj')) ? rmc_server_var($_POST, 'status', $comment->getVar('status')) : $comment->getVar('status'); $status = $status == 'approved' ? $status : 'unapproved'; $user = $xoopsUser->isAdmin($comment->getVar('id_obj')) ? rmc_server_var($_POST, 'user', $xoopsUser->getVar('uid')) : $xoopsUser->getVar('uid'); $content = rmc_server_var($_POST, 'content', ''); if ($content == '') { redirect_header('post_comment.php?id=' . $id . '&ret=' . urlencode($ret) . '&action=edit', 2, __('You must provide a text for comment!', 'rmcommon')); die; } // save basic info in comment object $comment->setVar('content', $content); $comment->setVar('status', $status); // Modify, if neccessary, the user $cuser = new RMCommentUser($comment->getVar('user')); if ($cuser->getVar('xuid') != $user) { if ($user == 0) { $cuser->setVar('xuid', 0); $cuser->save(); } else { $xuser = new XoopsUser($user); $cuser = new RMCommentUser($xuser->getVar('email')); $cuser->setVar('name', $xuser->getVar('uname')); $cuser->setVar('email', $xuser->getVar('email')); $cuser->setVar('xuid', $user); $cuser->setVar('url', $xuser->getVar('url')); $cuser->save();
function save_comment() { global $xoopsSecurity; $id = rmc_server_var($_POST, 'id', 0); $page = rmc_server_var($_POST, 'page', 1); $filter = rmc_server_var($_POST, 'filter', ''); $w = rmc_server_var($_POST, 'w', '1'); $qs = "id={$id}&w={$w}&page={$page}&filter={$filter}"; if (!$xoopsSecurity->check()) { redirectMsg('comments.php?action=edit&' . $qs, __('Sorry, session token expired!', 'rmcommon'), 1); die; } if ($id <= 0) { redirectMsg('comments.php', __('Comment ID not specified!', 'rmcommon'), 1); die; } $comment = new RMComment($id); if ($comment->isNew()) { redirectMsg('comments.php?' . $qs, __('Specified comment does not exist!', 'rmcommon'), 1); die; } $status = rmc_server_var($_POST, 'status', 'unapproved'); $status = $status == 'approved' ? $status : 'unapproved'; $user = rmc_server_var($_POST, 'user', 0); $content = rmc_server_var($_POST, 'content', ''); // save basic info in comment object $comment->setVar('content', $content); $comment->setVar('status', $status); // Modify, if neccessary, the user $cuser = new RMCommentUser($comment->getVar('user')); if ($cuser->getVar('xuid') != $user) { if ($user == 0) { $cuser->setVar('xuid', 0); $cuser->save(); } else { $xuser = new XoopsUser($user); $cuser = new RMCommentUser($xuser->getVar('email')); $cuser->setVar('name', $xuser->getVar('uname')); $cuser->setVar('email', $xuser->getVar('email')); $cuser->setVar('xuid', $user); $cuser->setVar('url', $xuser->getVar('url')); $cuser->save(); } $comment->setVar('user', $cuser->id()); } if ($comment->save()) { redirectMsg('comments.php?' . $qs, __('Comment updated successfully!', 'rmcommon'), 0); } else { redirectMsg('comments.php?action=edit&' . $qs, __('Errros ocurrs while trying to update comment!', 1) . '<br />' . $comment->errors(), 1); } }