die; } $post = new bXPost($id); if ($post->isNew()) { redirect_header('./', 2, __('Specified post does not exists!', 'bxpress')); die; } $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); // Verificamos que el usuario tenga permiso if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'delete')) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress')); die; } // Verificamos si el usuario tiene permiso de eliminación para el post if ($xoopsUser->uid() != $post->user() && (!$xoopsUser->isAdmin() && !$forum->isModerator($xoopsUser->uid()))) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress')); die; } if ($ok) { if (!$xoopsSecurity->check()) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Session token expired!', 'bxpress')); die; } if ($post->id() == bXFunctions::getFirstId($topic->id())) { $ret = $topic->delete(); $wtopic = true; } else { $ret = $post->delete(); $wtopic = false; }
$tbl3 = $db->prefix("mod_bxpress_likes"); $sql = "SELECT\n posts.*,\n texts.*,\n (SELECT COUNT(*) FROM {$tbl1} WHERE parent=posts.id_post) as replies,\n GROUP_CONCAT(tlikes.uid ORDER BY " . ($xoopsUser ? "tlikes.uid=" . $xoopsUser->uid() . ' DESC' : 'tlikes.uid') . ") as liked\n FROM\n {$tbl1} posts\n LEFT JOIN {$tbl3} tlikes ON tlikes.post=posts.id_post\n INNER JOIN {$tbl2} texts ON texts.post_id=posts.id_post\n WHERE\n posts.id_topic='" . $topic->id() . "'\n AND\n texts.post_id=posts.id_post\n GROUP BY\n posts.id_post\n ORDER BY\n posts.post_time ASC,\n posts.parent ASC\n LIMIT\n {$start},{$limit}"; $result = $db->query($sql); $users = array(); $posts_ids = array(); $posts = array(); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); // Permisos de edición y eliminación $canedit = $moderator || $admin ? true : $edit && $post->isOwner(); $candelete = $moderator || $admin ? true : $delete && $post->isOwner(); //Permiso de visualizar mensaje $canshow = $moderator || $admin ? true : false; // Datos del usuario if ($post->user() > 0) { if (!isset($users[$post->user()])) { $users[$post->user()] = new XoopsUser($post->user()); } $bbUser = $users[$post->user()]; $userData = array(); $userData['id'] = $bbUser->uid(); $userData['uname'] = $bbUser->uname(); $userData['name'] = $bbUser->getVar('name') != '' ? $bbUser->getVar('name') : $bbUser->uname(); //$userData['rank'] = $ranks[$bbUser->getVar('rank')]['title']; //$userData['rank_image'] = $ranks[$bbUser->getVar('rank')]['image']; $userData['registered'] = sprintf(__('Registered: %s', 'bxpress'), date($mc['dates'], $bbUser->getVar('user_regdate'))); $userData['avatar'] = RMEvents::get()->run_event("rmcommon.get.avatar", $bbUser->getVar('email'), 0); $userData['posts'] = sprintf(__('Posts: %u', 'bxpress'), $bbUser->getVar('posts')); if ($xoopsUser && ($moderator || $admin)) { $userData['ip'] = sprintf(__('IP: %s', 'bxpress'), $post->ip());