Пример #1
0
         $topic->setDate(time());
         $topic->setTitle($myts->addSlashes($subject));
         if ($xoopsUser && isset($sticky) && $xoopsModuleConfig['sticky']) {
             if ($xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts'] && $xoopsUser->uid() == $topic->poster()) {
                 $topic->setSticky($sticky);
             }
         }
     }
     $post->setPid(0);
     $post->setIP($_SERVER['REMOTE_ADDR']);
     $post->setIcon('');
     $post->setSignature(isset($sig) ? 1 : 0);
     if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'approve') || $xoopsUser->isAdmin() || $forum->isModerator()) {
         $post->setText($msg);
     } else {
         $post->setEditText($msg);
         bXFunctions::notifyAdmin($forum->moderators(), $forum, $topic, $post, 1);
     }
     if (!$post->save() || !$topic->save()) {
         redirect_header('edit.php?id=' . $id, 2, __('Changes could not be stored. Please try again!', 'bxpress'));
         die;
     }
     redirect_header('topic.php?pid=' . $post->id() . '#p' . $post->id(), 1, __('Changes stored successfully!', 'bxpress'));
     break;
 case 'delete':
     /**
      * Eliminamos archivos siempre y cuando el usuario se al propietario
      * del mensaje, sea administrador o moderador
      */
     if (!$xoopsSecurity->check()) {
         redirect_header('edit.php?id=' . $post->id() . '#attachments', 2, __('Session token expired!', 'bxpress'));
Пример #2
0
/**
* @desc Aprueba o no un mensaje editado
**/
function approvedPosts($app = 0)
{
    global $xoopsUser, $xoopsSecurity;
    $posts = isset($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0;
    //Verifica que el mensaje sea válido
    if ($posts <= 0) {
        redirect_header('./topic.php?id=' . $posts, 1, __('Topic not valid!', 'bxpress'));
        die;
    }
    //Comprueba que el mensaje exista
    $post = new bXPost($posts);
    if ($post->isNew()) {
        redirect_header('./topic.php?id=' . $posts, 1, __('Post doesn\'t exists!', 'bxpress'));
        die;
    }
    //Comprueba si usuario es moderador del foro
    $forum = new bXForum($post->forum());
    if (!$forum->isModerator($xoopsUser->uid()) || !$xoopsUser->isAdmin()) {
        redirect_header('./topic.php?id=' . $posts, 1, __('You don\'t have permission to do this action!', 'bxpress'));
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirect_header('./topic.php?id=' . $posts, 2, __('Session token expired!', 'bxpress'));
        die;
    }
    $post->setApproved($app);
    if ($post->editText()) {
        $post->setText($post->editText());
    }
    $post->setEditText('');
    $post->save();
    redirect_header('./topic.php?id=' . $post->topic(), 1, __('Operation completed!', 'bxpress'));
}