예제 #1
0
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;
    }
    if ($ret) {
        redirect_header($wtopic ? 'forum.php?id=' . $forum->id() : 'topic.php?id=' . $topic->id(), 1, $wtopic ? __('Topic deleted successfully!', 'bxpress') : __('Post deleted successfully!', 'bxpress'));
    } else {
        redirect_header('topic.php?pid=' . $id, 1, ($wtopic ? __('The topic could not be deleted!', 'bxpress') : __('The post could not be deleted!', 'bxpress')) . '<br />' . ($wtopic ? $topic->errors() : $post->errors()));
    }
} else {
    include 'header.php';
    //include '../../header.php';
    $myts =& MyTextSanitizer::getInstance();
    $hiddens['ok'] = 1;
예제 #2
0
 $post->setForum($forum->id());
 $post->setDate(time());
 $post->setUser($xoopsUser ? $xoopsUser->uid() : 0);
 $post->setUname($xoopsUser ? $xoopsUser->uname() : $name);
 $post->setIP($_SERVER['REMOTE_ADDR']);
 $post->setHTML(isset($dohtml) ? 1 : 0);
 $post->setBBCode(isset($doxcode) ? 1 : 0);
 $post->setSmiley(isset($dosmiley) ? 1 : 0);
 $post->setBR(isset($dobr) ? 1 : 0);
 $post->setImage(isset($doimg) ? 1 : 0);
 $post->setIcon('');
 $post->setApproved($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'approve'));
 $post->setSignature(isset($sig) ? 1 : 0);
 $post->setText($msg);
 if (!$post->save() && $create) {
     $topic->delete();
     redirect_header($retlink, 2, __('Message could not be posted! Please try again', 'bxpress'));
     die;
 }
 if (!$topic->approved()) {
     bXFunctions::notifyAdmin($forum->moderators(), $forum, $topic, $post);
 }
 // Adjuntamos archivos si existen
 if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) {
     $folder = $xoopsModuleConfig['attachdir'];
     $exts = array();
     include_once RMCPATH . '/class/uploader.php';
     $up = new RMFileUploader($folder, $xoopsModuleConfig['maxfilesize'] * 1024, $forum->extensions());
     $errors = '';
     $filename = '';
     if ($up->fetchMedia('attach')) {
예제 #3
0
 /**
  * @desc Elimina un foro junto con sus temas y mensajes
  */
 public function delete()
 {
     $sql = "SELECT * FROM " . $this->db->prefix("mod_bxpress_topics") . " WHERE id_forum='" . $this->id() . "'";
     $result = $this->db->query($sql);
     while ($row = $this->db->fetchArray($result)) {
         $topic = new bXTopic();
         $topic->assignVars($row);
         $topic->delete();
     }
     return $this->deleteFromTable();
 }
예제 #4
0
/**
* @desc Eliminar temas
*/
function deleteTopics()
{
    global $db, $xoopsModuleConfig, $bxpress, $forum, $xoopsUser, $xoopsSecurity;
    $ok = isset($_POST['ok']) ? $_POST['ok'] : 0;
    $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null;
    if (empty($topics) || is_array($topics) && empty($topics)) {
        redirect_header('moderate.php?id=' . $forum->id(), 2, __('Select at least one topic to delete!', 'bxpress'));
        die;
    }
    $topics = !is_array($topics) ? array($topics) : $topics;
    $lastpost = false;
    if (!$xoopsSecurity->check()) {
        redirect_header('moderate.php?id=' . $forum->id(), 2, __('Session token expired!', 'bxpress'));
        die;
    }
    foreach ($topics as $k) {
        $topic = new bXTopic($k);
        if ($topic->isNew()) {
            continue;
        }
        if ($topic->forum() != $forum->id()) {
            continue;
        }
        //Verificamos si el tema contiene el último mensaje del foro
        if (!$lastpost && array_key_exists($forum->lastPostId(), $topic->getPosts(0))) {
            $lastpost = true;
        }
        $topic->delete();
    }
    //Actualizamos el último mensaje del foro
    if ($lastpost) {
        $forum = new bXForum($forum->id());
        $post = $forum->getLastPost();
        $forum->setPostId($post);
        $forum->save();
    }
    redirect_header('moderate.php?id=' . $forum->id(), 1, __('Action completed!', 'bxpress'));
}